summaryrefslogtreecommitdiffstats
path: root/test/vfd_swmr_vlstr_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/vfd_swmr_vlstr_reader.c')
-rw-r--r--test/vfd_swmr_vlstr_reader.c134
1 files changed, 62 insertions, 72 deletions
diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c
index 5905a3d..f9b3eef 100644
--- a/test/vfd_swmr_vlstr_reader.c
+++ b/test/vfd_swmr_vlstr_reader.c
@@ -11,8 +11,8 @@
* help@hdfgroup.org.
*/
-#define H5C_FRIEND /*suppress error about including H5Cpkg */
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5C_FRIEND /*suppress error about including H5Cpkg */
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
#include "hdf5.h"
@@ -29,25 +29,19 @@
#include <err.h>
-typedef enum _step {
- CREATE = 0
-, LENGTHEN
-, SHORTEN
-, DELETE
-, NSTEPS
-} step_t;
+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;
@@ -63,9 +57,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);
}
@@ -82,52 +76,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;
@@ -165,23 +158,20 @@ 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();
+ (void)snprintf(name[which], sizeof(name[which]), "dset-%d", which);
+ es = disable_estack();
dset[which] = H5Dopen(fid, name[which], H5P_DEFAULT);
restore_estack(es);
if (caught_out_of_bounds || dset[which] == badhid) {
@@ -193,14 +183,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]);
}