summaryrefslogtreecommitdiffstats
path: root/test/vfd_swmr_dsetops_writer.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-03-31 07:56:29 (GMT)
committerGitHub <noreply@github.com>2022-03-31 07:56:29 (GMT)
commitbc62da7eb911727497475d1cc90991230f33fa3d (patch)
treed2bd03b84b8e97d21dbcdfaa04199c898b6ae291 /test/vfd_swmr_dsetops_writer.c
parentfbb532cd633e216f47ce846493b38af02cfbb43a (diff)
downloadhdf5-bc62da7eb911727497475d1cc90991230f33fa3d.zip
hdf5-bc62da7eb911727497475d1cc90991230f33fa3d.tar.gz
hdf5-bc62da7eb911727497475d1cc90991230f33fa3d.tar.bz2
VFD SWMR: Normalization with develop and cleanup (#1559)
* Brought over plugin and test script changes * Removes remaining register keywords (#1481) * Fixed warnings in the aux process code * Minor fixes from develop * Minor changes from develop, fixed format warnings * Formatted source * Added HD prefix to timespec_get * Cleanup in new files * Removes the MANIFEST file and unused release files (#1497) * Removes the MANIFEST file and unused release files * Updated tar command * checkposix corrections * More checkposix fixes * Ripped out unused instrumentation functionality * Brought over cache tagging changes from develop * Changes to tagged metadata expulsion iteration * Fixed typo * Brought over H5O__free() changes from develop * Brings (unused) parallel page buffer test in line with develop * Moved the functionality in supervise.subr to test_vfd_swmr.sh * Tools VFD parameter updates * Committing clang-format changes * H5F VFD SWMR refactoring * Committing clang-format changes * Misc changes * Acceptance test cleanup * HD prefix * H5_get_option instead of getopt * Some bool fixes * Changes to VFD SWMR acceptance tests * Minor cleanup * Use AC_MSG_RESULT/AC_MSG_ERROR/AC_MSG_WARN instead of echo (#1532) * Merges from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/vfd_swmr_dsetops_writer.c')
-rw-r--r--test/vfd_swmr_dsetops_writer.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c
index 7760dab..8ef0962 100644
--- a/test/vfd_swmr_dsetops_writer.c
+++ b/test/vfd_swmr_dsetops_writer.c
@@ -192,8 +192,6 @@ static bool verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool
static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config,
np_state_t *np);
-static const hid_t badhid = H5I_INVALID_HID;
-
/* Names for datasets */
#define DSET_COMPACT_NAME "compact_dset"
#define DSET_CONTIG_NAME "contig_dset"
@@ -265,10 +263,12 @@ usage(const char *progname)
static bool
state_init(state_t *s, int argc, char **argv)
{
- unsigned long tmp;
- int ch;
- char * tfile = NULL;
- char * end;
+ unsigned long tmp;
+ int opt;
+ char * tfile = NULL;
+ char * end;
+ const char * s_opts = "pte:gkm:n:s:r:l:w:bqSNUORu:c:";
+ struct h5_long_options l_opts[] = {{NULL, 0, '\0'}};
*s = ALL_HID_INITIALIZER;
@@ -284,8 +284,8 @@ state_init(state_t *s, int argc, char **argv)
tfile = NULL;
}
- while ((ch = getopt(argc, argv, "pte:gkm:n:s:r:l:w:bqSNUORu:c:")) != -1) {
- switch (ch) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
+ switch (opt) {
case 'p': /* compact dataset */
s->compact = true;
@@ -341,37 +341,37 @@ state_init(state_t *s, int argc, char **argv)
case 'u': /* ticks for raeder to wait before verification */
case 'c': /* communication interval */
errno = 0;
- tmp = HDstrtoul(optarg, &end, 0);
- if (end == optarg || *end != '\0') {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ tmp = HDstrtoul(H5_optarg, &end, 0);
+ if (end == H5_optarg || *end != '\0') {
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (errno != 0) {
- HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg);
+ HDprintf("couldn't parse `-%c` argument `%s`\n", opt, H5_optarg);
TEST_ERROR;
}
else if (tmp > UINT_MAX) {
- HDprintf("`-%c` argument `%lu` too large\n", ch, tmp);
+ HDprintf("`-%c` argument `%lu` too large\n", opt, tmp);
TEST_ERROR;
}
- if (ch == 'e')
+ if (opt == 'e')
s->compact_elmts = (unsigned)tmp;
- else if (ch == 'm')
+ else if (opt == 'm')
s->rows = (unsigned)tmp;
- else if (ch == 'n')
+ else if (opt == 'n')
s->cols = (unsigned)tmp;
- else if (ch == 's')
+ else if (opt == 's')
s->swrites = (unsigned)tmp;
- else if (ch == 'r')
+ else if (opt == 'r')
s->rwrites = (unsigned)tmp;
- else if (ch == 'l')
+ else if (opt == 'l')
s->lwrites = (unsigned)tmp;
- else if (ch == 'w')
+ else if (opt == 'w')
s->wwrites = (unsigned)tmp;
- else if (ch == 'u')
+ else if (opt == 'u')
s->update_interval = (unsigned)tmp;
- else if (ch == 'c')
+ else if (opt == 'c')
s->csteps = (unsigned)tmp;
break;
@@ -382,8 +382,8 @@ state_init(state_t *s, int argc, char **argv)
break;
}
}
- argc -= optind;
- argv += optind;
+ argc -= H5_optind;
+ argv += H5_optind;
/* Require to specify at least -p or -g or -k option */
if (!s->compact && !s->contig && !s->chunked) {
@@ -476,11 +476,11 @@ error:
static bool
create_dsets(const state_t *s, dsets_state_t *ds)
{
- hid_t dcpl = badhid;
- hid_t dtid = badhid;
+ hid_t dcpl = H5I_INVALID_HID;
+ hid_t dtid = H5I_INVALID_HID;
unsigned i;
H5R_ref_t *obj_buf = NULL; /* Buffer for object references */
- hid_t sid = badhid;
+ hid_t sid = H5I_INVALID_HID;
hsize_t obj_dims = OBJ_REF_DIMS; /* Dimension for object reference dataset */
hsize_t reg_dims = REG_REF_DIMS; /* Dimension for region reference dataset */
@@ -1095,12 +1095,12 @@ error:
static bool
close_dset_real(hid_t did, hid_t sid)
{
- if (did != badhid && H5Dclose(did) < 0) {
+ if (did != H5I_INVALID_HID && H5Dclose(did) < 0) {
HDprintf("H5Dclose dataset failed\n");
TEST_ERROR;
}
- if (sid != badhid && H5Sclose(sid) < 0) {
+ if (sid != H5I_INVALID_HID && H5Sclose(sid) < 0) {
HDprintf("H5Sclose dataspace for dataset failed\n");
TEST_ERROR;
}
@@ -1783,7 +1783,7 @@ verify_dset(hid_t did, hid_t tid, hid_t sid, hid_t mem_sid, hsize_t *start, hsiz
/* If region reference is enabled, obtain the dataset selection from the reference buffer */
if (reg_buf != NULL) { /* Imply region reference is enabled */
- hid_t temp_sid = badhid;
+ hid_t temp_sid = H5I_INVALID_HID;
H5E_BEGIN_TRY
{
@@ -1841,7 +1841,7 @@ error:
static bool
verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, bool flush_raw_data)
{
- unsigned int *rbuf;
+ unsigned int *rbuf = NULL;
unsigned i;
/* Refresh the dataset */
@@ -1999,7 +1999,10 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_
/* At communication interval, notify the reader about the failure and quit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
}
@@ -2054,7 +2057,10 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np)
/* At communication interval, tell the writer about the failure and exit */
if (step % s->csteps == 0) {
np->notify = -1;
- HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int));
+ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) {
+ HDprintf("HDwrite failed\n");
+ TEST_ERROR;
+ }
goto error;
}
/* The verification succeeds */
@@ -2337,7 +2343,7 @@ error:
}
return EXIT_FAILURE;
-} /* main */
+}
#else /* H5_HAVE_WIN32_API */
@@ -2346,6 +2352,6 @@ main(void)
{
HDfprintf(stderr, "Non-POSIX platform. Skipping.\n");
return EXIT_SUCCESS;
-} /* end main() */
+}
#endif /* H5_HAVE_WIN32_API */