From 2b70d0dfdfa810e6c7b4e6d35922e58574c487f6 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu, 18 May 2023 11:41:05 -0500 Subject: Add h5copy help test and verify consistency (#2903) --- tools/src/h5copy/h5copy.c | 8 ----- tools/src/h5import/h5import.c | 19 +++++------ tools/src/h5stat/h5stat.c | 29 +--------------- tools/test/h5copy/CMakeTests.cmake | 32 +++++++++++++++++ tools/test/h5copy/testfiles/h5copy_help1.ddl | 49 +++++++++++++++++++++++++++ tools/test/h5copy/testfiles/h5copy_help2.ddl | 49 +++++++++++++++++++++++++++ tools/test/h5stat/testfiles/h5stat_help1.ddl | 2 +- tools/test/h5stat/testfiles/h5stat_help2.ddl | 2 +- tools/test/h5stat/testfiles/h5stat_nofile.ddl | 2 +- 9 files changed, 142 insertions(+), 50 deletions(-) create mode 100644 tools/test/h5copy/testfiles/h5copy_help1.ddl create mode 100644 tools/test/h5copy/testfiles/h5copy_help2.ddl diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index c4e4275..3734628 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -46,8 +46,6 @@ char *str_flag = NULL; * Programmer: Quincey Koziol * Saturday, 31. January 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -77,8 +75,6 @@ leave(int ret) * * Programmer: Pedro Vicente Nunes, 7/8/2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -159,8 +155,6 @@ usage(void) * * Programmer: Pedro Vicente Nunes, 7/8/2006 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -207,8 +201,6 @@ parse_flag(const char *s_flag, unsigned *flag) * * Programmer: Pedro Vicente Nunes * - * Modifications: - * *------------------------------------------------------------------------- */ diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index bda7ea0..3984b5c 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -342,9 +342,6 @@ gtoken(char *s) * * Programmer: pkmat * - * Modifications: pvn - * 7/23/2007. Added support for STR type, extra parameter FILE_ID - * *------------------------------------------------------------------------- */ @@ -455,7 +452,7 @@ processDataFile(char *infile, struct Input *in, hid_t file_id) error: if (strm) HDfclose(strm); - return (retval); + return retval; } static int @@ -1428,10 +1425,10 @@ processConfigurationFile(char *infile, struct Input *in) const char *err19 = "Unable to get integer value.\n"; const char *err20 = "Unable to get subset values.\n"; - /* create vector to map which keywords have been found - check vector after each keyword to check for violation - at the end check vector to see if required fields have been provided - process the output file according to the options + /* - create vector to map which keywords have been found + * - check vector after each keyword to check for violation + * - at the end check vector to see if required fields have been provided + * - process the output file according to the options */ /* Initialize machine endian */ @@ -2434,7 +2431,7 @@ processConfigurationFile(char *infile, struct Input *in) error: if (strm) HDfclose(strm); - return (retval); + return retval; } static int @@ -4742,7 +4739,7 @@ process(struct Options *opt) } /* STR */ H5Fclose(file_id); - return (0); + return 0; } uint16_t @@ -5084,7 +5081,7 @@ help(char *name) void usage(char *name) { - (void)HDfprintf(stdout, "\nUsage:\t%s -h[elp], OR\n", name); + (void)HDfprintf(stdout, "\nusage:\t%s -h[elp], OR\n", name); (void)HDfprintf(stdout, "\t%s -c[onfig] \ [ -c[config] ...] -o[utfile] \n\n", name); diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 7ffb861..ec742e8 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -208,7 +208,7 @@ static void usage(const char *prog) { HDfflush(stdout); - HDfprintf(stdout, "Usage: %s [OPTIONS] file\n", prog); + HDfprintf(stdout, "usage: %s [OPTIONS] file\n", prog); HDfprintf(stdout, "\n"); HDfprintf(stdout, " ERROR\n"); HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); @@ -335,18 +335,6 @@ attribute_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *na * Programmer: Quincey Koziol * Tuesday, August 16, 2005 * - * Modifications: Refactored code from the walk_function - * EIP, Wednesday, August 16, 2006 - * - * Vailin Choi 12 July 2007 - * 1. Gathered storage info for btree and heap - * (groups and attributes) - * 2. Gathered info for attributes - * - * Vailin Choi 14 July 2007 - * Cast "num_objs" and "num_attrs" to size_t - * Due to the -Mbounds problem for the pgi-32 bit compiler on indexing - * *------------------------------------------------------------------------- */ static herr_t @@ -1103,8 +1091,6 @@ iter_free(iter_t *iter) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1190,11 +1176,6 @@ print_file_metadata(const iter_t *iter) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * bug #1253; Oct 6th 2008; Vailin Choi - * Fixed segmentation fault: print iter->group_bins[0] when - * there is iter->group_nbins - * *------------------------------------------------------------------------- */ static herr_t @@ -1636,8 +1617,6 @@ print_file_statistics(const iter_t *iter) * Programmer: Elena Pourmal * Thursday, August 17, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -1658,8 +1637,6 @@ print_object_statistics(const char *name) * Programmer: Elena Pourmal * Thursday, August 17, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -1674,10 +1651,6 @@ print_statistics(const char *name, const iter_t *iter) /*------------------------------------------------------------------------- * Function: main * - * Modifications: - * 2/2010; Vailin Choi - * Get the size of user block - * *------------------------------------------------------------------------- */ int diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 154ca15..e00d305 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -35,6 +35,8 @@ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail_ERR.out.h5.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_test.out.h5.txt + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_help1.ddl + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_help2.ddl ) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -376,6 +378,32 @@ endif () endmacro () + macro (ADD_SIMPLE_TEST resultfile resultcode) + # If using memchecker add tests without using scripts + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5COPY-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) + if (${resultcode}) + set_tests_properties (H5COPY-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + else (HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5COPY-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${resultfile}.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (H5COPY-${resultfile} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + ) + endmacro () + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -448,6 +476,10 @@ set (USE_FILTER_SZIP "true") endif () +# Test for help flag + ADD_SIMPLE_TEST (h5copy_help1 0 -h) + ADD_SIMPLE_TEST (h5copy_help2 0 --help) + # "Test copying various forms of datasets" ADD_H5_TEST (simple 0 ${HDF_FILE1}.h5 -v -s simple -d simple) ADD_H5_TEST (chunk 0 ${HDF_FILE1}.h5 -v -s chunk -d chunk) diff --git a/tools/test/h5copy/testfiles/h5copy_help1.ddl b/tools/test/h5copy/testfiles/h5copy_help1.ddl new file mode 100644 index 0000000..418faea --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_help1.ddl @@ -0,0 +1,49 @@ + +usage: h5copy [OPTIONS] [OBJECTS...] + OBJECTS + -i, --input input file name + -o, --output output file name + -s, --source source object name + -d, --destination destination object name + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. + OPTIONS + -h, --help Print a usage message and exit + -p, --parents No error if existing, make parent groups as needed + -v, --verbose Print information about OBJECTS and OPTIONS + -V, --version Print version number and exit + -f, --flag Flag type + + Flag type is one of the following strings: + + shallow Copy only immediate members for groups + + soft Expand soft links into new objects + + ext Expand external links into new objects + + ref Copy references and any referenced objects, i.e., objects + that the references point to. + Referenced objects are copied in addition to the objects + specified on the command line and reference datasets are + populated with correct reference values. Copies of referenced + datasets outside the copy range specified on the command line + will normally have a different name from the original. + (Default:Without this option, reference value(s) in any + reference datasets are set to NULL and referenced objects are + not copied unless they are otherwise within the copy range + specified on the command line.) + + noattr Copy object without copying attributes + + allflags Switches all flags from the default to the non-default setting + + These flag types correspond to the following API symbols + + H5O_COPY_SHALLOW_HIERARCHY_FLAG + H5O_COPY_EXPAND_SOFT_LINK_FLAG + H5O_COPY_EXPAND_EXT_LINK_FLAG + H5O_COPY_EXPAND_REFERENCE_FLAG + H5O_COPY_WITHOUT_ATTR_FLAG + H5O_COPY_ALL diff --git a/tools/test/h5copy/testfiles/h5copy_help2.ddl b/tools/test/h5copy/testfiles/h5copy_help2.ddl new file mode 100644 index 0000000..418faea --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_help2.ddl @@ -0,0 +1,49 @@ + +usage: h5copy [OPTIONS] [OBJECTS...] + OBJECTS + -i, --input input file name + -o, --output output file name + -s, --source source object name + -d, --destination destination object name + ERROR + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. + OPTIONS + -h, --help Print a usage message and exit + -p, --parents No error if existing, make parent groups as needed + -v, --verbose Print information about OBJECTS and OPTIONS + -V, --version Print version number and exit + -f, --flag Flag type + + Flag type is one of the following strings: + + shallow Copy only immediate members for groups + + soft Expand soft links into new objects + + ext Expand external links into new objects + + ref Copy references and any referenced objects, i.e., objects + that the references point to. + Referenced objects are copied in addition to the objects + specified on the command line and reference datasets are + populated with correct reference values. Copies of referenced + datasets outside the copy range specified on the command line + will normally have a different name from the original. + (Default:Without this option, reference value(s) in any + reference datasets are set to NULL and referenced objects are + not copied unless they are otherwise within the copy range + specified on the command line.) + + noattr Copy object without copying attributes + + allflags Switches all flags from the default to the non-default setting + + These flag types correspond to the following API symbols + + H5O_COPY_SHALLOW_HIERARCHY_FLAG + H5O_COPY_EXPAND_SOFT_LINK_FLAG + H5O_COPY_EXPAND_EXT_LINK_FLAG + H5O_COPY_EXPAND_REFERENCE_FLAG + H5O_COPY_WITHOUT_ATTR_FLAG + H5O_COPY_ALL diff --git a/tools/test/h5stat/testfiles/h5stat_help1.ddl b/tools/test/h5stat/testfiles/h5stat_help1.ddl index 1f65f0d..54d6a31 100644 --- a/tools/test/h5stat/testfiles/h5stat_help1.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help1.ddl @@ -1,4 +1,4 @@ -Usage: h5stat [OPTIONS] file +usage: h5stat [OPTIONS] file ERROR --enable-error-stack Prints messages from the HDF5 error stack as they occur diff --git a/tools/test/h5stat/testfiles/h5stat_help2.ddl b/tools/test/h5stat/testfiles/h5stat_help2.ddl index 1f65f0d..54d6a31 100644 --- a/tools/test/h5stat/testfiles/h5stat_help2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help2.ddl @@ -1,4 +1,4 @@ -Usage: h5stat [OPTIONS] file +usage: h5stat [OPTIONS] file ERROR --enable-error-stack Prints messages from the HDF5 error stack as they occur diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl index 1f65f0d..54d6a31 100644 --- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl +++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl @@ -1,4 +1,4 @@ -Usage: h5stat [OPTIONS] file +usage: h5stat [OPTIONS] file ERROR --enable-error-stack Prints messages from the HDF5 error stack as they occur -- cgit v0.12