summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-03-04 20:53:35 (GMT)
committerGitHub <noreply@github.com>2021-03-04 20:53:35 (GMT)
commit84b31b5a558bdc816e91c414f98155bf72ae1502 (patch)
treee8ad14db9c0b8a687f0aa2afa8cd211be5c2fe79 /test
parent7cd0949828f81cf148e45be076e52ee65baf5ab4 (diff)
parentef5a1941f7638688c3d66cead33f03c329c2ed3e (diff)
downloadhdf5-84b31b5a558bdc816e91c414f98155bf72ae1502.zip
hdf5-84b31b5a558bdc816e91c414f98155bf72ae1502.tar.gz
hdf5-84b31b5a558bdc816e91c414f98155bf72ae1502.tar.bz2
Merge pull request #416 from derobins/vfd_swmr/thg_standards
Brings VFD SWMR code closer to THG standards and allows C library compilation on Windows
Diffstat (limited to 'test')
-rw-r--r--test/page_buffer.c5
-rw-r--r--test/vfd_swmr.c66
-rw-r--r--test/vfd_swmr_addrem_writer.c1
-rw-r--r--test/vfd_swmr_bigset_writer.c5
-rw-r--r--test/vfd_swmr_common.h1
-rw-r--r--test/vfd_swmr_group_writer.c5
-rw-r--r--test/vfd_swmr_remove_reader.c1
-rw-r--r--test/vfd_swmr_vlstr_reader.c2
-rw-r--r--test/vfd_swmr_vlstr_writer.c2
-rw-r--r--test/vfd_swmr_zoo_writer.c6
10 files changed, 41 insertions, 53 deletions
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/vfd_swmr.c b/test/vfd_swmr.c
index d49629f..09188f6 100644
--- a/test/vfd_swmr.c
+++ b/test/vfd_swmr.c
@@ -824,19 +824,13 @@ error:
return 1;
} /* test_writer_create_open_flush() */
-/* Sleep for `tenths` tenths of a second.
- *
- * This routine may quietly perform a too-short sleep if an error occurs
- * in nanosleep(2).
- */
+/* Sleep for `tenths` tenths of a second */
static void
decisleep(uint32_t tenths)
{
- struct timespec delay = {.tv_sec = tenths / 10,
- .tv_nsec = tenths * 100 * 1000 * 1000};
+ uint64_t nsec = tenths * 100 * 1000 * 1000;
- while (nanosleep(&delay, &delay) == -1 && errno == EINTR)
- ; // do nothing
+ H5_nanosleep(nsec);
}
@@ -948,7 +942,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
@@ -981,7 +975,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
@@ -1015,7 +1009,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
@@ -1237,6 +1231,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
@@ -1499,7 +1497,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
@@ -1577,7 +1575,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
@@ -1632,7 +1630,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
@@ -1686,7 +1684,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
@@ -2167,6 +2165,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
@@ -2440,6 +2442,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
@@ -3059,7 +3065,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";
@@ -3073,7 +3079,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;
@@ -3089,55 +3095,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.h b/test/vfd_swmr_common.h
index f64ee87..d96983a 100644
--- a/test/vfd_swmr_common.h
+++ b/test/vfd_swmr_common.h
@@ -18,7 +18,6 @@
/* Headers */
/***********/
-#include <stdarg.h>
#include "h5test.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 c98b2e1..1792a93 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"
@@ -227,7 +223,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;
char step = 'b';