Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ERR test to use grep #4451

Merged
merged 14 commits into from
May 3, 2024
72 changes: 44 additions & 28 deletions tools/test/h5stat/CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@
h5stat_numattrs3
h5stat_numattrs4
)
set (HDF5_REFERENCE_ERR_FILES
h5stat_err_refcount
h5stat_err_old_layout
h5stat_err_old_fill
h5stat_err1_dims
h5stat_err1_links
h5stat_err1_numattrs
h5stat_err2_numattrs
h5stat_notexist
h5stat_nofile
)
set (HDF5_REFERENCE_TEST_FILES
h5stat_err_refcount.h5
h5stat_err_old_layout.h5
Expand All @@ -78,10 +67,6 @@
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/expected/${ddl_file}.ddl" "${PROJECT_BINARY_DIR}/${ddl_file}.ddl" "h5stat_files")
endforeach ()

foreach (h5_file ${HDF5_REFERENCE_ERR_FILES})
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/expected/${h5_file}.err" "${PROJECT_BINARY_DIR}/${h5_file}.err" "h5stat_files")
endforeach ()

foreach (h5_file ${HDF5_REFERENCE_TEST_FILES})
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5stat_files")
endforeach ()
Expand Down Expand Up @@ -122,7 +107,7 @@
endif ()
endmacro ()

macro (ADD_H5_ERR_TEST resultfile resultcode)
macro (ADD_H5_ERR_TEST resultfile resultcode errtext)
# If using memchecker add tests without using scripts
if (HDF5_USING_ANALYSIS_TOOL)
add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat> ${ARGN})
Expand All @@ -135,13 +120,44 @@
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5stat>"
-D "TEST_ARGS=${ARGN}"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-D "TEST_OUTPUT=${resultfile}.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}.mty"
-D "TEST_ERRREF=${resultfile}.err"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
-D "TEST_ERRREF=${errtext}"
-D "TEST_SKIP_COMPARE=true"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
endif ()
set_tests_properties (H5STAT-${resultfile} PROPERTIES
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
if ("H5STAT-${resultfile}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5STAT-${resultfile} PROPERTIES DISABLED true)
endif ()
endmacro ()

macro (ADD_H5_CMP_TEST resultfile resultcode errtext)
# If using memchecker add tests without using scripts
if (HDF5_USING_ANALYSIS_TOOL)
add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat> ${ARGN})
if (${resultcode})
set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true")
endif ()
else (HDF5_USING_ANALYSIS_TOOL)
add_test (
NAME H5STAT-${resultfile}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5stat>"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-D "TEST_OUTPUT=${resultfile}.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}.ddl"
-D "TEST_ERRREF=${errtext}"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
endif ()
set_tests_properties (H5STAT-${resultfile} PROPERTIES
Expand All @@ -163,8 +179,8 @@
ADD_H5_TEST (h5stat_help2 0 --help)

# Test when h5stat a file that does not exist
ADD_H5_TEST (h5stat_notexist 1 notexist.h5)
ADD_H5_TEST (h5stat_nofile 1 '')
ADD_H5_CMP_TEST (h5stat_notexist 1 "unable to open file" notexist.h5)
ADD_H5_CMP_TEST (h5stat_nofile 1 "missing file name" '')

# Test file with groups, compressed datasets, user-applied filters, etc.
# h5stat_filters.h5 is a copy of ../../testfiles/tfilters.h5 as of release 1.8.0-alpha4
Expand All @@ -191,7 +207,7 @@
# -g -l 8
# --links=8
# --links=20 -g
ADD_H5_ERR_TEST (h5stat_err1_links 1 -l 0 h5stat_threshold.h5)
ADD_H5_ERR_TEST (h5stat_err1_links 1 "Invalid threshold for small groups" -l 0 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_links1 0 -g -l 8 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_links2 0 --links=8 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_links3 0 --links=20 -g h5stat_threshold.h5)
Expand All @@ -206,7 +222,7 @@
# -d --dims=-1 (incorrect threshold value)
# -gd -m 5
# -d --di=15
ADD_H5_ERR_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5)
ADD_H5_ERR_TEST (h5stat_err1_dims 1 "Invalid threshold for small datasets" -d --dims=-1 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_dims1 0 -gd -m 5 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_dims2 0 -d --dims=15 h5stat_threshold.h5)
#
Expand All @@ -216,8 +232,8 @@
# -AS -a 10
# -a 1
# -A --numattrs=25
ADD_H5_ERR_TEST (h5stat_err1_numattrs 1 -a -2 h5stat_threshold.h5)
ADD_H5_ERR_TEST (h5stat_err2_numattrs 1 --numattrs h5stat_threshold.h5)
ADD_H5_ERR_TEST (h5stat_err1_numattrs 1 "Invalid threshold for small # of attributes" -a -2 h5stat_threshold.h5)
ADD_H5_ERR_TEST (h5stat_err2_numattrs 1 "Invalid threshold for small # of attributes" --numattrs h5stat_threshold.h5)
ADD_H5_TEST (h5stat_numattrs1 0 -AS -a 10 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_numattrs2 0 -a 1 h5stat_threshold.h5)
ADD_H5_TEST (h5stat_numattrs3 0 -A --numattrs=25 h5stat_threshold.h5)
Expand All @@ -229,8 +245,8 @@
# Tests to verify HDFFV-10333:
# h5stat_err_refcount.h5 is generated by h5stat_gentest.c
# h5stat_err_old_layout.h5 and h5stat_err_old_fill.h5: see explanation in h5stat_gentest.c
ADD_H5_TEST (h5stat_err_refcount 1 h5stat_err_refcount.h5)
ADD_H5_TEST (h5stat_err_old_layout 1 h5stat_err_old_layout.h5)
ADD_H5_TEST (h5stat_err_old_fill 1 h5stat_err_old_fill.h5)
ADD_H5_CMP_TEST (h5stat_err_refcount 1 "unable to traverse objects" h5stat_err_refcount.h5)
ADD_H5_CMP_TEST (h5stat_err_old_layout 1 "unable to traverse objects" h5stat_err_old_layout.h5)
ADD_H5_CMP_TEST (h5stat_err_old_fill 1 "unable to traverse objects" h5stat_err_old_fill.h5)
#
#
Loading