Skip to content

Commit

Permalink
Grep for error messages instead of comparing files (#4024)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF authored Feb 16, 2024
1 parent bdddf43 commit 02a5732
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 4 additions & 4 deletions tools/test/h5copy/CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
# Similar to ADD_H5_TEST macro. Compare to outputs from source & target
# files instead of checking with h5ls.
#
macro (ADD_H5_CMP_TEST testname resultcode infile vparam sparam srcname dparam dstname)
macro (ADD_H5_CMP_TEST testname resultcode result_errcheck infile vparam sparam srcname dparam dstname)
# Remove any output file left over from previous test run
add_test (
NAME H5COPY-CMP-${testname}-clear-objects
Expand All @@ -276,9 +276,9 @@
-D "TEST_OUTPUT=./testfiles/${testname}.out.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=./testfiles/${testname}.out"
-D "TEST_ERRREF=./testfiles/${testname}.err"
-D "TEST_ERRREF=${result_errcheck}"
-D "TEST_MASK=true"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
endif ()
set_tests_properties (H5COPY-CMP-${testname} PROPERTIES DEPENDS H5COPY-CMP-${testname}-clear-objects)
Expand Down Expand Up @@ -598,7 +598,7 @@
#-----------------------------------------------------------------
# "Test copying object into group which doesn't exist, without -p"
#
ADD_H5_CMP_TEST (h5copy_misc1 1 ${HDF_FILE1}.h5 -v -s /simple -d /g1/g2/simple)
ADD_H5_CMP_TEST (h5copy_misc1 1 "h5copy error" ${HDF_FILE1}.h5 -v -s /simple -d /g1/g2/simple)

#-------------------------------------------
# "Test copying objects to the same file "
Expand Down
13 changes: 7 additions & 6 deletions tools/test/h5ls/CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
endif ()
endmacro ()

macro (ADD_H5_ERR_TEST resultfile resultcode)
macro (ADD_H5_ERR_TEST resultfile resultcode result_errcheck)
# If using memchecker add tests without using scripts
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5ls${tgt_file_ext}> ${ARGN})
Expand All @@ -193,8 +193,9 @@
-D "TEST_OUTPUT=${resultfile}.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}.ls"
-D "TEST_ERRREF=${resultfile}.err"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
-D "TEST_ERRREF=${result_errcheck}"
-D "TEST_SKIP_COMPARE=true"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
endif ()
set_tests_properties (H5LS-${resultfile} PROPERTIES
Expand Down Expand Up @@ -264,7 +265,7 @@
# test for displaying groups
# The following combination of arguments is expected to return an error message
# and return value 1
ADD_H5_ERR_TEST (tgroup-1 1 -w80 -r -g tgroup.h5)
ADD_H5_ERR_TEST (tgroup-1 1 "option not compatible" -w80 -r -g tgroup.h5)
ADD_H5_TEST (tgroup-2 0 -w80 -g tgroup.h5/g1)

# test for files with groups that have long comments
Expand Down Expand Up @@ -305,7 +306,7 @@
# tests for no-dangling-links
# if this option is given on dangling link, h5ls should return exit code 1
# when used alone , expect to print out help and return exit code 1
ADD_H5_ERR_TEST (textlinksrc-nodangle-1 1 -w80 --no-dangling-links textlinksrc.h5)
ADD_H5_ERR_TEST (textlinksrc-nodangle-1 1 "no-dangling-links must be used" -w80 --no-dangling-links textlinksrc.h5)
# external dangling link - expected exit code 1
ADD_H5_TEST (textlinksrc-nodangle-2 1 -w80 --follow-symlinks --no-dangling-links textlinksrc.h5)
# soft dangling link - expected exit code 1
Expand Down Expand Up @@ -367,7 +368,7 @@
endif ()

# test for non-existing file
ADD_H5_ERR_TEST (nosuchfile 1 nosuchfile.h5)
ADD_H5_ERR_TEST (nosuchfile 1 "unable to open file" nosuchfile.h5)

# test for variable length data types in verbose mode
if (H5_WORDS_BIGENDIAN)
Expand Down
19 changes: 10 additions & 9 deletions tools/test/misc/CMakeTestsClear.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
endif ()
endmacro ()

macro (ADD_H5_ERR_CMP testname resultfile resultcode)
macro (ADD_H5_ERR_CMP testname resultfile resultcode result_errcheck)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
NAME H5CLEAR_CMP-${testname}
Expand All @@ -124,8 +124,9 @@
-D "TEST_OUTPUT=${testname}.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}.mty"
-D "TEST_ERRREF=${resultfile}.err"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
-D "TEST_ERRREF=${result_errcheck}"
-D "TEST_SKIP_COMPARE=true"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
if ("H5CLEAR_CMP-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DISABLED true)
Expand Down Expand Up @@ -443,11 +444,11 @@
ADD_H5_CMP (h5clr_usage_junk h5clear_usage 1 "" junk.h5)
ADD_H5_CMP (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5)
ADD_H5_CMP (h5clr_missing_file_m h5clear_missing_file 1 "-m")
ADD_H5_ERR_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5)
ADD_H5_ERR_CMP (h5clr_open_fail_s h5clear_open_fail 1 "h5clear error" "-s" junk.h5)
ADD_H5_CMP (h5clr_missing_file_ms h5clear_missing_file 1 "-m" "-s")
ADD_H5_ERR_CMP (h5clr_open_fail_ms h5clear_open_fail 1 "-m" "-s" junk.h5)
ADD_H5_ERR_CMP (h5clr_no_mdc_image_m h5clear_no_mdc_image 0 "-m" orig_h5clear_sec2_v2.h5)
ADD_H5_ERR_CMP (h5clr_no_mdc_image_ms h5clear_no_mdc_image 0 "-s" "-m" orig_h5clear_sec2_v0.h5)
ADD_H5_ERR_CMP (h5clr_open_fail_ms h5clear_open_fail 1 "h5clear error" "-m" "-s" junk.h5)
ADD_H5_ERR_CMP (h5clr_no_mdc_image_m h5clear_no_mdc_image 0 "h5clear warning" "-m" orig_h5clear_sec2_v2.h5)
ADD_H5_ERR_CMP (h5clr_no_mdc_image_ms h5clear_no_mdc_image 0 "h5clear warning" "-s" "-m" orig_h5clear_sec2_v0.h5)
#
#
#
Expand Down Expand Up @@ -478,8 +479,8 @@
#
#
# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear:
ADD_H5_ERR_CMP (h5clr_mdc_image_m h5clear_no_mdc_image 0 "-m" mod_h5clear_mdc_image.h5)
ADD_H5_ERR_CMP (h5clr_mdc_image_sm h5clear_no_mdc_image 0 "-s" "-m" mod_h5clear_mdc_image2.h5)
ADD_H5_ERR_CMP (h5clr_mdc_image_m h5clear_no_mdc_image 0 "h5clear warning" "-m" mod_h5clear_mdc_image.h5)
ADD_H5_ERR_CMP (h5clr_mdc_image_sm h5clear_no_mdc_image 0 "h5clear warning" "-s" "-m" mod_h5clear_mdc_image2.h5)
#
#
#
Expand Down

0 comments on commit 02a5732

Please sign in to comment.