diff options
author | raylu-hdf <60487644+raylu-hdf@users.noreply.github.com> | 2021-03-05 16:05:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-05 16:05:41 (GMT) |
commit | 9835edcdad2cfb567c7d8af98e8dbbaa4e712eca (patch) | |
tree | 2bf92f9d0387f909711c7653381984a9482d401c /test | |
parent | 8e14c386aaa9e09dd9bc7d2b28995ff73b1a9903 (diff) | |
parent | 84b31b5a558bdc816e91c414f98155bf72ae1502 (diff) | |
download | hdf5-9835edcdad2cfb567c7d8af98e8dbbaa4e712eca.zip hdf5-9835edcdad2cfb567c7d8af98e8dbbaa4e712eca.tar.gz hdf5-9835edcdad2cfb567c7d8af98e8dbbaa4e712eca.tar.bz2 |
Merge branch 'feature/vfd_swmr' into raylu_zoo_test
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 8 | ||||
-rw-r--r-- | test/page_buffer.c | 5 | ||||
-rw-r--r-- | test/testvfdswmr.sh.in | 32 | ||||
-rw-r--r-- | test/vfd_swmr.c | 55 | ||||
-rw-r--r-- | test/vfd_swmr_addrem_writer.c | 1 | ||||
-rw-r--r-- | test/vfd_swmr_bigset_writer.c | 5 | ||||
-rw-r--r-- | test/vfd_swmr_common.c | 87 | ||||
-rw-r--r-- | test/vfd_swmr_common.h | 7 | ||||
-rw-r--r-- | test/vfd_swmr_group_writer.c | 5 | ||||
-rw-r--r-- | test/vfd_swmr_remove_reader.c | 1 | ||||
-rw-r--r-- | test/vfd_swmr_vlstr_reader.c | 2 | ||||
-rw-r--r-- | test/vfd_swmr_vlstr_writer.c | 2 | ||||
-rw-r--r-- | test/vfd_swmr_zoo_writer.c | 6 |
13 files changed, 163 insertions, 53 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 023c07e..ad6b258 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -46,6 +46,11 @@ if (NOT ONLY_SHARED_LIBS) endif () H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} STATIC 0) set_target_properties (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test) + + # Always link to pthreads for VFD SWMR tests + if (NOT WIN32) + target_link_libraries (${HDF5_TEST_LIB_TARGET} PRIVATE Threads::Threads) + endif () endif () if (BUILD_SHARED_LIBS) @@ -66,6 +71,9 @@ if (BUILD_SHARED_LIBS) endif () H5_SET_LIB_OPTIONS (${HDF5_TEST_LIBSH_TARGET} ${HDF5_TEST_LIB_NAME} SHARED "LIB") set_target_properties (${HDF5_TEST_LIBSH_TARGET} PROPERTIES FOLDER libraries/test) + + # Always link to pthreads for VFD SWMR tests + target_link_libraries (${HDF5_TEST_LIBSH_TARGET} PRIVATE Threads::Threads) endif () ################################################################################# diff --git a/test/page_buffer.c b/test/page_buffer.c index 88b3317..112ea77 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -20,7 +20,6 @@ *************************************************************/ #include <err.h> -#include <libgen.h> #include "h5test.h" @@ -151,8 +150,8 @@ swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) HDfprintf(stderr, "temporary string allocation failed\n"); return -1; } - dname = dirname(tname[0]); - bname = basename(tname[1]); + dname = HDdirname(tname[0]); + bname = HDbasename(tname[1]); snprintf(config.md_file_path, sizeof(config.md_file_path), "%s/%s.shadow", dname, bname); free(tname[0]); diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 97c13cf..acd8185 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -40,6 +40,30 @@ nsofterrors=0 # soft errors are expected to occur some of the time # on a couple of nondeterministic tests. ############################################################################### +## test parameters for vfd_swmr_bigset_writer.c based on HDF5TestExpress: +## 0: Exhaustive run: Tests take a long time to run. +## 1: Default run. +## 2+: Quick run +############################################################################### +if [ -z $HDF5TestExpress ]; then # Set to default when not set + HDF5TestExpress=1 +fi +## +##Default setting +BIGSET_n=25 # -n option: # of iterations +BIGSET_few_s=20 # -s option: # of datasets (for few_big test) +BIGSET_many_s=500 # -s option: # of datasets (for many_small test) +if [[ "$HDF5TestExpress" -eq 0 ]] ; then # Setting for exhaustive run + BIGSET_n=50 + BIGSET_few_s=40 + BIGSET_many_s=1000 +elif [[ "$HDF5TestExpress" -gt 1 ]]; then # Setting for quick run + BIGSET_n=10 + BIGSET_few_s=10 + BIGSET_many_s=100 +fi + +############################################################################### ## definitions for message file to coordinate test runs ############################################################################### WRITER_MESSAGE=VFD_SWMR_WRITER_MESSAGE # The message file created by writer that the open is complete @@ -637,11 +661,11 @@ for options in "-d 1" "-d 1 -F" "-d 2" "-d 2 -F" "-d 1 -V" "-d 1 -M" "-d 1 -V -F # echo launch vfd_swmr_bigset_writer many small, options $options catch_out_err_and_rc vfd_swmr_bigset_writer \ - ../vfd_swmr_bigset_writer -n 50 $options -s 1000 -r 16 -c 16 -q & + ../vfd_swmr_bigset_writer -n $BIGSET_n $options -s $BIGSET_many_s -r 16 -c 16 -q & pid_writer=$! catch_out_err_and_rc vfd_swmr_bigset_reader \ - ../vfd_swmr_bigset_reader -n 50 $options -s 1000 -r 16 -c 16 -q -W & + ../vfd_swmr_bigset_reader -n $BIGSET_n $options -s $BIGSET_many_s -r 16 -c 16 -q -W & pid_reader=$! # Wait for the reader to finish before signalling the @@ -686,11 +710,11 @@ for options in "-d 1" "-d 1 -F" "-d 2" "-d 2 -F" "-d 1 -V" "-d 1 -M" "-d 1 -V -F fi echo launch vfd_swmr_bigset_writer few big, options $options catch_out_err_and_rc vfd_swmr_bigset_writer \ - ../vfd_swmr_bigset_writer -n 50 $options -s 40 -r 256 -c 256 -q & + ../vfd_swmr_bigset_writer -n $BIGSET_n $options -s $BIGSET_few_s -r 256 -c 256 -q & pid_writer=$! catch_out_err_and_rc vfd_swmr_bigset_reader \ - ../vfd_swmr_bigset_reader -n 50 $options -s 40 -r 256 -c 256 -q -W & + ../vfd_swmr_bigset_reader -n $BIGSET_n $options -s $BIGSET_few_s -r 256 -c 256 -q -W & pid_reader=$! # Wait for the reader to finish before signalling the diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 9d2c2c0..47098a6 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -824,7 +824,6 @@ error: return 1; } /* test_writer_create_open_flush() */ - /*------------------------------------------------------------------------- * Function: test_writer_md() * @@ -933,7 +932,7 @@ test_writer_md(void) decisleep(my_config->tick_len); /* Create a chunked dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dcreate2(fid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -966,7 +965,7 @@ test_writer_md(void) decisleep(my_config->tick_len); /* Open the dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1000,7 +999,7 @@ test_writer_md(void) decisleep(my_config->tick_len); /* Open the dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1222,6 +1221,10 @@ test_reader_md_concur(void) if(HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); + /* Free unused configuration */ + if(config_writer) + HDfree(config_writer); + /* * Case A: reader * --verify an empty index @@ -1484,7 +1487,7 @@ test_reader_md_concur(void) decisleep(config_writer->tick_len); /* Create a chunked dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dcreate2(fid_writer, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1562,7 +1565,7 @@ test_reader_md_concur(void) decisleep(config_writer->tick_len); /* Open the dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1617,7 +1620,7 @@ test_reader_md_concur(void) decisleep(config_writer->tick_len); /* Open the dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1671,7 +1674,7 @@ test_reader_md_concur(void) decisleep(config_writer->tick_len); /* Open the dataset */ - sprintf(dname, "dset %d", i); + HDsprintf(dname, "dset %d", i); if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -2152,6 +2155,10 @@ test_disable_enable_eot_concur(void) if(HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); + /* Free unused configuration */ + if(config_writer) + HDfree(config_writer); + /* * Open the file 3 times as VFD SWMR reader * Enable and disable EOT for a file @@ -2425,6 +2432,10 @@ test_file_end_tick_concur(void) if(HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); + /* Free unused configuration */ + if(config_writer) + HDfree(config_writer); + /* * Open the file 3 times as VFD SWMR reader * Trigger EOT for the files @@ -3044,7 +3055,7 @@ test_shadow_index_lookup(void) char vector[8]; unsigned seed = 1; unsigned i, j, failj = UINT_MAX; - bool have_failj = false; + hbool_t have_failj = FALSE; unsigned long tmpl; char *ostate; const char *seedvar = "H5_SHADOW_INDEX_SEED"; @@ -3058,7 +3069,7 @@ test_shadow_index_lookup(void) nerrors = 1; goto out; case 0: - seed = (unsigned int)time(NULL); + seed = (unsigned int)HDtime(NULL); break; default: seed = (unsigned int)tmpl; @@ -3074,55 +3085,55 @@ test_shadow_index_lookup(void) break; default: failj = (unsigned int)tmpl; - have_failj = true; + have_failj = TRUE; break; } ostate = initstate(seed, vector, _arraycount(vector)); - size[5] = (uint32_t)(1024 + random() % (16 * 1024 * 1024 - 1024)); + size[5] = (uint32_t)(1024 + HDrandom() % (16 * 1024 * 1024 - 1024)); for (i = 0; i < _arraycount(size); i++) { uint32_t cursize = size[i]; const uint64_t modulus = UINT64_MAX / MAX(1, cursize); uint64_t pageno; - assert(modulus > 1); // so that modulus - 1 > 0, below + HDassert(modulus > 1); // so that modulus - 1 > 0, below - idx = (cursize == 0) ? NULL : calloc(cursize, sizeof(*idx)); + idx = (cursize == 0) ? NULL : HDcalloc(cursize, sizeof(*idx)); if (idx == NULL && cursize != 0) { - fprintf(stderr, "couldn't allocate %" PRIu32 " indices\n", + HDfprintf(stderr, "couldn't allocate %" PRIu32 " indices\n", cursize); - exit(EXIT_FAILURE); + HDexit(EXIT_FAILURE); } - for (pageno = (uint64_t)random() % modulus, j = 0; + for (pageno = (uint64_t)HDrandom() % modulus, j = 0; j < cursize; - j++, pageno += 1 + (uint64_t)random() % (modulus - 1)) { + j++, pageno += 1 + (uint64_t)HDrandom() % (modulus - 1)) { idx[j].hdf5_page_offset = pageno; } for (j = 0; j < cursize; j++) { H5FD_vfd_swmr_idx_entry_t *found; found = vfd_swmr_pageno_to_mdf_idx_entry(idx, cursize, - idx[j].hdf5_page_offset, false); + idx[j].hdf5_page_offset, FALSE); if ((have_failj && failj == j) || found != &idx[j]) break; } if (j < cursize) { - printf("\nshadow-index entry %d lookup, pageno %" PRIu64 + HDprintf("\nshadow-index entry %d lookup, pageno %" PRIu64 ", index size %" PRIu32 ", seed %u", j, idx[j].hdf5_page_offset, cursize, seed); nerrors++; } if (idx != NULL) - free(idx); + HDfree(idx); } (void)setstate(ostate); out: if (nerrors == 0) PASSED(); else - printf(" FAILED\n"); + HDprintf(" FAILED\n"); return nerrors; } diff --git a/test/vfd_swmr_addrem_writer.c b/test/vfd_swmr_addrem_writer.c index ad651e6..b4c0e1f 100644 --- a/test/vfd_swmr_addrem_writer.c +++ b/test/vfd_swmr_addrem_writer.c @@ -33,7 +33,6 @@ /***********/ #include <err.h> /* errx(3) */ -#include <stdlib.h> /* EXIT_FAILURE */ #include "h5test.h" #include "vfd_swmr_common.h" diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index d57479a..7b0f451 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -67,9 +67,6 @@ */ #include <err.h> -#include <libgen.h> -#include <time.h> /* nanosleep(2) */ -#include <unistd.h> /* getopt(3) */ #define H5C_FRIEND /*suppress error about including H5Cpkg */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -273,7 +270,7 @@ state_init(state_t *s, int argc, char **argv) *s = state_initializer(); esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); while ((ch = getopt(argc, argv, "FMSVWa:bc:d:n:qr:s:u:")) != -1) { switch (ch) { diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index bc68617..65671fc 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -21,6 +21,11 @@ #include <err.h> /* for err(3) */ +/* Only need the pthread solution if sigtimedwai(2) isn't available */ +#ifndef H5_HAVE_SIGTIMEDWAIT +#include <pthread.h> +#endif + #include "h5test.h" #include "vfd_swmr_common.h" #include "swmr_common.h" @@ -193,6 +198,55 @@ strsignal(int signum) } #endif +#ifndef H5_HAVE_SIGTIMEDWAIT + +typedef struct timer_params_t { + struct timespec *tick; + hid_t fid; +} timer_params_t; + +pthread_mutex_t timer_mutex; +hbool_t timer_stop = FALSE; + +static void * +timer_function(void *arg) +{ + timer_params_t *params = (timer_params_t *)arg; + sigset_t sleepset; + hbool_t done = FALSE; + + /* Ignore any signals */ + sigfillset(&sleepset); + pthread_sigmask(SIG_SETMASK, &sleepset, NULL); + + for (;;) { + estack_state_t es; + + nanosleep(params->tick, NULL); + + /* Check the mutex */ + pthread_mutex_lock(&timer_mutex); + done = timer_stop; + pthread_mutex_unlock(&timer_mutex); + if (done) + break; + + /* Avoid deadlock with peer: periodically enter the API so that + * tick processing occurs and data is flushed so that the peer + * can see it. + * + * The call we make will fail, but that's ok, + * so squelch errors. + */ + es = disable_estack(); + (void)H5Aexists_by_name(params->fid, "nonexistent", "nonexistent", H5P_DEFAULT); + restore_estack(es); + } + + return NULL; +} +#endif /* H5_HAVE_SIGTIMEDWAIT */ + /* Wait for any signal to occur and then return. Wake periodically * during the wait to perform API calls: in this way, the * VFD SWMR tick number advances and recent changes do not languish @@ -201,8 +255,8 @@ strsignal(int signum) void await_signal(hid_t fid) { - sigset_t sleepset; struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100}; + sigset_t sleepset; if (sigfillset(&sleepset) == -1) { err(EXIT_FAILURE, "%s.%d: could not initialize signal mask", @@ -217,7 +271,37 @@ await_signal(hid_t fid) dbgf(1, "waiting for signal\n"); +#ifndef H5_HAVE_SIGTIMEDWAIT + { + /* Use an alternative scheme for platforms like MacOS that do not have + * sigtimedwait(2) + */ + timer_params_t params; + int rc; + pthread_t timer; + + params.tick = &tick; + params.fid = fid; + + pthread_mutex_init(&timer_mutex, NULL); + + pthread_create(&timer, NULL, timer_function, ¶ms); + + rc = sigwait(&sleepset, NULL); + + if (rc != -1) { + fprintf(stderr, "Received signal, wrapping things up.\n"); + pthread_mutex_lock(&timer_mutex); + timer_stop = TRUE; + pthread_mutex_unlock(&timer_mutex); + pthread_join(timer, NULL); + } + else + err(EXIT_FAILURE, "%s: sigtimedwait", __func__); + } +#else for (;;) { + /* Linux and other systems */ const int rc = sigtimedwait(&sleepset, NULL, &tick); if (rc != -1) { @@ -241,6 +325,7 @@ await_signal(hid_t fid) } else if (rc == -1) err(EXIT_FAILURE, "%s: sigtimedwait", __func__); } +#endif /* H5_HAVE_SIGTIMEDWAIT */ } /* Revised support routines that can be used for all VFD SWMR integration tests diff --git a/test/vfd_swmr_common.h b/test/vfd_swmr_common.h index 90c0f36..b798328 100644 --- a/test/vfd_swmr_common.h +++ b/test/vfd_swmr_common.h @@ -11,14 +11,13 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _VFD_SWMR_COMMON_H -#define _VFD_SWMR_COMMON_H +#ifndef VFD_SWMR_COMMON_H +#define VFD_SWMR_COMMON_H /***********/ /* Headers */ /***********/ -#include <stdarg.h> #include "h5test.h" /**********/ @@ -95,4 +94,4 @@ H5TEST_DLL int fetch_env_ulong(const char *, unsigned long, unsigned long *); extern int verbosity; -#endif /* _SWMR_COMMON_H */ +#endif /* SWMR_COMMON_H */ diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index ede4594..2f355c2 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -12,9 +12,6 @@ */ #include <err.h> -#include <libgen.h> -#include <time.h> /* nanosleep(2) */ -#include <unistd.h> /* getopt(3) */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -87,7 +84,7 @@ state_init(state_t *s, int argc, char **argv) *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); while ((ch = getopt(argc, argv, "SWa:bn:qu:")) != -1) { switch (ch) { diff --git a/test/vfd_swmr_remove_reader.c b/test/vfd_swmr_remove_reader.c index c4eaba2..80fe042 100644 --- a/test/vfd_swmr_remove_reader.c +++ b/test/vfd_swmr_remove_reader.c @@ -28,7 +28,6 @@ /***********/ #include <err.h> /* errx(3) */ -#include <stdlib.h> /* EXIT_FAILURE */ #include "h5test.h" #include "vfd_swmr_common.h" diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index e75af35..c6bf1dc 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -12,8 +12,6 @@ */ #include <err.h> -#include <time.h> /* nanosleep(2) */ -#include <unistd.h> /* getopt(3) */ #define H5C_FRIEND /*suppress error about including H5Cpkg */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ diff --git a/test/vfd_swmr_vlstr_writer.c b/test/vfd_swmr_vlstr_writer.c index 17e7d83..3085575 100644 --- a/test/vfd_swmr_vlstr_writer.c +++ b/test/vfd_swmr_vlstr_writer.c @@ -12,8 +12,6 @@ */ #include <err.h> -#include <time.h> /* nanosleep(2) */ -#include <unistd.h> /* getopt(3) */ #define H5C_FRIEND /*suppress error about including H5Cpkg */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index a7ae40a..60c61d6 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -12,9 +12,6 @@ */ #include <err.h> -#include <libgen.h> /* basename(3) */ -#include <time.h> /* nanosleep(2) */ -#include <unistd.h> /* getopt(3) */ #define H5C_FRIEND /* suppress error about including H5Cpkg */ #define H5F_FRIEND /* suppress error about including H5Fpkg */ @@ -25,7 +22,6 @@ #include "H5retry_private.h" #include "H5Cpkg.h" #include "H5Fpkg.h" -// #include "H5Iprivate.h" #include "H5HGprivate.h" #include "H5VLprivate.h" @@ -232,7 +228,7 @@ main(int argc, char **argv) const char *seedvar = "H5_ZOO_STEP_SEED"; bool use_vfd_swmr = true; bool print_estack = false; - const char *progname = basename(argv[0]); + const char *progname = HDbasename(argv[0]); const char *personality = strstr(progname, "vfd_swmr_zoo_"); estack_state_t es; H5F_vfd_swmr_config_t vfd_swmr_config; |