enhance the encoding test suite and remove unsued CONFIGURE_FILE into a CMakeList
This commit is contained in:
parent
7c2feb78d2
commit
aaa47850c3
3
CHANGES
3
CHANGES
|
@ -5,6 +5,9 @@ What's New for OpenJPEG
|
||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
|
August 31, 2011
|
||||||
|
+ [mickael] enhance the encoding test suite and remove unsued CONFIGURE_FILE into a CMakeList
|
||||||
|
|
||||||
August 30, 2011
|
August 30, 2011
|
||||||
+ [mickael] added first version of the encoding tests suite
|
+ [mickael] added first version of the encoding tests suite
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@ SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
|
|
||||||
# Exclude files from the Testing directories
|
# Exclude files from the Testing directories
|
||||||
".*/tests/.*"
|
".*/tests/.*"
|
||||||
".*/Testing/.*"
|
|
||||||
|
# Exclude files from the ThirdParty Utilities directories
|
||||||
|
".*/thirdparty/.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
|
|
|
@ -13,6 +13,8 @@ SET(comparePGXimages_SRCS comparePGXimages.c ${OPENJPEG_SOURCE_DIR}/applications
|
||||||
|
|
||||||
SET(compare_dump_files_SRCS compare_dump_files.c)
|
SET(compare_dump_files_SRCS compare_dump_files.c)
|
||||||
|
|
||||||
|
SET(compareRAWimages_SRCS compareRAWimages.c)
|
||||||
|
|
||||||
# If not getopt was found then add it to the exe:
|
# If not getopt was found then add it to the exe:
|
||||||
IF(DONT_HAVE_GETOPT)
|
IF(DONT_HAVE_GETOPT)
|
||||||
message("dont have getopt, we will add it")
|
message("dont have getopt, we will add it")
|
||||||
|
@ -25,6 +27,11 @@ IF(DONT_HAVE_GETOPT)
|
||||||
${compare_dump_files_SRCS}
|
${compare_dump_files_SRCS}
|
||||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SET(compareRAWimages_SRCS
|
||||||
|
${compareRAWimages_SRCS}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
||||||
|
)
|
||||||
ENDIF(DONT_HAVE_GETOPT)
|
ENDIF(DONT_HAVE_GETOPT)
|
||||||
|
|
||||||
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
|
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
|
||||||
|
@ -36,6 +43,8 @@ TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
|
||||||
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
|
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(compareRAWimages ${compareRAWimages_SRCS})
|
||||||
|
|
||||||
# No image send to the dashboard if lib PNG is not available.
|
# No image send to the dashboard if lib PNG is not available.
|
||||||
IF(NOT HAVE_LIBPNG)
|
IF(NOT HAVE_LIBPNG)
|
||||||
MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")
|
MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* compareRAWimages.c
|
||||||
|
*
|
||||||
|
* Created on: 31 August 2011
|
||||||
|
* Author: mickael
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
|
void compareRAWimages_help_display(void);
|
||||||
|
|
||||||
|
typedef struct test_cmp_parameters
|
||||||
|
{
|
||||||
|
/** */
|
||||||
|
char* base_filename;
|
||||||
|
/** */
|
||||||
|
char* test_filename;
|
||||||
|
} test_cmp_parameters;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Command line help function
|
||||||
|
*******************************************************************************/
|
||||||
|
void compareRAWimages_help_display(void) {
|
||||||
|
fprintf(stdout,"\nList of parameters for the comparePGX function \n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -b \t REQUIRED \t filename to the reference/baseline RAW image \n");
|
||||||
|
fprintf(stdout," -t \t REQUIRED \t filename to the test RAW image\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Parse command line
|
||||||
|
*******************************************************************************/
|
||||||
|
int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
|
||||||
|
{
|
||||||
|
int sizemembasefile, sizememtestfile;
|
||||||
|
int index;
|
||||||
|
const char optlist[] = "b:t:";
|
||||||
|
int c;
|
||||||
|
|
||||||
|
// Init parameters
|
||||||
|
param->base_filename = NULL;
|
||||||
|
param->test_filename = NULL;
|
||||||
|
|
||||||
|
opterr = 0;
|
||||||
|
while ((c = getopt(argc, argv, optlist)) != -1)
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'b':
|
||||||
|
sizemembasefile = (int)strlen(optarg)+1;
|
||||||
|
param->base_filename = (char*) malloc(sizemembasefile);
|
||||||
|
param->base_filename[0] = '\0';
|
||||||
|
strncpy(param->base_filename, optarg, strlen(optarg));
|
||||||
|
param->base_filename[strlen(optarg)] = '\0';
|
||||||
|
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
sizememtestfile = (int) strlen(optarg) + 1;
|
||||||
|
param->test_filename = (char*) malloc(sizememtestfile);
|
||||||
|
param->test_filename[0] = '\0';
|
||||||
|
strncpy(param->test_filename, optarg, strlen(optarg));
|
||||||
|
param->test_filename[strlen(optarg)] = '\0';
|
||||||
|
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
if ((optopt == 'b') || (optopt == 't'))
|
||||||
|
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
|
||||||
|
else
|
||||||
|
if (isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt);
|
||||||
|
else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
for (index = optind; index < argc; index++)
|
||||||
|
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* MAIN
|
||||||
|
*******************************************************************************/
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
test_cmp_parameters inParam;
|
||||||
|
FILE *file_test=NULL, *file_base=NULL;
|
||||||
|
unsigned char equal = 1;
|
||||||
|
|
||||||
|
// Get parameters from command line
|
||||||
|
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
|
||||||
|
{
|
||||||
|
compareRAWimages_help_display();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_test = fopen(inParam.test_filename, "rb");
|
||||||
|
if (!file_test) {
|
||||||
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_base = fopen(inParam.base_filename, "rb");
|
||||||
|
if (!file_base) {
|
||||||
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read simultaneously the two files
|
||||||
|
while (equal)
|
||||||
|
{
|
||||||
|
unsigned char value_test = 0;
|
||||||
|
unsigned char eof_test = 0;
|
||||||
|
unsigned char value_base = 0;
|
||||||
|
unsigned char eof_base = 0;
|
||||||
|
|
||||||
|
// Read one byte
|
||||||
|
if (!fread(&value_test, 1, 1, file_test)) {
|
||||||
|
eof_test = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read one byte
|
||||||
|
if (!fread(&value_base, 1, 1, file_base)) {
|
||||||
|
eof_base = 1;;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of file reached by the two files?
|
||||||
|
if (eof_test && eof_base)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// End of file reached only by one file?
|
||||||
|
if (eof_test || eof_base)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"Files have different sizes.\n");
|
||||||
|
equal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Binary values are equal?
|
||||||
|
if (value_test != value_base)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"Binary values read in the file are different.\n");
|
||||||
|
equal = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file_test);
|
||||||
|
fclose(file_base);
|
||||||
|
|
||||||
|
if (equal)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"---- TEST SUCCEED: Files are equal ----\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
|
@ -75,13 +75,14 @@ IF (NOT WIN32)
|
||||||
CONFIGURE_FILE("opj_ref_decode_cmd.sh.in"
|
CONFIGURE_FILE("opj_ref_decode_cmd.sh.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh"
|
"${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh"
|
||||||
@ONLY)
|
@ONLY)
|
||||||
ELSE (NOT WIN32)
|
|
||||||
|
|
||||||
CONFIGURE_FILE("opj_ref_decode_cmd.bat.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.bat"
|
|
||||||
@ONLY)
|
|
||||||
ENDIF (NOT WIN32)
|
ENDIF (NOT WIN32)
|
||||||
|
|
||||||
|
string(COMPARE EQUAL ${REF_DECODER_BIN_PATH} "NOTFOUND" REF_DECODER_NOTFOUND)
|
||||||
|
IF (REF_DECODER_NOTFOUND)
|
||||||
|
MESSAGE(STATUS "REF_DECODER_BIN_PATH not found, if you want all the encoding tests suite please provide a ragular path")
|
||||||
|
ENDIF (REF_DECODER_NOTFOUND)
|
||||||
|
|
||||||
|
|
||||||
# Read the file into a list
|
# Read the file into a list
|
||||||
FILE(STRINGS encoder_test_suite.txt OPJ_TEST_ENC_CMD_LINE_LIST)
|
FILE(STRINGS encoder_test_suite.txt OPJ_TEST_ENC_CMD_LINE_LIST)
|
||||||
|
|
||||||
|
@ -183,13 +184,11 @@ FOREACH(OPJ_TEST_ENC_CMD_LINE ${OPJ_TEST_ENC_CMD_LINE_LIST})
|
||||||
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-dump)
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-dump)
|
||||||
|
|
||||||
# Decode the encoding file with kakadu expand command
|
# Decode the encoding file with kakadu expand command
|
||||||
string(COMPARE EQUAL ${REF_DECODER_BIN_PATH} "NOTFOUND" REF_DECODER_NOTFOUND)
|
|
||||||
|
|
||||||
IF (NOT REF_DECODER_NOTFOUND)
|
IF (NOT REF_DECODER_NOTFOUND)
|
||||||
IF (NOT WIN32)
|
IF (NOT WIN32)
|
||||||
# Need a bash script to export the path of the kakadu library into PATH
|
# Need a bash script to export the path of the kakadu library into PATH
|
||||||
ADD_TEST(NAME NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
ADD_TEST( NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
||||||
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh
|
bash ${CMAKE_CURRENT_BINARY_DIR}/opj_ref_decode_cmd.sh
|
||||||
-i ${OUTPUT_FILENAME}
|
-i ${OUTPUT_FILENAME}
|
||||||
-o ${OUTPUT_FILENAME}.raw
|
-o ${OUTPUT_FILENAME}.raw
|
||||||
)
|
)
|
||||||
|
@ -204,15 +203,20 @@ FOREACH(OPJ_TEST_ENC_CMD_LINE ${OPJ_TEST_ENC_CMD_LINE_LIST})
|
||||||
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref
|
||||||
PROPERTIES DEPENDS
|
PROPERTIES DEPENDS
|
||||||
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-encode)
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-encode)
|
||||||
ELSE (NOT REF_DECODER_NOTFOUND)
|
|
||||||
MESSAGE(STATUS "REF_DECODER_BIN_PATH not found, if you want all the encoding tests suite please provide a ragular path")
|
|
||||||
ENDIF (NOT REF_DECODER_NOTFOUND)
|
|
||||||
|
|
||||||
# Compare the decoding file with baseline generated from the kdu_expand and baseline.j2k
|
# Compare the decoding file with baseline generated from the kdu_expand and baseline.j2k
|
||||||
#ADD_TEST(NR-ENC-${it_test}-compare_expand
|
ADD_TEST(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dec-ref-out2base
|
||||||
# -b ${BASELINE_NR}/.raw
|
${EXECUTABLE_OUTPUT_PATH}/compareRAWimages
|
||||||
# -t ${TEMP}/${OUTPUT_FILENAME}.raw
|
#-b ${BASELINE_NR}/opj_${OUTPUT_FILENAME_NAME_WE}-ENC-${it_test}.raw
|
||||||
#)
|
-b ${BASELINE_NR}/opj_${OUTPUT_FILENAME_NAME_WE}-ENC-${it_test}.raw
|
||||||
|
-t ${OUTPUT_FILENAME}.raw
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_TESTS_PROPERTIES(NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-compare_dec-ref-out2base
|
||||||
|
PROPERTIES DEPENDS
|
||||||
|
NR-ENC-${INPUT_FILENAME_NAME}-${it_test}-decode-ref)
|
||||||
|
|
||||||
|
ENDIF (NOT REF_DECODER_NOTFOUND)
|
||||||
|
|
||||||
ENDIF(NOT IGNORE_LINE_FOUND)
|
ENDIF(NOT IGNORE_LINE_FOUND)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue