diff options
Diffstat (limited to 'test/vfd_swmr_vlstr_reader.c')
-rw-r--r-- | test/vfd_swmr_vlstr_reader.c | 178 |
1 files changed, 90 insertions, 88 deletions
diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index c6bf1dc..226c0a8 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -1,20 +1,17 @@ -/* - * 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://support.hdfgroup.org/ftp/HDF5/releases. - * If you do not have access to either file, you may request a copy from - * help@hdfgroup.org. - */ - -#include <err.h> - -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -27,25 +24,23 @@ #include "testhdf5.h" #include "vfd_swmr_common.h" -typedef enum _step { - CREATE = 0 -, LENGTHEN -, SHORTEN -, DELETE -, NSTEPS -} step_t; +#ifndef H5_HAVE_WIN32_API + +#include <err.h> + +typedef enum _step { CREATE = 0, LENGTHEN, SHORTEN, DELETE, NSTEPS } step_t; -static const hid_t badhid = H5I_INVALID_HID; // abbreviate -static bool caught_out_of_bounds = false; -static bool read_null = false; +static const hid_t badhid = H5I_INVALID_HID; // abbreviate +static bool caught_out_of_bounds = false; +static bool read_null = false; static bool read_vl_dset(hid_t dset, hid_t type, char **data) { - bool success; + bool success; estack_state_t es; - es = disable_estack(); + es = disable_estack(); success = H5Dread(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) >= 0; if (*data == NULL) { read_null = true; @@ -61,9 +56,9 @@ usage(const char *progname) { fprintf(stderr, "usage: %s [-W] [-V] [-t (oob|null)] \n", progname); fprintf(stderr, "\n -S: do not use VFD SWMR\n"); - fprintf(stderr, " -n: number of test steps to perform\n"); - fprintf(stderr, " -q: be quiet: few/no progress messages\n"); - fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); + fprintf(stderr, " -n: number of test steps to perform\n"); + fprintf(stderr, " -q: be quiet: few/no progress messages\n"); + fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); exit(EXIT_FAILURE); } @@ -80,52 +75,51 @@ H5HG_trap(const char *reason) int main(int argc, char **argv) { - hid_t fapl, fid, space, type; - hid_t dset[2]; - char *content[2]; - char name[2][96]; - int ch, i, ntimes = 100; - unsigned long tmp; - bool use_vfd_swmr = true; - char *end; - const long millisec_in_nanosecs = 1000 * 1000; - const struct timespec delay = - {.tv_sec = 0, .tv_nsec = millisec_in_nanosecs * 11 / 10}; - testsel_t sel = TEST_NONE; + hid_t fapl, fid, space, type; + hid_t dset[2]; + char * content[2]; + char name[2][96]; + int ch, i, ntimes = 100; + unsigned long tmp; + bool use_vfd_swmr = true; + char * end; + const long millisec_in_nanosecs = 1000 * 1000; + const struct timespec delay = {.tv_sec = 0, .tv_nsec = millisec_in_nanosecs * 11 / 10}; + testsel_t sel = TEST_NONE; H5F_vfd_swmr_config_t config; assert(H5T_C_S1 != badhid); while ((ch = getopt(argc, argv, "Sn:qt:")) != -1) { - switch(ch) { - case 'S': - use_vfd_swmr = false; - break; - case 'n': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') - errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (errno != 0) - err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (tmp > INT_MAX) - errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); - ntimes = (int)tmp; - break; - case 'q': - verbosity = 1; - break; - case 't': - if (strcmp(optarg, "oob") == 0) - sel = TEST_OOB; - else if (strcmp(optarg, "null") == 0) - sel = TEST_NULL; - else + switch (ch) { + case 'S': + use_vfd_swmr = false; + break; + case 'n': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') + errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (errno != 0) + err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (tmp > INT_MAX) + errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); + ntimes = (int)tmp; + break; + case 'q': + verbosity = 1; + break; + case 't': + if (strcmp(optarg, "oob") == 0) + sel = TEST_OOB; + else if (strcmp(optarg, "null") == 0) + sel = TEST_NULL; + else + usage(argv[0]); + break; + default: usage(argv[0]); - break; - default: - usage(argv[0]); - break; + break; } } argv += optind; @@ -163,24 +157,21 @@ main(int argc, char **argv) * content 1 seq 1 long long long long long long long long * content 1 seq 1 medium medium medium */ - for (i = 0; - !caught_out_of_bounds && i < ntimes; - (i % 2 == 0) ? nanosleep(&delay, NULL) : 0, i++) { + for (i = 0; !caught_out_of_bounds && i < ntimes; (i % 2 == 0) ? nanosleep(&delay, NULL) : 0, i++) { estack_state_t es; - const int ndsets = 2; - const int which = i % ndsets; - int nconverted; + const int ndsets = 2; + const int which = i % ndsets; + int nconverted; struct { - int which; - int seq; + int which; + int seq; char tail[96]; } scanned_content; dbgf(2, "iteration %d which %d", i, which); - (void)snprintf(name[which], sizeof(name[which]), - "dset-%d", which); - es = disable_estack(); - dset[which] = H5Dopen(fid, name[which], H5P_DEFAULT); + (void)snprintf(name[which], sizeof(name[which]), "dset-%d", which); + es = disable_estack(); + dset[which] = H5Dopen2(fid, name[which], H5P_DEFAULT); restore_estack(es); if (caught_out_of_bounds || dset[which] == badhid) { dbgf(2, ": couldn't open\n"); @@ -191,14 +182,14 @@ main(int argc, char **argv) dbgf(2, ": couldn't read\n"); continue; } - nconverted = sscanf(content[which], "content %d seq %d %96s", - &scanned_content.which, &scanned_content.seq, scanned_content.tail); + nconverted = sscanf(content[which], "content %d seq %d %96s", &scanned_content.which, + &scanned_content.seq, scanned_content.tail); if (nconverted != 3) { dbgf(2, ": couldn't scan\n"); continue; } - dbgf(2, ": read which %d seq %d tail %s\n", - scanned_content.which, scanned_content.seq, scanned_content.tail); + dbgf(2, ": read which %d seq %d tail %s\n", scanned_content.which, scanned_content.seq, + scanned_content.tail); H5Dclose(dset[which]); } @@ -227,3 +218,14 @@ main(int argc, char **argv) return EXIT_SUCCESS; } + +#else /* H5_HAVE_WIN32_API */ + +int +main(void) +{ + HDfprintf(stderr, "Non-POSIX platform. Skipping.\n"); + return EXIT_SUCCESS; +} /* end main() */ + +#endif /* H5_HAVE_WIN32_API */ |