mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r20875] Refactor h5import to close files and free allocations. Also corrected test dependencies so that memcheck would process tests in correct order.
Tested: local linux - confirmed with valgrind
This commit is contained in:
parent
2de5fa986f
commit
3f11adaec2
@ -41,22 +41,6 @@ SET (CTEST_CUSTOM_MEMCHECK_IGNORE
|
||||
H5DUMP-XML-clearall-objects
|
||||
######### tools/h5import #########
|
||||
H5IMPORT-clear-objects
|
||||
H5IMPORT-ASCII_F32-clear-objects
|
||||
H5IMPORT-ASCII_UI16-clear-objects
|
||||
H5IMPORT-ASCII_UI32-clear-objects
|
||||
H5IMPORT-ASCII_I8-clear-objects
|
||||
H5IMPORT-ASCII_I16-clear-objects
|
||||
H5IMPORT-ASCII_I32-clear-objects
|
||||
H5IMPORT-ASCII_F64_R1-clear-objects
|
||||
H5IMPORT-BINARY_I8_EOF-clear-objects
|
||||
H5IMPORT-STR-clear-objects
|
||||
H5IMPORT-BINARY_UI32-clear-objects
|
||||
H5IMPORT-BINARY_UI16-clear-objects
|
||||
H5IMPORT-BINARY_I32-clear-objects
|
||||
H5IMPORT-BINARY_I8-clear-objects
|
||||
H5IMPORT-BINARY_I16-clear-objects
|
||||
H5IMPORT-BINARY_F64-clear-objects
|
||||
H5IMPORT-ASCII_F64-clear-objects
|
||||
######### tools/h5jam #########
|
||||
H5JAM-SETUP-N_twithub_u10_c-clear-objects
|
||||
H5JAM-SETUP-N_twithub_u10_c
|
||||
|
@ -116,21 +116,27 @@ IF (BUILD_TESTING)
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
MACRO (ADD_H5_TEST testname importfile conffile testfile)
|
||||
ADD_TEST (
|
||||
NAME H5IMPORT-${testname}-clear-objects
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E remove
|
||||
${testfile}
|
||||
${testfile}.new
|
||||
${testfile}.new.err
|
||||
${testfile}.out
|
||||
${testfile}.out.err
|
||||
)
|
||||
IF (NOT "${last_test}" STREQUAL "")
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
|
||||
ENDIF (NOT "${last_test}" STREQUAL "")
|
||||
IF (NOT HDF5_ENABLE_USING_MEMCHECKER)
|
||||
ADD_TEST (
|
||||
NAME H5IMPORT-${testname}-clear-objects
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E remove
|
||||
${testfile}
|
||||
${testfile}.new
|
||||
${testfile}.new.err
|
||||
${testfile}.out
|
||||
${testfile}.out.err
|
||||
)
|
||||
IF (NOT "${last_test}" STREQUAL "")
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
|
||||
ENDIF (NOT "${last_test}" STREQUAL "")
|
||||
SET (last_test "H5IMPORT-${testname}-clear-objects")
|
||||
ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER)
|
||||
|
||||
ADD_TEST (NAME H5IMPORT-${testname} COMMAND $<TARGET_FILE:h5import> ${importfile} -c testfiles/${conffile} -o ${testfile})
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-${testname}-clear-objects)
|
||||
IF (NOT "${last_test}" STREQUAL "")
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-${testname} PROPERTIES DEPENDS ${last_test})
|
||||
ENDIF (NOT "${last_test}" STREQUAL "")
|
||||
SET (last_test "H5IMPORT-${testname}")
|
||||
|
||||
# If using memchecker add tests without using scripts
|
||||
@ -187,9 +193,12 @@ IF (BUILD_TESTING)
|
||||
txtin32.txt
|
||||
${HDF5_REFERENCE_TEST_FILES}
|
||||
)
|
||||
SET (last_test "H5IMPORT-clear-objects")
|
||||
|
||||
ADD_TEST (NAME H5IMPORT-h5importtest COMMAND $<TARGET_FILE:h5importtest>)
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-h5importtest PROPERTIES DEPENDS H5IMPORT-clear-objects)
|
||||
IF (NOT "${last_test}" STREQUAL "")
|
||||
SET_TESTS_PROPERTIES (H5IMPORT-h5importtest PROPERTIES DEPENDS ${last_test})
|
||||
ENDIF (NOT "${last_test}" STREQUAL "")
|
||||
SET (last_test "H5IMPORT-h5importtest")
|
||||
|
||||
# ----- TESTING "ASCII I32 rank 3 - Output BE " ;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -74,111 +74,110 @@
|
||||
|
||||
struct path_info
|
||||
{
|
||||
char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
|
||||
int count;
|
||||
char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
|
||||
int count;
|
||||
};
|
||||
|
||||
struct Input
|
||||
{
|
||||
struct path_info path;
|
||||
int inputClass;
|
||||
int inputSize;
|
||||
int rank;
|
||||
hsize_t* sizeOfDimension;
|
||||
int outputClass;
|
||||
int outputSize;
|
||||
int outputArchitecture;
|
||||
int outputByteOrder;
|
||||
hsize_t* sizeOfChunk;
|
||||
hsize_t* maxsizeOfDimension;
|
||||
int compressionType;
|
||||
int compressionParam;
|
||||
char *externFilename;
|
||||
VOIDP data;
|
||||
int configOptionVector[NUM_KEYS];
|
||||
struct path_info path;
|
||||
int inputClass;
|
||||
int inputSize;
|
||||
int rank;
|
||||
hsize_t* sizeOfDimension;
|
||||
int outputClass;
|
||||
int outputSize;
|
||||
int outputArchitecture;
|
||||
int outputByteOrder;
|
||||
hsize_t* sizeOfChunk;
|
||||
hsize_t* maxsizeOfDimension;
|
||||
int compressionType;
|
||||
int compressionParam;
|
||||
char *externFilename;
|
||||
VOIDP data;
|
||||
int configOptionVector[NUM_KEYS];
|
||||
};
|
||||
|
||||
struct infilesformat
|
||||
{
|
||||
char datafile[255];
|
||||
char configfile[255];
|
||||
struct Input in;
|
||||
int config; /* Configfile present? No - 0. Yes - 1 */
|
||||
char datafile[255];
|
||||
char configfile[255];
|
||||
struct Input in;
|
||||
int config; /* Configfile present? No - 0. Yes - 1 */
|
||||
};
|
||||
|
||||
struct Options
|
||||
{
|
||||
struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/
|
||||
char outfile[256]; /* output file name */
|
||||
int fcount; /* number of input files */
|
||||
struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/
|
||||
char outfile[256]; /* output file name */
|
||||
int fcount; /* number of input files */
|
||||
};
|
||||
|
||||
char keytable[NUM_KEYS][30] = {
|
||||
"PATH",
|
||||
"INPUT-CLASS",
|
||||
"INPUT-SIZE",
|
||||
"RANK",
|
||||
"DIMENSION-SIZES",
|
||||
"OUTPUT-CLASS",
|
||||
"OUTPUT-SIZE",
|
||||
"OUTPUT-ARCHITECTURE",
|
||||
"OUTPUT-BYTE-ORDER",
|
||||
"CHUNKED-DIMENSION-SIZES",
|
||||
"COMPRESSION-TYPE",
|
||||
"COMPRESSION-PARAM",
|
||||
"EXTERNAL-STORAGE",
|
||||
"MAXIMUM-DIMENSIONS"
|
||||
"PATH",
|
||||
"INPUT-CLASS",
|
||||
"INPUT-SIZE",
|
||||
"RANK",
|
||||
"DIMENSION-SIZES",
|
||||
"OUTPUT-CLASS",
|
||||
"OUTPUT-SIZE",
|
||||
"OUTPUT-ARCHITECTURE",
|
||||
"OUTPUT-BYTE-ORDER",
|
||||
"CHUNKED-DIMENSION-SIZES",
|
||||
"COMPRESSION-TYPE",
|
||||
"COMPRESSION-PARAM",
|
||||
"EXTERNAL-STORAGE",
|
||||
"MAXIMUM-DIMENSIONS"
|
||||
};
|
||||
|
||||
static int state_table[15][8] =
|
||||
{
|
||||
/* token ordering:
|
||||
FILNAME OPT_o OPT_c OPT_h OPT_d OPT_p OPT_t OPT_s */
|
||||
/* token ordering: FILNAME OPT_o OPT_c OPT_h OPT_d OPT_p OPT_t OPT_s */
|
||||
|
||||
/* state 0: start */
|
||||
{1, ERR, ERR, 6, ERR, ERR, ERR, ERR},
|
||||
/* state 0: start */
|
||||
{1, ERR, ERR, 6, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 1: input files */
|
||||
{ERR, ERR, 2, ERR, 7, ERR, ERR, ERR},
|
||||
/* state 1: input files */
|
||||
{ERR, ERR, 2, ERR, 7, ERR, ERR, ERR},
|
||||
|
||||
/* state 2: -c[onfigfile] */
|
||||
{3, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 2: -c[onfigfile] */
|
||||
{3, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 3: configfile */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 3: configfile */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 4: -o[utfile] */
|
||||
{5, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 4: -o[utfile] */
|
||||
{5, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 5: outfile */
|
||||
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 5: outfile */
|
||||
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 6: -h[elp] */
|
||||
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 6: -h[elp] */
|
||||
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 7: -d[ims] */
|
||||
{8, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 7: -d[ims] */
|
||||
{8, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 8: dimensions */
|
||||
{1, 4, ERR, ERR, ERR, 9, 11, 13},
|
||||
/* state 8: dimensions */
|
||||
{1, 4, ERR, ERR, ERR, 9, 11, 13},
|
||||
|
||||
/* state 9: -p[ath] */
|
||||
{10, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 9: -p[ath] */
|
||||
{10, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 10: path name */
|
||||
{1, 4, ERR, ERR, ERR, ERR, 11, 13},
|
||||
/* state 10: path name */
|
||||
{1, 4, ERR, ERR, ERR, ERR, 11, 13},
|
||||
|
||||
/* state 11: -t[ype] */
|
||||
{12, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 11: -t[ype] */
|
||||
{12, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 12: data type */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, 13},
|
||||
/* state 12: data type */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, 13},
|
||||
|
||||
/* state 13: -s[ize] */
|
||||
{14, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
/* state 13: -s[ize] */
|
||||
{14, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
|
||||
|
||||
/* state 14: data size */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR}
|
||||
/* state 14: data size */
|
||||
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR}
|
||||
|
||||
};
|
||||
|
||||
@ -193,39 +192,39 @@ void help(char *);
|
||||
|
||||
static int gtoken(char *s);
|
||||
static int process(struct Options *opt);
|
||||
static int processConfigurationFile(char *infile, struct Input *in, FILE **strm);
|
||||
static int processConfigurationFile(char *infile, struct Input *in);
|
||||
static int mapKeywordToIndex(char *key);
|
||||
static int parsePathInfo(struct path_info *path, char *strm);
|
||||
static int parseDimensions(struct Input *in, char *strm);
|
||||
static int getInputSize(struct Input *in, int ival);
|
||||
static int getInputClass(struct Input *in, char * strm);
|
||||
static int InputClassStrToInt(char *temp);
|
||||
static int getRank(struct Input *in, FILE** strm);
|
||||
static int getDimensionSizes(struct Input *in, FILE** strm);
|
||||
static int getOutputSize(struct Input *in, FILE** strm);
|
||||
static int getOutputClass(struct Input *in, FILE** strm);
|
||||
static int getRank(struct Input *in, FILE *strm);
|
||||
static int getDimensionSizes(struct Input *in, FILE *strm);
|
||||
static int getOutputSize(struct Input *in, FILE *strm);
|
||||
static int getOutputClass(struct Input *in, FILE *strm);
|
||||
static int OutputClassStrToInt(char *temp);
|
||||
static int getOutputArchitecture(struct Input *in, FILE** strm);
|
||||
static int getOutputArchitecture(struct Input *in, FILE *strm);
|
||||
static int OutputArchStrToInt(char *temp);
|
||||
static int getOutputByteOrder(struct Input *in, FILE** strm);
|
||||
static int getOutputByteOrder(struct Input *in, FILE *strm);
|
||||
static int OutputByteOrderStrToInt(char *temp);
|
||||
static int getChunkedDimensionSizes(struct Input *in, FILE **strm);
|
||||
static int getCompressionType(struct Input *in, FILE** strm);
|
||||
static int getChunkedDimensionSizes(struct Input *in, FILE *strm);
|
||||
static int getCompressionType(struct Input *in, FILE *strm);
|
||||
static int CompressionTypeStrToInt(char *temp);
|
||||
static int getCompressionParameter(struct Input *in, FILE** strm);
|
||||
static int getExternalFilename(struct Input *in, FILE** strm);
|
||||
static int getMaximumDimensionSizes(struct Input *in, FILE **strm);
|
||||
static int processDataFile(char *infile, struct Input *in, FILE **strm, hid_t file_id);
|
||||
static int readIntegerData(FILE **strm, struct Input *in);
|
||||
static int readFloatData(FILE **strm, struct Input *in);
|
||||
static int getCompressionParameter(struct Input *in, FILE *strm);
|
||||
static int getExternalFilename(struct Input *in, FILE *strm);
|
||||
static int getMaximumDimensionSizes(struct Input *in, FILE *strm);
|
||||
static int processDataFile(char *infile, struct Input *in, hid_t file_id);
|
||||
static int readIntegerData(FILE *strm, struct Input *in);
|
||||
static int readFloatData(FILE *strm, struct Input *in);
|
||||
static int allocateIntegerStorage(struct Input *in);
|
||||
static int allocateFloatStorage(struct Input *in);
|
||||
hid_t createOutputDataType(struct Input *in);
|
||||
hid_t createInputDataType(struct Input *in);
|
||||
static int readUIntegerData(FILE **strm, struct Input *in);
|
||||
static int readUIntegerData(FILE *strm, struct Input *in);
|
||||
static int allocateUIntegerStorage(struct Input *in);
|
||||
static int validateConfigurationParameters(struct Input * in);
|
||||
static int processStrData(FILE **strm, struct Input *in, hid_t file_id);
|
||||
static int validateConfigurationParameters(struct Input *in);
|
||||
static int processStrData(FILE *strm, struct Input *in, hid_t file_id);
|
||||
|
||||
#endif /* H5IMPORT_H__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user