diff options
Diffstat (limited to 'test/vfd_swmr_dsetops_writer.c')
-rw-r--r-- | test/vfd_swmr_dsetops_writer.c | 102 |
1 files changed, 62 insertions, 40 deletions
diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c index 8030be5..a238e95 100644 --- a/test/vfd_swmr_dsetops_writer.c +++ b/test/vfd_swmr_dsetops_writer.c @@ -91,17 +91,6 @@ typedef struct { unsigned int lastwrite; /* The last operation (-s, -r, -l or -w) performed. */ } state_t; -/* Initializations for state_t */ -#define ALL_HID_INITIALIZER \ - (state_t) \ - { \ - .filename = "", .file = H5I_INVALID_HID, .filetype = H5T_NATIVE_UINT32, \ - .update_interval = READER_WAIT_TICKS, .csteps = 1, .use_np = true, .use_vfd_swmr = true, \ - .flush_raw_data = true, .compact = false, .compact_write = false, .compact_elmts = MAX_COMPACT_ELMS, \ - .contig = false, .rows = 10, .cols = 5, .swrites = 0, .rwrites = 0, .lwrites = 0, .wwrites = 0, \ - .lastwrite = 0, .obj_ref = false, .reg_ref = false \ - } - /* Structure to hold info for different dataset types */ typedef struct { hid_t compact_did; /* ID for compact dataset */ @@ -270,7 +259,29 @@ state_init(state_t *s, int argc, char **argv) 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; + s->file = H5I_INVALID_HID; + s->filetype = H5T_NATIVE_UINT32; + s->update_interval = READER_WAIT_TICKS; + s->csteps = 1; + s->use_np = TRUE; + s->use_vfd_swmr = TRUE; + s->flush_raw_data = TRUE; + s->compact = FALSE; + s->compact_write = FALSE; + s->compact_elmts = MAX_COMPACT_ELMS; + s->contig = FALSE; + s->rows = 10; + s->cols = 5; + s->swrites = 0; + s->rwrites = 0; + s->lwrites = 0; + s->wwrites = 0; + s->lastwrite = 0; + s->obj_ref = FALSE; + s->reg_ref = FALSE; + + HDmemset(s->filename, 0, PATH_MAX); + HDmemset(s->progname, 0, PATH_MAX); if (H5_basename(argv[0], &tfile) < 0) { HDprintf("H5_basename failed\n"); @@ -2203,21 +2214,26 @@ error: int main(int argc, char **argv) { - hid_t fapl = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; - bool writer = FALSE; - state_t s; - const char * personality; - H5F_vfd_swmr_config_t config; - np_state_t np; - dsets_state_t ds; - - if (!state_init(&s, argc, argv)) { + hid_t fapl = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + bool writer = FALSE; + state_t * s = NULL; + const char * personality; + H5F_vfd_swmr_config_t *config = NULL; + np_state_t np; + dsets_state_t ds; + + if (NULL == (s = HDcalloc(1, sizeof(state_t)))) + TEST_ERROR; + if (NULL == (config = HDcalloc(1, sizeof(H5F_vfd_swmr_config_t)))) + TEST_ERROR; + + if (!state_init(s, argc, argv)) { HDprintf("state_init() failed\n"); TEST_ERROR; } - personality = HDstrstr(s.progname, "vfd_swmr_dsetops_"); + personality = HDstrstr(s->progname, "vfd_swmr_dsetops_"); if (personality != NULL && HDstrcmp(personality, "vfd_swmr_dsetops_writer") == 0) writer = true; @@ -2231,11 +2247,11 @@ main(int argc, char **argv) /* config, tick_len, max_lag, presume_posix_semantics, writer, * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, * md_file_path, md_file_name, updater_file_path */ - init_vfd_swmr_config(&config, 4, 7, FALSE, writer, TRUE, FALSE, s.flush_raw_data, 128, "./", + init_vfd_swmr_config(config, 4, 7, FALSE, writer, TRUE, FALSE, s->flush_raw_data, 128, "./", "dsetops-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ - if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(true, s->use_vfd_swmr, true, 4096, config)) < 0) { HDprintf("vfd_swmr_create_fapl() failed\n"); TEST_ERROR; } @@ -2247,43 +2263,43 @@ main(int argc, char **argv) } if (writer) { - if ((s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { + if ((s->file = H5Fcreate(s->filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { HDprintf("H5Fcreate failed\n"); TEST_ERROR; } - if (!create_dsets(&s, &ds)) { + if (!create_dsets(s, &ds)) { HDprintf("create_dsets() failed\n"); TEST_ERROR; } } else { - if ((s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl)) < 0) { + if ((s->file = H5Fopen(s->filename, H5F_ACC_RDONLY, fapl)) < 0) { HDprintf("H5Fopen failed\n"); TEST_ERROR; } - if (!open_dsets(&s, &ds)) { + if (!open_dsets(s, &ds)) { HDprintf("open_dsets() failed\n"); TEST_ERROR; } } /* Initiailze named pipes */ - if (s.use_np && !np_init(&np, writer)) { + if (s->use_np && !np_init(&np, writer)) { HDprintf("np_init() failed\n"); TEST_ERROR; } if (writer) { - if (!perform_dsets_operations(&s, &ds, &config, &np)) { + if (!perform_dsets_operations(s, &ds, config, &np)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { - if (!verify_dsets_operations(&s, &ds, &config, &np, false)) { + if (!verify_dsets_operations(s, &ds, config, &np, false)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } @@ -2299,9 +2315,9 @@ main(int argc, char **argv) TEST_ERROR; } - if (!s.flush_raw_data && s.use_np) { + if (!s->flush_raw_data && s->use_np) { - if (!closing_on_noflush(writer, &s, &ds, &config, &np)) + if (!closing_on_noflush(writer, s, &ds, config, &np)) TEST_ERROR; } else { @@ -2311,17 +2327,20 @@ main(int argc, char **argv) TEST_ERROR; } - if (H5Fclose(s.file) < 0) { + if (H5Fclose(s->file) < 0) { HDprintf("H5Fclose failed\n"); TEST_ERROR; } - if (s.use_np && !np_close(&np, writer)) { + if (s->use_np && !np_close(&np, writer)) { HDprintf("np_close() failed\n"); TEST_ERROR; } } + HDfree(s); + HDfree(config); + return EXIT_SUCCESS; error: @@ -2329,21 +2348,24 @@ error: { H5Pclose(fapl); H5Pclose(fcpl); - H5Fclose(s.file); + H5Fclose(s->file); } H5E_END_TRY; - if (s.use_np && np.fd_writer_to_reader >= 0) + if (s->use_np && np.fd_writer_to_reader >= 0) HDclose(np.fd_writer_to_reader); - if (s.use_np && np.fd_reader_to_writer >= 0) + if (s->use_np && np.fd_reader_to_writer >= 0) HDclose(np.fd_reader_to_writer); - if (s.use_np && !writer) { + if (s->use_np && !writer) { HDremove(np.fifo_writer_to_reader); HDremove(np.fifo_reader_to_writer); } + HDfree(s); + HDfree(config); + return EXIT_FAILURE; } |