From b9470be379354af209daf8418b6c571dde99e776 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 10 Mar 2022 10:22:16 -0800 Subject: Plugin test cleanup (#1479) * Autotools plugin test cleanup * Combines filter, VFD, and VOL plugin tests * Adds VFD plugin tests to the Autotools * Implements a uniform shell script naming scheme in test/ * codespell fix * Changes after code review --- MANIFEST | 31 ++- configure.ac | 25 +- test/CMakeTests.cmake | 42 ++-- test/Makefile.am | 67 ++--- test/ShellTests.cmake | 58 ++--- test/filter_plugin.c | 10 - test/test_abort_fail.sh.in | 66 +++++ test/test_check_version.sh.in | 261 ++++++++++++++++++++ test/test_error.sh.in | 126 ++++++++++ test/test_external_env.sh.in | 42 ++++ test/test_filter_plugin.sh.in | 113 --------- test/test_flush_refresh.sh.in | 238 ++++++++++++++++++ test/test_libinfo.sh.in | 120 +++++++++ test/test_links_env.sh.in | 42 ++++ test/test_plugin.sh.in | 140 +++++++++++ test/test_swmr.pwsh.in | 519 ++++++++++++++++++++++++++++++++++++++ test/test_swmr.sh.in | 563 ++++++++++++++++++++++++++++++++++++++++++ test/test_use_cases.sh.in | 219 ++++++++++++++++ test/test_usecases.sh.in | 219 ---------------- test/test_vds_env.sh.in | 44 ++++ test/test_vds_swmr.pwsh.in | 190 ++++++++++++++ test/test_vds_swmr.sh.in | 233 +++++++++++++++++ test/test_vol_plugin.sh.in | 84 ------- test/testabort_fail.sh.in | 66 ----- test/testcheck_version.sh.in | 261 -------------------- test/testerror.sh.in | 126 ---------- test/testexternal_env.sh.in | 42 ---- test/testflushrefresh.sh.in | 238 ------------------ test/testlibinfo.sh.in | 120 --------- test/testlinks_env.sh.in | 42 ---- test/testswmr.pwsh.in | 519 -------------------------------------- test/testswmr.sh.in | 563 ------------------------------------------ test/testvds_env.sh.in | 44 ---- test/testvdsswmr.pwsh.in | 190 -------------- test/testvdsswmr.sh.in | 233 ----------------- 35 files changed, 2910 insertions(+), 2986 deletions(-) create mode 100644 test/test_abort_fail.sh.in create mode 100644 test/test_check_version.sh.in create mode 100644 test/test_error.sh.in create mode 100644 test/test_external_env.sh.in delete mode 100644 test/test_filter_plugin.sh.in create mode 100644 test/test_flush_refresh.sh.in create mode 100644 test/test_libinfo.sh.in create mode 100644 test/test_links_env.sh.in create mode 100644 test/test_plugin.sh.in create mode 100644 test/test_swmr.pwsh.in create mode 100644 test/test_swmr.sh.in create mode 100644 test/test_use_cases.sh.in delete mode 100644 test/test_usecases.sh.in create mode 100644 test/test_vds_env.sh.in create mode 100644 test/test_vds_swmr.pwsh.in create mode 100644 test/test_vds_swmr.sh.in delete mode 100644 test/test_vol_plugin.sh.in delete mode 100644 test/testabort_fail.sh.in delete mode 100644 test/testcheck_version.sh.in delete mode 100644 test/testerror.sh.in delete mode 100644 test/testexternal_env.sh.in delete mode 100644 test/testflushrefresh.sh.in delete mode 100644 test/testlibinfo.sh.in delete mode 100644 test/testlinks_env.sh.in delete mode 100644 test/testswmr.pwsh.in delete mode 100644 test/testswmr.sh.in delete mode 100644 test/testvds_env.sh.in delete mode 100644 test/testvdsswmr.pwsh.in delete mode 100644 test/testvdsswmr.sh.in diff --git a/MANIFEST b/MANIFEST index 4d11d7f..cd6d086 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1341,28 +1341,27 @@ ./test/tchecksum.c ./test/tconfig.c ./test/tcoords.c -./test/test_filter_plugin.sh.in +./test/test_abort_fail.sh.in +./test/test_check_version.sh.in +./test/test_error.sh.in +./test/test_external_env.sh.in ./test/test_filters_be.h5 ./test/test_filters_le.h5 -./test/test_usecases.sh.in -./test/test_vol_plugin.sh.in -./test/testabort_fail.sh.in -./test/testcheck_version.sh.in -./test/testerror.sh.in -./test/testexternal_env.sh.in -./test/testflushrefresh.sh.in +./test/test_flush_refresh.sh.in +./test/test_libinfo.sh.in +./test/test_links_env.sh.in +./test/test_mirror.sh.in +./test/test_plugin.sh.in +./test/test_swmr.pwsh.in +./test/test_swmr.sh.in +./test/test_use_cases.sh.in +./test/test_vds_env.sh.in +./test/test_vds_swmr.pwsh.in +./test/test_vds_swmr.sh.in ./test/testframe.c ./test/testhdf5.c ./test/testhdf5.h -./test/testlibinfo.sh.in -./test/testlinks_env.sh.in ./test/testmeta.c -./test/test_mirror.sh.in -./test/testswmr.pwsh.in -./test/testswmr.sh.in -./test/testvds_env.sh.in -./test/testvdsswmr.pwsh.in -./test/testvdsswmr.sh.in ./test/tfile.c ./test/tgenprop.c ./test/th5o.c diff --git a/configure.ac b/configure.ac index e426632..4d7be31 100644 --- a/configure.ac +++ b/configure.ac @@ -4165,20 +4165,19 @@ AC_CONFIG_FILES([src/libhdf5.settings src/Makefile test/Makefile test/H5srcdir_str.h - test/testabort_fail.sh - test/testcheck_version.sh - test/testerror.sh - test/testexternal_env.sh - test/testflushrefresh.sh - test/testlibinfo.sh - test/testlinks_env.sh - test/testswmr.sh - test/testvds_env.sh - test/testvdsswmr.sh - test/test_filter_plugin.sh + test/test_abort_fail.sh + test/test_check_version.sh + test/test_error.sh + test/test_external_env.sh + test/test_flush_refresh.sh + test/test_libinfo.sh + test/test_links_env.sh test/test_mirror.sh - test/test_usecases.sh - test/test_vol_plugin.sh + test/test_plugin.sh + test/test_swmr.sh + test/test_use_cases.sh + test/test_vds_env.sh + test/test_vds_swmr.sh testpar/Makefile testpar/testpflush.sh utils/Makefile diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 4e828f8..6abef3b 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -674,18 +674,18 @@ set_tests_properties (H5TEST-tcheck_version-release PROPERTIES # flushrefresh ############################################################################## # autotools script tests -# error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. -# NOT CONVERTED accum_swmr_reader is used by accum.c. -# NOT CONVERTED atomic_writer and atomic_reader are standalone programs. -# links_env is used by testlinks_env.sh -# filenotclosed and del_many_dense_attrs are used by testabort_fail.sh -# NOT CONVERTED flushrefresh is used by testflushrefresh.sh. -# NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh -# NOT CONVERTED swmr_* files (besides swmr.c) are used by testswmr.sh. -# NOT CONVERTED vds_swmr_* files are used by testvdsswmr.sh -# NOT CONVERTED 'make check' doesn't run them directly, so they are not included in TEST_PROG. -# NOT CONVERTED Also build testmeta, which is used for timings test. It builds quickly, -# NOT CONVERTED and this lets automake keep all its test programs in one place. +# error_test and err_compat are built at the same time as the other tests, but executed by test_error.sh +# NOT CONVERTED accum_swmr_reader is used by accum.c +# NOT CONVERTED atomic_writer and atomic_reader are stand-alone programs +# links_env is used by test_links_env.sh +# filenotclosed and del_many_dense_attrs are used by test_abort_fail.sh +# NOT CONVERTED flushrefresh is used by test_flush_refresh.sh +# NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_use_cases.sh +# NOT CONVERTED swmr_* files (besides swmr.c) are used by test_swmr.sh +# NOT CONVERTED vds_swmr_* files are used by test_vds_swmr.sh +# 'make check' doesn't run them directly, so they are not included in TEST_PROG. +# Also build testmeta, which is used for timings test. It builds quickly +# and this lets automake keep all its test programs in one place. ############################################################################## #-- Adding test for filenotclosed @@ -853,16 +853,6 @@ if (BUILD_SHARED_LIBS) ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/filter_plugin_dir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/filter_plugin_dir2;srcdir=${HDF5_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} ) - -############################################################################## -# HDFFV-9655 relative plugin test disabled -# -# add_test (NAME H5PLUGIN-pluginRelative COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) -# set_tests_properties (H5PLUGIN-pluginRelative PROPERTIES -# ENVIRONMENT "HDF5_PLUGIN_PATH=@/${BIN_REL_PATH}testdir1${CMAKE_SEP}@/${BIN_REL_PATH}testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" -# WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} -# ) -############################################################################## endif () option (TEST_SHELL_SCRIPTS "Enable shell script tests" ON) @@ -875,10 +865,10 @@ if (ENABLE_EXTENDED_TESTS) ############################################################################## ### S W M R T E S T S ############################################################################## -# testflushrefresh.sh: flushrefresh -# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes -# testswmr.sh: swmr* -# testvdsswmr.sh: vds_swmr* +# test_flush_refresh.sh: flushrefresh +# test_use_cases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes +# test_swmr.sh: swmr* +# test_vds_swmr.sh: vds_swmr* #-- Adding test for flushrefresh file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/flushrefresh_test") diff --git a/test/Makefile.am b/test/Makefile.am index ff09003..1d31525 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -22,21 +22,23 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # Test scripts-- -# testerror.sh: err_compat, error_test -# testlibinfo.sh: -# testcheck_version.sh: tcheck_version -# testlinks_env.sh: links_env -# testexternal_env.sh: external_env -# testflushrefresh.sh: flushrefresh -# testvds_env.sh: vds_env -# testswmr.sh: swmr* -# testvdsswmr.sh: vds_swmr* -# testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c -# test_filter_plugin.sh: filter_plugin.c +# test_abort_fail.sh: filenotclosed.c and del_many_dense_attrs.c +# test_check_version.sh: tcheck_version +# test_error.sh: err_compat, error_test +# test_external_env.sh: external_env +# test_flush_refresh.sh: flushrefresh +# test_libinfo.sh: +# test_links_env.sh: links_env # test_mirror.sh: mirror_vfd ../utils/mirror_vfd/* -# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes -TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ - testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh +# test_plugin.sh: filter_plugin.c vfd_plugin.c vol_plugin.c +# test_swmr.sh: swmr* +# test_vds_env.sh: vds_env +# test_vds_swmr.sh: vds_swmr* +# test_use_cases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes +TEST_SCRIPT = test_abort_fail.sh test_check_version.sh test_error.sh \ + test_flush_refresh.sh test_external_env.sh test_libinfo.sh \ + test_links_env.sh test_swmr.sh test_vds_env.sh test_vds_swmr.sh \ + test_use_cases.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ @@ -45,10 +47,9 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ vds_env$(EXEEXT) vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL - TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh - SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) + TEST_SCRIPT += test_plugin.sh + SCRIPT_DEPEND += filter_plugin$(EXEEXT) vfd_plugin $(EXEEXT) vol_plugin$(EXEEXT) endif - if MIRROR_VFD_CONDITIONAL TEST_SCRIPT += test_mirror.sh endif @@ -71,22 +72,25 @@ TEST_PROG= testhdf5 \ dangle dtransform reserved cross_read freespace mf vds file_image \ unregister cache_logging cork swmr thread_id vol timer event_set -# List programs to be built when testing here. -# error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. -# tcheck_version is used by testcheck_version.sh. -# accum_swmr_reader is used by accum.c. -# atomic_writer and atomic_reader are standalone programs. -# links_env is used by testlinks_env.sh -# external_env is used by testexternal_env.sh -# filenotclosed and del_many_dense_attrs are used by testabort_fail.sh -# flushrefresh is used by testflushrefresh.sh. -# use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh -# swmr_* files (besides swmr.c) are used by testswmr.sh. -# vds_swmr_* files are used by testvdsswmr.sh -# vds_env is used by testvds_env.sh +# List programs to be built when testing here +# +# error_test and err_compat are built at the same time as the other tests, but executed by test_error.sh +# tcheck_version is used by test_check_version.sh +# accum_swmr_reader is used by accum.c +# atomic_writer and atomic_reader are stand-alone programs +# links_env is used by test_links_env.sh +# external_env is used by test_external_env.sh +# filenotclosed and del_many_dense_attrs are used by test_abort_fail.sh +# flushrefresh is used by test_flush_refresh.sh +# use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_use_cases.sh +# swmr_* files (besides swmr.c) are used by test_swmr.sh +# vds_swmr_* files are used by test_vds_swmr.sh +# vds_env is used by test_vds_env.sh # mirror_vfd is used by test_mirror.sh +# # 'make check' doesn't run them directly, so they are not included in TEST_PROG. -# Also build testmeta, which is used for timings test. It builds quickly, +# +# Also build testmeta, which is used for the timing test. It builds quickly # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ testmeta accum_swmr_reader atomic_writer atomic_reader external_env \ @@ -98,7 +102,6 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vfd_plugin vol_plugin endif - if MIRROR_VFD_CONDITIONAL check_PROGRAMS+= mirror_vfd endif diff --git a/test/ShellTests.cmake b/test/ShellTests.cmake index e7de735..140da6f 100644 --- a/test/ShellTests.cmake +++ b/test/ShellTests.cmake @@ -17,21 +17,21 @@ find_program (PWSH NAMES pwsh powershell) if (PWSH) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/usecases_test") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/use_cases_test") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/swmr_test") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/vds_swmr_test") set (srcdir ${HDF5_TEST_SOURCE_DIR}) set (H5_UTILS_TEST_BUILDDIR ${CMAKE_TEST_OUTPUT_DIRECTORY}) set (H5_TEST_BUILDDIR ${HDF5_TEST_BINARY_DIR}/H5TEST) - configure_file(${HDF5_TEST_SOURCE_DIR}/testswmr.pwsh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/testswmr.ps1 @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_swmr.pwsh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_swmr.ps1 @ONLY) # test commented out as currently the programs are not allowing another access to the data file #add_test (H5SHELL-testswmr ${PWSH} ${HDF5_TEST_BINARY_DIR}/H5TEST/testswmr.ps1) #set_tests_properties (H5SHELL-testswmr PROPERTIES # ENVIRONMENT "PATH=$ENV{PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" # WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST #) - configure_file(${HDF5_TEST_SOURCE_DIR}/testvdsswmr.pwsh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/testvdsswmr.ps1 @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_vds_swmr.pwsh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_vds_swmr.ps1 @ONLY) # test commented out as currently the programs are not allowing another access to the data file #add_test (H5SHELL-testvdsswmr ${PWSH} ${HDF5_TEST_BINARY_DIR}/H5TEST/testvdsswmr.ps1) #set_tests_properties (H5SHELL-testvdsswmr PROPERTIES @@ -48,11 +48,11 @@ elseif (UNIX) # configure scripts to test dir ############################################################################## if (H5_PERL_FOUND) - configure_file(${HDF5_TEST_SOURCE_DIR}/testflushrefresh.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/testflushrefresh.sh @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_flush_refresh.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_flush_refresh.sh @ONLY) endif () - configure_file(${HDF5_TEST_SOURCE_DIR}/test_usecases.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_usecases.sh @ONLY) - configure_file(${HDF5_TEST_SOURCE_DIR}/testswmr.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/testswmr.sh @ONLY) - configure_file(${HDF5_TEST_SOURCE_DIR}/testvdsswmr.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/testvdsswmr.sh @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_use_cases.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_use_cases.sh @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_swmr.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_swmr.sh @ONLY) + configure_file(${HDF5_TEST_SOURCE_DIR}/test_vds_swmr.sh.in ${HDF5_TEST_BINARY_DIR}/H5TEST/test_vds_swmr.sh @ONLY) ############################################################################## # copy test programs to test dir @@ -78,44 +78,44 @@ elseif (UNIX) # flushrefresh ############################################################################## # autotools script tests - # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. - # NOT CONVERTED accum_swmr_reader is used by accum.c. - # NOT CONVERTED atomic_writer and atomic_reader are standalone programs. - # links_env is used by testlinks_env.sh - # filenotclosed and del_many_dense_attrs are used by testabort_fail.sh - # NOT CONVERTED flushrefresh is used by testflushrefresh.sh. - # NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh - # NOT CONVERTED swmr_* files (besides swmr.c) are used by testswmr.sh. - # NOT CONVERTED vds_swmr_* files are used by testvdsswmr.sh + # error_test and err_compat are built at the same time as the other tests, but executed by test_error.sh + # NOT CONVERTED accum_swmr_reader is used by accum.c + # NOT CONVERTED atomic_writer and atomic_reader are stand-alone programs + # links_env is used by test_links_env.sh + # filenotclosed and del_many_dense_attrs are used by test_abort_fail.sh + # NOT CONVERTED flushrefresh is used by test_flush_refresh.sh. + # NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_use_cases.sh + # NOT CONVERTED swmr_* files (besides swmr.c) are used by test_swmr.sh. + # NOT CONVERTED vds_swmr_* files are used by test_vds_swmr.sh # NOT CONVERTED 'make check' doesn't run them directly, so they are not included in TEST_PROG. - # NOT CONVERTED Also build testmeta, which is used for timings test. It builds quickly, + # NOT CONVERTED Also build testmeta, which is used for timing test. It builds quickly # NOT CONVERTED and this lets automake keep all its test programs in one place. ############################################################################## ############################################################################## ### S W M R T E S T S ############################################################################## - # testflushrefresh.sh: flushrefresh - # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes - # testswmr.sh: swmr* - # testvdsswmr.sh: vds_swmr* - add_test (H5SHELL-testflushrefresh ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/testflushrefresh.sh) - set_tests_properties (H5SHELL-testflushrefresh PROPERTIES + # test_flush_refresh.sh: flushrefresh + # test_use_cases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes + # test_swmr.sh: swmr* + # test_vds_swmr.sh: vds_swmr* + add_test (H5SHELL-test_flush_refresh ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/test_flush_refresh.sh) + set_tests_properties (H5SHELL-test_flush_refresh PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) - add_test (H5SHELL-test_usecases ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/test_usecases.sh) - set_tests_properties (H5SHELL-test_usecases PROPERTIES + add_test (H5SHELL-test_use_cases ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/test_use_cases.sh) + set_tests_properties (H5SHELL-test_use_cases PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) - add_test (H5SHELL-testswmr ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/testswmr.sh) - set_tests_properties (H5SHELL-testswmr PROPERTIES + add_test (H5SHELL-test_swmr ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/test_swmr.sh) + set_tests_properties (H5SHELL-test_swmr PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) - add_test (H5SHELL-testvdsswmr ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/testvdsswmr.sh) - set_tests_properties (H5SHELL-testvdsswmr PROPERTIES + add_test (H5SHELL-test_vds_swmr ${SH_PROGRAM} ${HDF5_TEST_BINARY_DIR}/H5TEST/test_vds_swmr.sh) + set_tests_properties (H5SHELL-test_vds_swmr PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) diff --git a/test/filter_plugin.c b/test/filter_plugin.c index c373b3b..dd61a43 100644 --- a/test/filter_plugin.c +++ b/test/filter_plugin.c @@ -968,16 +968,6 @@ test_path_api_calls(void) */ n_starting_paths = 42; - /* Check that initialization is correct */ - TESTING(" initialize"); - - if (H5PLsize(&n_paths) < 0) - TEST_ERROR; - if (n_paths != 2) - TEST_ERROR; - - PASSED(); - /****************/ /* H5PLremove() */ /****************/ diff --git a/test/test_abort_fail.sh.in b/test/test_abort_fail.sh.in new file mode 100644 index 0000000..a866f9e --- /dev/null +++ b/test/test_abort_fail.sh.in @@ -0,0 +1,66 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test to verify that the assertion/abort failure is fixed when the application +# does not close the file. (See HDFFV-10160) +# +# Test to verify that the infinite loop closing library/abort failure is fixed +# when the application creates and removes dense attributes (See HDFFV-10659) + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## +# +# +echo "Testing file not closed assertion/abort failure" +TEST_NAME=filenotclosed # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +# +# Run the test +$RUNSERIAL $TEST_BIN >/dev/null 2>&1 +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test PASSED" +else + echo "Test FAILED" + nerrors="`expr $nerrors + 1`" +fi +# +# +echo "Testing infinite loop closing library/abort failure" +TEST_NAME=del_many_dense_attrs # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +# Run the test +$RUNSERIAL $TEST_BIN >/dev/null 2>&1 +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test PASSED" +else + echo "Test FAILED" + nerrors="`expr $nerrors + 1`" +fi +# +# +if test $nerrors -eq 0 ; then + echo "All tests for abort failure passed." + exit 0 +else + echo "Tests for abort failure failed with $nerrors errors." + exit 1 +fi diff --git a/test/test_check_version.sh.in b/test/test_check_version.sh.in new file mode 100644 index 0000000..273702e --- /dev/null +++ b/test/test_check_version.sh.in @@ -0,0 +1,261 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + +# +# Tests for the H5check_version function. +# +# Programmer: Albert Cheng +# Sep 28, 2009 + +srcdir=@srcdir@ + +# Variables filled in by the configure process. +# Determine the configure options of the hdf5 library and executables. +Shared_Lib=@enable_shared@ +Static_Lib=@enable_static@ +Static_exec=@STATIC_EXEC@ +h5haveexitcode=yes # default is yes + +CMP='cmp -s' +DIFF='diff -c' +RM='rm -f' + +# Function definitions +# +# Show the purpose of this test script and a note about the abort messages. +PURPOSE() { + echo "Tests for the H5check_version function." + echo "Note that abort messages may appear due to the expected termination" + echo "of the program when it is tested with mis-matched version numbers." +} + +# Print a line-line message left justified in a field of 70 characters. +# +LINEMSG() { + SPACES=" " + echo "$* $SPACES" | cut -c1-70 | tr -d '\012' +} + + +# Print a "SKIP" message +SKIP() { + LINEMSG $* + echo " -SKIP-" +} + + +# Print warning message of version mismatch. +WarnMesg(){ + echo "Warning! ***HDF5 library version mismatched error***" + echo "The HDF5 header files used to compile this application do not match" + echo "the version used by the HDF5 library to which this application is linked." + echo "Data corruption or segmentation faults may occur if the application continues." + echo "This can happen when an application was compiled by one version of HDF5 but" + echo "linked with a different version of static or shared HDF5 library." + echo "You should recompile the application or check your shared library related" + echo "settings such as 'LD_LIBRARY_PATH'." + echo "You can, at your own risk, disable this warning by setting the environment" + echo "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'." + echo "Setting it to 2 or higher will suppress the warning messages totally." + echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease" + test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings + echo "Bye..." +} + + +# Print warning message2 of version mismatch. +WarnMesg2(){ + echo "Warning! ***HDF5 library version mismatched error***" + echo "The HDF5 header files used to compile this application do not match" + echo "the version used by the HDF5 library to which this application is linked." + echo "Data corruption or segmentation faults may occur if the application continues." + echo "This can happen when an application was compiled by one version of HDF5 but" + echo "linked with a different version of static or shared HDF5 library." + echo "You should recompile the application or check your shared library related" + echo "settings such as 'LD_LIBRARY_PATH'." + echo "'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will" + echo "continue at your own risk." + echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease" + test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings +} + + +# Run a test and print PASS or *FAIL*. If a test fails then increment +# the `nerrors' global variable and (if $verbose is set) display the +# difference between the actual output and the expected output. The +# expected output generated according to the parameter values and compared +# against actual output. +# The expected and actual output files are removed unless $HDF5_NOCLEANUP +# has a non-zero value. +# $1: the set value of $HDF5_DISABLE_VERSION_CHECK. (unset means not to set +# it at all. +# $2: Change the version number(s) to cause a mismatch. (none means no +# mismatch). +# +# Expected results: +# Value of $HDF5_DISABLE_VERSION_CHECK +# unset "" -1 0 1 2 3 +# Matched OK OK OK OK OK OK OK +# Mismatched W/A W/A W/A W/A W2/OK OK W2/OK +# Result codes: +# OK: No warning, exit 0. +# W/A: Warning, abort and exit non-0. +# W2/OK: Different Warning, exit 0. +# +# Implemented only exit code matching. Still need to match output. +TESTING() { + DEBUGPRINT command is $0 $* + TEST_NAME=tcheck_version # The test name + TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary + + expect=${TEST_NAME}_expect.out + actual=${TEST_NAME}_actual.out + actual_err=${TEST_NAME}_actual.err + arguments= + + h5DisableVersion="$1" + wrongversionnumbers="$2" + xxh5versmajor=$h5versmajor + xxh5versminor=$h5versminor + xxh5versrelease=$h5versrelease + + if [ "$h5DisableVersion" = unset ]; then + envcmd="" # noop + else + envcmd="env HDF5_DISABLE_VERSION_CHECK=$h5DisableVersion" + fi + + if [ "$wrongversionnumbers" = none ]; then + # OK: No warning, exit 0 + cp /dev/null $expect + expect_code=0 + else + arguments=-t"$wrongversionnumbers" + # calculate mismatched version numbers by listing. + case $wrongversionnumbers in + "M") xxh5versmajor=`expr $h5versmajor + 1` + ;; + "m") xxh5versminor=`expr $h5versminor + 1` + ;; + "r") xxh5versrelease=`expr $h5versrelease + 1` + ;; + esac + case "$h5DisableVersion" in + 1) + # W2/OK: Different Warning, exit 0. + WarnMesg2 > $expect + expect_code=0 + ;; + [2-9]|[1-9][0-9]*) + # OK: No warning, exit 0 + cp /dev/null $expect + expect_code=0 + ;; + *) # W/A: Warning, abort and exit non-0. + WarnMesg > $expect + expect_code=6 # Signal Abort exit code (128+6) + ;; + esac + fi + + # Run test. + LINEMSG $envcmd $TEST_NAME $arguments + ( + $envcmd $RUNSERIAL $TEST_BIN $arguments + ) >$actual 2>$actual_err + ret_code=$? + cat $actual_err >> $actual + + if [ $h5haveexitcode = 'yes' -a \( $expect_code -ne $ret_code \) ]; then + echo "*FAILED*" + echo " Expected exit code ($expect_code) differs from actual code ($ret_code)" + nerrors="`expr $nerrors + 1`" + elif $CMP $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file. + # Also clean the core file generated by H5check_version's abort. + if test -z "$HDF5_NOCLEANUP"; then + $RM $expect $actual $actual_err + $RM core + fi +} + + +# Echo parameters for debugging if verbose mode is on. +DEBUGPRINT() { + if [ -n "$debugmode" ]; then + echo $* + fi +} + + +# MAIN Body +nerrors=0 +verbose=yes # default on +debugmode= # default off +H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h` +h5libsettings=../src/libhdf5.settings + +PURPOSE + +# Figure out library version numbers from the header file. +h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | awk '{print $3}'` +h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | awk '{print $3}'` +h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | awk '{print $3}'` +DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease +case "$h5versmajor$h5versminor$h5versrelease" in + [0-9]*) # good. noop. + ;; + *) + echo "Illegal library version numbers($h5versmajor.$h5versminor.$h5versrelease)" + echo "Test aborted" + exit 1 + ;; +esac + +# RUNSERIAL is used. Check if it can return exit code from executalbe correctly. +if [ -n "$RUNSERIAL_NOEXITCODE" ]; then + echo "***Warning*** Serial Exit Code is not passed back to shell correctly." + echo "***Warning*** Exit code checking is skipped." + h5haveexitcode=no +fi + +# Three Categories of tests: +# Normal: where the version numbers all matched (wrong_version == none). +# Mismatched version numbers (could be Major or minor version +# or release numbers or a combination of all three.) +# Test all the above with different values of the environment variable, +# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3 + +for val_disable_version_check in unset "" -1 0 1 2 3; do + for wrong_version in none M m; do + TESTING "$val_disable_version_check" "$wrong_version" + done +done + + +# Check and report results. +if [ $nerrors -gt 0 ]; then + echo "***$nerrors errors encountered***" + exit 1 +else + echo "No error encountered" + exit 0 +fi diff --git a/test/test_error.sh.in b/test/test_error.sh.in new file mode 100644 index 0000000..4fb2a81 --- /dev/null +++ b/test/test_error.sh.in @@ -0,0 +1,126 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for test_error and err_compat + +srcdir=@srcdir@ + +# Determine backward compatibility options eneabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +CMP='cmp -s' +DIFF='diff -c' + +# Skip plugin module to test missing filter +# Also reset the VOL connector to only use the native connector, because of the +# error stack checking. QAK - 2019/03/09 +ENVCMD="env HDF5_PLUGIN_PRELOAD=:: HDF5_VOL_CONNECTOR=native" + +nerrors=0 +verbose=yes + +test -d ./testfiles || mkdir ./testfiles + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Run a test and print PASS or *FAIL*. If a test fails then increment +# the `nerrors' global variable and (if $verbose is set) display the +# difference between the actual output and the expected output. The +# expected output is given as the first argument to this function and +# the actual output file is calculated by replacing the `.ddl' with +# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a +# non-zero value. +# +TEST() { + TEST_ERR=$1 # The test name + TEST_ERR_BIN=`pwd`/$TEST_ERR # The path of the test binary + + expect1="$srcdir/testfiles/$1_1" + expect2="$srcdir/testfiles/$1_2" + actual="./`basename $1`.out" + actual_err="./`basename $1`.err" + actual_ext="./`basename $1`.ext" + shift + + # Run test. + TESTING $TEST_ERR + ( + # Skip the plugin for testing missing filter. + $ENVCMD $RUNSERIAL $TEST_ERR_BIN + ) >$actual 2>$actual_err + + # Check for core dump + if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` + fi + + # Extract file name, line number, version and thread IDs because they may be different + sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ + -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ + $actual_err > $actual_ext + cat $actual_ext >> $actual + + if $CMP $expect1 $actual; then + echo " PASSED" + elif $CMP $expect2 $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect1 $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err $actual_ext + fi +} + +# Print a "SKIP" message +SKIP() { + TESTING $@ + echo " -SKIP-" +} + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for err_compat +if test $DEPRECATED_SYMBOLS != "yes"; then +SKIP err_compat +else +TEST err_compat +fi + +# test for error_test. Skip the plugin for testing missing filter. +TEST error_test + +if test $nerrors -eq 0 ; then + echo "All Error API tests passed." +fi + +exit $nerrors diff --git a/test/test_external_env.sh.in b/test/test_external_env.sh.in new file mode 100644 index 0000000..94fbb88 --- /dev/null +++ b/test/test_external_env.sh.in @@ -0,0 +1,42 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_EXTFILE_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for external file with HDF5_EXTFILE_PREFIX +echo "Testing external file with HDF5_EXTFILE_PREFIX" +TEST_NAME=external_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_EXTFILE_PREFIX PASSED" +else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_EXTFILE_PREFIX test***" +fi +exit $nerrors diff --git a/test/test_filter_plugin.sh.in b/test/test_filter_plugin.sh.in deleted file mode 100644 index 78cdb3a..0000000 --- a/test/test_filter_plugin.sh.in +++ /dev/null @@ -1,113 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -srcdir=@srcdir@ -TOP_BUILDDIR=@top_builddir@ - -# Determine if backward compatibility options enabled -DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" - -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -nerrors=0 -verbose=yes -exit_code=$EXIT_SUCCESS - -TEST_NAME=filter_plugin -TEST_BIN=`pwd`/$TEST_NAME -FROM_DIR=`pwd`/.libs -case $(uname) in - CYGWIN* ) - PLUGINS_FOR_DIR1="$FROM_DIR/cygfilter_plugin1* $FROM_DIR/cygfilter_plugin3*" - PLUGINS_FOR_DIR2="$FROM_DIR/cygfilter_plugin2* $FROM_DIR/cygfilter_plugin4*" - ;; - *) - PLUGINS_FOR_DIR1="$FROM_DIR/libfilter_plugin1* $FROM_DIR/libfilter_plugin3*" - PLUGINS_FOR_DIR2="$FROM_DIR/libfilter_plugin2* $FROM_DIR/libfilter_plugin4*" - ;; -esac -PLUGIN_DIR1=filter_plugin_dir1 -PLUGIN_DIR2=filter_plugin_dir2 -CP="cp -p" # Use -p to preserve mode,ownership,timestamps -RM="rm -rf" - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Main Body -# Create test directories if necessary. -test -d $PLUGIN_DIR1 || mkdir -p $PLUGIN_DIR1 -if [ $? != 0 ]; then - echo "Failed to create filter plugin test directory ($PLUGIN_DIR1)" - exit $EXIT_FAILURE -fi - -test -d $PLUGIN_DIR2 || mkdir -p $PLUGIN_DIR2 -if [ $? != 0 ]; then - echo "Failed to create filter plugin test directory ($PLUGIN_DIR2)" - exit $EXIT_FAILURE -fi - -# Copy plugins for the tests. -$CP $PLUGINS_FOR_DIR1 $PLUGIN_DIR1 -if [ $? != 0 ]; then - echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR1) to test directory." - exit $EXIT_FAILURE -fi - -$CP $PLUGINS_FOR_DIR2 $PLUGIN_DIR2 -if [ $? != 0 ]; then - echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR2) to test directory." - exit $EXIT_FAILURE -fi - -# setup plugin path -ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_DIR1}:${PLUGIN_DIR2}" - -# Run the test -$ENVCMD $TEST_BIN -if [ $? != 0 ]; then - nerrors=`expr $nerrors + 1` -fi - -############################################ -# HDFFV-9655 test for relative path disabled -# setup filter plugin path relative to test -# actual executable is in the .libs folder -#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_DIR1}:@/../${PLUGIN_DIR2}" -# -# Run the test -#$ENVCMD $TEST_BIN -#if [ $? != 0 ]; then -# nerrors=`expr $nerrors + 1` -#fi -############################################# - -# print results -if test $nerrors -ne 0 ; then - echo "$nerrors errors encountered" - exit_code=$EXIT_FAILURE -else - echo "All filter plugin tests passed." - exit_code=$EXIT_SUCCESS -fi - -# Clean up temporary files/directories and leave -$RM $PLUGIN_DIR1 $PLUGIN_DIR2 - -exit $exit_code diff --git a/test/test_flush_refresh.sh.in b/test/test_flush_refresh.sh.in new file mode 100644 index 0000000..209d370 --- /dev/null +++ b/test/test_flush_refresh.sh.in @@ -0,0 +1,238 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# +# Test script for the flush/evict single objects feature. +# +# This test file doesn't actually perform any tests, rather, it acts +# as a process manager for the 'flushrefresh' test file, which is where +# the tests are actually housed. The reason this script exists is because +# the verification of this feature needs to occur in separate processes +# from the one in which the file is being manipulated in. (i.e., we have +# a single writer process, and various reader processes spawning off +# and doing the verification that individual objects are being +# correctly flushed). +# +# Programmer: +# Mike McGreevy +# Tuesday, July 20, 2010 + +############################################################################### +## test variables +############################################################################### + +# Number of errors encountered during test run. +nerrors=0 + +# Set up a function to check the current time since the epoch - ideally, we'd +# like to use Perl. If it wasn't detected by configure, then use date, though +# this is less portable and might cause problems on machines that don't +# recognize the +%s option (like Solaris). +# +# Note that PERL will resolve to true or false, not a path. +PERL=@PERL@ +if test -n "$PERL"; then + TimeStamp() + { + time=`perl -e 'print int(time)'` + echo "$time" + } +else + TimeStamp() + { + time=`date +%s` + echo "$time" + } +fi + +############################################################################### +## Main +############################################################################### +srcdir=@srcdir@ +utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ +testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$utils_testdir/swmr_check_compat_vfd +rc=$? +if [ $rc -ne 0 ] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR." + echo + echo "flush/refresh tests skipped" + echo + exit 0 +fi + +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir -p flushrefresh_test +cp $testdir/flushrefresh flushrefresh_test + +# With the --disable-shared option, flushrefresh is built in the test directory, +# otherwise it is in test/.libs with a wrapper script named flushrefresh in +# the test directory. test/flushrefresh should always be copied, +# .libs/flushrefresh should be copied only if it exists. +if [ -f .libs/flushrefresh ]; then + mkdir -p flushrefresh_test/.libs + for FILE in .libs/flushrefresh*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE flushrefresh_test/.libs + fi + done +fi +cd flushrefresh_test + +# ================================================= +# Set up/initialize some variables to be used later +# ================================================= +testfile=flushrefresh.h5 +startsignal=flushrefresh_VERIFICATION_START +endsignal=flushrefresh_VERIFICATION_DONE +timeout_length=300 +timedout=0 +verification_done=0 +if [ -e $testfile ]; then + rm $testfile +fi + +# ======================== +# Launch the Test Program. +# ======================== +$testdir/flushrefresh & +pid_main=$! + +# ======================================= +# Run flush verification on test program. +# ======================================= + +until [ $verification_done -eq 1 ]; do + + # Wait for signal from test program that verification routine can run. + before=`TimeStamp` + until [ -s $startsignal ]; do + after=`TimeStamp` + timediff=`expr $after - $before` + if [ $timediff -gt $timeout_length ]; then + nerrors=`expr $nerrors + 1` + timedout=1 + break + fi + done + + # Check to see if we timed out looking for the signal before continuing. + if [ $timedout -gt 0 ]; then + echo "timed out waiting for signal from test program (flush)." + break + fi + + # Read in test routine parameters from signal file, then delete signal file. + param1=`head -1 $startsignal` + param2=`tail -1 $startsignal` + rm $startsignal + + # Check if we're done with verifications, otherwise run the specified verification. + if [ "$param1" = "VERIFICATION_DONE" ]; then + verification_done=1 + echo "all flush verification complete" > $endsignal + else + $testdir/flushrefresh $param1 $param2 + + # Check for core dump + if [ $? -gt 0 ]; then + nerrors=`expr $nerrors + 1` + fi + + echo "verification flush process done" > $endsignal + fi + +done + +# ========================================= +# Run refresh verification on test program. +# ========================================= +if [ $timedout -eq 0 ]; then + until [ $verification_done -eq 2 ]; do + + # Wait for signal from test program that verification routine can run. + before=`TimeStamp` + until [ -s $startsignal ]; do + after=`TimeStamp` + timediff=`expr $after - $before` + if [ $timediff -gt $timeout_length ]; then + nerrors=`expr $nerrors + 1` + timedout=1 + break + fi + done + + # Check to see if we timed out looking for the signal before continuing. + if [ $timedout -gt 0 ]; then + echo "timed out waiting for signal from test program (refresh)." + break + fi + + # Read in test routine parameter from signal file, then delete signal file. + param1=`head -n 1 $startsignal` + rm $startsignal + + # Check if we're done with verifications, otherwise run the specified verification. + if [ "$param1" = "VERIFICATION_DONE" ]; then + verification_done=2 + echo "all refresh verification complete" > $endsignal + else + $testdir/flushrefresh $param1 + + # Check for core dump + if [ $? -gt 0 ]; then + nerrors=`expr $nerrors + 1` + fi + + echo "refresh verifiction process done" > $endsignal + fi + + done +fi + +# ============================================ +# Wait for main to finish up, and end testing. +# ============================================ +wait $pid_main +if test $? -ne 0; then + echo flushrefresh had error + nerrors=`expr $nerrors + 1` +fi + +############################################################################### +## Report and exit +############################################################################### + +if test $nerrors -eq 0 ; then + echo "flush/refresh objects tests passed." + if test -z "$HDF5_NOCLEANUP"; then + # delete the test directory + rm -rf flushrefresh_test + fi + exit 0 +else + echo "flush/refresh objects tests failed with $nerrors errors." + exit 1 +fi diff --git a/test/test_libinfo.sh.in b/test/test_libinfo.sh.in new file mode 100644 index 0000000..d9fee48 --- /dev/null +++ b/test/test_libinfo.sh.in @@ -0,0 +1,120 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# +# Tests for the embedded library information feature. +# Part 1: +# Verify the HDF5 library does contains an exact copy of the content of the +# libhdf5.settings file. +# Part 2: +# If executable is linked with the static hdf5 library (how to determine?), +# verify an executable indeed contains an exact copy of the content of the +# libhdf5.settings file. +# +# Programmer: Albert Cheng +# Sep 18, 2009 + +srcdir=@srcdir@ + +# Determine the configure options of the hdf5 library and executables. + +Shared_Lib=@enable_shared@ +Static_Lib=@enable_static@ +Static_exec=@STATIC_EXEC@ + + +# Print a line-line message left justified in a field of 70 characters. +# +LINEMSG() { + SPACES=" " + echo "Check file $* $SPACES" | cut -c1-70 | tr -d '\012' +} + + +# Print a "SKIP" message +SKIP() { + LINEMSG $* + echo " -SKIP-" +} + +# Function definitions +CHECK_LIBINFO(){ + LINEMSG $1 + # Some systems, like Mac, the strings command inspects library files. Older + # versions of strings may not know newer library format, resulting in + # command errors. Make it read the file as stdin to avoid the problem. + if strings < $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then + echo " PASSED" + else + echo " FAILED" + nerrors=`expr $nerrors + 1` + fi +} + + +# MAIN Body +nerrors=0 +H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h` + +# Skip the rest if embedded-libinfo is not enabled. +if [ -z "$H5_HAVE_EMBEDDED_LIBINFO" ]; then + echo "embedded-libinfo is not enabled. Test skipped." + exit 0 +fi + +# The location of HDF library file(s) depends on whether shared lib is +# built too. +if [ -n $Shared_Lib ]; then + h5libdir=../src/.libs + shlib=$(grep dlname ../src/libhdf5.la | sed -e "s/dlname='//" -e "s/'//") +else + h5libdir=../src +fi + +h5libsettings=../src/libhdf5.settings + +# Part 1: +# Verify the HDF5 library does contains an exact copy of the content of the +# libhdf5.settings file. +# Check dynamic library file if built. +if [ x-$Shared_Lib = x-yes ]; then + CHECK_LIBINFO ${h5libdir}/${shlib} +else + SKIP shlib +fi + +# Though rare, libhdf5.a may not have been built. +if [ x-$Static_Lib = x-yes ]; then + CHECK_LIBINFO ${h5libdir}/libhdf5.a +else + SKIP ${h5libdir}/libhdf5.a +fi + +# Check if executables has the lib information only if shared lib is not +# built or static-exec is used. (Don't care static-exec since it affects +# tools binary only.) +if [ x-$Shared_Lib != x-yes ]; then + CHECK_LIBINFO testhdf5 +else + SKIP testhdf5 +fi + + +if [ $nerrors -gt 0 ]; then + echo "***$nerrors errors encountered***" + exit 1 +else + echo "No error encountered" + exit 0 +fi diff --git a/test/test_links_env.sh.in b/test/test_links_env.sh.in new file mode 100644 index 0000000..09074c3 --- /dev/null +++ b/test/test_links_env.sh.in @@ -0,0 +1,42 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external link with environment variable: HDF5_EXT_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for external links with HDF5_EXT_PREFIX +echo "Testing external link with HDF5_EXT_PREFIX" +TEST_NAME=links_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXT_PREFIX=.:tmp_links_env" # The environment variable & value +# +# Run the test +echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test for HDF5_EXT_PREFIX PASSED" +else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_EXT_PREFIX test***" +fi +exit $nerrors diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in new file mode 100644 index 0000000..d958b4b --- /dev/null +++ b/test/test_plugin.sh.in @@ -0,0 +1,140 @@ +#!/usr/bin/env bash +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# This shell script is for testing filter, VFD, and VOL plugins. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +CP="cp -p" # Use -p to preserve mode,ownership, timestamps +RM="rm -rf" + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +# Test binary names +FILTER_TEST_NAME=filter_plugin +FILTER_TEST_BIN=`pwd`/$FILTER_TEST_NAME + +VFD_TEST_NAME=vfd_plugin +VFD_TEST_BIN=`pwd`/$VFD_TEST_NAME + +VOL_TEST_NAME=vol_plugin +VOL_TEST_BIN=`pwd`/$VOL_TEST_NAME + +# Paths to actual plugins ("libraries" in test directory are just stubs) +FROM_DIR=`pwd`/.libs +case $(uname) in + CYGWIN* ) + NULL_VFD_PLUGIN="$FROM_DIR/cygnull_vfd_plugin*" + NULL_VOL_PLUGIN="$FROM_DIR/cygnull_vol_connector*" + PLUGINS_FOR_DIR1="$FROM_DIR/cygfilter_plugin1* $FROM_DIR/cygfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/cygfilter_plugin2* $FROM_DIR/cygfilter_plugin4*" + ;; + *) + NULL_VFD_PLUGIN="$FROM_DIR/libnull_vfd_plugin*" + NULL_VOL_PLUGIN="$FROM_DIR/libnull_vol_connector*" + PLUGINS_FOR_DIR1="$FROM_DIR/libfilter_plugin1* $FROM_DIR/libfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/libfilter_plugin2* $FROM_DIR/libfilter_plugin4*" + ;; +esac + +# Directories where we'll copy plugins +TEMP_PLUGIN_DIR=temp_plugins +TEMP_FILTER_DIR1=temp_filter_plugin_dir1 +TEMP_FILTER_DIR2=temp_filter_plugin_dir2 + +# Function to print a line-line message left justified in a field of +# 70 characters beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +############# +# Main Body # +############# + +# Create plugin directories +test -d $TEMP_PLUGIN_DIR || mkdir -p $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to create plugin test directory ($TEMP_PLUGIN_DIR)" + exit $EXIT_FAILURE +fi +test -d $TEMP_FILTER_DIR1 || mkdir -p $TEMP_FILTER_DIR1 +if [ $? != 0 ]; then + echo "Failed to create filter plugin test directory ($TEMP_FILTER_DIR1)" + exit $EXIT_FAILURE +fi +test -d $TEMP_FILTER_DIR2 || mkdir -p $TEMP_FILTER_DIR2 +if [ $? != 0 ]; then + echo "Failed to create filter plugin test directory ($TEMP_FILTER_DIR2)" + exit $EXIT_FAILURE +fi + +# Copy plugins for the tests +$CP $NULL_VFD_PLUGIN $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to copy NULL VFD plugin ($NULL_VFD_PLUGIN) to test directory." + exit $EXIT_FAILURE +fi +$CP $NULL_VOL_PLUGIN $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to copy NULL VOL plugin ($NULL_VOL_PLUGIN) to test directory." + exit $EXIT_FAILURE +fi +$CP $PLUGINS_FOR_DIR1 $TEMP_FILTER_DIR1 +if [ $? != 0 ]; then + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR1) to test directory." + exit $EXIT_FAILURE +fi +$CP $PLUGINS_FOR_DIR2 $TEMP_FILTER_DIR2 +if [ $? != 0 ]; then + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR2) to test directory." + exit $EXIT_FAILURE +fi + +# Set plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${TEMP_PLUGIN_DIR}:${TEMP_FILTER_DIR1}:${TEMP_FILTER_DIR2}" + +# Run the tests +$ENVCMD $FILTER_TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi +$ENVCMD $VFD_TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi +$ENVCMD $VOL_TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# Print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All plugin tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $TEMP_PLUGIN_DIR $TEMP_FILTER_DIR1 $TEMP_FILTER_DIR2 + +exit $exit_code diff --git a/test/test_swmr.pwsh.in b/test/test_swmr.pwsh.in new file mode 100644 index 0000000..de7a57a --- /dev/null +++ b/test/test_swmr.pwsh.in @@ -0,0 +1,519 @@ +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for the swmr feature. + +$srcdir = '@srcdir@' +$utils_testdir=@H5_UTILS_TEST_BUILDDIR@ +$testdir=@H5_TEST_BUILDDIR@ + +############################################################################### +## test parameters +############################################################################### + +$Nreaders = 5 # number of readers to launch +$Nrdrs_spa = 3 # number of sparse readers to launch +$Nrecords = 200000 # number of records to write +$Nrecs_rem = 40000 # number of times to shrink +$Nrecs_spa = 20000 # number of records to write in the sparse test +$Nsecs_add = 5 # number of seconds per read interval +$Nsecs_rem = 3 # number of seconds per read interval +$Nsecs_addrem = 8 # number of seconds per read interval +$nerrors = 0 + +############################################################################### +## definitions for message file to coordinate test runs +############################################################################### +$WRITER_MESSAGE = 'SWMR_WRITER_MESSAGE' # The message file created by writer that the open is complete + # This should be the same as the define in "test/swmr_common.h" +$MESSAGE_TIMEOUT = 300 # Message timeout length in secs + # This should be the same as the define in "test/h5test.h" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +function Test-WithSpaces { + $SPACES=' ' + #Write-Output "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# To wait for the writer message file or till the maximum # of seconds is reached +# $Message is the message file to wait for +# This performs similar function as the routine h5_wait_message() in test/h5test.c +function Wait-Message { + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [string]$TestPath, # Get the path of the message file to wait for + [Parameter(Mandatory, ValueFromPipeline)] + [string]$Message # Get the name of the message file to wait for + ) + + PROCESS { + $message = Join-Path -Path $TestPath -ChildPath $Message + $t0 = Get-Date # Get current time + $t1 = $t0 + $difft = New-Timespan -Start $t0 -End $t1 # Initialize the time difference + $mexist = 0 # Indicate whether the message file is found + while ($difft.TotalSeconds -lt $MESSAGE_TIMEOUT) { # Loop till message times out + $t1 = Get-Date # Get current time in seconds + $difft = New-Timespan -Start $t0 -End $t1 # Calculate the time difference + #Write-Output "Check for $message : time=$difft" + if ([System.IO.File]::Exists($message)) { # If message file is found: + $mexist = 1 # indicate the message file is found + Remove-Item $message # remove the message file + break # get out of the while loop + } + } + if ($mexist -eq 0) { + # Issue warning that the writer message file is not found, continue with launching the reader(s) + Write-Warning -Message "$WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds" + } + else { + Write-Output "$WRITER_MESSAGE is found" + } + } +} + +############################################################################### +## Main +## +## Modifications: +## Vailin Choi; July 2013 +## Add waiting of message file before launching the reader(s). +## Due to the implementation of file locking, coordination +## is needed in file opening for the writer/reader tests +## to proceed as expected. +## +############################################################################### + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$testprog = Join-Path -Path $utils_testdir -ChildPath swmr_check_compat_vfd.exe +$rp = Start-Process -FilePath $testprog -PassThru -Wait -NoNewWindow +if ($rp.ExitCode -ne 0) { + Write-Output "" + Write-Output "The VFD specified by the HDF5_DRIVER environment variable" + Write-Output "does not support SWMR." + Write-Output "" + Write-Output "SWMR acceptance tests skipped" + Write-Output "" + exit 0 +} + +Set-Location -Path swmr_test +$testdir = Join-Path -Path $testdir -ChildPath swmr_test + +# Loop over index types +$IndexTypeLoop = '-i ea', '-i b2' +foreach ($index_type in $IndexTypeLoop) { + # Try with and without compression + $CompressLoop = '', '-c 5' + foreach ($compress in $CompressLoop) { + Write-Output "" + Write-Output "*******************************************************************************" + Write-Output "** Loop testing parameters: $index_type $compress" + Write-Output "*******************************************************************************" + Write-Output "" + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Generator test" + Write-Output "###############################################################################" + # Launch the Generator without SWMR_WRITE + Write-Output "launch the swmr_generator" + $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -ArgumentList "$compress $index_type" -PassThru -Wait + if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 + } + + # Launch the Generator with SWMR_WRITE + Write-Output "launch the swmr_generator with SWMR_WRITE" + $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -ArgumentList "-s $compress $index_type" -PassThru -Wait + if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + exit 1 + } + + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Use H5Fstart_swmr_write() to enable SWMR writing mode" + Write-Output "###############################################################################" + + # Remove any possible writer message file before launching writer + if ([System.IO.File]::Exists($WRITER_MESSAGE)) { # If message file is found + Remove-Item $WRITER_MESSAGE + } + # + # Launch the Writer + Write-Output "launch the swmr_start_writer" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_start_write.exe -NoNewWindow -PassThru -ArgumentList "$compress $index_type $Nrecords $seed" 2>&1 |tee swmr_writer.out + $pid_writer = $rp.id + #Write-Output "pid_writer=$pid_writer" + + # Wait for message from writer process before starting reader(s) + Wait-Message $testdir $WRITER_MESSAGE + + # + # Launch the Readers + #declare -a seeds = ( ... ) + Write-Output "launch $Nreaders swmr_readers" + $pid_readers = @() + $n = 0 + while ($n -lt $Nreaders) { + #seed = "-r ${seeds[$n]}" + $seed = "" + $rp = Start-Process -FilePath $testdir/swmr_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_add $seed" 2>&1 | tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 + } + #Write-Output "pid_readers=$pid_readers" + + # Collect exit code of the readers first because they usually finish + # before the writer. + foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } + } + + # Collect exit code of the writer + #Write-Output "checked writer $pid_writer" + $result = Wait-Process -Id $pid_writer + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + Write-Warning "(Writer and reader output preserved)" + exit 1 + } + + # Clean up output files + Remove-Item swmr_writer.out + Remove-Item swmr_reader.out.* + + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Writer test - test expanding the dataset" + Write-Output "###############################################################################" + + # Launch the Generator + Write-Output "launch the swmr_generator" + $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -PassThru -Wait -ArgumentList "-s $compress $index_type" + if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 + } + + # Remove any possible writer message file before launching writer + Remove-Item $WRITER_MESSAGE + # + # Launch the Writer + Write-Output "launch the swmr_writer" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_writer.exe -NoNewWindow -PassThru -ArgumentList "-o $Nrecords $seed" 2>&1 |tee swmr_writer.out + $pid_writer = $rp.id + #Write-Output "pid_writer=$pid_writer" + + # Wait for message from writer process before starting reader(s) + Wait-Message $testdir $WRITER_MESSAGE + # + # Launch the Readers + #declare -a seeds = ( ... ) + Write-Output "launch $Nreaders swmr_readers" + $pid_readers = @() + $n = 0 + while ($n -lt $Nreaders) { + #seed = "-r ${seeds[$n]}" + $seed = "" + $rp = Start-Process -FilePath $testdir/swmr_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_add $seed" 2>&1 |tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 + } + #Write-Output "pid_readers=$pid_readers" + + # Collect exit code of the readers first because they usually finish + # before the writer. + foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } + } + + # Collect exit code of the writer + #Write-Output "checked writer $pid_writer" + $result = Wait-Process -Id $pid_writer + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + Write-Warning "(Writer and reader output preserved)" + exit 1 + } + + # Clean up output files + Remove-Item swmr_writer.out + Remove-Item swmr_reader.out.* + + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Remove test - test shrinking the dataset" + Write-Output "###############################################################################" + + # Remove any possible writer message file before launching writer + Remove-Item $WRITER_MESSAGE + # Launch the Remove Writer + Write-Output "launch the swmr_remove_writer" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_remove_writer.exe -NoNewWindow -PassThru -ArgumentList "-o $Nrecs_rem $seed" 2>&1 |tee swmr_writer.out + $pid_writer = $rp.id + #Write-Output "pid_writer=$pid_writer" + + # Wait for message from writer process before starting reader(s) + Wait-Message $testdir $WRITER_MESSAGE + # + # Launch the Remove Readers + #declare -a seeds = ( ... ) + $n = 0 + $pid_readers = @() + Write-Output "launch $Nreaders swmr_remove_readers" + while ($n -lt $Nreaders) { + #seed = "-r ${seeds[$n]}" + $seed = "" + $rp = Start-Process -FilePath $testdir/swmr_remove_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_rem $seed" 2>&1 |tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 + } + #Write-Output "pid_readers=$pid_readers" + + # Collect exit code of the readers first because they usually finish + # before the writer. + foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } + } + + # Collect exit code of the writer + #Write-Output "checked writer $pid_writer" + $result = Wait-Process -Id $pid_writer + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + Write-Warning "(Writer and reader output preserved)" + exit 1 + } + + # Clean up output files + Remove-Item swmr_writer.out + Remove-Item swmr_reader.out.* + + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Add/remove test - randomly grow or shrink the dataset" + Write-Output "###############################################################################" + + # Launch the Generator + Write-Output "launch the swmr_generator" + $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow-PassThru -Wait -ArgumentList "$compress $index_type" + if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 + } + + # Launch the Writer (not in parallel - just to rebuild the datasets) + Write-Output "launch the swmr_writer" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_writer.exe -NoNewWindow -PassThru -Wait -ArgumentList "$Nrecords $seed" + if ($rp.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Remove any possible writer message file before launching writer + Remove-Item $WRITER_MESSAGE + # + # Launch the Add/Remove Writer + Write-Output "launch the swmr_addrem_writer" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_addrem_writer.exe -NoNewWindow -PassThru -ArgumentList "$Nrecords $seed" 2>&1 |tee swmr_writer.out + $pid_writer = $rp.id + #Write-Output "pid_writer=$pid_writer" + + # Wait for message from writer process before starting reader(s) + Wait-Message $testdir $WRITER_MESSAGE + # + # Launch the Add/Remove Readers + #declare -a seeds = ( ... ) + $n = 0 + $pid_readers = @() + Write-Output "launch $Nreaders swmr_remove_readers" + while ($n -lt $Nreaders) { + #seed = "-r ${seeds[$n]}" + $seed = "" + $rp = Start-Process -FilePath $testdir/swmr_remove_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_addrem $seed" 2>&1 |tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 + } + #Write-Output "pid_readers=$pid_readers" + + # Collect exit code of the readers first because they usually finish + # before the writer. + foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } + } + + # Collect exit code of the writer + #Write-Output "checked writer $pid_writer" + $result = Wait-Process -Id $pid_writer + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + Write-Warning "(Writer and reader output preserved)" + exit 1 + } + + # Clean up output files + Remove-Item swmr_writer.out + Remove-Item swmr_reader.out.* + + Write-Output "" + Write-Output "###############################################################################" + Write-Output "## Sparse writer test - test writing to random locations in the dataset" + Write-Output "###############################################################################" + + # Launch the Generator + # NOTE: Random seed is shared between readers and writers and is + # created by the generator. + Write-Output "launch the swmr_generator" + $seed = "" # Put -r command here + $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -PassThru -Wait -ArgumentList "$compress $index_type $seed" + if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 + } + + # Remove any possible writer message file before launching writer + Remove-Item $WRITER_MESSAGE + # Launch the Sparse writer + Write-Output "launch the swmr_sparse_writer" + $rp = Start-Process -FilePath $testdir/swmr_sparse_writer.exe -NoNewWindow -PassThru -ArgumentList "$Nrecs_spa" 2>&1 |tee swmr_writer.out + $pid_writer = $rp.Id + #Write-Output "pid_writer=$pid_writer" + + # Wait for message from writer process before starting reader(s) + Wait-Message $testdir $WRITER_MESSAGE + # + # Launch the Sparse readers + $n = 0 + $pid_readers = @() + Write-Output "launch $Nrdrs_spa swmr_sparse_readers" + while ($n -lt $Nrdrs_spa) { + # The sparse reader spits out a LOT of data so it's set to 'quiet' + $rp = Start-Process -FilePath $testdir/swmr_sparse_reader.exe -NoNewWindow -PassThru -ArgumentList "-q $Nrecs_spa" 2>&1 |tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 + } + #Write-Output "pid_readers=$pid_readers" + + # Collect exit code of the writer + #Write-Output "checked writer $pid_writer" + $result = Wait-Process -Id $pid_writer + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } + + # Collect exit code of the readers + foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } + } + + # Check for error and exit if one occurred + #Write-Output "nerrors=$nerrors" + if ($nerrors -ne 0) { + Write-Warning "SWMR tests failed with $nerrors errors." + Write-Warning "(Writer and reader output preserved)" + exit 1 + } + + # Clean up output files + Remove-Item swmr_writer.out + Remove-Item swmr_reader.out.* + } +} + +############################################################################### +## Report and exit +############################################################################### +cd .. +#Write-Output "nerrors=$nerrors" +if ($nerrors -eq 0) { + Write-Output "SWMR tests passed." +# if test -z "$HDF5_NOCLEANUP"; then +# # delete the test directory +# Remove-Item swmr_test -Recurse +# fi + exit 0 +} +else { + Write-Warning "SWMR tests failed with $nerrors errors." + exit 1 +} + diff --git a/test/test_swmr.sh.in b/test/test_swmr.sh.in new file mode 100644 index 0000000..771fe4a --- /dev/null +++ b/test/test_swmr.sh.in @@ -0,0 +1,563 @@ +#! /bin/bash +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for the swmr feature. +# +# Created: +# Albert Cheng, 2009/07/22 + +srcdir=@srcdir@ +utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ +testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ + +############################################################################### +## test parameters +############################################################################### + +Nreaders=5 # number of readers to launch +Nrdrs_spa=3 # number of sparse readers to launch +Nrecords=200000 # number of records to write +Nrecs_rem=40000 # number of times to shrink +Nrecs_spa=20000 # number of records to write in the sparse test +Nsecs_add=5 # number of seconds per read interval +Nsecs_rem=3 # number of seconds per read interval +Nsecs_addrem=8 # number of seconds per read interval +nerrors=0 + +############################################################################### +## definitions for message file to coordinate test runs +############################################################################### +WRITER_MESSAGE=SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete + # This should be the same as the define in "test/swmr_common.h" +MESSAGE_TIMEOUT=300 # Message timeout length in secs + # This should be the same as the define in "test/h5test.h" + +############################################################################### +## short hands and function definitions +############################################################################### +DPRINT=: # Set to "echo Debug:" for debugging printing, + # else ":" for noop. +IFDEBUG=: # Set to null to turn on debugging, else ":" for noop. + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# To wait for the writer message file or till the maximum # of seconds is reached +# $1 is the message file to wait for +# This performs similar function as the routine h5_wait_message() in test/h5test.c +WAIT_MESSAGE() { + message=$1 # Get the name of the message file to wait for + t0=`date +%s` # Get current time in seconds + difft=0 # Initialize the time difference + mexist=0 # Indicate whether the message file is found + while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out + do + t1=`date +%s` # Get current time in seconds + difft=`expr $t1 - $t0` # Calculate the time difference + if [ -e $message ]; then # If message file is found: + mexist=1 # indicate the message file is found + rm $message # remove the message file + break # get out of the while loop + fi + done; + if test $mexist -eq 0; then + # Issue warning that the writer message file is not found, continue with launching the reader(s) + echo warning: $WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds + else + echo $WRITER_MESSAGE is found + fi +} + +############################################################################### +## Main +## +## Modifications: +## Vailin Choi; July 2013 +## Add waiting of message file before launching the reader(s). +## Due to the implementation of file locking, coordination +## is needed in file opening for the writer/reader tests +## to proceed as expected. +## +############################################################################### + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$utils_testdir/swmr_check_compat_vfd +rc=$? +if [ $rc -ne 0 ] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR." + echo + echo "SWMR acceptance tests skipped" + echo + exit 0 +fi + +# Parse options (none accepted at this time) +while [ $# -gt 0 ]; do + case "$1" in + *) # unknown option + echo "$0: Unknown option ($1)" + exit 1 + ;; + esac +done + +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir swmr_test +for FILE in swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE swmr_test + fi +done + +# With the --disable-shared option, swmr program files are built in the test +# directory, otherwise they are in test/.libs with a corresponding wrapper +# script in the test directory. The programs or wrapper scripts in test should +# always be copied, swmr files in .libs should be copied only if they exists. +if [ -f .libs/swmr ]; then + mkdir swmr_test/.libs + for FILE in .libs/swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE swmr_test/.libs + fi + done +fi + +cd swmr_test + + +# Loop over index types +for index_type in "-i ea" "-i b2" +do + # Try with and without compression + for compress in "" "-c 5" + do + echo + echo "*******************************************************************************" + echo "** Loop testing parameters: $index_type $compress" + echo "*******************************************************************************" + echo + echo + echo "###############################################################################" + echo "## Generator test" + echo "###############################################################################" + # Launch the Generator without SWMR_WRITE + echo launch the swmr_generator + $testdir/swmr_generator $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Launch the Generator with SWMR_WRITE + echo launch the swmr_generator with SWMR_WRITE + $testdir/swmr_generator -s $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + exit 1 + fi + + echo + echo "###############################################################################" + echo "## Use H5Fstart_swmr_write() to enable SWMR writing mode" + echo "###############################################################################" + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # + # Launch the Writer + echo launch the swmr_start_writer + seed="" # Put -r command here + $testdir/swmr_start_write $compress $index_type $Nrecords $seed 2>&1 |tee swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + + # + # Launch the Readers + #declare -a seeds=( ... ) + echo launch $Nreaders swmr_readers + pid_readers="" + n=0 + while [ $n -lt $Nreaders ]; do + #seed="-r ${seeds[$n]}" + seed="" + $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the readers first because they usually finish + # before the writer. + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + rm -f swmr_writer.out + rm -f swmr_reader.out.* + + echo + echo "###############################################################################" + echo "## Writer test - test expanding the dataset" + echo "###############################################################################" + + # Launch the Generator + echo launch the swmr_generator + $testdir/swmr_generator -s $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # + # Launch the Writer + echo launch the swmr_writer + seed="" # Put -r command here + $testdir/swmr_writer -o $Nrecords $seed 2>&1 |tee swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + # + # Launch the Readers + #declare -a seeds=( ... ) + echo launch $Nreaders swmr_readers + pid_readers="" + n=0 + while [ $n -lt $Nreaders ]; do + #seed="-r ${seeds[$n]}" + seed="" + $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the readers first because they usually finish + # before the writer. + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + rm -f swmr_writer.out + rm -f swmr_reader.out.* + + echo + echo "###############################################################################" + echo "## Remove test - test shrinking the dataset" + echo "###############################################################################" + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # Launch the Remove Writer + echo launch the swmr_remove_writer + seed="" # Put -r command here + $testdir/swmr_remove_writer -o $Nrecs_rem $seed 2>&1 |tee swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + # + # Launch the Remove Readers + #declare -a seeds=( ... ) + n=0 + pid_readers="" + echo launch $Nreaders swmr_remove_readers + while [ $n -lt $Nreaders ]; do + #seed="-r ${seeds[$n]}" + seed="" + $testdir/swmr_remove_reader $Nsecs_rem $seed 2>&1 |tee swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the readers first because they usually finish + # before the writer. + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + rm -f swmr_writer.out + rm -f swmr_reader.out.* + + echo + echo "###############################################################################" + echo "## Add/remove test - randomly grow or shrink the dataset" + echo "###############################################################################" + + # Launch the Generator + echo launch the swmr_generator + $testdir/swmr_generator $compress $index_type + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Launch the Writer (not in parallel - just to rebuild the datasets) + echo launch the swmr_writer + seed="" # Put -r command here + $testdir/swmr_writer $Nrecords $seed + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # + # Launch the Add/Remove Writer + echo launch the swmr_addrem_writer + seed="" # Put -r command here + $testdir/swmr_addrem_writer $Nrecords $seed 2>&1 |tee swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + # + # Launch the Add/Remove Readers + #declare -a seeds=( ... ) + n=0 + pid_readers="" + echo launch $Nreaders swmr_remove_readers + while [ $n -lt $Nreaders ]; do + #seed="-r ${seeds[$n]}" + seed="" + $testdir/swmr_remove_reader $Nsecs_addrem $seed 2>&1 |tee swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the readers first because they usually finish + # before the writer. + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + rm -f swmr_writer.out + rm -f swmr_reader.out.* + + echo + echo "###############################################################################" + echo "## Sparse writer test - test writing to random locations in the dataset" + echo "###############################################################################" + + # Launch the Generator + # NOTE: Random seed is shared between readers and writers and is + # created by the generator. + echo launch the swmr_generator + seed="" # Put -r command here + $testdir/swmr_generator $compress $index_type $seed + if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` + fi + + # Remove any possible writer message file before launching writer + rm -f $WRITER_MESSAGE + # Launch the Sparse writer + echo launch the swmr_sparse_writer + nice -n 20 $testdir/swmr_sparse_writer $Nrecs_spa 2>&1 |tee swmr_writer.out & + pid_writer=$! + $DPRINT pid_writer=$pid_writer + + # Wait for message from writer process before starting reader(s) + WAIT_MESSAGE $WRITER_MESSAGE + # + # Launch the Sparse readers + n=0 + pid_readers="" + echo launch $Nrdrs_spa swmr_sparse_readers + while [ $n -lt $Nrdrs_spa ]; do + # The sparse reader spits out a LOT of data so it's set to 'quiet' + $testdir/swmr_sparse_reader -q $Nrecs_spa 2>&1 |tee swmr_reader.out.$n & + pid_readers="$pid_readers $!" + n=`expr $n + 1` + done + $DPRINT pid_readers=$pid_readers + $IFDEBUG ps + + # Collect exit code of the writer + $DPRINT checked writer $pid_writer + wait $pid_writer + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi + + # Collect exit code of the readers + for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi + done + + # Check for error and exit if one occurred + $DPRINT nerrors=$nerrors + if test $nerrors -ne 0 ; then + echo "SWMR tests failed with $nerrors errors." + echo "(Writer and reader output preserved)" + exit 1 + fi + + # Clean up output files + rm -f swmr_writer.out + rm -f swmr_reader.out.* + done +done + +############################################################################### +## Report and exit +############################################################################### +cd .. +$DPRINT nerrors=$nerrors +if test $nerrors -eq 0 ; then + echo "SWMR tests passed." + if test -z "$HDF5_NOCLEANUP"; then + # delete the test directory + rm -rf swmr_test + fi + exit 0 +else + echo "SWMR tests failed with $nerrors errors." + exit 1 +fi + diff --git a/test/test_use_cases.sh.in b/test/test_use_cases.sh.in new file mode 100644 index 0000000..fd30afd --- /dev/null +++ b/test/test_use_cases.sh.in @@ -0,0 +1,219 @@ +#! /bin/bash +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests the use cases of swmr features. +# +# Created: +# Albert Cheng, 2013/06/01. +# Modified: +# + +# This is work in progress. +# For now, it shows how to run the test cases programs. It only verifies the +# exit codes are okay (0). + +############################################################################### +## test variables +############################################################################### + +# Number of errors encountered during test run. +nerrors=0 + +# Define variables +verbose=yes + +############################################################################### +## Main +############################################################################### +srcdir=@srcdir@ +utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ +testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$utils_testdir/swmr_check_compat_vfd +rc=$? +if [[ $rc != 0 ]] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR" + echo + echo "SWMR use case tests skipped" + echo + exit 0 +fi + +# Define symbols +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_VALUE=$EXIT_SUCCESS # Default all tests succeed +RESULT_PASSED=" PASSED" +RESULT_FAILED="*FAILED*" +RESULT_SKIP="-SKIP-" +USECASES_PROGRAMS="use_append_chunk use_append_mchunks" +TESTNAME="Use Case" + +# Source in the output filter function definitions. +. $srcdir/../bin/output_filter.sh + +# Define functions +# Print a line-line message left justified in a field of 72 characters. +# Results can be " PASSED", "*FAILED*", "-SKIP-", up to 8 characters +# wide. +# SPACES should be at least 71 spaces. ($* + ' ' + 71 + 8 >= 80) +# +TESTING() { + SPACES=" " + echo "$* $SPACES" | cut -c1-72 | tr -d '\012' +} + +# Run a test and print PASS or *FAIL*. If a test fails then increment +# the `nerrors' global variable and (if $verbose is set) display the +# difference between the actual output and the expected output. The +# expected output is given as the first argument to this function and +# the actual output file is calculated by replacing the `.ddl' with +# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a +# non-zero value. +# ADD_H5_TEST +TOOLTEST() { + program=$1 + shift + + actual="$program.out" + actual_err="$program.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + + # Run test. + TESTING $program $@ + ( + $RUNSERIAL $testdir/$program "$@" + ) >$actual 2>$actual_err + exit_code=$? + + # save actual and actual_err in case they are needed later. + cp $actual $actual_sav + STDOUT_FILTER $actual + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + cat $actual_err >> $actual + + if [ $exit_code -eq 0 ];then + echo "$RESULT_PASSED" + test yes = "$verbose" && sed 's/^/ /' < $actual + else + echo "$RESULT_FAILED" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && sed 's/^/ /' < $actual + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + fi +} + +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir usecases_test +cp $testdir/twriteorder usecases_test +for FILE in use_*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE usecases_test + fi +done + +# With the --disable-shared option, swmr program files are built in the test +# directory, otherwise they are in test/.libs with a corresponding wrapper +# script in the test directory. The programs or wrapper scripts in test should +# always be copied, swmr files in .libs should be copied only if they exists. +if [ -f .libs/use_append_chunk ]; then + mkdir usecases_test/.libs + for FILE in .libs/use_*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE usecases_test/.libs + fi + done + cp .libs/twriteorder usecases_test/.libs +fi + +cd usecases_test + + +# run tests for H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled here temporary +USECORK=use_disable_mdc_flushes +for p in $USECORK; do + TOOLTEST $p + TOOLTEST $p -y 3 + TOOLTEST $p -n 3000 + TOOLTEST $p -n 5000 +done + +# run write order test here temporary +WRITEORDER=twriteorder +for p in $WRITEORDER; do + TOOLTEST $p + TOOLTEST $p -b 1000 + TOOLTEST $p -p 3000 + TOOLTEST $p -n 2000 + TOOLTEST $p -l w + TOOLTEST $p -l r +done + +# Report test results +if test $nerrors -eq 0 ; then + echo "$WRITEORDER test passed." +else + echo "$WRITEORDER test failed with $nerrors errors." + EXIT_VALUE=$EXIT_FAILURE + nerrors=0 # reset nerror for the regular tests below. +fi + +# main body +for p in $USECASES_PROGRAMS; do + TOOLTEST $p + TOOLTEST $p -z 256 + tmpfile=/tmp/datatfile.$$ + TOOLTEST $p -f $tmpfile; rm -f $tmpfile + TOOLTEST $p -l w + TOOLTEST $p -l r + # use case 1.9, testing with multi-planes chunks + TOOLTEST $p -z 256 -y 5 # 5 planes chunks + # cleanup temp datafile + if test -z "$HDF5_NOCLEANUP"; then + rm -f $p.h5 + fi +done + +cd .. +# Report test results and exit +if test $nerrors -eq 0 ; then + echo "All $TESTNAME tests passed." + if test -z "$HDF5_NOCLEANUP"; then + # delete the test directory + rm -rf usecases_test + fi +else + echo "$TESTNAME tests failed with $nerrors errors." + EXIT_VALUE=$EXIT_FAILURE +fi + +exit $EXIT_VALUE diff --git a/test/test_usecases.sh.in b/test/test_usecases.sh.in deleted file mode 100644 index fd30afd..0000000 --- a/test/test_usecases.sh.in +++ /dev/null @@ -1,219 +0,0 @@ -#! /bin/bash -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests the use cases of swmr features. -# -# Created: -# Albert Cheng, 2013/06/01. -# Modified: -# - -# This is work in progress. -# For now, it shows how to run the test cases programs. It only verifies the -# exit codes are okay (0). - -############################################################################### -## test variables -############################################################################### - -# Number of errors encountered during test run. -nerrors=0 - -# Define variables -verbose=yes - -############################################################################### -## Main -############################################################################### -srcdir=@srcdir@ -utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ -testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$utils_testdir/swmr_check_compat_vfd -rc=$? -if [[ $rc != 0 ]] ; then - echo - echo "The VFD specified by the HDF5_DRIVER environment variable" - echo "does not support SWMR" - echo - echo "SWMR use case tests skipped" - echo - exit 0 -fi - -# Define symbols -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_VALUE=$EXIT_SUCCESS # Default all tests succeed -RESULT_PASSED=" PASSED" -RESULT_FAILED="*FAILED*" -RESULT_SKIP="-SKIP-" -USECASES_PROGRAMS="use_append_chunk use_append_mchunks" -TESTNAME="Use Case" - -# Source in the output filter function definitions. -. $srcdir/../bin/output_filter.sh - -# Define functions -# Print a line-line message left justified in a field of 72 characters. -# Results can be " PASSED", "*FAILED*", "-SKIP-", up to 8 characters -# wide. -# SPACES should be at least 71 spaces. ($* + ' ' + 71 + 8 >= 80) -# -TESTING() { - SPACES=" " - echo "$* $SPACES" | cut -c1-72 | tr -d '\012' -} - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# ADD_H5_TEST -TOOLTEST() { - program=$1 - shift - - actual="$program.out" - actual_err="$program.err" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - - # Run test. - TESTING $program $@ - ( - $RUNSERIAL $testdir/$program "$@" - ) >$actual 2>$actual_err - exit_code=$? - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - cat $actual_err >> $actual - - if [ $exit_code -eq 0 ];then - echo "$RESULT_PASSED" - test yes = "$verbose" && sed 's/^/ /' < $actual - else - echo "$RESULT_FAILED" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && sed 's/^/ /' < $actual - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext - fi -} - -# HDF5 has several tests that create and delete signal files to communicate -# between processes, and it seems that even though the names of the files are -# different, occasionally the wrong file is deleted, interrupting the flow of -# the test. Running each of these tests in its own directory should eliminate -# the problem. -mkdir usecases_test -cp $testdir/twriteorder usecases_test -for FILE in use_*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE usecases_test - fi -done - -# With the --disable-shared option, swmr program files are built in the test -# directory, otherwise they are in test/.libs with a corresponding wrapper -# script in the test directory. The programs or wrapper scripts in test should -# always be copied, swmr files in .libs should be copied only if they exists. -if [ -f .libs/use_append_chunk ]; then - mkdir usecases_test/.libs - for FILE in .libs/use_*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE usecases_test/.libs - fi - done - cp .libs/twriteorder usecases_test/.libs -fi - -cd usecases_test - - -# run tests for H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled here temporary -USECORK=use_disable_mdc_flushes -for p in $USECORK; do - TOOLTEST $p - TOOLTEST $p -y 3 - TOOLTEST $p -n 3000 - TOOLTEST $p -n 5000 -done - -# run write order test here temporary -WRITEORDER=twriteorder -for p in $WRITEORDER; do - TOOLTEST $p - TOOLTEST $p -b 1000 - TOOLTEST $p -p 3000 - TOOLTEST $p -n 2000 - TOOLTEST $p -l w - TOOLTEST $p -l r -done - -# Report test results -if test $nerrors -eq 0 ; then - echo "$WRITEORDER test passed." -else - echo "$WRITEORDER test failed with $nerrors errors." - EXIT_VALUE=$EXIT_FAILURE - nerrors=0 # reset nerror for the regular tests below. -fi - -# main body -for p in $USECASES_PROGRAMS; do - TOOLTEST $p - TOOLTEST $p -z 256 - tmpfile=/tmp/datatfile.$$ - TOOLTEST $p -f $tmpfile; rm -f $tmpfile - TOOLTEST $p -l w - TOOLTEST $p -l r - # use case 1.9, testing with multi-planes chunks - TOOLTEST $p -z 256 -y 5 # 5 planes chunks - # cleanup temp datafile - if test -z "$HDF5_NOCLEANUP"; then - rm -f $p.h5 - fi -done - -cd .. -# Report test results and exit -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - if test -z "$HDF5_NOCLEANUP"; then - # delete the test directory - rm -rf usecases_test - fi -else - echo "$TESTNAME tests failed with $nerrors errors." - EXIT_VALUE=$EXIT_FAILURE -fi - -exit $EXIT_VALUE diff --git a/test/test_vds_env.sh.in b/test/test_vds_env.sh.in new file mode 100644 index 0000000..39f13a5 --- /dev/null +++ b/test/test_vds_env.sh.in @@ -0,0 +1,44 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_VDS_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for VDS with HDF5_VDS_PREFIX +echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" +TEST_NAME=vds_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp_vds_env" # Set the environment variable & value +UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_VDS_PREFIX PASSED" +else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_VDS_PREFIX test***" +fi +$UNENVCMD +exit $nerrors diff --git a/test/test_vds_swmr.pwsh.in b/test/test_vds_swmr.pwsh.in new file mode 100644 index 0000000..bf5aabb --- /dev/null +++ b/test/test_vds_swmr.pwsh.in @@ -0,0 +1,190 @@ +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for the swmr feature using virtual datasets. + +$srcdir = '@srcdir@' +$utils_testdir=@H5_UTILS_TEST_BUILDDIR@ +$testdir=@H5_TEST_BUILDDIR@ + +############################################################################### +## test parameters +############################################################################### + +$Nwriters = 6 # number of writers (1 per source dataset) +$Nreaders = 5 # number of readers to launch +$nerrors = 0 + +############################################################################### +## definitions for message file to coordinate test runs +############################################################################### +$WRITER_MESSAGE = 'SWMR_WRITER_MESSAGE' # The message file created by writer that the open is complete + # This should be the same as the define in "test/swmr_common.h" +$MESSAGE_TIMEOUT = 300 # Message timeout length in secs + # This should be the same as the define in "test/h5test.h" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +function Test-WithSpaces { + $SPACES=' ' + #Write-Output "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# To wait for the writer message file or till the maximum # of seconds is reached +# $Message is the message file to wait for +# This performs similar function as the routine h5_wait_message() in test/h5test.c +function Wait-Message { + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [string]$TestPath, # Get the path of the message file to wait for + [Parameter(Mandatory, ValueFromPipeline)] + [string]$Message # Get the name of the message file to wait for + ) + + PROCESS { + $message = Join-Path -Path $TestPath -ChildPath $Message + $t0 = Get-Date # Get current time + $t1 = $t0 + $difft = New-Timespan -Start $t0 -End $t1 # Initialize the time difference + $mexist = 0 # Indicate whether the message file is found + while ($difft.TotalSeconds -lt $MESSAGE_TIMEOUT) { # Loop till message times out + $t1 = Get-Date # Get current time in seconds + $difft = New-Timespan -Start $t0 -End $t1 # Calculate the time difference + #Write-Output "Check for $message : time=$difft" + if ([System.IO.File]::Exists($message)) { # If message file is found: + $mexist = 1 # indicate the message file is found + Remove-Item $message # remove the message file + break # get out of the while loop + } + } + if ($mexist -eq 0) { + # Issue warning that the writer message file is not found, continue with launching the reader(s) + Write-Warning -Message "$WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds" + } + else { + Write-Output "$WRITER_MESSAGE is found" + } + } +} + +############################################################################### +## Main +############################################################################### + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$testprog = Join-Path -Path $utils_testdir -ChildPath swmr_check_compat_vfd.exe +$rp = Start-Process -FilePath $testprog -PassThru -Wait -NoNewWindow +if ($rp.ExitCode -ne 0) { + Write-Output "" + Write-Output "The VFD specified by the HDF5_DRIVER environment variable" + Write-Output "does not support SWMR." + Write-Output "" + Write-Output "SWMR acceptance tests skipped" + Write-Output "" + exit 0 +} + +Set-Location -Path vds_swmr_test +$testdir = Join-Path -Path $testdir -ChildPath vds_swmr_test + +Write-Output "" +Write-Output "###############################################################################" +Write-Output "## Basic VDS SWMR test - writing to a tiled plane" +Write-Output "###############################################################################" + +# Launch the file generator +Write-Output "launch the swmr_generator" +$rp = Start-Process -FilePath $testdir/vds_swmr_gen.exe -NoNewWindow -PassThru -Wait +if ($rp.ExitCode -ne 0) { + Write-Warning "generator had error" + $nerrors += 1 +} + +# Check for error and exit if one occurred +#Write-Output "nerrors=$nerrors" +if ($nerrors -ne 0) { + Write-Warning "VDS SWMR tests failed with $nerrors errors." + exit 1 +} + +# Launch the writers +Write-Output "launch the $Nwriters SWMR VDS writers (1 per source)" +$pid_writers = @() +$n = 0 +while ($n -lt $Nwriters) { + $rp = Start-Process -FilePath $testdir/vds_swmr_writer.exe -NoNewWindow -PassThru -ArgumentList "$n" 2>&1 | tee swmr_writer.out.$n + $pid_writers += $rp.id + $n += 1 +} +#Write-Output "pid_writers=$pid_writers" + +# Sleep to ensure that the writers have started +Start-Sleep -Seconds 3 + +# Launch the readers +Write-Output "launch $Nreaders SWMR readers" +$pid_readers = @() +$n = 0 +while ($n -lt $Nreaders) { + $rp = Start-Process -FilePath $testdir/vds_swmr_reader.exe -NoNewWindow -PassThru 2>&1 | tee swmr_reader.out.$n + $pid_readers += $rp.id + $n += 1 +} +#Write-Output "pid_readers=$pid_readers" + +# Collect exit code of the writers +foreach ($xpid in $pid_writers) { + #Write-Output "checked writer $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "writer had error" + $nerrors += 1 + } +} + +# Collect exit code of the readers +# (they usually finish after the writers) +foreach ($xpid in $pid_readers) { + #Write-Output "checked reader $xpid" + $result = Wait-Process -Id $xpid + if ($result.ExitCode -ne 0) { + Write-Warning "reader had error" + $nerrors += 1 + } +} + +# Check for error and exit if one occurred +#Write-Output "nerrors=$nerrors" +if ($nerrors -ne 0) { + Write-Warning "VDS SWMR tests failed with $nerrors errors." + exit 1 +} + +############################################################################### +## Report and exit +############################################################################### +cd .. +#Write-Output "nerrors=$nerrors" +if ($nerrors -eq 0) { + Write-Output "VDS SWMR tests passed." +# if test -z "$HDF5_NOCLEANUP"; then +# # delete the test directory +# Remove-Item vds_swmr_test -Recurse +# fi + exit 0 +} +else { + Write-Warning "VDS SWMR tests failed with $nerrors errors." + exit 1 +} + diff --git a/test/test_vds_swmr.sh.in b/test/test_vds_swmr.sh.in new file mode 100644 index 0000000..399fdef --- /dev/null +++ b/test/test_vds_swmr.sh.in @@ -0,0 +1,233 @@ +#! /bin/bash +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for the swmr feature using virtual datasets. +# +# Created: +# Dana Robinson, November 2015 + +srcdir=@srcdir@ +utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ +testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ + +############################################################################### +## test parameters +############################################################################### + +Nwriters=6 # number of writers (1 per source dataset) +Nreaders=5 # number of readers to launch +nerrors=0 + +############################################################################### +## definitions for message file to coordinate test runs +############################################################################### +WRITER_MESSAGE=SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete + # This should be the same as the define in "test/swmr_common.h" +MESSAGE_TIMEOUT=300 # Message timeout length in secs + # This should be the same as the define in "test/h5test.h" + +############################################################################### +## short hands and function definitions +############################################################################### +DPRINT=: # Set to "echo Debug:" for debugging printing, + # else ":" for noop. +IFDEBUG=: # Set to null to turn on debugging, else ":" for noop. + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# To wait for the writer message file or till the maximum # of seconds is reached +# $1 is the message file to wait for +# This performs similar function as the routine h5_wait_message() in test/h5test.c +WAIT_MESSAGE() { + message=$1 # Get the name of the message file to wait for + t0=`date +%s` # Get current time in seconds + difft=0 # Initialize the time difference + mexist=0 # Indicate whether the message file is found + while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out + do + t1=`date +%s` # Get current time in seconds + difft=`expr $t1 - $t0` # Calculate the time difference + if [ -e $message ]; then # If message file is found: + mexist=1 # indicate the message file is found + rm $message # remove the message file + break # get out of the while loop + fi + done; + if test $mexist -eq 0; then + # Issue warning that the writer message file is not found, continue with launching the reader(s) + echo warning: $WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds + else + echo $WRITER_MESSAGE is found + fi +} + +############################################################################### +## Main +############################################################################### + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +$utils_testdir/swmr_check_compat_vfd +rc=$? +if [ $rc -ne 0 ] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR." + echo + echo "SWMR acceptance tests skipped" + echo + exit 0 +fi + +# Parse options (none accepted at this time) +while [ $# -gt 0 ]; do + case "$1" in + *) # unknown option + echo "$0: Unknown option ($1)" + exit 1 + ;; + esac +done + +# HDF5 has several tests that create and delete signal files to communicate +# between processes, and it seems that even though the names of the files are +# different, occasionally the wrong file is deleted, interrupting the flow of +# the test. Running each of these tests in its own directory should eliminate +# the problem. +mkdir vds_swmr_test +for FILE in vds_swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE vds_swmr_test + fi +done + +# With the --disable-shared option, swmr program files are built in the test +# directory, otherwise they are in test/.libs with a corresponding wrapper +# script in the test directory. The programs or wrapper scripts in test should +# always be copied, swmr files in .libs should be copied only if they exists. +if [ -f .libs/vds_swmr_writer ]; then + mkdir vds_swmr_test/.libs + for FILE in .libs/vds_swmr*; do + case "$FILE" in + *.o) continue ;; ## don't copy the .o files + esac + if test -f "$FILE" ; then + cp $FILE vds_swmr_test/.libs + fi + done +fi + +cd vds_swmr_test + + +echo +echo "###############################################################################" +echo "## Basic VDS SWMR test - writing to a tiled plane" +echo "###############################################################################" + +# Launch the file generator +echo launch the generator +$testdir/vds_swmr_gen +if test $? -ne 0; then + echo generator had error + nerrors=`expr $nerrors + 1` +fi + +# Check for error and exit if one occurred +$DPRINT nerrors=$nerrors +if test $nerrors -ne 0 ; then + echo "VDS SWMR tests failed with $nerrors errors." + exit 1 +fi + +# Launch the writers +echo "launch the $Nwriters SWMR VDS writers (1 per source)" +pid_writers="" +n=0 +while [ $n -lt $Nwriters ]; do + $testdir/vds_swmr_writer $n & + pid_writers="$pid_writers $!" + n=`expr $n + 1` +done +$DPRINT pid_writers=$pid_writers +$IFDEBUG ps + +# Sleep to ensure that the writers have started +sleep 3 + +# Launch the readers +echo launch $Nreaders SWMR readers +pid_readers="" +n=0 +while [ $n -lt $Nreaders ]; do + $testdir/vds_swmr_reader & + pid_readers="$pid_readers $!" + n=`expr $n + 1` +done +$DPRINT pid_readers=$pid_readers +$IFDEBUG ps + +# Collect exit code of the writers +for xpid in $pid_writers; do + $DPRINT checked writer $xpid + wait $xpid + if test $? -ne 0; then + echo writer had error + nerrors=`expr $nerrors + 1` + fi +done + +# Collect exit code of the readers +# (they usually finish after the writers) +for xpid in $pid_readers; do + $DPRINT checked reader $xpid + wait $xpid + if test $? -ne 0; then + echo reader had error + nerrors=`expr $nerrors + 1` + fi +done + +# Check for error and exit if one occurred +$DPRINT nerrors=$nerrors +if test $nerrors -ne 0 ; then + echo "VDS SWMR tests failed with $nerrors errors." + exit 1 +fi + +############################################################################### +## Report and exit +############################################################################### +cd .. +$DPRINT nerrors=$nerrors +if test $nerrors -eq 0 ; then + echo "VDS SWMR tests passed." + if test -z "$HDF5_NOCLEANUP"; then + # delete the test directory + rm -rf vds_swmr_test + fi + exit 0 +else + echo "VDS SWMR tests failed with $nerrors errors." + exit 1 +fi + diff --git a/test/test_vol_plugin.sh.in b/test/test_vol_plugin.sh.in deleted file mode 100644 index d31646b..0000000 --- a/test/test_vol_plugin.sh.in +++ /dev/null @@ -1,84 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# This shell script is for testing VOL connector plugins. -# -srcdir=@srcdir@ -TOP_BUILDDIR=@top_builddir@ - -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -nerrors=0 -verbose=yes -exit_code=$EXIT_SUCCESS - -TEST_NAME=vol_plugin -TEST_BIN=`pwd`/$TEST_NAME -FROM_DIR=`pwd`/.libs -case $(uname) in - CYGWIN* ) - NULL_VOL_PLUGIN="$FROM_DIR/cygnull_vol_connector*" - ;; - *) - NULL_VOL_PLUGIN="$FROM_DIR/libnull_vol_connector*" - ;; -esac -TEMP_PLUGIN_DIR=null_vol_plugin_dir -CP="cp -p" # Use -p to preserve mode,ownership, timestamps -RM="rm -rf" - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Main Body -# Create test directory if necessary. -test -d $TEMP_PLUGIN_DIR || mkdir -p $TEMP_PLUGIN_DIR -if [ $? != 0 ]; then - echo "Failed to create VOL connector plugin test directory ($TEMP_PLUGIN_DIR)" - exit $EXIT_FAILURE -fi - -# Copy plugin for the tests. -$CP $NULL_VOL_PLUGIN $TEMP_PLUGIN_DIR -if [ $? != 0 ]; then - echo "Failed to copy NULL VOL plugin ($NULL_VOL_PLUGIN) to test directory." - exit $EXIT_FAILURE -fi - -# setup plugin path -ENVCMD="env HDF5_PLUGIN_PATH=${TEMP_PLUGIN_DIR}" - -# Run the test -$ENVCMD $TEST_BIN -if [ $? != 0 ]; then - nerrors=`expr $nerrors + 1` -fi - -# print results -if test $nerrors -ne 0 ; then - echo "$nerrors errors encountered" - exit_code=$EXIT_FAILURE -else - echo "All VOL plugin tests passed." - exit_code=$EXIT_SUCCESS -fi - -# Clean up temporary files/directories and leave -$RM $TEMP_PLUGIN_DIR - -exit $exit_code diff --git a/test/testabort_fail.sh.in b/test/testabort_fail.sh.in deleted file mode 100644 index a866f9e..0000000 --- a/test/testabort_fail.sh.in +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Test to verify that the assertion/abort failure is fixed when the application -# does not close the file. (See HDFFV-10160) -# -# Test to verify that the infinite loop closing library/abort failure is fixed -# when the application creates and removes dense attributes (See HDFFV-10659) - -srcdir=@srcdir@ - -nerrors=0 - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# -# -echo "Testing file not closed assertion/abort failure" -TEST_NAME=filenotclosed # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -# -# Run the test -$RUNSERIAL $TEST_BIN >/dev/null 2>&1 -exitcode=$? -if [ $exitcode -eq 0 ]; then - echo "Test PASSED" -else - echo "Test FAILED" - nerrors="`expr $nerrors + 1`" -fi -# -# -echo "Testing infinite loop closing library/abort failure" -TEST_NAME=del_many_dense_attrs # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -# Run the test -$RUNSERIAL $TEST_BIN >/dev/null 2>&1 -exitcode=$? -if [ $exitcode -eq 0 ]; then - echo "Test PASSED" -else - echo "Test FAILED" - nerrors="`expr $nerrors + 1`" -fi -# -# -if test $nerrors -eq 0 ; then - echo "All tests for abort failure passed." - exit 0 -else - echo "Tests for abort failure failed with $nerrors errors." - exit 1 -fi diff --git a/test/testcheck_version.sh.in b/test/testcheck_version.sh.in deleted file mode 100644 index 273702e..0000000 --- a/test/testcheck_version.sh.in +++ /dev/null @@ -1,261 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. - -# -# Tests for the H5check_version function. -# -# Programmer: Albert Cheng -# Sep 28, 2009 - -srcdir=@srcdir@ - -# Variables filled in by the configure process. -# Determine the configure options of the hdf5 library and executables. -Shared_Lib=@enable_shared@ -Static_Lib=@enable_static@ -Static_exec=@STATIC_EXEC@ -h5haveexitcode=yes # default is yes - -CMP='cmp -s' -DIFF='diff -c' -RM='rm -f' - -# Function definitions -# -# Show the purpose of this test script and a note about the abort messages. -PURPOSE() { - echo "Tests for the H5check_version function." - echo "Note that abort messages may appear due to the expected termination" - echo "of the program when it is tested with mis-matched version numbers." -} - -# Print a line-line message left justified in a field of 70 characters. -# -LINEMSG() { - SPACES=" " - echo "$* $SPACES" | cut -c1-70 | tr -d '\012' -} - - -# Print a "SKIP" message -SKIP() { - LINEMSG $* - echo " -SKIP-" -} - - -# Print warning message of version mismatch. -WarnMesg(){ - echo "Warning! ***HDF5 library version mismatched error***" - echo "The HDF5 header files used to compile this application do not match" - echo "the version used by the HDF5 library to which this application is linked." - echo "Data corruption or segmentation faults may occur if the application continues." - echo "This can happen when an application was compiled by one version of HDF5 but" - echo "linked with a different version of static or shared HDF5 library." - echo "You should recompile the application or check your shared library related" - echo "settings such as 'LD_LIBRARY_PATH'." - echo "You can, at your own risk, disable this warning by setting the environment" - echo "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'." - echo "Setting it to 2 or higher will suppress the warning messages totally." - echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease" - test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings - echo "Bye..." -} - - -# Print warning message2 of version mismatch. -WarnMesg2(){ - echo "Warning! ***HDF5 library version mismatched error***" - echo "The HDF5 header files used to compile this application do not match" - echo "the version used by the HDF5 library to which this application is linked." - echo "Data corruption or segmentation faults may occur if the application continues." - echo "This can happen when an application was compiled by one version of HDF5 but" - echo "linked with a different version of static or shared HDF5 library." - echo "You should recompile the application or check your shared library related" - echo "settings such as 'LD_LIBRARY_PATH'." - echo "'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will" - echo "continue at your own risk." - echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease" - test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings -} - - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output generated according to the parameter values and compared -# against actual output. -# The expected and actual output files are removed unless $HDF5_NOCLEANUP -# has a non-zero value. -# $1: the set value of $HDF5_DISABLE_VERSION_CHECK. (unset means not to set -# it at all. -# $2: Change the version number(s) to cause a mismatch. (none means no -# mismatch). -# -# Expected results: -# Value of $HDF5_DISABLE_VERSION_CHECK -# unset "" -1 0 1 2 3 -# Matched OK OK OK OK OK OK OK -# Mismatched W/A W/A W/A W/A W2/OK OK W2/OK -# Result codes: -# OK: No warning, exit 0. -# W/A: Warning, abort and exit non-0. -# W2/OK: Different Warning, exit 0. -# -# Implemented only exit code matching. Still need to match output. -TESTING() { - DEBUGPRINT command is $0 $* - TEST_NAME=tcheck_version # The test name - TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary - - expect=${TEST_NAME}_expect.out - actual=${TEST_NAME}_actual.out - actual_err=${TEST_NAME}_actual.err - arguments= - - h5DisableVersion="$1" - wrongversionnumbers="$2" - xxh5versmajor=$h5versmajor - xxh5versminor=$h5versminor - xxh5versrelease=$h5versrelease - - if [ "$h5DisableVersion" = unset ]; then - envcmd="" # noop - else - envcmd="env HDF5_DISABLE_VERSION_CHECK=$h5DisableVersion" - fi - - if [ "$wrongversionnumbers" = none ]; then - # OK: No warning, exit 0 - cp /dev/null $expect - expect_code=0 - else - arguments=-t"$wrongversionnumbers" - # calculate mismatched version numbers by listing. - case $wrongversionnumbers in - "M") xxh5versmajor=`expr $h5versmajor + 1` - ;; - "m") xxh5versminor=`expr $h5versminor + 1` - ;; - "r") xxh5versrelease=`expr $h5versrelease + 1` - ;; - esac - case "$h5DisableVersion" in - 1) - # W2/OK: Different Warning, exit 0. - WarnMesg2 > $expect - expect_code=0 - ;; - [2-9]|[1-9][0-9]*) - # OK: No warning, exit 0 - cp /dev/null $expect - expect_code=0 - ;; - *) # W/A: Warning, abort and exit non-0. - WarnMesg > $expect - expect_code=6 # Signal Abort exit code (128+6) - ;; - esac - fi - - # Run test. - LINEMSG $envcmd $TEST_NAME $arguments - ( - $envcmd $RUNSERIAL $TEST_BIN $arguments - ) >$actual 2>$actual_err - ret_code=$? - cat $actual_err >> $actual - - if [ $h5haveexitcode = 'yes' -a \( $expect_code -ne $ret_code \) ]; then - echo "*FAILED*" - echo " Expected exit code ($expect_code) differs from actual code ($ret_code)" - nerrors="`expr $nerrors + 1`" - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result differs from actual result" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file. - # Also clean the core file generated by H5check_version's abort. - if test -z "$HDF5_NOCLEANUP"; then - $RM $expect $actual $actual_err - $RM core - fi -} - - -# Echo parameters for debugging if verbose mode is on. -DEBUGPRINT() { - if [ -n "$debugmode" ]; then - echo $* - fi -} - - -# MAIN Body -nerrors=0 -verbose=yes # default on -debugmode= # default off -H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h` -h5libsettings=../src/libhdf5.settings - -PURPOSE - -# Figure out library version numbers from the header file. -h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | awk '{print $3}'` -h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | awk '{print $3}'` -h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | awk '{print $3}'` -DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease -case "$h5versmajor$h5versminor$h5versrelease" in - [0-9]*) # good. noop. - ;; - *) - echo "Illegal library version numbers($h5versmajor.$h5versminor.$h5versrelease)" - echo "Test aborted" - exit 1 - ;; -esac - -# RUNSERIAL is used. Check if it can return exit code from executalbe correctly. -if [ -n "$RUNSERIAL_NOEXITCODE" ]; then - echo "***Warning*** Serial Exit Code is not passed back to shell correctly." - echo "***Warning*** Exit code checking is skipped." - h5haveexitcode=no -fi - -# Three Categories of tests: -# Normal: where the version numbers all matched (wrong_version == none). -# Mismatched version numbers (could be Major or minor version -# or release numbers or a combination of all three.) -# Test all the above with different values of the environment variable, -# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3 - -for val_disable_version_check in unset "" -1 0 1 2 3; do - for wrong_version in none M m; do - TESTING "$val_disable_version_check" "$wrong_version" - done -done - - -# Check and report results. -if [ $nerrors -gt 0 ]; then - echo "***$nerrors errors encountered***" - exit 1 -else - echo "No error encountered" - exit 0 -fi diff --git a/test/testerror.sh.in b/test/testerror.sh.in deleted file mode 100644 index 4fb2a81..0000000 --- a/test/testerror.sh.in +++ /dev/null @@ -1,126 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests for test_error and err_compat - -srcdir=@srcdir@ - -# Determine backward compatibility options eneabled -DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" - -CMP='cmp -s' -DIFF='diff -c' - -# Skip plugin module to test missing filter -# Also reset the VOL connector to only use the native connector, because of the -# error stack checking. QAK - 2019/03/09 -ENVCMD="env HDF5_PLUGIN_PRELOAD=:: HDF5_VOL_CONNECTOR=native" - -nerrors=0 -verbose=yes - -test -d ./testfiles || mkdir ./testfiles - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# -TEST() { - TEST_ERR=$1 # The test name - TEST_ERR_BIN=`pwd`/$TEST_ERR # The path of the test binary - - expect1="$srcdir/testfiles/$1_1" - expect2="$srcdir/testfiles/$1_2" - actual="./`basename $1`.out" - actual_err="./`basename $1`.err" - actual_ext="./`basename $1`.ext" - shift - - # Run test. - TESTING $TEST_ERR - ( - # Skip the plugin for testing missing filter. - $ENVCMD $RUNSERIAL $TEST_ERR_BIN - ) >$actual 2>$actual_err - - # Check for core dump - if [ $? != 0 ]; then - nerrors=`expr $nerrors + 1` - fi - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - cat $actual_ext >> $actual - - if $CMP $expect1 $actual; then - echo " PASSED" - elif $CMP $expect2 $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result differs from actual result" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect1 $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_ext - fi -} - -# Print a "SKIP" message -SKIP() { - TESTING $@ - echo " -SKIP-" -} - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - -# test for err_compat -if test $DEPRECATED_SYMBOLS != "yes"; then -SKIP err_compat -else -TEST err_compat -fi - -# test for error_test. Skip the plugin for testing missing filter. -TEST error_test - -if test $nerrors -eq 0 ; then - echo "All Error API tests passed." -fi - -exit $nerrors diff --git a/test/testexternal_env.sh.in b/test/testexternal_env.sh.in deleted file mode 100644 index 94fbb88..0000000 --- a/test/testexternal_env.sh.in +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Test for external file with environment variable: HDF5_EXTFILE_PREFIX - -srcdir=@srcdir@ - -nerrors=0 - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - -# test for external file with HDF5_EXTFILE_PREFIX -echo "Testing external file with HDF5_EXTFILE_PREFIX" -TEST_NAME=external_env # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value -# -# Run the test -# echo "$ENVCMD $RUNSERIAL $TEST_BIN" -$ENVCMD $RUNSERIAL $TEST_BIN -exitcode=$? -if [ $exitcode -eq 0 ]; then - echo "Test prefix for HDF5_EXTFILE_PREFIX PASSED" -else - nerrors="`expr $nerrors + 1`" - echo "***Error encountered for HDF5_EXTFILE_PREFIX test***" -fi -exit $nerrors diff --git a/test/testflushrefresh.sh.in b/test/testflushrefresh.sh.in deleted file mode 100644 index 209d370..0000000 --- a/test/testflushrefresh.sh.in +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# -# Test script for the flush/evict single objects feature. -# -# This test file doesn't actually perform any tests, rather, it acts -# as a process manager for the 'flushrefresh' test file, which is where -# the tests are actually housed. The reason this script exists is because -# the verification of this feature needs to occur in separate processes -# from the one in which the file is being manipulated in. (i.e., we have -# a single writer process, and various reader processes spawning off -# and doing the verification that individual objects are being -# correctly flushed). -# -# Programmer: -# Mike McGreevy -# Tuesday, July 20, 2010 - -############################################################################### -## test variables -############################################################################### - -# Number of errors encountered during test run. -nerrors=0 - -# Set up a function to check the current time since the epoch - ideally, we'd -# like to use Perl. If it wasn't detected by configure, then use date, though -# this is less portable and might cause problems on machines that don't -# recognize the +%s option (like Solaris). -# -# Note that PERL will resolve to true or false, not a path. -PERL=@PERL@ -if test -n "$PERL"; then - TimeStamp() - { - time=`perl -e 'print int(time)'` - echo "$time" - } -else - TimeStamp() - { - time=`date +%s` - echo "$time" - } -fi - -############################################################################### -## Main -############################################################################### -srcdir=@srcdir@ -utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ -testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$utils_testdir/swmr_check_compat_vfd -rc=$? -if [ $rc -ne 0 ] ; then - echo - echo "The VFD specified by the HDF5_DRIVER environment variable" - echo "does not support SWMR." - echo - echo "flush/refresh tests skipped" - echo - exit 0 -fi - -# HDF5 has several tests that create and delete signal files to communicate -# between processes, and it seems that even though the names of the files are -# different, occasionally the wrong file is deleted, interrupting the flow of -# the test. Running each of these tests in its own directory should eliminate -# the problem. -mkdir -p flushrefresh_test -cp $testdir/flushrefresh flushrefresh_test - -# With the --disable-shared option, flushrefresh is built in the test directory, -# otherwise it is in test/.libs with a wrapper script named flushrefresh in -# the test directory. test/flushrefresh should always be copied, -# .libs/flushrefresh should be copied only if it exists. -if [ -f .libs/flushrefresh ]; then - mkdir -p flushrefresh_test/.libs - for FILE in .libs/flushrefresh*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE flushrefresh_test/.libs - fi - done -fi -cd flushrefresh_test - -# ================================================= -# Set up/initialize some variables to be used later -# ================================================= -testfile=flushrefresh.h5 -startsignal=flushrefresh_VERIFICATION_START -endsignal=flushrefresh_VERIFICATION_DONE -timeout_length=300 -timedout=0 -verification_done=0 -if [ -e $testfile ]; then - rm $testfile -fi - -# ======================== -# Launch the Test Program. -# ======================== -$testdir/flushrefresh & -pid_main=$! - -# ======================================= -# Run flush verification on test program. -# ======================================= - -until [ $verification_done -eq 1 ]; do - - # Wait for signal from test program that verification routine can run. - before=`TimeStamp` - until [ -s $startsignal ]; do - after=`TimeStamp` - timediff=`expr $after - $before` - if [ $timediff -gt $timeout_length ]; then - nerrors=`expr $nerrors + 1` - timedout=1 - break - fi - done - - # Check to see if we timed out looking for the signal before continuing. - if [ $timedout -gt 0 ]; then - echo "timed out waiting for signal from test program (flush)." - break - fi - - # Read in test routine parameters from signal file, then delete signal file. - param1=`head -1 $startsignal` - param2=`tail -1 $startsignal` - rm $startsignal - - # Check if we're done with verifications, otherwise run the specified verification. - if [ "$param1" = "VERIFICATION_DONE" ]; then - verification_done=1 - echo "all flush verification complete" > $endsignal - else - $testdir/flushrefresh $param1 $param2 - - # Check for core dump - if [ $? -gt 0 ]; then - nerrors=`expr $nerrors + 1` - fi - - echo "verification flush process done" > $endsignal - fi - -done - -# ========================================= -# Run refresh verification on test program. -# ========================================= -if [ $timedout -eq 0 ]; then - until [ $verification_done -eq 2 ]; do - - # Wait for signal from test program that verification routine can run. - before=`TimeStamp` - until [ -s $startsignal ]; do - after=`TimeStamp` - timediff=`expr $after - $before` - if [ $timediff -gt $timeout_length ]; then - nerrors=`expr $nerrors + 1` - timedout=1 - break - fi - done - - # Check to see if we timed out looking for the signal before continuing. - if [ $timedout -gt 0 ]; then - echo "timed out waiting for signal from test program (refresh)." - break - fi - - # Read in test routine parameter from signal file, then delete signal file. - param1=`head -n 1 $startsignal` - rm $startsignal - - # Check if we're done with verifications, otherwise run the specified verification. - if [ "$param1" = "VERIFICATION_DONE" ]; then - verification_done=2 - echo "all refresh verification complete" > $endsignal - else - $testdir/flushrefresh $param1 - - # Check for core dump - if [ $? -gt 0 ]; then - nerrors=`expr $nerrors + 1` - fi - - echo "refresh verifiction process done" > $endsignal - fi - - done -fi - -# ============================================ -# Wait for main to finish up, and end testing. -# ============================================ -wait $pid_main -if test $? -ne 0; then - echo flushrefresh had error - nerrors=`expr $nerrors + 1` -fi - -############################################################################### -## Report and exit -############################################################################### - -if test $nerrors -eq 0 ; then - echo "flush/refresh objects tests passed." - if test -z "$HDF5_NOCLEANUP"; then - # delete the test directory - rm -rf flushrefresh_test - fi - exit 0 -else - echo "flush/refresh objects tests failed with $nerrors errors." - exit 1 -fi diff --git a/test/testlibinfo.sh.in b/test/testlibinfo.sh.in deleted file mode 100644 index d9fee48..0000000 --- a/test/testlibinfo.sh.in +++ /dev/null @@ -1,120 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. - - -# -# Tests for the embedded library information feature. -# Part 1: -# Verify the HDF5 library does contains an exact copy of the content of the -# libhdf5.settings file. -# Part 2: -# If executable is linked with the static hdf5 library (how to determine?), -# verify an executable indeed contains an exact copy of the content of the -# libhdf5.settings file. -# -# Programmer: Albert Cheng -# Sep 18, 2009 - -srcdir=@srcdir@ - -# Determine the configure options of the hdf5 library and executables. - -Shared_Lib=@enable_shared@ -Static_Lib=@enable_static@ -Static_exec=@STATIC_EXEC@ - - -# Print a line-line message left justified in a field of 70 characters. -# -LINEMSG() { - SPACES=" " - echo "Check file $* $SPACES" | cut -c1-70 | tr -d '\012' -} - - -# Print a "SKIP" message -SKIP() { - LINEMSG $* - echo " -SKIP-" -} - -# Function definitions -CHECK_LIBINFO(){ - LINEMSG $1 - # Some systems, like Mac, the strings command inspects library files. Older - # versions of strings may not know newer library format, resulting in - # command errors. Make it read the file as stdin to avoid the problem. - if strings < $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then - echo " PASSED" - else - echo " FAILED" - nerrors=`expr $nerrors + 1` - fi -} - - -# MAIN Body -nerrors=0 -H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h` - -# Skip the rest if embedded-libinfo is not enabled. -if [ -z "$H5_HAVE_EMBEDDED_LIBINFO" ]; then - echo "embedded-libinfo is not enabled. Test skipped." - exit 0 -fi - -# The location of HDF library file(s) depends on whether shared lib is -# built too. -if [ -n $Shared_Lib ]; then - h5libdir=../src/.libs - shlib=$(grep dlname ../src/libhdf5.la | sed -e "s/dlname='//" -e "s/'//") -else - h5libdir=../src -fi - -h5libsettings=../src/libhdf5.settings - -# Part 1: -# Verify the HDF5 library does contains an exact copy of the content of the -# libhdf5.settings file. -# Check dynamic library file if built. -if [ x-$Shared_Lib = x-yes ]; then - CHECK_LIBINFO ${h5libdir}/${shlib} -else - SKIP shlib -fi - -# Though rare, libhdf5.a may not have been built. -if [ x-$Static_Lib = x-yes ]; then - CHECK_LIBINFO ${h5libdir}/libhdf5.a -else - SKIP ${h5libdir}/libhdf5.a -fi - -# Check if executables has the lib information only if shared lib is not -# built or static-exec is used. (Don't care static-exec since it affects -# tools binary only.) -if [ x-$Shared_Lib != x-yes ]; then - CHECK_LIBINFO testhdf5 -else - SKIP testhdf5 -fi - - -if [ $nerrors -gt 0 ]; then - echo "***$nerrors errors encountered***" - exit 1 -else - echo "No error encountered" - exit 0 -fi diff --git a/test/testlinks_env.sh.in b/test/testlinks_env.sh.in deleted file mode 100644 index 09074c3..0000000 --- a/test/testlinks_env.sh.in +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Test for external link with environment variable: HDF5_EXT_PREFIX - -srcdir=@srcdir@ - -nerrors=0 - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - -# test for external links with HDF5_EXT_PREFIX -echo "Testing external link with HDF5_EXT_PREFIX" -TEST_NAME=links_env # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -ENVCMD="env HDF5_EXT_PREFIX=.:tmp_links_env" # The environment variable & value -# -# Run the test -echo "$ENVCMD $RUNSERIAL $TEST_BIN" -$ENVCMD $RUNSERIAL $TEST_BIN -exitcode=$? -if [ $exitcode -eq 0 ]; then - echo "Test for HDF5_EXT_PREFIX PASSED" -else - nerrors="`expr $nerrors + 1`" - echo "***Error encountered for HDF5_EXT_PREFIX test***" -fi -exit $nerrors diff --git a/test/testswmr.pwsh.in b/test/testswmr.pwsh.in deleted file mode 100644 index de7a57a..0000000 --- a/test/testswmr.pwsh.in +++ /dev/null @@ -1,519 +0,0 @@ -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests for the swmr feature. - -$srcdir = '@srcdir@' -$utils_testdir=@H5_UTILS_TEST_BUILDDIR@ -$testdir=@H5_TEST_BUILDDIR@ - -############################################################################### -## test parameters -############################################################################### - -$Nreaders = 5 # number of readers to launch -$Nrdrs_spa = 3 # number of sparse readers to launch -$Nrecords = 200000 # number of records to write -$Nrecs_rem = 40000 # number of times to shrink -$Nrecs_spa = 20000 # number of records to write in the sparse test -$Nsecs_add = 5 # number of seconds per read interval -$Nsecs_rem = 3 # number of seconds per read interval -$Nsecs_addrem = 8 # number of seconds per read interval -$nerrors = 0 - -############################################################################### -## definitions for message file to coordinate test runs -############################################################################### -$WRITER_MESSAGE = 'SWMR_WRITER_MESSAGE' # The message file created by writer that the open is complete - # This should be the same as the define in "test/swmr_common.h" -$MESSAGE_TIMEOUT = 300 # Message timeout length in secs - # This should be the same as the define in "test/h5test.h" - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -function Test-WithSpaces { - $SPACES=' ' - #Write-Output "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# To wait for the writer message file or till the maximum # of seconds is reached -# $Message is the message file to wait for -# This performs similar function as the routine h5_wait_message() in test/h5test.c -function Wait-Message { - [CmdletBinding()] - param ( - [Parameter(Mandatory, ValueFromPipeline)] - [string]$TestPath, # Get the path of the message file to wait for - [Parameter(Mandatory, ValueFromPipeline)] - [string]$Message # Get the name of the message file to wait for - ) - - PROCESS { - $message = Join-Path -Path $TestPath -ChildPath $Message - $t0 = Get-Date # Get current time - $t1 = $t0 - $difft = New-Timespan -Start $t0 -End $t1 # Initialize the time difference - $mexist = 0 # Indicate whether the message file is found - while ($difft.TotalSeconds -lt $MESSAGE_TIMEOUT) { # Loop till message times out - $t1 = Get-Date # Get current time in seconds - $difft = New-Timespan -Start $t0 -End $t1 # Calculate the time difference - #Write-Output "Check for $message : time=$difft" - if ([System.IO.File]::Exists($message)) { # If message file is found: - $mexist = 1 # indicate the message file is found - Remove-Item $message # remove the message file - break # get out of the while loop - } - } - if ($mexist -eq 0) { - # Issue warning that the writer message file is not found, continue with launching the reader(s) - Write-Warning -Message "$WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds" - } - else { - Write-Output "$WRITER_MESSAGE is found" - } - } -} - -############################################################################### -## Main -## -## Modifications: -## Vailin Choi; July 2013 -## Add waiting of message file before launching the reader(s). -## Due to the implementation of file locking, coordination -## is needed in file opening for the writer/reader tests -## to proceed as expected. -## -############################################################################### - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$testprog = Join-Path -Path $utils_testdir -ChildPath swmr_check_compat_vfd.exe -$rp = Start-Process -FilePath $testprog -PassThru -Wait -NoNewWindow -if ($rp.ExitCode -ne 0) { - Write-Output "" - Write-Output "The VFD specified by the HDF5_DRIVER environment variable" - Write-Output "does not support SWMR." - Write-Output "" - Write-Output "SWMR acceptance tests skipped" - Write-Output "" - exit 0 -} - -Set-Location -Path swmr_test -$testdir = Join-Path -Path $testdir -ChildPath swmr_test - -# Loop over index types -$IndexTypeLoop = '-i ea', '-i b2' -foreach ($index_type in $IndexTypeLoop) { - # Try with and without compression - $CompressLoop = '', '-c 5' - foreach ($compress in $CompressLoop) { - Write-Output "" - Write-Output "*******************************************************************************" - Write-Output "** Loop testing parameters: $index_type $compress" - Write-Output "*******************************************************************************" - Write-Output "" - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Generator test" - Write-Output "###############################################################################" - # Launch the Generator without SWMR_WRITE - Write-Output "launch the swmr_generator" - $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -ArgumentList "$compress $index_type" -PassThru -Wait - if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 - } - - # Launch the Generator with SWMR_WRITE - Write-Output "launch the swmr_generator with SWMR_WRITE" - $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -ArgumentList "-s $compress $index_type" -PassThru -Wait - if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - exit 1 - } - - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Use H5Fstart_swmr_write() to enable SWMR writing mode" - Write-Output "###############################################################################" - - # Remove any possible writer message file before launching writer - if ([System.IO.File]::Exists($WRITER_MESSAGE)) { # If message file is found - Remove-Item $WRITER_MESSAGE - } - # - # Launch the Writer - Write-Output "launch the swmr_start_writer" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_start_write.exe -NoNewWindow -PassThru -ArgumentList "$compress $index_type $Nrecords $seed" 2>&1 |tee swmr_writer.out - $pid_writer = $rp.id - #Write-Output "pid_writer=$pid_writer" - - # Wait for message from writer process before starting reader(s) - Wait-Message $testdir $WRITER_MESSAGE - - # - # Launch the Readers - #declare -a seeds = ( ... ) - Write-Output "launch $Nreaders swmr_readers" - $pid_readers = @() - $n = 0 - while ($n -lt $Nreaders) { - #seed = "-r ${seeds[$n]}" - $seed = "" - $rp = Start-Process -FilePath $testdir/swmr_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_add $seed" 2>&1 | tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 - } - #Write-Output "pid_readers=$pid_readers" - - # Collect exit code of the readers first because they usually finish - # before the writer. - foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } - } - - # Collect exit code of the writer - #Write-Output "checked writer $pid_writer" - $result = Wait-Process -Id $pid_writer - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - Write-Warning "(Writer and reader output preserved)" - exit 1 - } - - # Clean up output files - Remove-Item swmr_writer.out - Remove-Item swmr_reader.out.* - - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Writer test - test expanding the dataset" - Write-Output "###############################################################################" - - # Launch the Generator - Write-Output "launch the swmr_generator" - $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -PassThru -Wait -ArgumentList "-s $compress $index_type" - if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 - } - - # Remove any possible writer message file before launching writer - Remove-Item $WRITER_MESSAGE - # - # Launch the Writer - Write-Output "launch the swmr_writer" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_writer.exe -NoNewWindow -PassThru -ArgumentList "-o $Nrecords $seed" 2>&1 |tee swmr_writer.out - $pid_writer = $rp.id - #Write-Output "pid_writer=$pid_writer" - - # Wait for message from writer process before starting reader(s) - Wait-Message $testdir $WRITER_MESSAGE - # - # Launch the Readers - #declare -a seeds = ( ... ) - Write-Output "launch $Nreaders swmr_readers" - $pid_readers = @() - $n = 0 - while ($n -lt $Nreaders) { - #seed = "-r ${seeds[$n]}" - $seed = "" - $rp = Start-Process -FilePath $testdir/swmr_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_add $seed" 2>&1 |tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 - } - #Write-Output "pid_readers=$pid_readers" - - # Collect exit code of the readers first because they usually finish - # before the writer. - foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } - } - - # Collect exit code of the writer - #Write-Output "checked writer $pid_writer" - $result = Wait-Process -Id $pid_writer - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - Write-Warning "(Writer and reader output preserved)" - exit 1 - } - - # Clean up output files - Remove-Item swmr_writer.out - Remove-Item swmr_reader.out.* - - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Remove test - test shrinking the dataset" - Write-Output "###############################################################################" - - # Remove any possible writer message file before launching writer - Remove-Item $WRITER_MESSAGE - # Launch the Remove Writer - Write-Output "launch the swmr_remove_writer" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_remove_writer.exe -NoNewWindow -PassThru -ArgumentList "-o $Nrecs_rem $seed" 2>&1 |tee swmr_writer.out - $pid_writer = $rp.id - #Write-Output "pid_writer=$pid_writer" - - # Wait for message from writer process before starting reader(s) - Wait-Message $testdir $WRITER_MESSAGE - # - # Launch the Remove Readers - #declare -a seeds = ( ... ) - $n = 0 - $pid_readers = @() - Write-Output "launch $Nreaders swmr_remove_readers" - while ($n -lt $Nreaders) { - #seed = "-r ${seeds[$n]}" - $seed = "" - $rp = Start-Process -FilePath $testdir/swmr_remove_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_rem $seed" 2>&1 |tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 - } - #Write-Output "pid_readers=$pid_readers" - - # Collect exit code of the readers first because they usually finish - # before the writer. - foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } - } - - # Collect exit code of the writer - #Write-Output "checked writer $pid_writer" - $result = Wait-Process -Id $pid_writer - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - Write-Warning "(Writer and reader output preserved)" - exit 1 - } - - # Clean up output files - Remove-Item swmr_writer.out - Remove-Item swmr_reader.out.* - - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Add/remove test - randomly grow or shrink the dataset" - Write-Output "###############################################################################" - - # Launch the Generator - Write-Output "launch the swmr_generator" - $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow-PassThru -Wait -ArgumentList "$compress $index_type" - if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 - } - - # Launch the Writer (not in parallel - just to rebuild the datasets) - Write-Output "launch the swmr_writer" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_writer.exe -NoNewWindow -PassThru -Wait -ArgumentList "$Nrecords $seed" - if ($rp.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Remove any possible writer message file before launching writer - Remove-Item $WRITER_MESSAGE - # - # Launch the Add/Remove Writer - Write-Output "launch the swmr_addrem_writer" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_addrem_writer.exe -NoNewWindow -PassThru -ArgumentList "$Nrecords $seed" 2>&1 |tee swmr_writer.out - $pid_writer = $rp.id - #Write-Output "pid_writer=$pid_writer" - - # Wait for message from writer process before starting reader(s) - Wait-Message $testdir $WRITER_MESSAGE - # - # Launch the Add/Remove Readers - #declare -a seeds = ( ... ) - $n = 0 - $pid_readers = @() - Write-Output "launch $Nreaders swmr_remove_readers" - while ($n -lt $Nreaders) { - #seed = "-r ${seeds[$n]}" - $seed = "" - $rp = Start-Process -FilePath $testdir/swmr_remove_reader.exe -NoNewWindow -PassThru -ArgumentList "$Nsecs_addrem $seed" 2>&1 |tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 - } - #Write-Output "pid_readers=$pid_readers" - - # Collect exit code of the readers first because they usually finish - # before the writer. - foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } - } - - # Collect exit code of the writer - #Write-Output "checked writer $pid_writer" - $result = Wait-Process -Id $pid_writer - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - Write-Warning "(Writer and reader output preserved)" - exit 1 - } - - # Clean up output files - Remove-Item swmr_writer.out - Remove-Item swmr_reader.out.* - - Write-Output "" - Write-Output "###############################################################################" - Write-Output "## Sparse writer test - test writing to random locations in the dataset" - Write-Output "###############################################################################" - - # Launch the Generator - # NOTE: Random seed is shared between readers and writers and is - # created by the generator. - Write-Output "launch the swmr_generator" - $seed = "" # Put -r command here - $rp = Start-Process -FilePath $testdir/swmr_generator.exe -NoNewWindow -PassThru -Wait -ArgumentList "$compress $index_type $seed" - if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 - } - - # Remove any possible writer message file before launching writer - Remove-Item $WRITER_MESSAGE - # Launch the Sparse writer - Write-Output "launch the swmr_sparse_writer" - $rp = Start-Process -FilePath $testdir/swmr_sparse_writer.exe -NoNewWindow -PassThru -ArgumentList "$Nrecs_spa" 2>&1 |tee swmr_writer.out - $pid_writer = $rp.Id - #Write-Output "pid_writer=$pid_writer" - - # Wait for message from writer process before starting reader(s) - Wait-Message $testdir $WRITER_MESSAGE - # - # Launch the Sparse readers - $n = 0 - $pid_readers = @() - Write-Output "launch $Nrdrs_spa swmr_sparse_readers" - while ($n -lt $Nrdrs_spa) { - # The sparse reader spits out a LOT of data so it's set to 'quiet' - $rp = Start-Process -FilePath $testdir/swmr_sparse_reader.exe -NoNewWindow -PassThru -ArgumentList "-q $Nrecs_spa" 2>&1 |tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 - } - #Write-Output "pid_readers=$pid_readers" - - # Collect exit code of the writer - #Write-Output "checked writer $pid_writer" - $result = Wait-Process -Id $pid_writer - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } - - # Collect exit code of the readers - foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } - } - - # Check for error and exit if one occurred - #Write-Output "nerrors=$nerrors" - if ($nerrors -ne 0) { - Write-Warning "SWMR tests failed with $nerrors errors." - Write-Warning "(Writer and reader output preserved)" - exit 1 - } - - # Clean up output files - Remove-Item swmr_writer.out - Remove-Item swmr_reader.out.* - } -} - -############################################################################### -## Report and exit -############################################################################### -cd .. -#Write-Output "nerrors=$nerrors" -if ($nerrors -eq 0) { - Write-Output "SWMR tests passed." -# if test -z "$HDF5_NOCLEANUP"; then -# # delete the test directory -# Remove-Item swmr_test -Recurse -# fi - exit 0 -} -else { - Write-Warning "SWMR tests failed with $nerrors errors." - exit 1 -} - diff --git a/test/testswmr.sh.in b/test/testswmr.sh.in deleted file mode 100644 index 771fe4a..0000000 --- a/test/testswmr.sh.in +++ /dev/null @@ -1,563 +0,0 @@ -#! /bin/bash -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests for the swmr feature. -# -# Created: -# Albert Cheng, 2009/07/22 - -srcdir=@srcdir@ -utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ -testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ - -############################################################################### -## test parameters -############################################################################### - -Nreaders=5 # number of readers to launch -Nrdrs_spa=3 # number of sparse readers to launch -Nrecords=200000 # number of records to write -Nrecs_rem=40000 # number of times to shrink -Nrecs_spa=20000 # number of records to write in the sparse test -Nsecs_add=5 # number of seconds per read interval -Nsecs_rem=3 # number of seconds per read interval -Nsecs_addrem=8 # number of seconds per read interval -nerrors=0 - -############################################################################### -## definitions for message file to coordinate test runs -############################################################################### -WRITER_MESSAGE=SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete - # This should be the same as the define in "test/swmr_common.h" -MESSAGE_TIMEOUT=300 # Message timeout length in secs - # This should be the same as the define in "test/h5test.h" - -############################################################################### -## short hands and function definitions -############################################################################### -DPRINT=: # Set to "echo Debug:" for debugging printing, - # else ":" for noop. -IFDEBUG=: # Set to null to turn on debugging, else ":" for noop. - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# To wait for the writer message file or till the maximum # of seconds is reached -# $1 is the message file to wait for -# This performs similar function as the routine h5_wait_message() in test/h5test.c -WAIT_MESSAGE() { - message=$1 # Get the name of the message file to wait for - t0=`date +%s` # Get current time in seconds - difft=0 # Initialize the time difference - mexist=0 # Indicate whether the message file is found - while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out - do - t1=`date +%s` # Get current time in seconds - difft=`expr $t1 - $t0` # Calculate the time difference - if [ -e $message ]; then # If message file is found: - mexist=1 # indicate the message file is found - rm $message # remove the message file - break # get out of the while loop - fi - done; - if test $mexist -eq 0; then - # Issue warning that the writer message file is not found, continue with launching the reader(s) - echo warning: $WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds - else - echo $WRITER_MESSAGE is found - fi -} - -############################################################################### -## Main -## -## Modifications: -## Vailin Choi; July 2013 -## Add waiting of message file before launching the reader(s). -## Due to the implementation of file locking, coordination -## is needed in file opening for the writer/reader tests -## to proceed as expected. -## -############################################################################### - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$utils_testdir/swmr_check_compat_vfd -rc=$? -if [ $rc -ne 0 ] ; then - echo - echo "The VFD specified by the HDF5_DRIVER environment variable" - echo "does not support SWMR." - echo - echo "SWMR acceptance tests skipped" - echo - exit 0 -fi - -# Parse options (none accepted at this time) -while [ $# -gt 0 ]; do - case "$1" in - *) # unknown option - echo "$0: Unknown option ($1)" - exit 1 - ;; - esac -done - -# HDF5 has several tests that create and delete signal files to communicate -# between processes, and it seems that even though the names of the files are -# different, occasionally the wrong file is deleted, interrupting the flow of -# the test. Running each of these tests in its own directory should eliminate -# the problem. -mkdir swmr_test -for FILE in swmr*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE swmr_test - fi -done - -# With the --disable-shared option, swmr program files are built in the test -# directory, otherwise they are in test/.libs with a corresponding wrapper -# script in the test directory. The programs or wrapper scripts in test should -# always be copied, swmr files in .libs should be copied only if they exists. -if [ -f .libs/swmr ]; then - mkdir swmr_test/.libs - for FILE in .libs/swmr*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE swmr_test/.libs - fi - done -fi - -cd swmr_test - - -# Loop over index types -for index_type in "-i ea" "-i b2" -do - # Try with and without compression - for compress in "" "-c 5" - do - echo - echo "*******************************************************************************" - echo "** Loop testing parameters: $index_type $compress" - echo "*******************************************************************************" - echo - echo - echo "###############################################################################" - echo "## Generator test" - echo "###############################################################################" - # Launch the Generator without SWMR_WRITE - echo launch the swmr_generator - $testdir/swmr_generator $compress $index_type - if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` - fi - - # Launch the Generator with SWMR_WRITE - echo launch the swmr_generator with SWMR_WRITE - $testdir/swmr_generator -s $compress $index_type - if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` - fi - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - exit 1 - fi - - echo - echo "###############################################################################" - echo "## Use H5Fstart_swmr_write() to enable SWMR writing mode" - echo "###############################################################################" - - # Remove any possible writer message file before launching writer - rm -f $WRITER_MESSAGE - # - # Launch the Writer - echo launch the swmr_start_writer - seed="" # Put -r command here - $testdir/swmr_start_write $compress $index_type $Nrecords $seed 2>&1 |tee swmr_writer.out & - pid_writer=$! - $DPRINT pid_writer=$pid_writer - - # Wait for message from writer process before starting reader(s) - WAIT_MESSAGE $WRITER_MESSAGE - - # - # Launch the Readers - #declare -a seeds=( ... ) - echo launch $Nreaders swmr_readers - pid_readers="" - n=0 - while [ $n -lt $Nreaders ]; do - #seed="-r ${seeds[$n]}" - seed="" - $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & - pid_readers="$pid_readers $!" - n=`expr $n + 1` - done - $DPRINT pid_readers=$pid_readers - $IFDEBUG ps - - # Collect exit code of the readers first because they usually finish - # before the writer. - for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi - done - - # Collect exit code of the writer - $DPRINT checked writer $pid_writer - wait $pid_writer - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - echo "(Writer and reader output preserved)" - exit 1 - fi - - # Clean up output files - rm -f swmr_writer.out - rm -f swmr_reader.out.* - - echo - echo "###############################################################################" - echo "## Writer test - test expanding the dataset" - echo "###############################################################################" - - # Launch the Generator - echo launch the swmr_generator - $testdir/swmr_generator -s $compress $index_type - if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` - fi - - # Remove any possible writer message file before launching writer - rm -f $WRITER_MESSAGE - # - # Launch the Writer - echo launch the swmr_writer - seed="" # Put -r command here - $testdir/swmr_writer -o $Nrecords $seed 2>&1 |tee swmr_writer.out & - pid_writer=$! - $DPRINT pid_writer=$pid_writer - - # Wait for message from writer process before starting reader(s) - WAIT_MESSAGE $WRITER_MESSAGE - # - # Launch the Readers - #declare -a seeds=( ... ) - echo launch $Nreaders swmr_readers - pid_readers="" - n=0 - while [ $n -lt $Nreaders ]; do - #seed="-r ${seeds[$n]}" - seed="" - $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & - pid_readers="$pid_readers $!" - n=`expr $n + 1` - done - $DPRINT pid_readers=$pid_readers - $IFDEBUG ps - - # Collect exit code of the readers first because they usually finish - # before the writer. - for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi - done - - # Collect exit code of the writer - $DPRINT checked writer $pid_writer - wait $pid_writer - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - echo "(Writer and reader output preserved)" - exit 1 - fi - - # Clean up output files - rm -f swmr_writer.out - rm -f swmr_reader.out.* - - echo - echo "###############################################################################" - echo "## Remove test - test shrinking the dataset" - echo "###############################################################################" - - # Remove any possible writer message file before launching writer - rm -f $WRITER_MESSAGE - # Launch the Remove Writer - echo launch the swmr_remove_writer - seed="" # Put -r command here - $testdir/swmr_remove_writer -o $Nrecs_rem $seed 2>&1 |tee swmr_writer.out & - pid_writer=$! - $DPRINT pid_writer=$pid_writer - - # Wait for message from writer process before starting reader(s) - WAIT_MESSAGE $WRITER_MESSAGE - # - # Launch the Remove Readers - #declare -a seeds=( ... ) - n=0 - pid_readers="" - echo launch $Nreaders swmr_remove_readers - while [ $n -lt $Nreaders ]; do - #seed="-r ${seeds[$n]}" - seed="" - $testdir/swmr_remove_reader $Nsecs_rem $seed 2>&1 |tee swmr_reader.out.$n & - pid_readers="$pid_readers $!" - n=`expr $n + 1` - done - $DPRINT pid_readers=$pid_readers - $IFDEBUG ps - - # Collect exit code of the readers first because they usually finish - # before the writer. - for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi - done - - # Collect exit code of the writer - $DPRINT checked writer $pid_writer - wait $pid_writer - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - echo "(Writer and reader output preserved)" - exit 1 - fi - - # Clean up output files - rm -f swmr_writer.out - rm -f swmr_reader.out.* - - echo - echo "###############################################################################" - echo "## Add/remove test - randomly grow or shrink the dataset" - echo "###############################################################################" - - # Launch the Generator - echo launch the swmr_generator - $testdir/swmr_generator $compress $index_type - if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` - fi - - # Launch the Writer (not in parallel - just to rebuild the datasets) - echo launch the swmr_writer - seed="" # Put -r command here - $testdir/swmr_writer $Nrecords $seed - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Remove any possible writer message file before launching writer - rm -f $WRITER_MESSAGE - # - # Launch the Add/Remove Writer - echo launch the swmr_addrem_writer - seed="" # Put -r command here - $testdir/swmr_addrem_writer $Nrecords $seed 2>&1 |tee swmr_writer.out & - pid_writer=$! - $DPRINT pid_writer=$pid_writer - - # Wait for message from writer process before starting reader(s) - WAIT_MESSAGE $WRITER_MESSAGE - # - # Launch the Add/Remove Readers - #declare -a seeds=( ... ) - n=0 - pid_readers="" - echo launch $Nreaders swmr_remove_readers - while [ $n -lt $Nreaders ]; do - #seed="-r ${seeds[$n]}" - seed="" - $testdir/swmr_remove_reader $Nsecs_addrem $seed 2>&1 |tee swmr_reader.out.$n & - pid_readers="$pid_readers $!" - n=`expr $n + 1` - done - $DPRINT pid_readers=$pid_readers - $IFDEBUG ps - - # Collect exit code of the readers first because they usually finish - # before the writer. - for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi - done - - # Collect exit code of the writer - $DPRINT checked writer $pid_writer - wait $pid_writer - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - echo "(Writer and reader output preserved)" - exit 1 - fi - - # Clean up output files - rm -f swmr_writer.out - rm -f swmr_reader.out.* - - echo - echo "###############################################################################" - echo "## Sparse writer test - test writing to random locations in the dataset" - echo "###############################################################################" - - # Launch the Generator - # NOTE: Random seed is shared between readers and writers and is - # created by the generator. - echo launch the swmr_generator - seed="" # Put -r command here - $testdir/swmr_generator $compress $index_type $seed - if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` - fi - - # Remove any possible writer message file before launching writer - rm -f $WRITER_MESSAGE - # Launch the Sparse writer - echo launch the swmr_sparse_writer - nice -n 20 $testdir/swmr_sparse_writer $Nrecs_spa 2>&1 |tee swmr_writer.out & - pid_writer=$! - $DPRINT pid_writer=$pid_writer - - # Wait for message from writer process before starting reader(s) - WAIT_MESSAGE $WRITER_MESSAGE - # - # Launch the Sparse readers - n=0 - pid_readers="" - echo launch $Nrdrs_spa swmr_sparse_readers - while [ $n -lt $Nrdrs_spa ]; do - # The sparse reader spits out a LOT of data so it's set to 'quiet' - $testdir/swmr_sparse_reader -q $Nrecs_spa 2>&1 |tee swmr_reader.out.$n & - pid_readers="$pid_readers $!" - n=`expr $n + 1` - done - $DPRINT pid_readers=$pid_readers - $IFDEBUG ps - - # Collect exit code of the writer - $DPRINT checked writer $pid_writer - wait $pid_writer - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi - - # Collect exit code of the readers - for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi - done - - # Check for error and exit if one occurred - $DPRINT nerrors=$nerrors - if test $nerrors -ne 0 ; then - echo "SWMR tests failed with $nerrors errors." - echo "(Writer and reader output preserved)" - exit 1 - fi - - # Clean up output files - rm -f swmr_writer.out - rm -f swmr_reader.out.* - done -done - -############################################################################### -## Report and exit -############################################################################### -cd .. -$DPRINT nerrors=$nerrors -if test $nerrors -eq 0 ; then - echo "SWMR tests passed." - if test -z "$HDF5_NOCLEANUP"; then - # delete the test directory - rm -rf swmr_test - fi - exit 0 -else - echo "SWMR tests failed with $nerrors errors." - exit 1 -fi - diff --git a/test/testvds_env.sh.in b/test/testvds_env.sh.in deleted file mode 100644 index 39f13a5..0000000 --- a/test/testvds_env.sh.in +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Test for external file with environment variable: HDF5_VDS_PREFIX - -srcdir=@srcdir@ - -nerrors=0 - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - -# test for VDS with HDF5_VDS_PREFIX -echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" -TEST_NAME=vds_env # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp_vds_env" # Set the environment variable & value -UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value -# -# Run the test -# echo "$ENVCMD $RUNSERIAL $TEST_BIN" -$ENVCMD $RUNSERIAL $TEST_BIN -exitcode=$? -if [ $exitcode -eq 0 ]; then - echo "Test prefix for HDF5_VDS_PREFIX PASSED" -else - nerrors="`expr $nerrors + 1`" - echo "***Error encountered for HDF5_VDS_PREFIX test***" -fi -$UNENVCMD -exit $nerrors diff --git a/test/testvdsswmr.pwsh.in b/test/testvdsswmr.pwsh.in deleted file mode 100644 index bf5aabb..0000000 --- a/test/testvdsswmr.pwsh.in +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests for the swmr feature using virtual datasets. - -$srcdir = '@srcdir@' -$utils_testdir=@H5_UTILS_TEST_BUILDDIR@ -$testdir=@H5_TEST_BUILDDIR@ - -############################################################################### -## test parameters -############################################################################### - -$Nwriters = 6 # number of writers (1 per source dataset) -$Nreaders = 5 # number of readers to launch -$nerrors = 0 - -############################################################################### -## definitions for message file to coordinate test runs -############################################################################### -$WRITER_MESSAGE = 'SWMR_WRITER_MESSAGE' # The message file created by writer that the open is complete - # This should be the same as the define in "test/swmr_common.h" -$MESSAGE_TIMEOUT = 300 # Message timeout length in secs - # This should be the same as the define in "test/h5test.h" - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -function Test-WithSpaces { - $SPACES=' ' - #Write-Output "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# To wait for the writer message file or till the maximum # of seconds is reached -# $Message is the message file to wait for -# This performs similar function as the routine h5_wait_message() in test/h5test.c -function Wait-Message { - [CmdletBinding()] - param ( - [Parameter(Mandatory, ValueFromPipeline)] - [string]$TestPath, # Get the path of the message file to wait for - [Parameter(Mandatory, ValueFromPipeline)] - [string]$Message # Get the name of the message file to wait for - ) - - PROCESS { - $message = Join-Path -Path $TestPath -ChildPath $Message - $t0 = Get-Date # Get current time - $t1 = $t0 - $difft = New-Timespan -Start $t0 -End $t1 # Initialize the time difference - $mexist = 0 # Indicate whether the message file is found - while ($difft.TotalSeconds -lt $MESSAGE_TIMEOUT) { # Loop till message times out - $t1 = Get-Date # Get current time in seconds - $difft = New-Timespan -Start $t0 -End $t1 # Calculate the time difference - #Write-Output "Check for $message : time=$difft" - if ([System.IO.File]::Exists($message)) { # If message file is found: - $mexist = 1 # indicate the message file is found - Remove-Item $message # remove the message file - break # get out of the while loop - } - } - if ($mexist -eq 0) { - # Issue warning that the writer message file is not found, continue with launching the reader(s) - Write-Warning -Message "$WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds" - } - else { - Write-Output "$WRITER_MESSAGE is found" - } - } -} - -############################################################################### -## Main -############################################################################### - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$testprog = Join-Path -Path $utils_testdir -ChildPath swmr_check_compat_vfd.exe -$rp = Start-Process -FilePath $testprog -PassThru -Wait -NoNewWindow -if ($rp.ExitCode -ne 0) { - Write-Output "" - Write-Output "The VFD specified by the HDF5_DRIVER environment variable" - Write-Output "does not support SWMR." - Write-Output "" - Write-Output "SWMR acceptance tests skipped" - Write-Output "" - exit 0 -} - -Set-Location -Path vds_swmr_test -$testdir = Join-Path -Path $testdir -ChildPath vds_swmr_test - -Write-Output "" -Write-Output "###############################################################################" -Write-Output "## Basic VDS SWMR test - writing to a tiled plane" -Write-Output "###############################################################################" - -# Launch the file generator -Write-Output "launch the swmr_generator" -$rp = Start-Process -FilePath $testdir/vds_swmr_gen.exe -NoNewWindow -PassThru -Wait -if ($rp.ExitCode -ne 0) { - Write-Warning "generator had error" - $nerrors += 1 -} - -# Check for error and exit if one occurred -#Write-Output "nerrors=$nerrors" -if ($nerrors -ne 0) { - Write-Warning "VDS SWMR tests failed with $nerrors errors." - exit 1 -} - -# Launch the writers -Write-Output "launch the $Nwriters SWMR VDS writers (1 per source)" -$pid_writers = @() -$n = 0 -while ($n -lt $Nwriters) { - $rp = Start-Process -FilePath $testdir/vds_swmr_writer.exe -NoNewWindow -PassThru -ArgumentList "$n" 2>&1 | tee swmr_writer.out.$n - $pid_writers += $rp.id - $n += 1 -} -#Write-Output "pid_writers=$pid_writers" - -# Sleep to ensure that the writers have started -Start-Sleep -Seconds 3 - -# Launch the readers -Write-Output "launch $Nreaders SWMR readers" -$pid_readers = @() -$n = 0 -while ($n -lt $Nreaders) { - $rp = Start-Process -FilePath $testdir/vds_swmr_reader.exe -NoNewWindow -PassThru 2>&1 | tee swmr_reader.out.$n - $pid_readers += $rp.id - $n += 1 -} -#Write-Output "pid_readers=$pid_readers" - -# Collect exit code of the writers -foreach ($xpid in $pid_writers) { - #Write-Output "checked writer $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "writer had error" - $nerrors += 1 - } -} - -# Collect exit code of the readers -# (they usually finish after the writers) -foreach ($xpid in $pid_readers) { - #Write-Output "checked reader $xpid" - $result = Wait-Process -Id $xpid - if ($result.ExitCode -ne 0) { - Write-Warning "reader had error" - $nerrors += 1 - } -} - -# Check for error and exit if one occurred -#Write-Output "nerrors=$nerrors" -if ($nerrors -ne 0) { - Write-Warning "VDS SWMR tests failed with $nerrors errors." - exit 1 -} - -############################################################################### -## Report and exit -############################################################################### -cd .. -#Write-Output "nerrors=$nerrors" -if ($nerrors -eq 0) { - Write-Output "VDS SWMR tests passed." -# if test -z "$HDF5_NOCLEANUP"; then -# # delete the test directory -# Remove-Item vds_swmr_test -Recurse -# fi - exit 0 -} -else { - Write-Warning "VDS SWMR tests failed with $nerrors errors." - exit 1 -} - diff --git a/test/testvdsswmr.sh.in b/test/testvdsswmr.sh.in deleted file mode 100644 index 399fdef..0000000 --- a/test/testvdsswmr.sh.in +++ /dev/null @@ -1,233 +0,0 @@ -#! /bin/bash -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Tests for the swmr feature using virtual datasets. -# -# Created: -# Dana Robinson, November 2015 - -srcdir=@srcdir@ -utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@ -testdir=@abs_top_builddir@/@H5_TEST_BUILDDIR@ - -############################################################################### -## test parameters -############################################################################### - -Nwriters=6 # number of writers (1 per source dataset) -Nreaders=5 # number of readers to launch -nerrors=0 - -############################################################################### -## definitions for message file to coordinate test runs -############################################################################### -WRITER_MESSAGE=SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete - # This should be the same as the define in "test/swmr_common.h" -MESSAGE_TIMEOUT=300 # Message timeout length in secs - # This should be the same as the define in "test/h5test.h" - -############################################################################### -## short hands and function definitions -############################################################################### -DPRINT=: # Set to "echo Debug:" for debugging printing, - # else ":" for noop. -IFDEBUG=: # Set to null to turn on debugging, else ":" for noop. - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# To wait for the writer message file or till the maximum # of seconds is reached -# $1 is the message file to wait for -# This performs similar function as the routine h5_wait_message() in test/h5test.c -WAIT_MESSAGE() { - message=$1 # Get the name of the message file to wait for - t0=`date +%s` # Get current time in seconds - difft=0 # Initialize the time difference - mexist=0 # Indicate whether the message file is found - while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out - do - t1=`date +%s` # Get current time in seconds - difft=`expr $t1 - $t0` # Calculate the time difference - if [ -e $message ]; then # If message file is found: - mexist=1 # indicate the message file is found - rm $message # remove the message file - break # get out of the while loop - fi - done; - if test $mexist -eq 0; then - # Issue warning that the writer message file is not found, continue with launching the reader(s) - echo warning: $WRITER_MESSAGE is not found after waiting $MESSAGE_TIMEOUT seconds - else - echo $WRITER_MESSAGE is found - fi -} - -############################################################################### -## Main -############################################################################### - -# Check to see if the VFD specified by the HDF5_DRIVER environment variable -# supports SWMR. -$utils_testdir/swmr_check_compat_vfd -rc=$? -if [ $rc -ne 0 ] ; then - echo - echo "The VFD specified by the HDF5_DRIVER environment variable" - echo "does not support SWMR." - echo - echo "SWMR acceptance tests skipped" - echo - exit 0 -fi - -# Parse options (none accepted at this time) -while [ $# -gt 0 ]; do - case "$1" in - *) # unknown option - echo "$0: Unknown option ($1)" - exit 1 - ;; - esac -done - -# HDF5 has several tests that create and delete signal files to communicate -# between processes, and it seems that even though the names of the files are -# different, occasionally the wrong file is deleted, interrupting the flow of -# the test. Running each of these tests in its own directory should eliminate -# the problem. -mkdir vds_swmr_test -for FILE in vds_swmr*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE vds_swmr_test - fi -done - -# With the --disable-shared option, swmr program files are built in the test -# directory, otherwise they are in test/.libs with a corresponding wrapper -# script in the test directory. The programs or wrapper scripts in test should -# always be copied, swmr files in .libs should be copied only if they exists. -if [ -f .libs/vds_swmr_writer ]; then - mkdir vds_swmr_test/.libs - for FILE in .libs/vds_swmr*; do - case "$FILE" in - *.o) continue ;; ## don't copy the .o files - esac - if test -f "$FILE" ; then - cp $FILE vds_swmr_test/.libs - fi - done -fi - -cd vds_swmr_test - - -echo -echo "###############################################################################" -echo "## Basic VDS SWMR test - writing to a tiled plane" -echo "###############################################################################" - -# Launch the file generator -echo launch the generator -$testdir/vds_swmr_gen -if test $? -ne 0; then - echo generator had error - nerrors=`expr $nerrors + 1` -fi - -# Check for error and exit if one occurred -$DPRINT nerrors=$nerrors -if test $nerrors -ne 0 ; then - echo "VDS SWMR tests failed with $nerrors errors." - exit 1 -fi - -# Launch the writers -echo "launch the $Nwriters SWMR VDS writers (1 per source)" -pid_writers="" -n=0 -while [ $n -lt $Nwriters ]; do - $testdir/vds_swmr_writer $n & - pid_writers="$pid_writers $!" - n=`expr $n + 1` -done -$DPRINT pid_writers=$pid_writers -$IFDEBUG ps - -# Sleep to ensure that the writers have started -sleep 3 - -# Launch the readers -echo launch $Nreaders SWMR readers -pid_readers="" -n=0 -while [ $n -lt $Nreaders ]; do - $testdir/vds_swmr_reader & - pid_readers="$pid_readers $!" - n=`expr $n + 1` -done -$DPRINT pid_readers=$pid_readers -$IFDEBUG ps - -# Collect exit code of the writers -for xpid in $pid_writers; do - $DPRINT checked writer $xpid - wait $xpid - if test $? -ne 0; then - echo writer had error - nerrors=`expr $nerrors + 1` - fi -done - -# Collect exit code of the readers -# (they usually finish after the writers) -for xpid in $pid_readers; do - $DPRINT checked reader $xpid - wait $xpid - if test $? -ne 0; then - echo reader had error - nerrors=`expr $nerrors + 1` - fi -done - -# Check for error and exit if one occurred -$DPRINT nerrors=$nerrors -if test $nerrors -ne 0 ; then - echo "VDS SWMR tests failed with $nerrors errors." - exit 1 -fi - -############################################################################### -## Report and exit -############################################################################### -cd .. -$DPRINT nerrors=$nerrors -if test $nerrors -eq 0 ; then - echo "VDS SWMR tests passed." - if test -z "$HDF5_NOCLEANUP"; then - # delete the test directory - rm -rf vds_swmr_test - fi - exit 0 -else - echo "VDS SWMR tests failed with $nerrors errors." - exit 1 -fi - -- cgit v0.12