From 0ca65235b7476e1a09f371afaa1407d127da29fe Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 3 May 2021 22:02:43 +0000 Subject: Committing clang-format changes --- src/H5FDros3.c | 5 +- src/H5trace.c | 2 +- test/genall5.c | 5 +- test/ntypes.c | 17 +- test/tvlstr.c | 17 +- test/vfd_swmr_attrdset_writer.c | 1059 +++++++++---------- test/vfd_swmr_common.c | 2 +- test/vfd_swmr_group_writer.c | 1965 ++++++++++++++++++----------------- test/vfd_swmr_zoo_writer.c | 325 +++--- tools/test/perform/pio_standalone.h | 28 +- 10 files changed, 1782 insertions(+), 1643 deletions(-) diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 5153c34..a241180 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -1539,7 +1539,7 @@ done: */ static herr_t H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf) + size_t size, void *buf) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; size_t filesize = 0; @@ -1562,8 +1562,7 @@ H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS filesize = H5FD_s3comms_s3r_get_filesize(file->s3r_handle); - if ((addr > filesize) || ((addr + size) > filesize)) -{ + if ((addr > filesize) || ((addr + size) > filesize)) { HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") } diff --git a/src/H5trace.c b/src/H5trace.c index 85195c5..6a570b6 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -25,7 +25,7 @@ /****************/ /* Module Setup */ /****************/ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ /***********/ /* Headers */ diff --git a/test/genall5.c b/test/genall5.c index 70190c6..2c9586b 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -2756,8 +2756,9 @@ out: if (!ok) { /* Currently not used: this step makes sure the operation doesn't take too long. * Any test that sets config.msgival or lastmsgtime to 0 will skip this step */ - if (strcmp(failure_mssg, last_failure_mssg) != 0 && ((config.msgival.tv_sec || config.msgival.tv_nsec)) - && (lastmsgtime->tv_sec || lastmsgtime->tv_nsec)) { + if (strcmp(failure_mssg, last_failure_mssg) != 0 && + ((config.msgival.tv_sec || config.msgival.tv_nsec)) && + (lastmsgtime->tv_sec || lastmsgtime->tv_nsec)) { if (below_speed_limit(lastmsgtime, &config.msgival)) { last_failure_mssg = failure_mssg; warnx("%s: %s", __func__, failure_mssg); diff --git a/test/ntypes.c b/test/ntypes.c index 0235c60..541670b 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -1993,16 +1993,13 @@ error: static herr_t test_vlstr_dtype(hid_t file) { - const char - * - wdata[SPACE1_DIM1] = - { - "Four score and seven years ago our forefathers brought forth on this continent a new " - "nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "Now we are engaged in a great civil war,", - "testing whether that nation or any nation so conceived and so dedicated can long " - "endure."}; /* Information + const char *wdata[SPACE1_DIM1] = { + "Four score and seven years ago our forefathers brought forth on this continent a new " + "nation,", + "conceived in liberty and dedicated to the proposition that all men are created equal.", + "Now we are engaged in a great civil war,", + "testing whether that nation or any nation so conceived and so dedicated can long " + "endure."}; /* Information to write */ diff --git a/test/tvlstr.c b/test/tvlstr.c index 091dd77..fb6a876 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -110,16 +110,13 @@ test_vlstr_free_custom(void *_mem, void *info) static void test_vlstrings_basic(void) { - const char - * - wdata[SPACE1_DIM1] = - { - "Four score and seven years ago our forefathers brought forth on this continent a new " - "nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "Now we are engaged in a great civil war,", - "testing whether that nation or any nation so conceived and so dedicated can long " - "endure."}; /* Information + const char *wdata[SPACE1_DIM1] = { + "Four score and seven years ago our forefathers brought forth on this continent a new " + "nation,", + "conceived in liberty and dedicated to the proposition that all men are created equal.", + "Now we are engaged in a great civil war,", + "testing whether that nation or any nation so conceived and so dedicated can long " + "endure."}; /* Information to write */ diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 7800727..dea5841 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -16,14 +16,14 @@ * Dataset types: * --dataset with compact layout * --dataset with contiguous layout - * --dataset with chunked layout: + * --dataset with chunked layout: * 1. single indexing type * 2. implicit indexing type * 3. fixed array indexing type * 4. extensible array indexing type * 5. version btree 2 indexing type * Attribute handling: - * -- Add attribute + * -- Add attribute * -- Delete attribute * -- Modify attribute * -- Add variable length attribute @@ -48,119 +48,106 @@ #ifndef H5_HAVE_WIN32_API -#define READER_WAIT_TICKS 4 +#define READER_WAIT_TICKS 4 /* Structure to hold info for options specified */ typedef struct { - hid_t file; /* File ID */ - hid_t filetype; /* ID for default datatype */ - hid_t one_by_one_sid; /* ID for default dataspace */ - char filename[PATH_MAX]; /* File name */ - char progname[PATH_MAX]; /* Program name */ - unsigned int update_interval; /* For -u option */ - unsigned int asteps; /* For -a option */ - unsigned int csteps; /* For -c option */ - unsigned int dattrs; /* For -d option */ - bool compact; /* For -p option */ - bool contig; /* For -g option */ - bool chunked; /* For -k option */ - bool vl_attr; /* For -v option */ - bool mod_attr; /* For -m option */ - bool use_np; /* For -N option */ - bool use_vfd_swmr; /* For -S option */ + hid_t file; /* File ID */ + hid_t filetype; /* ID for default datatype */ + hid_t one_by_one_sid; /* ID for default dataspace */ + char filename[PATH_MAX]; /* File name */ + char progname[PATH_MAX]; /* Program name */ + unsigned int update_interval; /* For -u option */ + unsigned int asteps; /* For -a option */ + unsigned int csteps; /* For -c option */ + unsigned int dattrs; /* For -d option */ + bool compact; /* For -p option */ + bool contig; /* For -g option */ + bool chunked; /* For -k option */ + bool vl_attr; /* For -v option */ + bool mod_attr; /* For -m option */ + bool use_np; /* For -N option */ + bool use_vfd_swmr; /* For -S option */ } state_t; /* Initializations for state_t */ -#define ALL_HID_INITIALIZER (state_t) { \ - .file = H5I_INVALID_HID \ - , .one_by_one_sid = H5I_INVALID_HID \ - , .filename = "" \ - , .filetype = H5T_NATIVE_UINT32 \ - , .asteps = 0 \ - , .csteps = 1 \ - , .dattrs = 0 \ - , .use_np = true \ - , .use_vfd_swmr = true \ - , .compact = false \ - , .contig = false \ - , .chunked = false \ - , .vl_attr = false \ - , .mod_attr = false \ - , .update_interval = READER_WAIT_TICKS } +#define ALL_HID_INITIALIZER \ + (state_t) \ + { \ + .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ + .filetype = H5T_NATIVE_UINT32, .asteps = 0, .csteps = 1, .dattrs = 0, .use_np = true, \ + .use_vfd_swmr = true, .compact = false, .contig = false, .chunked = false, .vl_attr = false, \ + .mod_attr = false, .update_interval = READER_WAIT_TICKS \ + } /* Structure to hold info for different dataset types */ typedef struct { - hid_t compact_did; /* ID for compact dataset */ - hid_t contig_did; /* ID for contiguous dataset */ - hid_t single_did; /* ID for chunked dataset: single index */ - hid_t implicit_did; /* ID for chunked dataset: implicit index */ - hid_t fa_did; /* ID for chunked dataset: fixed array index */ - hid_t ea_did; /* ID for chunked dataset: extensible array index */ - hid_t bt2_did; /* ID for chunked dataset: version 2 btree index */ - unsigned p_max_compact; /* Value of max_compact storage for -p */ - unsigned g_max_compact; /* Value of max_compact storage for -g */ - unsigned single_max_compact; /* Value of max_compact storage for -k: single index */ - unsigned implicit_max_compact; /* Value of max_compact storage for -k: implicit index */ - unsigned fa_max_compact; /* Value of max_compact storage for -k: fixed array index */ - unsigned ea_max_compact; /* Value of max_compact storage for -k: extensible array index */ - unsigned bt2_max_compact; /* Value of max_compact storage for -k: version 2 btree index */ - unsigned p_min_dense; /* Value of min_dense storage for -p */ - unsigned g_min_dense; /* Value of min_dense storage for -g */ - unsigned single_min_dense; /* Value of min_dense storage for -k: single index */ - unsigned implicit_min_dense; /* Value of min_dense storage for -k: implicit index */ - unsigned fa_min_dense; /* Value of min_dense storage for -k: fixed array index */ - unsigned ea_min_dense; /* Value of min_dense storage for -k: extensible array index */ - unsigned bt2_min_dense; /* Value of min_dense storage for -k: version 2 btree index */ + hid_t compact_did; /* ID for compact dataset */ + hid_t contig_did; /* ID for contiguous dataset */ + hid_t single_did; /* ID for chunked dataset: single index */ + hid_t implicit_did; /* ID for chunked dataset: implicit index */ + hid_t fa_did; /* ID for chunked dataset: fixed array index */ + hid_t ea_did; /* ID for chunked dataset: extensible array index */ + hid_t bt2_did; /* ID for chunked dataset: version 2 btree index */ + unsigned p_max_compact; /* Value of max_compact storage for -p */ + unsigned g_max_compact; /* Value of max_compact storage for -g */ + unsigned single_max_compact; /* Value of max_compact storage for -k: single index */ + unsigned implicit_max_compact; /* Value of max_compact storage for -k: implicit index */ + unsigned fa_max_compact; /* Value of max_compact storage for -k: fixed array index */ + unsigned ea_max_compact; /* Value of max_compact storage for -k: extensible array index */ + unsigned bt2_max_compact; /* Value of max_compact storage for -k: version 2 btree index */ + unsigned p_min_dense; /* Value of min_dense storage for -p */ + unsigned g_min_dense; /* Value of min_dense storage for -g */ + unsigned single_min_dense; /* Value of min_dense storage for -k: single index */ + unsigned implicit_min_dense; /* Value of min_dense storage for -k: implicit index */ + unsigned fa_min_dense; /* Value of min_dense storage for -k: fixed array index */ + unsigned ea_min_dense; /* Value of min_dense storage for -k: extensible array index */ + unsigned bt2_min_dense; /* Value of min_dense storage for -k: version 2 btree index */ } dsets_state_t; /* Initializations for dsets_state_t */ -#define DSETS_INITIALIZER (dsets_state_t) { \ - .compact_did = H5I_INVALID_HID \ - , .contig_did = H5I_INVALID_HID \ - , .single_did = H5I_INVALID_HID \ - , .implicit_did = H5I_INVALID_HID \ - , .fa_did = H5I_INVALID_HID \ - , .ea_did = H5I_INVALID_HID \ - , .bt2_did = H5I_INVALID_HID \ - , .p_max_compact = 0 \ - , .g_max_compact = 0 \ - , .single_max_compact = 0 \ - , .implicit_max_compact = 0 \ - , .fa_max_compact = 0 \ - , .ea_max_compact = 0 \ - , .bt2_max_compact = 0 } +#define DSETS_INITIALIZER \ + (dsets_state_t) \ + { \ + .compact_did = H5I_INVALID_HID, .contig_did = H5I_INVALID_HID, .single_did = H5I_INVALID_HID, \ + .implicit_did = H5I_INVALID_HID, .fa_did = H5I_INVALID_HID, .ea_did = H5I_INVALID_HID, \ + .bt2_did = H5I_INVALID_HID, .p_max_compact = 0, .g_max_compact = 0, .single_max_compact = 0, \ + .implicit_max_compact = 0, .fa_max_compact = 0, .ea_max_compact = 0, .bt2_max_compact = 0 \ + } /* Structure to hold info for named pipes */ typedef struct { - const char *fifo_writer_to_reader; /* Name of fifo for writer to reader */ - const char *fifo_reader_to_writer; /* Name of fifo for reader to writer */ - int fd_writer_to_reader; /* File ID for fifo from writer to reader */ - int fd_reader_to_writer; /* File ID for fifo from reader to writer */ - int notify; /* Value to notify between writer and reader */ - int verify; /* Value to verify between writer and reader */ + const char *fifo_writer_to_reader; /* Name of fifo for writer to reader */ + const char *fifo_reader_to_writer; /* Name of fifo for reader to writer */ + int fd_writer_to_reader; /* File ID for fifo from writer to reader */ + int fd_reader_to_writer; /* File ID for fifo from reader to writer */ + int notify; /* Value to notify between writer and reader */ + int verify; /* Value to verify between writer and reader */ } np_state_t; /* Initializations for np_state_t */ -#define NP_INITIALIZER (np_state_t) { \ - .fifo_writer_to_reader = "./fifo_attrdset_writer_to_reader" \ - , .fifo_reader_to_writer = "./fifo_attrdset_reader_to_writer" \ - , .fd_writer_to_reader = -1 \ - , .fd_reader_to_writer = -1 \ - , .notify = 0 \ - , .verify = 0 } +#define NP_INITIALIZER \ + (np_state_t) \ + { \ + .fifo_writer_to_reader = "./fifo_attrdset_writer_to_reader", \ + .fifo_reader_to_writer = "./fifo_attrdset_reader_to_writer", .fd_writer_to_reader = -1, \ + .fd_reader_to_writer = -1, .notify = 0, .verify = 0 \ + } static bool state_init(state_t *, int, char **); static bool np_init(np_state_t *np, bool writer); static bool np_close(np_state_t *np, bool writer); -static bool np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config); +static bool np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, + H5F_vfd_swmr_config_t *config); static bool np_reader(bool result, unsigned step, const state_t *s, np_state_t *np); static bool np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np); -static bool np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config); +static bool np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config); static bool create_dsets(const state_t *s, dsets_state_t *ds); static bool open_dsets(const state_t *s, dsets_state_t *ds); -static bool open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, unsigned *min_dense); +static bool open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, + unsigned *min_dense); static bool close_dsets(const dsets_state_t *ds); static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); @@ -169,59 +156,62 @@ static bool add_attr(const state_t *s, hid_t did, unsigned int which); static bool modify_attr(const state_t *s, hid_t did, unsigned int which); static bool delete_attr(hid_t did, unsigned int which); -static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); +static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, + unsigned which); static bool verify_attr_action(unsigned action, hid_t did, unsigned which); static bool verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which); static bool verify_delete_attr(hid_t did, char *attr_name); -static bool verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, unsigned min_dense, unsigned asteps); +static bool verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, + unsigned min_dense, unsigned asteps); static bool verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point); static const hid_t badhid = H5I_INVALID_HID; /* Names for datasets */ -#define DSET_COMPACT_NAME "compact_dset" -#define DSET_CONTIG_NAME "contig_dset" -#define DSET_SINGLE_NAME "chunked_single" -#define DSET_IMPLICIT_NAME "chunked_implicit" -#define DSET_FA_NAME "chunked_fa" -#define DSET_EA_NAME "chunked_ea" -#define DSET_BT2_NAME "chunked_bt2" +#define DSET_COMPACT_NAME "compact_dset" +#define DSET_CONTIG_NAME "contig_dset" +#define DSET_SINGLE_NAME "chunked_single" +#define DSET_IMPLICIT_NAME "chunked_implicit" +#define DSET_FA_NAME "chunked_fa" +#define DSET_EA_NAME "chunked_ea" +#define DSET_BT2_NAME "chunked_bt2" /* Action for attribute handling */ -#define ADD_ATTR 1 -#define MODIFY_ATTR 2 -#define DELETE_ATTR 3 +#define ADD_ATTR 1 +#define MODIFY_ATTR 2 +#define DELETE_ATTR 3 /* Test program usage info */ static void usage(const char *progname) { - fprintf(stderr, "usage: %s -a nattrs [-p] [-g] [-k] [-v] [-m]\n" - " [-d dattrs] [-u nticks] [-c csteps] [-S] [-N]\n" - "\n" - "-p: create a dataset with compact layout\n" - "-g: create a dataset with contiguous layout\n" - "-k: create datasets with chunked layout for the 5 indexing types\n" - "-m: modify attributes to all datasets after addition\n" - "-v: add variable length attribute to datasets\n" - " (default is H5T_NATIVE_UINT32)\n" - "-a nattrs: add `nattrs` attributes to all datasets\n" - "-d dattrs: delete `dattrs` attributes to all datasets after addition\n" - "-u nticks: `nticks` ticks for the reader to wait before verification\n" - " (default is 4)\n" - "-c csteps: `csteps` steps communication interval between reader and writer\n" - " (default is 1)\n" - "-S: do not use VFD SWMR\n" - "-N: do not use named pipes for test synchronization\n" - "-b: write data in big-endian byte order if no -v option\n" - " (default is H5T_NATIVE_UINT32)\n\n" - "Note:\n" - "1. Require to specify at least -p, -g or -k option\n" - "2. -c option cannot exceed -a option\n" - "3. -d option cannot exceed -a option\n" - "\n", - progname); - exit(EXIT_FAILURE); + fprintf(stderr, + "usage: %s -a nattrs [-p] [-g] [-k] [-v] [-m]\n" + " [-d dattrs] [-u nticks] [-c csteps] [-S] [-N]\n" + "\n" + "-p: create a dataset with compact layout\n" + "-g: create a dataset with contiguous layout\n" + "-k: create datasets with chunked layout for the 5 indexing types\n" + "-m: modify attributes to all datasets after addition\n" + "-v: add variable length attribute to datasets\n" + " (default is H5T_NATIVE_UINT32)\n" + "-a nattrs: add `nattrs` attributes to all datasets\n" + "-d dattrs: delete `dattrs` attributes to all datasets after addition\n" + "-u nticks: `nticks` ticks for the reader to wait before verification\n" + " (default is 4)\n" + "-c csteps: `csteps` steps communication interval between reader and writer\n" + " (default is 1)\n" + "-S: do not use VFD SWMR\n" + "-N: do not use named pipes for test synchronization\n" + "-b: write data in big-endian byte order if no -v option\n" + " (default is H5T_NATIVE_UINT32)\n\n" + "Note:\n" + "1. Require to specify at least -p, -g or -k option\n" + "2. -c option cannot exceed -a option\n" + "3. -d option cannot exceed -a option\n" + "\n", + progname); + exit(EXIT_FAILURE); } /* usage() */ /* @@ -231,10 +221,10 @@ static bool state_init(state_t *s, int argc, char **argv) { unsigned long tmp; - int ch; + int ch; const hsize_t dims = 1; - char tfile[PATH_MAX]; - char *end; + char tfile[PATH_MAX]; + char * end; *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); @@ -243,94 +233,96 @@ state_init(state_t *s, int argc, char **argv) while ((ch = getopt(argc, argv, "pgkvmbqSNa:d:u:c:")) != -1) { switch (ch) { - case 'p': - s->compact = true; - break; - - case 'g': - s->contig = true; - break; - - case 'k': - s->chunked = true; - break; - - case 'v': - s->vl_attr = true; - break; - - case 'm': - s->mod_attr = true; - break; - case 'b': - s->filetype = H5T_STD_U32BE; - break; - case 'q': - verbosity = 0; - break; - case 'S': - s->use_vfd_swmr = false; - break; - case 'N': - s->use_np = false; - break; - case 'a': - case 'd': - case 'u': - case 'c': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') { - printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); - TEST_ERROR; - } else if (errno != 0) { - printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); - TEST_ERROR; - } else if (tmp > UINT_MAX) { - printf("`-%c` argument `%lu` too large\n", ch, tmp); - TEST_ERROR; - } + case 'p': + s->compact = true; + break; + + case 'g': + s->contig = true; + break; + + case 'k': + s->chunked = true; + break; + + case 'v': + s->vl_attr = true; + break; + + case 'm': + s->mod_attr = true; + break; + case 'b': + s->filetype = H5T_STD_U32BE; + break; + case 'q': + verbosity = 0; + break; + case 'S': + s->use_vfd_swmr = false; + break; + case 'N': + s->use_np = false; + break; + case 'a': + case 'd': + case 'u': + case 'c': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') { + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + TEST_ERROR; + } + else if (errno != 0) { + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + TEST_ERROR; + } + else if (tmp > UINT_MAX) { + printf("`-%c` argument `%lu` too large\n", ch, tmp); + TEST_ERROR; + } - if (ch == 'a') - s->asteps = (unsigned)tmp; - else if (ch == 'd') - s->dattrs = (unsigned)tmp; - else if (ch == 'u') - s->update_interval = (unsigned)tmp; - else if (ch == 'c') - s->csteps = (unsigned)tmp; - break; + if (ch == 'a') + s->asteps = (unsigned)tmp; + else if (ch == 'd') + s->dattrs = (unsigned)tmp; + else if (ch == 'u') + s->update_interval = (unsigned)tmp; + else if (ch == 'c') + s->csteps = (unsigned)tmp; + break; - case '?': - default: - usage(s->progname); - break; + case '?': + default: + usage(s->progname); + break; } } argc -= optind; argv += optind; /* Require to specify at least -p, -g or -k option */ - if(!s->compact && !s->contig && !s->chunked) { + if (!s->compact && !s->contig && !s->chunked) { printf("Require to specify at least -p, -g or -k option\n"); usage(s->progname); goto error; } /* -c cannot be zero */ - if(!s->csteps) { + if (!s->csteps) { printf("communication interval cannot be zero\n"); TEST_ERROR; } /* -c and -a options */ - if(s->asteps && s->csteps > s->asteps) { + if (s->asteps && s->csteps > s->asteps) { printf("communication interval is out of bounds\n"); TEST_ERROR; } /* -d and -a */ - if(s->dattrs > s->asteps) { + if (s->dattrs > s->asteps) { printf("# of attributes to be deleted exceeds # of attributes created\n"); TEST_ERROR; } @@ -358,152 +350,152 @@ error: static bool create_dsets(const state_t *s, dsets_state_t *ds) { - hid_t dcpl = badhid; - hid_t dtid = badhid; - hid_t tmp_did = badhid; - hid_t cmpd_tid = badhid; + hid_t dcpl = badhid; + hid_t dtid = badhid; + hid_t tmp_did = badhid; + hid_t cmpd_tid = badhid; hid_t array_tid = badhid; - hid_t vl_tid = badhid; - hid_t sid = badhid; + hid_t vl_tid = badhid; + hid_t sid = badhid; *ds = DSETS_INITIALIZER; /* Dataset with compact layout, compound datatype */ - if(s->compact) { + if (s->compact) { const hsize_t dims = 2; - typedef struct { + typedef struct { int a; int b[2]; } cmpd; - cmpd wdata; /* Data for compact dataset */ + cmpd wdata; /* Data for compact dataset */ - wdata.a = 1; + wdata.a = 1; wdata.b[0] = 2; wdata.b[1] = 3; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; } - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) { + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) { printf("H5Pset_layout failed\n"); TEST_ERROR; } /* Create compound datatype */ - if((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd))) < 0) { + if ((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd))) < 0) { printf("H5Tcreate failed\n"); TEST_ERROR; } /* Create the array for the second element in the compound type */ - if((array_tid = H5Tarray_create2(H5T_NATIVE_INT, 1, &dims)) < 0) { + if ((array_tid = H5Tarray_create2(H5T_NATIVE_INT, 1, &dims)) < 0) { printf("H5Tarray_create2 failed\n"); TEST_ERROR; } /* First element in the compound type */ - if(H5Tinsert(cmpd_tid, "a", HOFFSET(cmpd, a), H5T_NATIVE_INT) < 0) { + if (H5Tinsert(cmpd_tid, "a", HOFFSET(cmpd, a), H5T_NATIVE_INT) < 0) { printf("H5Tinsert failed\n"); TEST_ERROR; } /* Second element in the compound type */ - if(H5Tinsert(cmpd_tid, "b", HOFFSET(cmpd, b), array_tid) < 0) { + if (H5Tinsert(cmpd_tid, "b", HOFFSET(cmpd, b), array_tid) < 0) { printf("H5Tinsert failed\n"); TEST_ERROR; } /* Create the compact dataset with compound datatype */ - if((ds->compact_did = H5Dcreate2(s->file, DSET_COMPACT_NAME, cmpd_tid, - s->one_by_one_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->compact_did = H5Dcreate2(s->file, DSET_COMPACT_NAME, cmpd_tid, s->one_by_one_sid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { printf("H5Dcreate2 compact dataset failed\n"); TEST_ERROR; } /* Write data to the dataset */ - if(H5Dwrite(ds->compact_did, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) { + if (H5Dwrite(ds->compact_did, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) { printf("H5Dwrite to compact dataset failed\n"); TEST_ERROR; } /* In order to trigger continuation block if -p is used alone by itself */ - if((tmp_did = H5Dcreate2(s->file, "JUNK_IGNORE", cmpd_tid, - s->one_by_one_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((tmp_did = H5Dcreate2(s->file, "JUNK_IGNORE", cmpd_tid, s->one_by_one_sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) { printf("H5Dcreate2 failed\n"); TEST_ERROR; } - if(H5Dclose(tmp_did) < 0) { + if (H5Dclose(tmp_did) < 0) { printf("H5Dclose failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } } /* Dataset with contiguous layout, early allocation, non-default attr phase change, named datatype */ - if(s->contig) { - int wdata1 = 9; /* Data for contiguous dataset */ + if (s->contig) { + int wdata1 = 9; /* Data for contiguous dataset */ unsigned def_max_compact = 0; - unsigned def_min_dense = 0; + unsigned def_min_dense = 0; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; } - if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) { + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) { printf("H5Pset_layout failed\n"); TEST_ERROR; } - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) { printf("H5Pset_alloc_time failed\n"); TEST_ERROR; } - if(H5Pget_attr_phase_change(dcpl, &def_max_compact, &def_min_dense) < 0) { + if (H5Pget_attr_phase_change(dcpl, &def_max_compact, &def_min_dense) < 0) { printf("H5Pget_attr_phase_change failed\n"); TEST_ERROR; } - if(H5Pset_attr_phase_change(dcpl, def_max_compact+2, def_min_dense+2) < 0) { + if (H5Pset_attr_phase_change(dcpl, def_max_compact + 2, def_min_dense + 2) < 0) { printf("H5Pset_attr_phase_change failed\n"); TEST_ERROR; } /* Create the named datatype */ - if((dtid = H5Tcopy(H5T_NATIVE_INT)) < 0) { + if ((dtid = H5Tcopy(H5T_NATIVE_INT)) < 0) { printf("H5Tcopy failed\n"); TEST_ERROR; } - if(H5Tcommit2(s->file, "named_dtype", dtid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(s->file, "named_dtype", dtid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { printf("H5Tcommit2 failed\n"); TEST_ERROR; } - + /* Create the contiguous dataset with the named datatype */ - if((ds->contig_did = H5Dcreate2(s->file, DSET_CONTIG_NAME, dtid, - s->one_by_one_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->contig_did = H5Dcreate2(s->file, DSET_CONTIG_NAME, dtid, s->one_by_one_sid, H5P_DEFAULT, + dcpl, H5P_DEFAULT)) < 0) { printf("H5Dcreate2 contiguous dataset failed\n"); TEST_ERROR; } /* Write to the dataset */ - if(H5Dwrite(ds->contig_did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { + if (H5Dwrite(ds->contig_did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { printf("H5Dwrite to contiguous dataset failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } - if(H5Tclose(dtid) < 0) { + if (H5Tclose(dtid) < 0) { printf("H5Tclose failed\n"); TEST_ERROR; } @@ -511,29 +503,28 @@ create_dsets(const state_t *s, dsets_state_t *ds) /* Datasets with the 5 indexes: single, implicit, fa, ea, bt2 */ /* All with variable length datatype */ - if(s->chunked) { - + if (s->chunked) { + /* For index: single, implicit and fa */ - hsize_t dims1[1] = {5}; - hsize_t max_dims1[1] = {100}; + hsize_t dims1[1] = {5}; + hsize_t max_dims1[1] = {100}; hsize_t chunk_dims1[1] = {2}; /* The variable length data */ - const char *vdata[5] = {"one", "two", "three", "four", "five" }; - + const char *vdata[5] = {"one", "two", "three", "four", "five"}; + /* For index: ea and bt2 */ - hsize_t dims2[2] = {5, 5}; - hsize_t max_dims2[2] = {100, H5S_UNLIMITED}; - hsize_t chunk_dims2[2] = {2, 2}; - const char *vdata2[5][5] = { - { "one", "two", "three", "four", "five" }, - { "two", "three", "four", "five", "six" }, - { "three", "four", "five", "six", "seven" }, - { "four", "five", "six", "seven", "eight" }, - { "five", "six", "seven", "eight", "nine" } }; + hsize_t dims2[2] = {5, 5}; + hsize_t max_dims2[2] = {100, H5S_UNLIMITED}; + hsize_t chunk_dims2[2] = {2, 2}; + const char *vdata2[5][5] = {{"one", "two", "three", "four", "five"}, + {"two", "three", "four", "five", "six"}, + {"three", "four", "five", "six", "seven"}, + {"four", "five", "six", "seven", "eight"}, + {"five", "six", "seven", "eight", "nine"}}; /* Create variable length datatype */ - if((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { + if ((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { printf("H5Tcopy failed\n"); TEST_ERROR; } @@ -543,36 +534,36 @@ create_dsets(const state_t *s, dsets_state_t *ds) TEST_ERROR; } - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; } - if(H5Pset_layout(dcpl, H5D_CHUNKED) < 0) { + if (H5Pset_layout(dcpl, H5D_CHUNKED) < 0) { printf("H5Pset_layout failed\n"); TEST_ERROR; } - if(H5Pset_chunk(dcpl, 1, dims1) < 0) { + if (H5Pset_chunk(dcpl, 1, dims1) < 0) { printf("H5Pset_chunk failed\n"); TEST_ERROR; } - + /* Create 1-D chunked dataset with single index */ /* Chunked, dims=max_dims=chunk_dims */ - if((sid = H5Screate_simple(1, dims1, dims1)) < 0) { + if ((sid = H5Screate_simple(1, dims1, dims1)) < 0) { printf("H5Screate_simple failed\n"); TEST_ERROR; } - if((ds->single_did = H5Dcreate2(s->file, DSET_SINGLE_NAME, vl_tid, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->single_did = + H5Dcreate2(s->file, DSET_SINGLE_NAME, vl_tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { printf("H5Dcreate2 chunked dataset: single index failed\n"); TEST_ERROR; } - if(H5Dwrite(ds->single_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { + if (H5Dwrite(ds->single_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { printf("H5Dwrite to chunked dataset: single index failed\n"); TEST_ERROR; } @@ -580,33 +571,33 @@ create_dsets(const state_t *s, dsets_state_t *ds) /* Create 1-D chunked dataset with implicit index */ /* Chunked, dims=max_dims, early allocation */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) { printf("H5Pset_alloc_time\n"); TEST_ERROR; } - if(H5Pset_chunk(dcpl, 1, chunk_dims1) < 0) { + if (H5Pset_chunk(dcpl, 1, chunk_dims1) < 0) { printf("H5Pset_chunk failed\n"); TEST_ERROR; } - if((ds->implicit_did = H5Dcreate2(s->file, DSET_IMPLICIT_NAME, vl_tid, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->implicit_did = + H5Dcreate2(s->file, DSET_IMPLICIT_NAME, vl_tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { printf("H5Dcreate2 chunked dataset: implicit index failed\n"); TEST_ERROR; } - if(H5Dwrite(ds->implicit_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { + if (H5Dwrite(ds->implicit_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { printf("H5Dwrite to chunked dataset: implicit index failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { printf("H5Sclose failed\n"); TEST_ERROR; } @@ -614,38 +605,38 @@ create_dsets(const state_t *s, dsets_state_t *ds) /* Create 1-D chunked dataset with fixed array index */ /* Chunked, fixed max_dims */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; } - if(H5Pset_chunk(dcpl, 1, chunk_dims1) < 0) { + if (H5Pset_chunk(dcpl, 1, chunk_dims1) < 0) { printf("H5Pset_chunk failed\n"); TEST_ERROR; } - if((sid = H5Screate_simple(1, dims1, max_dims1)) < 0) { + if ((sid = H5Screate_simple(1, dims1, max_dims1)) < 0) { printf("H5Screate_simple failed\n"); TEST_ERROR; } - if((ds->fa_did = H5Dcreate2(s->file, DSET_FA_NAME, vl_tid, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->fa_did = H5Dcreate2(s->file, DSET_FA_NAME, vl_tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { printf("H5Dcreaet2 chunked dataset: fa index failed\n"); TEST_ERROR; } - if(H5Dwrite(ds->fa_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { + if (H5Dwrite(ds->fa_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata) < 0) { printf("H5Dwrite to chunked dataset: fa index failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { printf("H5Sclose failed\n"); TEST_ERROR; } @@ -653,64 +644,63 @@ create_dsets(const state_t *s, dsets_state_t *ds) /* Create 2-D chunked dataset with extensible array index */ /* Chunked, 1 unlimited max_dims */ - if((sid = H5Screate_simple(2, dims2, max_dims2)) < 0) { + if ((sid = H5Screate_simple(2, dims2, max_dims2)) < 0) { printf("H5Screate_simple failed\n"); TEST_ERROR; } - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; } - if(H5Pset_chunk(dcpl, 2, chunk_dims2) < 0) { + if (H5Pset_chunk(dcpl, 2, chunk_dims2) < 0) { printf("H5Pset_chunk failed\n"); TEST_ERROR; } - if((ds->ea_did = H5Dcreate2(s->file, DSET_EA_NAME, vl_tid, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->ea_did = H5Dcreate2(s->file, DSET_EA_NAME, vl_tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { printf("H5Dcreate2 chunked dataset: ea index failed\n"); TEST_ERROR; } - if(H5Dwrite(ds->ea_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata2) < 0) { + if (H5Dwrite(ds->ea_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata2) < 0) { printf("H5Dwrite to chunked dataset: ea index failed\n"); TEST_ERROR; } - /* Create 2-D chunked dataset with bt2 index */ /* Chunked, 2 unlimited max_dims */ max_dims2[0] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims2)) < 0) { + if ((sid = H5Screate_simple(2, dims2, max_dims2)) < 0) { printf("H5Screate_simple failed\n"); TEST_ERROR; } - if((ds->bt2_did = H5Dcreate2(s->file, DSET_BT2_NAME, vl_tid, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((ds->bt2_did = H5Dcreate2(s->file, DSET_BT2_NAME, vl_tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { printf("H5Dcreate2 chunked dataset: bt2 index failed\n"); TEST_ERROR; } - if(H5Dwrite(ds->bt2_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata2) < 0) { + if (H5Dwrite(ds->bt2_did, vl_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vdata2) < 0) { printf("H5Dwrite to chunked dataset: bt2 index failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { printf("H5Sclose failed\n"); TEST_ERROR; } - if(H5Tclose(vl_tid) < 0) { + if (H5Tclose(vl_tid) < 0) { printf("H5Tclose failed\n"); TEST_ERROR; } @@ -719,7 +709,8 @@ create_dsets(const state_t *s, dsets_state_t *ds) return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Tclose(cmpd_tid); H5Tclose(array_tid); @@ -734,14 +725,14 @@ error: H5Dclose(ds->fa_did); H5Dclose(ds->ea_did); H5Dclose(ds->bt2_did); - } H5E_END_TRY; + } + H5E_END_TRY; return false; } /* create_dsets() */ - -/* +/* * Open the datasets as specified. */ static bool @@ -749,47 +740,44 @@ open_dsets(const state_t *s, dsets_state_t *ds) { *ds = DSETS_INITIALIZER; - if(s->compact) { - if(!open_dset_real(s->file, &ds->compact_did, DSET_COMPACT_NAME, - &ds->p_max_compact, &ds->p_min_dense)) { + if (s->compact) { + if (!open_dset_real(s->file, &ds->compact_did, DSET_COMPACT_NAME, &ds->p_max_compact, + &ds->p_min_dense)) { printf("open_dset_real() for compact dataset failed\n"); TEST_ERROR; } } - if(s->contig) { - if(!open_dset_real(s->file, &ds->contig_did, DSET_CONTIG_NAME, - &ds->g_max_compact, &ds->g_min_dense)) { + if (s->contig) { + if (!open_dset_real(s->file, &ds->contig_did, DSET_CONTIG_NAME, &ds->g_max_compact, + &ds->g_min_dense)) { printf("open_dset_real() for contiguous dataset failed\n"); TEST_ERROR; } } - if(s->chunked) { - if(!open_dset_real(s->file, &ds->single_did, DSET_SINGLE_NAME, - &ds->single_max_compact, &ds->single_min_dense)) { + if (s->chunked) { + if (!open_dset_real(s->file, &ds->single_did, DSET_SINGLE_NAME, &ds->single_max_compact, + &ds->single_min_dense)) { printf("open_dset_real() for chunked dataset: single failed\n"); TEST_ERROR; } - if(!open_dset_real(s->file, &ds->implicit_did, DSET_IMPLICIT_NAME, - &ds->implicit_max_compact, &ds->implicit_min_dense)) { + if (!open_dset_real(s->file, &ds->implicit_did, DSET_IMPLICIT_NAME, &ds->implicit_max_compact, + &ds->implicit_min_dense)) { printf("open_dset_real() for chunked dataset: implicit failed\n"); TEST_ERROR; } - if(!open_dset_real(s->file, &ds->fa_did, DSET_FA_NAME, - &ds->fa_max_compact, &ds->fa_min_dense)) { + if (!open_dset_real(s->file, &ds->fa_did, DSET_FA_NAME, &ds->fa_max_compact, &ds->fa_min_dense)) { printf("open_dset_real() for chunked dataset: fa failed\n"); TEST_ERROR; } - if(!open_dset_real(s->file, &ds->ea_did, DSET_FA_NAME, - &ds->ea_max_compact, &ds->ea_min_dense)) { + if (!open_dset_real(s->file, &ds->ea_did, DSET_FA_NAME, &ds->ea_max_compact, &ds->ea_min_dense)) { printf("open_dset_real() for chunked dataset: ea failed\n"); TEST_ERROR; } - if(!open_dset_real(s->file, &ds->bt2_did, DSET_BT2_NAME, - &ds->bt2_max_compact, &ds->bt2_min_dense)) { + if (!open_dset_real(s->file, &ds->bt2_did, DSET_BT2_NAME, &ds->bt2_max_compact, &ds->bt2_min_dense)) { printf("open_dset_real() for chunked dataset: bt2 failed\n"); TEST_ERROR; } @@ -811,22 +799,22 @@ open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, u { hid_t dcpl = badhid; - if((*did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) { + if ((*did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) { printf("H5Dopen dataset failed\n"); TEST_ERROR; } - if((dcpl = H5Dget_create_plist(*did)) < 0) { + if ((dcpl = H5Dget_create_plist(*did)) < 0) { printf("H5Dget_create_plist failed\n"); TEST_ERROR; } - if(H5Pget_attr_phase_change(dcpl, max_compact, min_dense) < 0) { + if (H5Pget_attr_phase_change(dcpl, max_compact, min_dense) < 0) { printf("H5Dget_attr_phase_change failed\n"); TEST_ERROR; } - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; } @@ -834,10 +822,12 @@ open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, u return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(*did); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return false; } /* open_dset_real() */ @@ -848,37 +838,37 @@ error: static bool close_dsets(const dsets_state_t *ds) { - if(ds->compact_did != badhid && H5Dclose(ds->compact_did) < 0) { + if (ds->compact_did != badhid && H5Dclose(ds->compact_did) < 0) { printf("H5Dclose compact dataset failed\n"); TEST_ERROR; } - if(ds->contig_did != badhid && H5Dclose(ds->contig_did) < 0) { + if (ds->contig_did != badhid && H5Dclose(ds->contig_did) < 0) { printf("H5Dclose contig dataset failed\n"); TEST_ERROR; } - if(ds->single_did != badhid && H5Dclose(ds->single_did) < 0) { + if (ds->single_did != badhid && H5Dclose(ds->single_did) < 0) { printf("H5Dclose chunked dataset: single index failed\n"); TEST_ERROR; } - if(ds->implicit_did != badhid && H5Dclose(ds->implicit_did) < 0) { + if (ds->implicit_did != badhid && H5Dclose(ds->implicit_did) < 0) { printf("H5Dclose chunked dataset: implicit index failed\n"); TEST_ERROR; } - if(ds->fa_did >= 0 && H5Dclose(ds->fa_did) < 0) { + if (ds->fa_did >= 0 && H5Dclose(ds->fa_did) < 0) { printf("H5Dclose chunked dataset: fa index failed\n"); TEST_ERROR; } - if(ds->ea_did >= 0 && H5Dclose(ds->ea_did) < 0) { + if (ds->ea_did >= 0 && H5Dclose(ds->ea_did) < 0) { printf("H5Dclose chunked dataset: ea index failed\n"); TEST_ERROR; } - if(ds->bt2_did >= 0 && H5Dclose(ds->bt2_did) < 0) { + if (ds->bt2_did >= 0 && H5Dclose(ds->bt2_did) < 0) { printf("H5Dclose chunked dataset: bt2 index failed\n"); TEST_ERROR; } @@ -886,7 +876,8 @@ close_dsets(const dsets_state_t *ds) return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(ds->compact_did); H5Dclose(ds->contig_did); H5Dclose(ds->single_did); @@ -894,7 +885,8 @@ error: H5Dclose(ds->fa_did); H5Dclose(ds->ea_did); H5Dclose(ds->bt2_did); - } H5E_END_TRY; + } + H5E_END_TRY; return false; } /* close_dsets() */ @@ -909,54 +901,54 @@ error: * MODIFY_ATTR : -m option * DELETE_ATTR : -d option */ -static bool +static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) { - int nerrors = 0; - bool ret = true; + int nerrors = 0; + bool ret = true; if (s->compact) { HDassert(ds->compact_did != badhid); dbgf(2, "to compact dataset\n"); - if(!attr_action(action, s, ds->compact_did, which)) + if (!attr_action(action, s, ds->compact_did, which)) ++nerrors; } if (s->contig) { HDassert(ds->contig_did != badhid); dbgf(2, "to contiguous dataset\n"); - if(!attr_action(action, s, ds->contig_did, which)) + if (!attr_action(action, s, ds->contig_did, which)) ++nerrors; } if (s->chunked) { HDassert(ds->single_did != badhid); dbgf(2, "to chunked dataset: single index\n"); - if(!attr_action(action, s, ds->single_did, which)) + if (!attr_action(action, s, ds->single_did, which)) ++nerrors; HDassert(ds->implicit_did != badhid); dbgf(2, "to chunked dataset: implicit index\n"); - if(!attr_action(action, s, ds->implicit_did, which)) + if (!attr_action(action, s, ds->implicit_did, which)) ++nerrors; HDassert(ds->fa_did != badhid); dbgf(2, "to chunked dataset: fixed array index\n"); - if(!attr_action(action, s, ds->fa_did, which)) + if (!attr_action(action, s, ds->fa_did, which)) ++nerrors; HDassert(ds->ea_did != badhid); dbgf(2, "to chunked dataset: extensible array index\n"); - if(!attr_action(action, s, ds->ea_did, which)) + if (!attr_action(action, s, ds->ea_did, which)) ++nerrors; HDassert(ds->bt2_did != badhid); dbgf(2, "to chunked dataset: version 2 btree index\n"); - if(!attr_action(action, s, ds->bt2_did, which)) + if (!attr_action(action, s, ds->bt2_did, which)) ++nerrors; } - if(nerrors) + if (nerrors) ret = false; return (ret); @@ -974,19 +966,19 @@ attr_action(unsigned action, const state_t *s, hid_t did, unsigned which) { bool ret; - switch(action) { - case ADD_ATTR: + switch (action) { + case ADD_ATTR: ret = add_attr(s, did, which); break; - case MODIFY_ATTR: + case MODIFY_ATTR: ret = modify_attr(s, did, which); break; - case DELETE_ATTR: + case DELETE_ATTR: ret = delete_attr(did, which); break; - + default: HDassert(0 && "Unknown action?!?"); } /* end switch */ @@ -995,36 +987,36 @@ attr_action(unsigned action, const state_t *s, hid_t did, unsigned which) } /* attr_action() */ -/* +/* * Add an attribute to the specified dataset. * The datatype can be: * variable length (-v) or - * H5T_NATIVE_UINT32 (-b) or + * H5T_NATIVE_UINT32 (-b) or * H5T_NATIVE_UINT32 (default) */ static bool add_attr(const state_t *s, hid_t did, unsigned int which) { - hid_t aid = badhid; - hid_t tid = badhid; + hid_t aid = badhid; + hid_t tid = badhid; hid_t vl_tid = badhid; - char name[sizeof("attr-9999999999")]; + char name[sizeof("attr-9999999999")]; char *val = NULL; esnprintf(name, sizeof(name), "attr-%u", which); - if(s->vl_attr) { - if((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { + if (s->vl_attr) { + if ((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { printf("H5Tcopy failed\n"); TEST_ERROR; } - if(H5Tset_size(vl_tid, H5T_VARIABLE) < 0) { + if (H5Tset_size(vl_tid, H5T_VARIABLE) < 0) { printf("H5Tset_size failed\n"); TEST_ERROR; } - if((val = HDmalloc(sizeof("9999999999"))) == NULL) { + if ((val = HDmalloc(sizeof("9999999999"))) == NULL) { printf("H5Dmalloc failed\n"); TEST_ERROR; } @@ -1032,18 +1024,18 @@ add_attr(const state_t *s, hid_t did, unsigned int which) HDsprintf(val, "%u", which); tid = vl_tid; - } else + } + else tid = s->filetype; /* Attach the attribute to the dataset */ - if ((aid = H5Acreate2(did, name, tid, s->one_by_one_sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { + if ((aid = H5Acreate2(did, name, tid, s->one_by_one_sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { printf("H5Acreate2 failed\n"); TEST_ERROR; } /* Write to the attribure */ - if (H5Awrite(aid, tid, s->vl_attr?&val:(const void *)&which) < 0) { + if (H5Awrite(aid, tid, s->vl_attr ? &val : (const void *)&which) < 0) { printf("H5Awrite failed\n"); TEST_ERROR; } @@ -1054,22 +1046,26 @@ add_attr(const state_t *s, hid_t did, unsigned int which) TEST_ERROR; } - if(vl_tid >= 0 && H5Tclose(vl_tid) < 0) { + if (vl_tid >= 0 && H5Tclose(vl_tid) < 0) { printf("H5Tclose failed\n"); TEST_ERROR; } - if(val) HDfree(val); + if (val) + HDfree(val); return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(vl_tid); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(val) HDfree(val); + if (val) + HDfree(val); return false; @@ -1081,27 +1077,27 @@ error: static bool modify_attr(const state_t *s, hid_t did, unsigned int which) { - hid_t aid = badhid; - hid_t tid = badhid; - hid_t vl_tid = badhid; - char name[sizeof("attr-9999999999")]; - char *val = NULL; + hid_t aid = badhid; + hid_t tid = badhid; + hid_t vl_tid = badhid; + char name[sizeof("attr-9999999999")]; + char * val = NULL; unsigned tmp_val = 0; esnprintf(name, sizeof(name), "attr-%u", which); - if(s->vl_attr) { - if((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { + if (s->vl_attr) { + if ((vl_tid = H5Tcopy(H5T_C_S1)) < 0) { printf("H5Tcopy failed\n"); TEST_ERROR; } - if(H5Tset_size(vl_tid, H5T_VARIABLE) < 0) { + if (H5Tset_size(vl_tid, H5T_VARIABLE) < 0) { printf("H5Tset_size failed\n"); TEST_ERROR; } - if((val = HDmalloc(sizeof("9999999999"))) == NULL) { + if ((val = HDmalloc(sizeof("9999999999"))) == NULL) { printf("HDmalloc failed\n"); TEST_ERROR; } @@ -1109,8 +1105,9 @@ modify_attr(const state_t *s, hid_t did, unsigned int which) HDsprintf(val, "%u %c", which, 'M'); tid = vl_tid; - } else { - tid = s->filetype; + } + else { + tid = s->filetype; tmp_val = which + 1; } @@ -1121,7 +1118,7 @@ modify_attr(const state_t *s, hid_t did, unsigned int which) } /* Write to the attribure */ - if (H5Awrite(aid, tid, s->vl_attr?&val:(const void *)&tmp_val) < 0) { + if (H5Awrite(aid, tid, s->vl_attr ? &val : (const void *)&tmp_val) < 0) { printf("H5Awrite failed\n"); TEST_ERROR; } @@ -1132,21 +1129,25 @@ modify_attr(const state_t *s, hid_t did, unsigned int which) TEST_ERROR; } - if(vl_tid >= 0 && H5Tclose(vl_tid) < 0) { + if (vl_tid >= 0 && H5Tclose(vl_tid) < 0) { printf("H5Tclose failed\n"); TEST_ERROR; } - if(val) HDfree(val); + if (val) + HDfree(val); return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(vl_tid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(val) HDfree(val); + if (val) + HDfree(val); return false; } /* modify_attr() */ @@ -1174,7 +1175,7 @@ error: } /* delete_attr() */ -/* +/* * Verification by the reader */ @@ -1185,22 +1186,23 @@ error: * DELETE_ATTR : -d option * * Also verify continuation block and compact<->dense storage if: - * --[-c ] is 1 - * --not -m option + * --[-c ] is 1 + * --not -m option */ static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) { - int nerrors = 0; - bool ret = true; + int nerrors = 0; + bool ret = true; if (s->compact) { HDassert(ds->compact_did != badhid); dbgf(2, "Verifying attribute to compact dataset\n"); - if(!verify_attr_action(action, ds->compact_did, which)) + if (!verify_attr_action(action, ds->compact_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->compact_did, which, ds->p_max_compact, ds->p_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->compact_did, which, ds->p_max_compact, ds->p_min_dense, + s->asteps)) ++nerrors; } } @@ -1208,10 +1210,11 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t if (s->contig) { HDassert(ds->contig_did != badhid); dbgf(2, "Verifying attribute to contiguous dataset\n"); - if(!verify_attr_action(action, ds->contig_did, which)) + if (!verify_attr_action(action, ds->contig_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->contig_did, which, ds->g_max_compact, ds->g_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->contig_did, which, ds->g_max_compact, ds->g_min_dense, + s->asteps)) ++nerrors; } } @@ -1219,51 +1222,56 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t if (s->chunked) { HDassert(ds->single_did != badhid); dbgf(2, "Verifying attribute to chunked dataset: single indedx\n"); - if(!verify_attr_action(action, ds->single_did, which)) + if (!verify_attr_action(action, ds->single_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->single_did, which, ds->single_max_compact, ds->single_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->single_did, which, ds->single_max_compact, + ds->single_min_dense, s->asteps)) ++nerrors; } HDassert(ds->implicit_did != badhid); dbgf(2, "Verifying attribute to chunked dataset: implicit index\n"); - if(!verify_attr_action(action, ds->implicit_did, which)) + if (!verify_attr_action(action, ds->implicit_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->implicit_did, which, ds->implicit_max_compact, ds->implicit_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->implicit_did, which, ds->implicit_max_compact, + ds->implicit_min_dense, s->asteps)) ++nerrors; } HDassert(ds->fa_did != badhid); dbgf(2, "Verifying attribute to chunked dataset: fa index\n"); - if(!verify_attr_action(action, ds->fa_did, which)) + if (!verify_attr_action(action, ds->fa_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->fa_did, which, ds->fa_max_compact, ds->fa_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->fa_did, which, ds->fa_max_compact, ds->fa_min_dense, + s->asteps)) ++nerrors; } HDassert(ds->ea_did != badhid); dbgf(2, "Verifying attribute to chunked dataset: ea index\n"); - if(!verify_attr_action(action, ds->ea_did, which)) + if (!verify_attr_action(action, ds->ea_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->ea_did, which, ds->ea_max_compact, ds->ea_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->ea_did, which, ds->ea_max_compact, ds->ea_min_dense, + s->asteps)) ++nerrors; } HDassert(ds->bt2_did != badhid); dbgf(2, "Verifying attribute to chunked dataset: bt2 index\n"); - if(!verify_attr_action(action, ds->bt2_did, which)) + if (!verify_attr_action(action, ds->bt2_did, which)) ++nerrors; - if(s->csteps == 1 && (action != MODIFY_ATTR)) { - if(!verify_storage_cont(action, ds->bt2_did, which, ds->bt2_max_compact, ds->bt2_min_dense, s->asteps)) + if (s->csteps == 1 && (action != MODIFY_ATTR)) { + if (!verify_storage_cont(action, ds->bt2_did, which, ds->bt2_max_compact, ds->bt2_min_dense, + s->asteps)) ++nerrors; } } - if(nerrors) + if (nerrors) ret = false; return (ret); @@ -1281,19 +1289,19 @@ verify_attr_action(unsigned action, hid_t did, unsigned which) esnprintf(name, sizeof(name), "attr-%u", which); - switch(action) { - case ADD_ATTR: + switch (action) { + case ADD_ATTR: ret = verify_add_or_modify_attr(action, did, name, which); break; - case MODIFY_ATTR: + case MODIFY_ATTR: ret = verify_add_or_modify_attr(action, did, name, which); break; - case DELETE_ATTR: + case DELETE_ATTR: ret = verify_delete_attr(did, name); break; - + default: HDassert(0 && "Unknown action?!?"); } /* end switch */ @@ -1301,18 +1309,18 @@ verify_attr_action(unsigned action, hid_t did, unsigned which) return ret; } /* verify_attr_action() */ -/* +/* * Verify the attribute is added or modified */ static bool verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which) { unsigned int read_which; - char vl_which[sizeof("attr-9999999999")]; - char *read_vl_which = NULL; - bool is_vl = false; - hid_t aid, atid; - bool ret; + char vl_which[sizeof("attr-9999999999")]; + char * read_vl_which = NULL; + bool is_vl = false; + hid_t aid, atid; + bool ret; HDassert(did != badhid); HDassert(action == ADD_ATTR || action == MODIFY_ATTR); @@ -1322,24 +1330,24 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned TEST_ERROR; } - if((atid = H5Aget_type(aid)) < 0) { + if ((atid = H5Aget_type(aid)) < 0) { printf("H5Aget_type failed\n"); TEST_ERROR; } - if((is_vl = H5Tis_variable_str(atid))) { - if(action == ADD_ATTR) + if ((is_vl = H5Tis_variable_str(atid))) { + if (action == ADD_ATTR) HDsprintf(vl_which, "%u", which); else HDsprintf(vl_which, "%u %c", which, 'M'); - if((read_vl_which = HDmalloc(sizeof("9999999999"))) == NULL) { + if ((read_vl_which = HDmalloc(sizeof("9999999999"))) == NULL) { printf("HDmalloc failed\n"); TEST_ERROR; } } - if (H5Aread(aid, atid, is_vl? (void *)&read_vl_which : (void *)&read_which) < 0) { + if (H5Aread(aid, atid, is_vl ? (void *)&read_vl_which : (void *)&read_which) < 0) { printf("H5Aread failed\n"); TEST_ERROR; } @@ -1349,36 +1357,39 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned TEST_ERROR; } - if(H5Tclose(atid) < 0) { + if (H5Tclose(atid) < 0) { printf("H5Tclose failed\n"); TEST_ERROR; } - if(is_vl) { - if(!HDstrcmp(vl_which, read_vl_which)) + if (is_vl) { + if (!HDstrcmp(vl_which, read_vl_which)) ret = true; - } else + } + else ret = (read_which == which); - if(read_vl_which) + if (read_vl_which) HDfree(read_vl_which); return ret; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(atid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(read_vl_which) + if (read_vl_which) HDfree(read_vl_which); return false; } /* verify_add_or_modify_attr() */ -/* +/* * Verify the attribute does not exist. */ static bool @@ -1386,11 +1397,11 @@ verify_delete_attr(hid_t did, char *attr_name) { int ret; - if((ret = H5Aexists(did, attr_name)) < 0) { + if ((ret = H5Aexists(did, attr_name)) < 0) { printf("H5Aexists failed\n"); TEST_ERROR; - - } else if(!ret) /* attribute does not exist */ + } + else if (!ret) /* attribute does not exist */ ret = true; else /* attribute exist */ ret = false; @@ -1409,7 +1420,7 @@ error: * --`which` is 0: no continuation block * * For addition: - * For deletion but [-a ] is not yet to dense storage: + * For deletion but [-a ] is not yet to dense storage: * --`which` is at (max_compact - 1): compact storage, continuation block exists * --`which` is at max_compact: dense storage, no continuation block * For deletion: @@ -1417,14 +1428,15 @@ error: * --`which` is at (min_dense - 1): compact storage, continuation block exists */ static bool -verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, unsigned min_dense, unsigned asteps) +verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, unsigned min_dense, + unsigned asteps) { bool ret = true; HDassert(action == ADD_ATTR || action == DELETE_ATTR); /* Verify no cont */ - if (!which) + if (!which) ret = verify_storage_cont_real(did, which, max_compact); /* For addition: */ @@ -1432,31 +1444,31 @@ verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max else if (action == ADD_ATTR || (action == DELETE_ATTR && asteps <= max_compact)) { /* Verify compact storage & cont */ - if (which == (max_compact - 1)) + if (which == (max_compact - 1)) ret = verify_storage_cont_real(did, which, max_compact); /* Verify dense storage & no cont */ - else if (which == max_compact) + else if (which == max_compact) ret = verify_storage_cont_real(did, which, max_compact); - /* For deletion */ - } else if (action == DELETE_ATTR) { + /* For deletion */ + } + else if (action == DELETE_ATTR) { /* Verify compact storage & cont */ - if(which == (min_dense - 1)) + if (which == (min_dense - 1)) ret = verify_storage_cont_real(did, which, min_dense); /* Verify dense storage & no cont */ - else if(which == min_dense) + else if (which == min_dense) ret = verify_storage_cont_real(did, which, min_dense); - } return ret; } /* verify_storage_cont() */ -/* +/* * Verify the storage condition at the specific checkpoint */ static bool @@ -1465,25 +1477,24 @@ verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point) H5O_native_info_t ninfo; /* Get the object information */ - if(H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR|H5O_NATIVE_INFO_META_SIZE) < 0) { + if (H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) < 0) { printf("H5Oget_native_info failed\n"); TEST_ERROR; } - if(!which) { + if (!which) { dbgf(2, "Verifying no cont\n"); - return(ninfo.hdr.nchunks == 1); - - } else if(which < cut_point) { + return (ninfo.hdr.nchunks == 1); + } + else if (which < cut_point) { dbgf(2, "Verifying storage compact & cont\n"); - return(ninfo.meta_size.attr.index_size == 0 && - ninfo.meta_size.attr.heap_size == 0 && - ninfo.hdr.nchunks > 1); - } else { + return (ninfo.meta_size.attr.index_size == 0 && ninfo.meta_size.attr.heap_size == 0 && + ninfo.hdr.nchunks > 1); + } + else { dbgf(2, "Verifying storage dense & no cont\n"); - return(ninfo.meta_size.attr.index_size != 0 && - ninfo.meta_size.attr.heap_size != 0 && - ninfo.hdr.nchunks == 1); + return (ninfo.meta_size.attr.index_size != 0 && ninfo.meta_size.attr.heap_size != 0 && + ninfo.hdr.nchunks == 1); } error: @@ -1491,7 +1502,6 @@ error: } /* verify_storage_cont_real() */ - /* * Named pipes handling */ @@ -1504,7 +1514,7 @@ np_init(np_state_t *np, bool writer) { *np = NP_INITIALIZER; - /* + /* * Use two named pipes(FIFO) to coordinate the writer and reader for * two-way communication so that the two sides can move forward together. * One is for the writer to write to the reader. @@ -1513,13 +1523,13 @@ np_init(np_state_t *np, bool writer) if (writer) { /* If the named pipes are present at the start of the test, remove them */ if (HDaccess(np->fifo_writer_to_reader, F_OK) == 0) - if(HDremove(np->fifo_writer_to_reader) != 0) { + if (HDremove(np->fifo_writer_to_reader) != 0) { printf("HDremove fifo_writer_to_reader failed\n"); TEST_ERROR; } if (HDaccess(np->fifo_reader_to_writer, F_OK) == 0) - if(HDremove(np->fifo_reader_to_writer) != 0) { + if (HDremove(np->fifo_reader_to_writer) != 0) { printf("HDremove fifo_reader_to_writer failed\n"); TEST_ERROR; } @@ -1572,13 +1582,13 @@ np_close(np_state_t *np, bool writer) } /* Reader finishes last and deletes the named pipes */ - if(!writer) { - if(HDremove(np->fifo_writer_to_reader) != 0) { + if (!writer) { + if (HDremove(np->fifo_writer_to_reader) != 0) { printf("HDremove fifo_writer_to_reader failed\n"); TEST_ERROR; } - if(HDremove(np->fifo_reader_to_writer) != 0) { + if (HDremove(np->fifo_reader_to_writer) != 0) { printf("HDremove fifo_reader_to_writer failed\n"); TEST_ERROR; } @@ -1593,14 +1603,15 @@ error: * Writer synchronization depending on the result from the attribute action performed. */ static bool -np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) +np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) { unsigned int i; /* The action fails */ - if(!result) { + if (!result) { printf("attribute action failed\n"); - H5_FAILED(); AT(); + H5_FAILED(); + AT(); /* At communication interval, notify the reader about the failure and quit */ if (step % s->csteps == 0) { @@ -1608,8 +1619,9 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)); goto error; } - /* The action succeeds */ - } else { + /* The action succeeds */ + } + else { /* At communication interval, notify the reader and wait for its response */ if (step % s->csteps == 0) { /* Bump up the value of notify to tell the reader to start reading */ @@ -1621,15 +1633,17 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd /* During the wait, writer makes repeated HDF5 API calls * to trigger EOT at approximately the correct time */ - for(i = 0; i < config->max_lag + 1; i++) { + for (i = 0; i < config->max_lag + 1; i++) { decisleep(config->tick_len); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aexists(s->file, "nonexistent"); - } H5E_END_TRY; + } + H5E_END_TRY; } /* Handshake between writer and reader */ - if(!np_confirm_verify_notify(np->fd_reader_to_writer, step, s, np)) { + if (!np_confirm_verify_notify(np->fd_reader_to_writer, step, s, np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1650,9 +1664,10 @@ static bool np_reader(bool result, unsigned step, const state_t *s, np_state_t *np) { /* The verification fails */ - if(!result) { + if (!result) { printf("verify action failed\n"); - H5_FAILED(); AT(); + H5_FAILED(); + AT(); /* At communication interval, tell the writer about the failure and exit */ if (step % s->csteps == 0) { @@ -1660,8 +1675,9 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np) HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)); goto error; } - /* The verification succeeds */ - } else { + /* The verification succeeds */ + } + else { if (step % s->csteps == 0) { /* Send back the same notify value for acknowledgement: * --inform the writer to move to the next step */ @@ -1714,9 +1730,9 @@ error: * next verification phase. */ static bool -np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) +np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) { - if(s->use_np) { + if (s->use_np) { if (!np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; @@ -1726,7 +1742,7 @@ np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config /* Wait for a few ticks for the update to happen */ decisleep(config->tick_len * s->update_interval); - if(s->use_np) { + if (s->use_np) { /* Send back the same notify value for acknowledgement: * --inform the writer to move to the next step */ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) { @@ -1745,29 +1761,27 @@ error: int main(int argc, char **argv) { - hid_t fapl, fcpl; - unsigned step; - bool writer; - state_t s; - const char *personality; + hid_t fapl, fcpl; + unsigned step; + bool writer; + state_t s; + const char * personality; H5F_vfd_swmr_config_t config; - np_state_t np; - dsets_state_t ds; - unsigned dd; - bool result; + np_state_t np; + dsets_state_t ds; + unsigned dd; + bool result; - if(!state_init(&s, argc, argv)) { + if (!state_init(&s, argc, argv)) { printf("state_init() failed\n"); TEST_ERROR; } personality = strstr(s.progname, "vfd_swmr_attrdset_"); - if (personality != NULL && - strcmp(personality, "vfd_swmr_attrdset_writer") == 0) + if (personality != NULL && strcmp(personality, "vfd_swmr_attrdset_writer") == 0) writer = true; - else if (personality != NULL && - strcmp(personality, "vfd_swmr_attrdset_reader") == 0) + else if (personality != NULL && strcmp(personality, "vfd_swmr_attrdset_reader") == 0) writer = false; else { printf("unknown personality, expected vfd_swmr_attrdset_{reader,writer}\n"); @@ -1778,7 +1792,7 @@ main(int argc, char **argv) init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./attrdset-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, &config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, &config)) < 0) { printf("vfd_swmr_create_fapl() failed\n"); TEST_ERROR; } @@ -1788,35 +1802,35 @@ main(int argc, char **argv) TEST_ERROR; } - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { printf("H5Pset_file_space_strategy failed\n"); TEST_ERROR; } 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) { printf("H5Fcreate failed\n"); TEST_ERROR; } - if(!create_dsets(&s, &ds)) { + if (!create_dsets(&s, &ds)) { printf("create_dsets() failed\n"); TEST_ERROR; } - - } else { - if ((s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl)) < 0) { + } + else { + if ((s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl)) < 0) { printf("H5Fopen failed\n"); TEST_ERROR; } - if(!open_dsets(&s, &ds)) { + if (!open_dsets(&s, &ds)) { printf("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)) { printf("np_init() failed\n"); TEST_ERROR; } @@ -1827,17 +1841,16 @@ main(int argc, char **argv) result = attr_dsets_action(ADD_ATTR, &s, &ds, step); - if(s.use_np && !np_writer(result, step, &s, &np, &config)) { + if (s.use_np && !np_writer(result, step, &s, &np, &config)) { printf("np_writer() for addition failed\n"); TEST_ERROR; } - } - if(s.mod_attr) { + if (s.mod_attr) { /* Need to sync up writer/reader before moving onto the next phase */ - if(s.use_np && !np_writer(true, 0, &s, &np, &config)) { + if (s.use_np && !np_writer(true, 0, &s, &np, &config)) { printf("np_writer() for modification failed\n"); TEST_ERROR; } @@ -1848,17 +1861,17 @@ main(int argc, char **argv) result = attr_dsets_action(MODIFY_ATTR, &s, &ds, step); - if(s.use_np && !np_writer(result, step, &s, &np, &config)) { + if (s.use_np && !np_writer(result, step, &s, &np, &config)) { printf("np_writer() for modification failed\n"); TEST_ERROR; } } } - if(s.dattrs) { + if (s.dattrs) { /* Need to sync up writer/reader before moving onto the next phase */ - if(s.use_np && !np_writer(true, 0, &s, &np, &config)) { + if (s.use_np && !np_writer(true, 0, &s, &np, &config)) { printf("np_writer() for deletion failed\n"); TEST_ERROR; } @@ -1869,21 +1882,20 @@ main(int argc, char **argv) result = attr_dsets_action(DELETE_ATTR, &s, &ds, step); - if(s.use_np && !np_writer(result, step, &s, &np, &config)) { + if (s.use_np && !np_writer(result, step, &s, &np, &config)) { printf("np_writer() for deletion failed\n"); TEST_ERROR; } } - } - - } else { + } + else { /* Start verifying addition */ for (step = 0; step < s.asteps; step++) { dbgf(2, "Verifying...attribute %d\n", step); - if(s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { + if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1893,15 +1905,15 @@ main(int argc, char **argv) result = verify_attr_dsets_action(ADD_ATTR, &s, &ds, step); - if(s.use_np && !np_reader(result, step, &s, &np)) { + if (s.use_np && !np_reader(result, step, &s, &np)) { printf("np_reader() for verifying addition failed\n"); TEST_ERROR; } } - if(s.mod_attr) { + if (s.mod_attr) { /* Need to sync up writer/reader before moving onto the next phase */ - if(!np_reader_no_verification(&s, &np, &config)) { + if (!np_reader_no_verification(&s, &np, &config)) { printf("np_reader_no_verification() for verifying modification failed\n"); TEST_ERROR; } @@ -1910,7 +1922,7 @@ main(int argc, char **argv) for (step = 0; step < s.asteps; step++) { dbgf(2, "Verifying...modify attribute %d\n", step); - if(s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { + if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1920,18 +1932,17 @@ main(int argc, char **argv) result = verify_attr_dsets_action(MODIFY_ATTR, &s, &ds, step); - if(s.use_np && !np_reader(result, step, &s, &np)) { + if (s.use_np && !np_reader(result, step, &s, &np)) { printf("np_reader() for verifying modification failed\n"); TEST_ERROR; } - } } - if(s.dattrs) { + if (s.dattrs) { /* Need to sync up writer/reader before moving onto the next phase */ - if(!np_reader_no_verification(&s, &np, &config)) { + if (!np_reader_no_verification(&s, &np, &config)) { printf("np_reader_no_verification() for verifying modification failed\n"); TEST_ERROR; } @@ -1940,7 +1951,7 @@ main(int argc, char **argv) for (dd = 0, step = s.asteps - 1; dd < s.dattrs; dd++, --step) { dbgf(2, "Verifying...delete attribute %d\n", step); - if(s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { + if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1950,17 +1961,15 @@ main(int argc, char **argv) result = verify_attr_dsets_action(DELETE_ATTR, &s, &ds, step); - if(s.use_np && !np_reader(result, step, &s, &np)) { + if (s.use_np && !np_reader(result, step, &s, &np)) { printf("np_reader() for verifying deletion failed\n"); TEST_ERROR; } - } - } } - if(!close_dsets(&ds)) { + if (!close_dsets(&ds)) { printf("close_dsets() failed\n"); TEST_ERROR; } @@ -1985,7 +1994,7 @@ main(int argc, char **argv) TEST_ERROR; } - if(s.use_np && !np_close(&np, writer)) { + if (s.use_np && !np_close(&np, writer)) { printf("np_close() failed\n"); TEST_ERROR; } @@ -1993,12 +2002,14 @@ main(int argc, char **argv) return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Fclose(s.file); H5Sclose(s.one_by_one_sid); - } H5E_END_TRY; + } + H5E_END_TRY; if (s.use_np && np.fd_writer_to_reader >= 0) HDclose(np.fd_writer_to_reader); @@ -2006,7 +2017,7 @@ error: 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); } diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index aed9cbe..d04b564 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -391,7 +391,7 @@ vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_p if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return H5I_INVALID_HID; } - else {/* Currently this is used only for old-styled group implementation tests.*/ + else { /* Currently this is used only for old-styled group implementation tests.*/ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) return H5I_INVALID_HID; } diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 7f083c8..b6a2b27 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -23,86 +23,79 @@ #ifndef H5_HAVE_WIN32_API -#define READER_WAIT_TICKS 3 -#define VS_ATTR_NAME_LEN 21 +#define READER_WAIT_TICKS 3 +#define VS_ATTR_NAME_LEN 21 typedef struct { - hid_t file, filetype, one_by_one_sid; - char filename[PATH_MAX]; - char progname[PATH_MAX]; - unsigned int asteps; - unsigned int csteps; - unsigned int nsteps; - unsigned int update_interval; - bool use_vfd_swmr; - bool old_style_grp; - bool use_named_pipes; - char at_pattern; - bool attr_test; - uint32_t max_lag; - uint32_t tick_len; - int np_fd_w_to_r; - int np_fd_r_to_w; - int np_notify; - int np_verify; + hid_t file, filetype, one_by_one_sid; + char filename[PATH_MAX]; + char progname[PATH_MAX]; + unsigned int asteps; + unsigned int csteps; + unsigned int nsteps; + unsigned int update_interval; + bool use_vfd_swmr; + bool old_style_grp; + bool use_named_pipes; + char at_pattern; + bool attr_test; + uint32_t max_lag; + uint32_t tick_len; + int np_fd_w_to_r; + int np_fd_r_to_w; + int np_notify; + int np_verify; } state_t; #define ALL_HID_INITIALIZER \ (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, .update_interval = READER_WAIT_TICKS, \ - .use_vfd_swmr = true, \ - .old_style_grp = false, \ - .use_named_pipes = true \ - , .at_pattern = ' ' \ - , .attr_test = false \ - , .tick_len = 4 \ - , .max_lag = 7 \ - , .np_fd_w_to_r = -1 \ - , .np_fd_r_to_w = -1 \ - , .np_notify = 0 \ - , .np_verify = 0 } - + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, \ + .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ + .use_named_pipes = true, .at_pattern = ' ', .attr_test = false, .tick_len = 4, .max_lag = 7, \ + .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, .np_notify = 0, .np_verify = 0 \ + } static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-G] [-a steps] [-b] [-c]\n" - " [-n iterations] [-N] [-q] [-u numb_ticks] [-A at_pattern]\n" - "\n" - "-S: do not use VFD SWMR\n" - "-G: old-style type of group\n" - "-a steps: `steps` between adding attributes\n" - "-b: write data in big-endian byte order\n" - "-c steps: `steps` between communication between the writer and reader\n" - "-n ngroups: the number of groups\n" - "-N: do not use named pipes, \n" - " mainly for running the writer and reader seperately\n" - "-u numb_ticks: `numb_ticks` for the reader to wait before verification\n" - "-A at_pattern: `at_pattern' for different attribute tests\n" - " The value of `at_pattern` is one of the following:\n" - " `compact` - Attributes added in compact storage\n" - " `dense` - An attribute added in dense storage\n" - " `compact-del` - Attributes added and then one\n" - " attribute deleted, in compact \n" - " `dense-del` - Attributes added until the storage\n" - " is dense then an attribute deleted\n" - " the storge still in dense\n" - " `compact-add-to-dense` - Attributes added first in compact\n" - " then in dense storage\n" - " `dense-del-to-compact` - Attributes added until the storage\n" - " is dense, then several attributes \n" - " deleted, the storage changed to\n" - " compact\n" - " `modify` - An attribute added then modified\n" - " `add-vstr` - A VL string attribute added\n" - " `remove-vstr` - A VL string attribute added then\n" - " deleted\n" - " `modify-vstr` - A VL string attribute added then \n" - " modified \n" - "-q: silence printouts, few messages\n" - "\n", + fprintf(stderr, + "usage: %s [-S] [-G] [-a steps] [-b] [-c]\n" + " [-n iterations] [-N] [-q] [-u numb_ticks] [-A at_pattern]\n" + "\n" + "-S: do not use VFD SWMR\n" + "-G: old-style type of group\n" + "-a steps: `steps` between adding attributes\n" + "-b: write data in big-endian byte order\n" + "-c steps: `steps` between communication between the writer and reader\n" + "-n ngroups: the number of groups\n" + "-N: do not use named pipes, \n" + " mainly for running the writer and reader seperately\n" + "-u numb_ticks: `numb_ticks` for the reader to wait before verification\n" + "-A at_pattern: `at_pattern' for different attribute tests\n" + " The value of `at_pattern` is one of the following:\n" + " `compact` - Attributes added in compact storage\n" + " `dense` - An attribute added in dense storage\n" + " `compact-del` - Attributes added and then one\n" + " attribute deleted, in compact \n" + " `dense-del` - Attributes added until the storage\n" + " is dense then an attribute deleted\n" + " the storge still in dense\n" + " `compact-add-to-dense` - Attributes added first in compact\n" + " then in dense storage\n" + " `dense-del-to-compact` - Attributes added until the storage\n" + " is dense, then several attributes \n" + " deleted, the storage changed to\n" + " compact\n" + " `modify` - An attribute added then modified\n" + " `add-vstr` - A VL string attribute added\n" + " `remove-vstr` - A VL string attribute added then\n" + " deleted\n" + " `modify-vstr` - A VL string attribute added then \n" + " modified \n" + "-q: silence printouts, few messages\n" + "\n", progname); exit(EXIT_FAILURE); } @@ -112,14 +105,15 @@ state_init(state_t *s, int argc, char **argv) { unsigned long tmp; int ch; - const hsize_t dims = 1; - char *tfile = NULL; + const hsize_t dims = 1; + char * tfile = NULL; char * end; *s = ALL_HID_INITIALIZER; if (H5_basename(argv[0], &tfile) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5_basename failed\n"); goto error; } @@ -142,17 +136,22 @@ state_init(state_t *s, int argc, char **argv) case 'n': case 'u': errno = 0; - tmp = HDstrtoul(optarg, &end, 0); + tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); goto error; - } else if (errno != 0) { - H5_FAILED(); AT(); + } + else if (errno != 0) { + H5_FAILED(); + AT(); printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); goto error; - } else if (tmp > UINT_MAX) { - H5_FAILED(); AT(); + } + else if (tmp > UINT_MAX) { + H5_FAILED(); + AT(); printf("`-%c` argument `%lu` too large\n", ch, tmp); goto error; } @@ -177,24 +176,25 @@ state_init(state_t *s, int argc, char **argv) s->at_pattern = 'c'; else if (HDstrcmp(optarg, "dense") == 0) s->at_pattern = 'd'; - else if (HDstrcmp(optarg, "compact-add-to-dense") == 0) + else if (HDstrcmp(optarg, "compact-add-to-dense") == 0) s->at_pattern = 't'; - else if (HDstrcmp(optarg, "compact-del") == 0) + else if (HDstrcmp(optarg, "compact-del") == 0) s->at_pattern = 'C'; - else if (HDstrcmp(optarg, "dense-del") == 0) + else if (HDstrcmp(optarg, "dense-del") == 0) s->at_pattern = 'D'; - else if (HDstrcmp(optarg, "dense-del-to-compact") == 0) + else if (HDstrcmp(optarg, "dense-del-to-compact") == 0) s->at_pattern = 'T'; - else if (HDstrcmp(optarg, "modify") == 0) + else if (HDstrcmp(optarg, "modify") == 0) s->at_pattern = 'M'; - else if (HDstrcmp(optarg,"add-vstr") ==0) + else if (HDstrcmp(optarg, "add-vstr") == 0) s->at_pattern = 'v'; - else if (HDstrcmp(optarg, "remove-vstr") == 0) + else if (HDstrcmp(optarg, "remove-vstr") == 0) s->at_pattern = 'r'; - else if (HDstrcmp(optarg, "modify-vstr") == 0) + else if (HDstrcmp(optarg, "modify-vstr") == 0) s->at_pattern = 'm'; else { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Invalid -A argument \"%s\"", optarg); goto error; } @@ -213,25 +213,29 @@ state_init(state_t *s, int argc, char **argv) /* space for attributes */ if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Screate_simple failed\n"); goto error; } - if( s->csteps < 1 || s->csteps > s->nsteps) { - H5_FAILED(); AT(); + if (s->csteps < 1 || s->csteps > s->nsteps) { + H5_FAILED(); + AT(); printf("communication interval is out of bounds\n"); goto error; } - if( s->asteps < 1 || s->asteps > s->nsteps) { - H5_FAILED(); AT(); + if (s->asteps < 1 || s->asteps > s->nsteps) { + H5_FAILED(); + AT(); printf("attribute interval is out of bounds\n"); goto error; } if (argc > 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unexpected command-line arguments\n"); goto error; } @@ -248,53 +252,61 @@ error: /* Named Pipe Subroutine: np_wr_send_receive * Description: - * The writer sends a message to the reader, + * The writer sends a message to the reader, * then waits for max_lag ticks, - * then checks the returned message from the reader. + * then checks the returned message from the reader. * Return: * True if succeed - * False if an error occurs in any step above. + * False if an error occurs in any step above. * An error is mostly caused by an unexpected - * notification number from the message sent + * notification number from the message sent * by the reader. - */ -static bool np_wr_send_receive(state_t *s) { + */ +static bool +np_wr_send_receive(state_t *s) +{ unsigned int i; /* Bump up the value of notify to notice the reader to start to read */ s->np_notify++; if (HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed\n"); goto error; } /* During the wait, writer makes repeated HDF5 API calls - * to trigger EOT at approximately the correct time */ - for(i = 0; i < s->max_lag + 1; i++) { + * to trigger EOT at approximately the correct time */ + for (i = 0; i < s->max_lag + 1; i++) { decisleep(s->tick_len); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aexists(s->file, "nonexistent"); - } H5E_END_TRY; + } + H5E_END_TRY; } /* Receive the same value from the reader and verify it before * going to the next step */ (s->np_verify)++; - if (HDread(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0){ - H5_FAILED(); AT(); + if (HDread(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { + H5_FAILED(); + AT(); printf("HDread failed\n"); goto error; } if (s->np_notify == -1) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("reader failed to verify group or attribute operation.\n"); goto error; } if (s->np_notify != s->np_verify) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); goto error; } @@ -303,22 +315,23 @@ static bool np_wr_send_receive(state_t *s) { error: return false; - } /* Named Pipe Subroutine: np_rd_receive * Description: - * The reader receives a message from the writer, + * The reader receives a message from the writer, * then checks if the notification number from * the writer is expected. * Return: * True if succeed - * False if an error occurs in any step above. + * False if an error occurs in any step above. * An error is mostly caused by an unexpected - * notification number from the message sent + * notification number from the message sent * by the writer. - */ -static bool np_rd_receive(state_t *s) { + */ +static bool +np_rd_receive(state_t *s) +{ /* The writer should have bumped up the value of notify. * Do the same with verify and confirm it */ @@ -326,23 +339,26 @@ static bool np_rd_receive(state_t *s) { /* Receive the notify that the writer bumped up the value */ if (HDread(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDread failed\n"); goto error; } if (s->np_notify == -1) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("writer failed to create group or carry out an attribute operation.\n"); goto error; } if (s->np_notify != s->np_verify) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); goto error; } - + return true; error: @@ -351,15 +367,18 @@ error: /* Named Pipe Subroutine: np_rd_send * Description: - * The reader sends an acknowledgement to the writer + * The reader sends an acknowledgement to the writer * Return: * True if succeed - * False if an error occurs in sending the message. - */ -static bool np_rd_send(state_t *s) { + * False if an error occurs in sending the message. + */ +static bool +np_rd_send(state_t *s) +{ if (HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed\n"); return false; } @@ -369,18 +388,20 @@ static bool np_rd_send(state_t *s) { /* Named Pipe Subroutine: np_send_error * Description: - * An error (notification number is 1) message is sent + * An error (notification number is 1) message is sent * either from the reader or the writer. * A boolean input parameter is used to choose - * either reader or writer. + * either reader or writer. * Return: * None */ -static void np_send_error(state_t *s,bool writer) { +static void +np_send_error(state_t *s, bool writer) +{ s->np_notify = -1; - if(writer) + if (writer) HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)); - else + else HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)); } @@ -391,13 +412,13 @@ static void np_send_error(state_t *s,bool writer) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t oid * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate + * The number of iterations for group creation, use to generate * newly created group name. The group name is "group-which". * * unsigned num_attrs @@ -414,27 +435,25 @@ static void np_send_error(state_t *s,bool writer) { * Failure: false * *------------------------------------------------------------------------- -*/ + */ -static bool -add_attr(state_t *s, - hid_t oid, - unsigned int which, - unsigned num_attrs, - const char*aname_fmt, - unsigned int g_which) { +static bool +add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const char *aname_fmt, + unsigned int g_which) +{ - char attrname[VS_ATTR_NAME_LEN]; + char attrname[VS_ATTR_NAME_LEN]; unsigned u; unsigned attr_value; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; - hid_t atype = s->filetype; - hid_t sid = s->one_by_one_sid; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + hid_t atype = s->filetype; + hid_t sid = s->one_by_one_sid; /* Need to obtain native datatype for H5Aread */ - if((amtype = H5Tget_native_type(atype,H5T_DIR_ASCEND)) <0) { - H5_FAILED(); AT(); + if ((amtype = H5Tget_native_type(atype, H5T_DIR_ASCEND)) < 0) { + H5_FAILED(); + AT(); printf("H5Tget_native_type failed\n"); goto error; } @@ -443,42 +462,45 @@ add_attr(state_t *s, /* Create attribute */ /* Construct attribute name like attr-0-0 */ - HDsprintf(attrname, aname_fmt, which,u); - if((aid = H5Acreate2(oid, attrname, atype, sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + HDsprintf(attrname, aname_fmt, which, u); + if ((aid = H5Acreate2(oid, attrname, atype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Acreate2 failed\n"); goto error; } - attr_value = u+which; + attr_value = u + which; #if 0 // Just for debugging to check if error handling works. attr_value = u+which+1; #endif - dbgf(1, "setting attribute %s on group %u to %u\n", attrname, g_which, u+which); + dbgf(1, "setting attribute %s on group %u to %u\n", attrname, g_which, u + which); /* Write data into the attribute */ if (H5Awrite(aid, amtype, &attr_value) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Awrite failed\n"); goto error; } /* Close attribute */ - if(H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + if (H5Aclose(aid) < 0) { + H5_FAILED(); + AT(); printf("H5Aclose failed\n"); goto error; } - /* Writer sends a message to reader: an attribute is successfully generated. + /* Writer sends a message to reader: an attribute is successfully generated. then wait for the reader to verify and send an acknowledgement message back.*/ if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: write attr - ready to send/receive message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + dbgf(2, "writer: write attr - ready to send/receive message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: write attr - verification failed.\n"); /* Note: This is (mostly) because the verification failure message * from the reader. So don't send the error message back to @@ -486,11 +508,12 @@ add_attr(state_t *s, goto error2; } } - + } /* end for */ - if(H5Tclose(amtype) < 0) { - H5_FAILED(); AT(); + if (H5Tclose(amtype) < 0) { + H5_FAILED(); + AT(); goto error; } @@ -498,17 +521,18 @@ add_attr(state_t *s, error: /* Writer needs to send an error message to the reader to stop the test*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); -error2: - H5E_BEGIN_TRY { +error2: + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(amtype); - } H5E_END_TRY; + } + H5E_END_TRY; return false; - } /*------------------------------------------------------------------------- @@ -518,14 +542,14 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -536,17 +560,17 @@ error2: * Note: This function is used for the "dense" storage test. * It is also used by the group-only test. *------------------------------------------------------------------------- -*/ + */ -static bool -add_default_group_attr(state_t *s, hid_t g, unsigned int which) { +static bool +add_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ - const char* aname_format ="attr-%u"; + const char *aname_format = "attr-%u"; /* Note: Since we only add one attribute, the parameter for - * the number of attributes is 1. */ - return add_attr(s,g,which,1,aname_format,which); - + * the number of attributes is 1. */ + return add_attr(s, g, which, 1, aname_format, which); } /*------------------------------------------------------------------------- @@ -556,14 +580,14 @@ add_default_group_attr(state_t *s, hid_t g, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -573,78 +597,85 @@ add_default_group_attr(state_t *s, hid_t g, unsigned int which) { * * Note: This is for the "vstr" test. *------------------------------------------------------------------------- -*/ - + */ -static bool -add_vlstr_attr(state_t*s, hid_t g, unsigned int which) { +static bool +add_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ - hid_t aid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; hid_t atype = H5I_INVALID_HID; - char name[VS_ATTR_NAME_LEN]; + char name[VS_ATTR_NAME_LEN]; char *astr_val = NULL; - hid_t sid = s->one_by_one_sid; + hid_t sid = s->one_by_one_sid; /* Allocate buffer for the VL string value */ astr_val = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val == NULL) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Allocate memory for VL string failed.\n"); goto error; } /* Assign the VL string value and the attribute name.. */ - HDsprintf(astr_val,"%u",which); + HDsprintf(astr_val, "%u", which); esnprintf(name, sizeof(name), "attr-%u", which); dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); /* Create a datatype to refer to. */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot create variable length datatype.\n"); goto error; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot set variable length datatype.\n"); goto error; } /* Generate the VL string attribute.*/ - if ((aid = H5Acreate2(g, name, atype, sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((aid = H5Acreate2(g, name, atype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Acreate2 failed.\n"); goto error; } if (H5Awrite(aid, atype, &astr_val) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Awrite failed.\n"); goto error; } if (H5Tclose(atype) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Tclose() failed\n"); goto error; } if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aclose() failed\n"); goto error; } HDfree(astr_val); - /* Writer sends a message to reader: a VL string attribute is successfully generated. + /* Writer sends a message to reader: a VL string attribute is successfully generated. then wait for the reader to verify and send an acknowledgement message back. */ if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: write attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + dbgf(2, "writer: write attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: write attr - verification failed.\n"); goto error2; } @@ -654,17 +685,19 @@ add_vlstr_attr(state_t*s, hid_t g, unsigned int which) { error: /* Writer needs to send an error message to the reader to stop the test*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); - H5E_BEGIN_TRY { + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(atype); - } H5E_END_TRY; + } + H5E_END_TRY; - if(astr_val) + if (astr_val) HDfree(astr_val); -error2: +error2: return false; } @@ -675,20 +708,20 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * - * hid_t obj_id + * hid_t obj_id * HDF5 object ID (in this file: means group ID) * * bool is_dense * if the deleted attribute is for checking the dense storage - * + * * bool is_vl * if the deleted attribute is a VL string * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute names * according to if this attribute is a VL string or for checking * the dense storage or the storage transition from dense to @@ -699,45 +732,48 @@ error2: * Failure: false * *------------------------------------------------------------------------- -*/ + */ -static bool -del_one_attr(state_t *s, hid_t obj_id,bool is_dense,bool is_vl,unsigned int which) { +static bool +del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl, unsigned int which) +{ char attrname[VS_ATTR_NAME_LEN]; /*attribute name template for the dense storage related deletion operation */ - const char* aname_format_d = "attr-d-%u-%u"; + const char *aname_format_d = "attr-d-%u-%u"; /*attribute name template used for general attribute deletion operation */ - const char* aname_format = "attr-%u-%u"; + const char *aname_format = "attr-%u-%u"; /*attribute name template used for VL string attribute deletion operation */ - const char* aname_format_vl="attr-%u"; - + const char *aname_format_vl = "attr-%u"; + dbgf(2, "writer: coming to delete the attribute.\n"); /* Construct the attribute name */ - if(is_dense == true) - HDsprintf(attrname, aname_format_d, which,0); - else if(is_vl == true) - HDsprintf(attrname, aname_format_vl, which,0); + if (is_dense == true) + HDsprintf(attrname, aname_format_d, which, 0); + else if (is_vl == true) + HDsprintf(attrname, aname_format_vl, which, 0); else - HDsprintf(attrname, aname_format, which,0); - + HDsprintf(attrname, aname_format, which, 0); + /* Delete the attribute */ - if(H5Adelete(obj_id, attrname) <0) { - H5_FAILED(); AT(); + if (H5Adelete(obj_id, attrname) < 0) { + H5_FAILED(); + AT(); printf("H5Adelete() failed\n"); goto error; } - /* Writer sends a message to reader: an attribute is successfully generated. + /* Writer sends a message to reader: an attribute is successfully generated. then wait for the reader to verify and send an acknowledgement message back. */ - if(s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: delete attr - verification failed.\n"); goto error2; } @@ -746,8 +782,8 @@ del_one_attr(state_t *s, hid_t obj_id,bool is_dense,bool is_vl,unsigned int whic return true; error: - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); error2: return false; @@ -756,19 +792,19 @@ error2: /*------------------------------------------------------------------------- * Function: add_del_vlstr_attr * - * Purpose: Add a variable length string attribute + * Purpose: Add a variable length string attribute * then delete this attribute in this a group. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -778,21 +814,20 @@ error2: * * Note: This is for the "remove-vstr" test. *------------------------------------------------------------------------- -*/ - + */ static bool -add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) { +add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ bool ret_value = false; /* Add a VL string attribute then delete it. */ - ret_value = add_vlstr_attr(s,g,which); - if(ret_value == true) - ret_value = del_one_attr(s,g,false,true,which); + ret_value = add_vlstr_attr(s, g, which); + if (ret_value == true) + ret_value = del_one_attr(s, g, false, true, which); return ret_value; - } /*------------------------------------------------------------------------- @@ -802,7 +837,7 @@ add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -811,7 +846,7 @@ add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) { * The attribute name template used to create unique attribute names. * * unsigned int which - * The number of iterations for group creation, use to generate + * The number of iterations for group creation, use to generate * newly created group name. The group name is "group-which". * * @@ -819,53 +854,59 @@ add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) { * Failure: false * *------------------------------------------------------------------------- -*/ - + */ -static bool -modify_attr(state_t *s, hid_t g, const char* aname_fmt,unsigned int which) { +static bool +modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which) +{ - char attrname[VS_ATTR_NAME_LEN]; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; + char attrname[VS_ATTR_NAME_LEN]; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; unsigned int modify_value; - HDsprintf(attrname,aname_fmt,which,0); - if((aid = H5Aopen(g,attrname,H5P_DEFAULT))<0) { - H5_FAILED(); AT(); + HDsprintf(attrname, aname_fmt, which, 0); + if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Aopen failed\n"); goto error; } - if((amtype = H5Tget_native_type(s->filetype,H5T_DIR_ASCEND))<0) { - H5_FAILED(); AT(); + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + H5_FAILED(); + AT(); printf("H5Tget_native_type failed\n"); goto error; } - + /* Make a large number to verify the change easily */ - modify_value = which+10000; + modify_value = which + 10000; - if (H5Awrite(aid,amtype,&modify_value) <0) { - H5_FAILED(); AT(); + if (H5Awrite(aid, amtype, &modify_value) < 0) { + H5_FAILED(); + AT(); printf("H5Awrite failed\n"); goto error; } if (H5Tclose(amtype) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); goto error; } if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); goto error; } - /* Writer sends a message to reader: an attribute is successfully modified. + /* Writer sends a message to reader: an attribute is successfully modified. then wait for the reader to verify and send an acknowledgement message back.*/ if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: modify attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + dbgf(2, "writer: modify attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: write attr - verification failed.\n"); /* Note: This is (mostly) because the verification failure message * from the reader. So don't send the error message back to @@ -877,16 +918,17 @@ modify_attr(state_t *s, hid_t g, const char* aname_fmt,unsigned int which) { return true; error: /* Writer needs to send an error message to the reader to stop the test*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); - H5E_BEGIN_TRY { + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; error2: return false; - } /*------------------------------------------------------------------------- @@ -896,13 +938,13 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate + * The number of iterations for group creation, use to generate * newly created group name. The group name is "group-which". * * @@ -910,47 +952,50 @@ error2: * Failure: false * *------------------------------------------------------------------------- -*/ - - + */ -static bool -modify_vlstr_attr(state_t*s,hid_t g, unsigned int which) { +static bool +modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ - hid_t aid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; hid_t atype = H5I_INVALID_HID; - char name[VS_ATTR_NAME_LEN]; + char name[VS_ATTR_NAME_LEN]; char *astr_val = NULL; astr_val = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val == NULL) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Allocate memory for VL string failed.\n"); goto error; } /* Change the VL string value and create the attribute name. */ - HDsprintf(astr_val,"%u%c",which,'A'); + HDsprintf(astr_val, "%u%c", which, 'A'); esnprintf(name, sizeof(name), "attr-%u", which); dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); /* Create a datatype to refer to. */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot create variable length datatype.\n"); goto error; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot set variable length datatype.\n"); goto error; } /* Open this attribute. */ - if ((aid = H5Aopen(g, name, H5P_DEFAULT))<0) { - H5_FAILED(); AT(); + if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Aopen failed.\n"); goto error; } @@ -958,31 +1003,35 @@ modify_vlstr_attr(state_t*s,hid_t g, unsigned int which) { dbgf(1, "The modified VL string value is %s \n", astr_val); if (H5Awrite(aid, atype, &astr_val) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Awrite failed.\n"); goto error; } if (H5Tclose(atype) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Tclose() failed\n"); goto error; } if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aclose() failed\n"); goto error; } HDfree(astr_val); - /* Writer sends a message to reader: a VL string attribute is successfully generated. + /* Writer sends a message to reader: a VL string attribute is successfully generated. then wait for the reader to verify and send an acknowledgement message back. */ if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: modify vl attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + dbgf(2, "writer: modify vl attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: write attr - verification failed.\n"); goto error2; } @@ -991,38 +1040,39 @@ modify_vlstr_attr(state_t*s,hid_t g, unsigned int which) { return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(atype); - } H5E_END_TRY; + } + H5E_END_TRY; - if(astr_val) + if (astr_val) HDfree(astr_val); - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); error2: return false; - } /*------------------------------------------------------------------------- * Function: add_modify_vlstr_attr * - * Purpose: Add a variable length string attribute + * Purpose: Add a variable length string attribute * then modify this attribute in this a group. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -1032,15 +1082,16 @@ error2: * * Note: This is for the "modify-vstr" test. *------------------------------------------------------------------------- -*/ + */ static bool -add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) { +add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ bool ret_value = false; - ret_value = add_vlstr_attr(s,g,which); - if (true == ret_value) - ret_value = modify_vlstr_attr(s,g,which); + ret_value = add_vlstr_attr(s, g, which); + if (true == ret_value) + ret_value = modify_vlstr_attr(s, g, which); return ret_value; } @@ -1049,22 +1100,22 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) { * Function: add_attrs_compact * * Purpose: Add some attributes to the group. - * the number of attributes should be the maximal number of + * the number of attributes should be the maximal number of * attributes that the compact storage can hold * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -1072,39 +1123,41 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) { * Return: Success: true * Failure: false * - * Note: This is for the "modify-vstr" test. + * Note: This is for the "modify-vstr" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ + */ -static bool -add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { +static bool +add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ - unsigned max_compact = 0; - unsigned min_dense = 0; - const char* aname_format="attr-%u-%u"; - - if(s->old_style_grp) + unsigned max_compact = 0; + unsigned min_dense = 0; + const char *aname_format = "attr-%u-%u"; + + if (s->old_style_grp) max_compact = 2; else { /* Obtain the maximal number of attributes to be stored in compact * storage and the minimal number of attributes to be stored in * dense storage. */ - if(H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense)<0) { - H5_FAILED(); AT(); + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + H5_FAILED(); + AT(); printf("H5Pget_attr_phase_change() failed\n"); goto error; } } - + /* Add max_compact attributes, these attributes are stored in * compact storage. */ - return add_attr(s,g,which,max_compact,aname_format,which); + return add_attr(s, g, which, max_compact, aname_format, which); error: - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); return false; } @@ -1112,43 +1165,45 @@ error: * Function: add_attrs_compact_dense * * Purpose: Add some attributes to the group. - * First, the number of attributes should be the maximal number + * First, the number of attributes should be the maximal number * of attributes that the compact storage can hold. * Then, add another atribute, the storage becomes dense. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * Return: Success: true * Failure: false * - * Note: This is for the "compact-to-dense" test. + * Note: This is for the "compact-to-dense" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ + */ -static bool -add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { +static bool +add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ - unsigned max_compact = 0; - unsigned min_dense = 0; - const char* aname_format="attr-d-%u-%u"; - bool ret_value = false; + unsigned max_compact = 0; + unsigned min_dense = 0; + const char *aname_format = "attr-d-%u-%u"; + bool ret_value = false; - if(H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); AT(); + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + H5_FAILED(); + AT(); printf("H5Pget_attr_phase_change failed\n"); goto error; } @@ -1157,14 +1212,14 @@ add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { ret_value = add_attrs_compact(s, g, gcpl, which); /* Add another attribute, the storage becomes dense. */ - if(ret_value == true) - ret_value = add_attr(s,g,which+max_compact,1,aname_format,which); + if (ret_value == true) + ret_value = add_attr(s, g, which + max_compact, 1, aname_format, which); return ret_value; error: - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); return false; } @@ -1178,70 +1233,70 @@ error: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * Return: Success: true * Failure: false * - * Note: This is an internal function used by the - * "dense-del-to-compact" test. + * Note: This is an internal function used by the + * "dense-del-to-compact" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ + */ static bool -del_attrs_compact_dense_compact(state_t *s, - hid_t obj_id, - hid_t gcpl, - unsigned int which) { - +del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned int which) +{ + unsigned max_compact = 0; - unsigned min_dense = 0; - unsigned u = 0; + unsigned min_dense = 0; + unsigned u = 0; - char attrname[VS_ATTR_NAME_LEN]; - const char* aname_format="attr-%u-%u"; - const char* adname_format="attr-d-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u-%u"; + const char *adname_format = "attr-d-%u-%u"; /* Obtain the maximal number of attributes to be stored in compact * storage and the minimal number of attributes to be stored in * dense storage. */ if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pget_attr_phase_change failed\n"); goto error; } - u= max_compact +1; - + u = max_compact + 1; /* delete a number of attributes so that the attribute storage just becomes dense.*/ - for(u--;u>=(min_dense-1);u--) { - HDsprintf(attrname, aname_format, which,max_compact-u); - if (H5Adelete(obj_id,attrname) < 0) { - H5_FAILED(); AT(); + for (u--; u >= (min_dense - 1); u--) { + HDsprintf(attrname, aname_format, which, max_compact - u); + if (H5Adelete(obj_id, attrname) < 0) { + H5_FAILED(); + AT(); printf("H5Adelete failed\n"); goto error; } /* For each attribute deletion, we want to ensure the verification - * from the reader. - * So writer sends a message to reader: an attribute is successfully deleted. + * from the reader. + * So writer sends a message to reader: an attribute is successfully deleted. then wait for reader to verify and send an acknowledgement message back. */ - if(s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: delete attr - verification failed.\n"); goto error2; } @@ -1250,23 +1305,25 @@ del_attrs_compact_dense_compact(state_t *s, /* The writer deletes another attribute, the storage is * still dense. However, the attribute to be deleted - * doesn't follow the previous for loop. It may be + * doesn't follow the previous for loop. It may be * in different location in the object header. Just add - * a litter variation to check if this operation is successful. + * a litter variation to check if this operation is successful. * The attribute name to be deleted is attr-max_compact+which-0 */ - - HDsprintf(attrname,adname_format,max_compact+which,0); - if (H5Adelete(obj_id,attrname) < 0) { - H5_FAILED(); AT(); - printf("H5Adelete failed\n"); - goto error; + + HDsprintf(attrname, adname_format, max_compact + which, 0); + if (H5Adelete(obj_id, attrname) < 0) { + H5_FAILED(); + AT(); + printf("H5Adelete failed\n"); + goto error; } /* Again we need to notify the reader via Named pipe. */ - if(s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: delete attr - verification failed.\n"); goto error2; } @@ -1284,9 +1341,9 @@ del_attrs_compact_dense_compact(state_t *s, return true; -error: - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); error2: return false; @@ -1296,151 +1353,147 @@ error2: * Function: add_del_attrs_compact * * Purpose: Add some attributes to the group and then delete one attribute. - * First, the number of attributes to be added should be the + * First, the number of attributes to be added should be the * maximal number of attributes that the compact storage can hold. * Then, delete one atribute, the storage is still compact. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * Return: Success: true * Failure: false * - * Note: This is for the "compact-del" test. + * Note: This is for the "compact-del" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ + */ -static bool -add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { +static bool +add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ bool ret_value = false; - ret_value = add_attrs_compact(s, g, gcpl, which); - if(ret_value == true) { + ret_value = add_attrs_compact(s, g, gcpl, which); + if (ret_value == true) { dbgf(2, "writer: before deleting the attribute.\n"); - ret_value = del_one_attr(s,g,false,false,which); + ret_value = del_one_attr(s, g, false, false, which); } return ret_value; - } /*------------------------------------------------------------------------- * Function: add_del_attrs_compact_dense * * Purpose: Add some attributes to the group and then delete one attribute. - * First, the number of attributes to be added exceeds + * First, the number of attributes to be added exceeds * the maximal number of attributes that the compact storage can hold. * The storage changes from compact to dense. * Then, delete one atribute, the storage is still dense. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * Return: Success: true * Failure: false * - * Note: This is for the "dense-del" test. + * Note: This is for the "dense-del" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ - + */ -static bool -add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { +static bool +add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ - bool ret_value = false; + bool ret_value = false; unsigned max_compact = 0; - unsigned min_dense = 0; + unsigned min_dense = 0; - if( H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); AT(); + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + H5_FAILED(); + AT(); printf("H5Pget_attr_phase_change failed\n"); goto error; } - ret_value = add_attrs_compact_dense(s,g,gcpl,which); - if(ret_value == true) - ret_value = del_one_attr(s,g,true,false,which+max_compact); + ret_value = add_attrs_compact_dense(s, g, gcpl, which); + if (ret_value == true) + ret_value = del_one_attr(s, g, true, false, which + max_compact); return ret_value; error: - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); return false; - } - /*------------------------------------------------------------------------- * Function: add_del_attrs_compact_dense_compact * * Purpose: Add attributes to the group and then delete some of them. - * First, the number of attributes to be added exceeds + * First, the number of attributes to be added exceeds * the maximal number of attributes that the compact storage can hold. * The storage changes from compact to dense. * Then, delete some attributes, the storage changes from - * dense to compact again. + * dense to compact again. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * Return: Success: true * Failure: false * - * Note: This is for the "dense-del-to-compact" test. + * Note: This is for the "dense-del-to-compact" test. * For attribute compact/dense storage, check the reference * manual of H5Pget_attr_phase_change. *------------------------------------------------------------------------- -*/ - + */ -static bool -add_del_attrs_compact_dense_compact(state_t *s, - hid_t g, - hid_t gcpl, - unsigned int which) { +static bool +add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ bool ret_value = false; - ret_value = add_attrs_compact_dense(s,g,gcpl,which); - if(ret_value == true) - ret_value = del_attrs_compact_dense_compact(s,g,gcpl,which); + ret_value = add_attrs_compact_dense(s, g, gcpl, which); + if (ret_value == true) + ret_value = del_attrs_compact_dense_compact(s, g, gcpl, which); return ret_value; } @@ -1452,14 +1505,14 @@ add_del_attrs_compact_dense_compact(state_t *s, * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * The group name is "group-which" and the attribute name * is "attr-which". * @@ -1469,20 +1522,19 @@ add_del_attrs_compact_dense_compact(state_t *s, * * Note: This function is used for the "modify" storage test. *------------------------------------------------------------------------- -*/ - + */ static bool -add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) { +add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ - bool ret_value = false; - const char* aname_format ="attr-%u"; - ret_value = add_default_group_attr(s,g,which); - if(ret_value == true) - ret_value = modify_attr(s,g,aname_format,which); + bool ret_value = false; + const char *aname_format = "attr-%u"; + ret_value = add_default_group_attr(s, g, which); + if (ret_value == true) + ret_value = modify_attr(s, g, aname_format, which); return ret_value; - -} +} /*------------------------------------------------------------------------- * Function: add_group_attribute @@ -1492,17 +1544,17 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl - * Object creation property list ID + * Object creation property list ID * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. + * The number of iterations for group creation, use to generate + * newly created group and attribute names. * * * Return: Success: true @@ -1510,13 +1562,13 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) { * * Note: This is called by the write_group() function. *------------------------------------------------------------------------- -*/ + */ static bool -add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { - bool ret_value = false; + bool ret_value = false; char test_pattern = s->at_pattern; switch (test_pattern) { @@ -1536,16 +1588,16 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) ret_value = add_del_attrs_compact_dense_compact(s, g, gcpl, which); break; case 'M': - ret_value = add_modify_default_group_attr(s, g, which); + ret_value = add_modify_default_group_attr(s, g, which); break; case 'v': - ret_value = add_vlstr_attr(s,g, which); + ret_value = add_vlstr_attr(s, g, which); break; case 'r': ret_value = add_del_vlstr_attr(s, g, which); break; case 'm': - ret_value = add_modify_vlstr_attr(s,g, which); + ret_value = add_modify_vlstr_attr(s, g, which); break; case 'd': case ' ': @@ -1554,7 +1606,6 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) break; } return ret_value; - } /*------------------------------------------------------------------------- @@ -1565,10 +1616,10 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -1576,104 +1627,112 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) * * Note: This is called by the main() function. *------------------------------------------------------------------------- -*/ + */ static bool write_group(state_t *s, unsigned int which) { - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - hid_t gcpl = H5I_INVALID_HID; - bool result = true; + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + bool result = true; H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } esnprintf(name, sizeof(name), "/group-%d", which); - if(s->old_style_grp) + if (s->old_style_grp) gcpl = H5P_DEFAULT; else { gcpl = H5Pcreate(H5P_GROUP_CREATE); - if(gcpl <0) { - H5_FAILED(); AT(); + if (gcpl < 0) { + H5_FAILED(); + AT(); printf("H5Pcreate failed\n"); goto error; } /* If we test the dense storage, change the attribute phase. */ - if(s->at_pattern =='d') { - if(H5Pset_attr_phase_change(gcpl, 0, 0) <0) { - H5_FAILED(); AT(); + if (s->at_pattern == 'd') { + if (H5Pset_attr_phase_change(gcpl, 0, 0) < 0) { + H5_FAILED(); + AT(); printf("H5Pset_attr_phase_change failed for the dense storage.\n"); goto error; } } } - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, - H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gcreate2 failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - - if(s->old_style_grp) { - if(group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); AT(); + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Old-styled group test: but the group is not in old-style. \n"); goto error; } - dbgf(2,"Writer: group is created with the old-style.\n"); + dbgf(2, "Writer: group is created with the old-style.\n"); } else { - if(group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); AT(); + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("The created group should NOT be in old-style . \n"); goto error; } - dbgf(2,"Writer: group is created with the new-style.\n"); - + dbgf(2, "Writer: group is created with the new-style.\n"); } /* If an attribute test is turned on and named pipes are used, * the writer should send and receive messages after the group creation. * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. + * group creation error. + * Writer sends a message to reader: an attribute is successfully generated. * then wait for the reader to verify and send an acknowledgement message back.*/ if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: ready to send the message: %d\n", s->np_notify+1); - if(np_wr_send_receive(s) == false) { - H5_FAILED(); AT(); + dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); /* Note: This is (mostly) because the verification failure message * from the reader. So don't send the error message back to * the reader. Just stop the test. */ goto error2; } } - + /* Then carry out the attribute operation. */ - if (s->asteps != 0 && which % s->asteps == 0) - result = add_group_attribute(s, g, gcpl,which); + if (s->asteps != 0 && which % s->asteps == 0) + result = add_group_attribute(s, g, gcpl, which); if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } - if(!s->old_style_grp && H5Pclose(gcpl) <0) { - H5_FAILED(); AT(); + if (!s->old_style_grp && H5Pclose(gcpl) < 0) { + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto error; } @@ -1682,19 +1741,20 @@ write_group(state_t *s, unsigned int which) error: /* Writer needs to send an error message to the reader to stop the test*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,true); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); -error2: +error2: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - if(!s->old_style_grp) + if (!s->old_style_grp) H5Pclose(gcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return false; - } /*------------------------------------------------------------------------- * Function: check_attr_storage_type @@ -1707,39 +1767,40 @@ error2: * bool is_compact * true if the attribute is stored in compact storage * false if the attribute is stored in dense storage - * + * * * Return: Success: true * Failure: false * *------------------------------------------------------------------------- -*/ + */ static bool -check_attr_storage_type(hid_t g, - bool is_compact) { +check_attr_storage_type(hid_t g, bool is_compact) +{ H5O_native_info_t ninfo; /* Get the object information */ - if(H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR|H5O_NATIVE_INFO_META_SIZE) < 0) { - H5_FAILED(); AT(); + if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) < 0) { + H5_FAILED(); + AT(); printf("H5Oget_native_info failed\n"); goto error; } - if(is_compact) { - if(ninfo.meta_size.attr.index_size != 0 || - ninfo.meta_size.attr.heap_size != 0) { - H5_FAILED(); AT(); + if (is_compact) { + if (ninfo.meta_size.attr.index_size != 0 || ninfo.meta_size.attr.heap_size != 0) { + H5_FAILED(); + AT(); printf("Should be in compact storage,but it is not.\n"); goto error; } } else { - if(ninfo.meta_size.attr.index_size == 0 || - ninfo.meta_size.attr.heap_size == 0) { - H5_FAILED(); AT(); + if (ninfo.meta_size.attr.index_size == 0 || ninfo.meta_size.attr.heap_size == 0) { + H5_FAILED(); + AT(); printf("Should be in dense storage,but it is not.\n"); goto error; } @@ -1749,10 +1810,8 @@ check_attr_storage_type(hid_t g, error: return false; - } - /*------------------------------------------------------------------------- * Function: vrfy_attr * @@ -1760,17 +1819,17 @@ error: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t oid * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate + * The number of iterations for group creation, use to generate * newly created group name. The group name is "group-which". * * const char*aname - * The attribute name + * The attribute name * * unsigned int g_which * This parameter is used to generate correct group name in a key @@ -1790,103 +1849,104 @@ error: * Failure: false * *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_attr(state_t *s, - hid_t g, - unsigned int which, - const char* aname, - unsigned int g_which, - bool check_storage, - bool is_compact) { +vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned int g_which, + bool check_storage, bool is_compact) +{ unsigned int read_which; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if receiving an error + * for a few ticks or stop the test if receiving an error * message. - */ - if(s->use_named_pipes && true == s->attr_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); /* Since receiving the error message from the writer, * just stop the test. */ goto error2; } decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n",s->np_notify); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); } /* Go ahead to read the attribute. */ - dbgf(1, "verifying attribute %s on group %u equals %u\n", aname, g_which, - which); + dbgf(1, "verifying attribute %s on group %u equals %u\n", aname, g_which, which); - if ((amtype = H5Tget_native_type(s->filetype,H5T_DIR_ASCEND)) <0) { - H5_FAILED(); AT(); + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + H5_FAILED(); + AT(); printf("H5Tget_native_type failed\n"); goto error; } if ((aid = H5Aopen(g, aname, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aopen failed\n"); goto error; } if (H5Aread(aid, amtype, &read_which) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aread failed\n"); goto error; } if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aclose failed\n"); goto error; } - if(read_which != which) { - H5_FAILED(); AT(); + if (read_which != which) { + H5_FAILED(); + AT(); dbgf(2, "reader: the add_attribute verfication failed,expected value is %d\n", which); dbgf(2, "reader: the add_attribute verfication failed, the value is %d\n", read_which); printf("The add_attribute verification failed\n"); goto error; } - - if(!s->old_style_grp && check_storage == true) { - if(false == check_attr_storage_type(g,is_compact)) { - H5_FAILED(); AT(); + if (!s->old_style_grp && check_storage == true) { + if (false == check_attr_storage_type(g, is_compact)) { + H5_FAILED(); + AT(); printf("The attribute storage type is wrong. \n"); goto error; } dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); - } /* If the read value is expected, send back an OK message to the writer. */ - if(s->use_named_pipes && s->attr_test == true) { - if(np_rd_send(s)==false) + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) goto error; dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); } return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(amtype); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; /* Send back an error message to the writer so that the writer can stop. */ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,false); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); error2: return false; - } /*------------------------------------------------------------------------- @@ -1897,7 +1957,7 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -1912,28 +1972,27 @@ error2: * Note: This function is used for the "dense" storage test. * It is also used by the group-only test. *------------------------------------------------------------------------- -*/ + */ static bool -verify_default_group_attr(state_t*s,hid_t g, unsigned int which) +verify_default_group_attr(state_t *s, hid_t g, unsigned int which) { - char attrname[VS_ATTR_NAME_LEN]; - const char* aname_format = "attr-%u"; + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u"; HDsprintf(attrname, aname_format, which); - return vrfy_attr(s,g,which,attrname,which,false,true); - + return vrfy_attr(s, g, which, attrname, which, false, true); } /*------------------------------------------------------------------------- * Function: verify_modify_attr * - * Purpose: Check if the reader can retrieve the correct value of + * Purpose: Check if the reader can retrieve the correct value of * an attribute in a group, first the original value then * the modified value. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -1941,105 +2000,114 @@ verify_default_group_attr(state_t*s,hid_t g, unsigned int which) * unsigned int which * The expected attribute value. It is also used to construct the * group name. The modified attribute value can be derived from - * the expected attribute value. + * the expected attribute value. * * Return: Success: true * Failure: false * * Note: This function is used for the "modified" test. *------------------------------------------------------------------------- -*/ + */ static bool -verify_modify_attr(state_t *s, hid_t g, unsigned int which) { +verify_modify_attr(state_t *s, hid_t g, unsigned int which) +{ - bool ret = false; - const char* aname_fmt ="attr-%u"; + bool ret = false; + const char * aname_fmt = "attr-%u"; unsigned int read_which; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; - char attrname[VS_ATTR_NAME_LEN]; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + char attrname[VS_ATTR_NAME_LEN]; /* First verify the original attribute value */ - ret = verify_default_group_attr(s,g,which); - + ret = verify_default_group_attr(s, g, which); + /* Then the modified value */ - if(ret == true) { + if (ret == true) { /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if receiving an error + * for a few ticks or stop the test if receiving an error * message. - */ - if(s->use_named_pipes && true == s->attr_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); goto error2; } decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n",s->np_notify); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); } /* Go ahead to read the attribute. */ esnprintf(attrname, sizeof(attrname), aname_fmt, which); - if ((amtype = H5Tget_native_type(s->filetype,H5T_DIR_ASCEND)) < 0) { - H5_FAILED(); AT(); + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + H5_FAILED(); + AT(); printf("H5Tget_native_type failed\n"); goto error; } if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aopen failed\n"); goto error; } if (H5Aread(aid, amtype, &read_which) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aread failed\n"); goto error; } - if(H5Tclose(amtype) <0) { - H5_FAILED(); AT(); + if (H5Tclose(amtype) < 0) { + H5_FAILED(); + AT(); printf("H5Tclose failed.\n"); - goto error; + goto error; } - + if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aclose failed\n"); goto error; } /* verify the modified value */ - if(read_which != (which+10000)) { - H5_FAILED(); AT(); - dbgf(2, "reader: the modified_attr() expected value is %d\n", (-1)*(int)which); + if (read_which != (which + 10000)) { + H5_FAILED(); + AT(); + dbgf(2, "reader: the modified_attr() expected value is %d\n", (-1) * (int)which); dbgf(2, "reader: the modified_attr() actual value is %d\n", read_which); printf("The modify_attribute verification failed.\n"); goto error; } /* The reader sends an OK message back to the writer. */ - if(s->use_named_pipes && s->attr_test == true) { - if(np_rd_send(s)==false) + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) goto error2; dbgf(2, "reader: modify_attr finish sending back the message: %d\n", s->np_notify); } return true; - } return false; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(amtype); - } H5E_END_TRY; + } + H5E_END_TRY; /* The reader needs to send an error message back to the writer to stop the test.*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,false); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); error2: @@ -2049,18 +2117,18 @@ error2: /*------------------------------------------------------------------------- * Function: verify_group_vlstr_attr * - * Purpose: Check if the reader can retrieve the correct value of + * Purpose: Check if the reader can retrieve the correct value of * a variable length string attribute created by the writer. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * Use to derieve the expected attribute value. It is also used + * Use to derieve the expected attribute value. It is also used * to construct the group name. * * bool vrfy_mod @@ -2070,39 +2138,40 @@ error2: * Return: Success: true * Failure: false * - * Note: This function is an internal function used by + * Note: This function is an internal function used by * both the "vlstr" and the "modify-vstr" tests. *------------------------------------------------------------------------- -*/ - + */ static bool -verify_group_vlstr_attr(state_t*s, hid_t g, unsigned int which, bool vrfy_mod) +verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) { - hid_t aid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; hid_t atype = H5I_INVALID_HID; - char name[VS_ATTR_NAME_LEN]; + char name[VS_ATTR_NAME_LEN]; char *astr_val_exp; - char * astr_val; + char *astr_val; /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message + * for a few ticks or stop the test if the received message * is an error message. - */ - if(s->use_named_pipes && true == s->attr_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); goto error2; } decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n",s->np_notify); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); } /* Go ahead to read the VL string attribute. */ astr_val_exp = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val_exp == NULL) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Allocate memory for expected buffer failed.\n"); goto error; } @@ -2110,59 +2179,65 @@ verify_group_vlstr_attr(state_t*s, hid_t g, unsigned int which, bool vrfy_mod) esnprintf(name, sizeof(name), "attr-%u", which); /* Construct the expected VL string value,depending if - * it is the modified value or the original value. */ - if(vrfy_mod == true) - HDsprintf(astr_val_exp,"%u%c",which,'A'); - else - HDsprintf(astr_val_exp,"%u",which); + * it is the modified value or the original value. */ + if (vrfy_mod == true) + HDsprintf(astr_val_exp, "%u%c", which, 'A'); + else + HDsprintf(astr_val_exp, "%u", which); - dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, - which); + dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, which); - dbgf(1,"expected vl attr is= %s\n",astr_val_exp); + dbgf(1, "expected vl attr is= %s\n", astr_val_exp); if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aopen failed\n"); goto error; } /* Create a VL string datatype */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot create variable length datatype.\n"); goto error; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot set variable length datatype.\n"); goto error; } if (H5Aread(aid, atype, &astr_val) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Cannot read the attribute.\n"); goto error; } - dbgf(1,"read attr is= %s\n",astr_val); + dbgf(1, "read attr is= %s\n", astr_val); if (HDstrcmp(astr_val, astr_val_exp) != 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); dbgf(2, "reader: the vl add_attribute verfication failed,expected value is %s\n", astr_val_exp); dbgf(2, "reader: the vl add_attribute verfication failed, the value is %s\n", astr_val); printf("The vl add_attribute verification failed\n"); goto error; } - if(H5Tclose(atype) <0) { - H5_FAILED(); AT(); + if (H5Tclose(atype) < 0) { + H5_FAILED(); + AT(); printf("H5Tclose failed.\n"); goto error; } - + if (H5Aclose(aid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Aclose failed.\n"); goto error; } @@ -2171,8 +2246,8 @@ verify_group_vlstr_attr(state_t*s, hid_t g, unsigned int which, bool vrfy_mod) HDfree(astr_val_exp); /* Reader sends an OK message back to the reader */ - if(s->use_named_pipes && s->attr_test == true) { - if(np_rd_send(s)==false) + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) goto error2; dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); } @@ -2180,23 +2255,24 @@ verify_group_vlstr_attr(state_t*s, hid_t g, unsigned int which, bool vrfy_mod) return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(atype); - } H5E_END_TRY; - if(astr_val) + } + H5E_END_TRY; + if (astr_val) H5free_memory(astr_val); - if(astr_val_exp) + if (astr_val_exp) HDfree(astr_val_exp); /* The reader sends an error message to the writer to stop the test.*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,false); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); error2: return false; - } /*------------------------------------------------------------------------- @@ -2206,7 +2282,7 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2220,69 +2296,65 @@ error2: * Note: This is an internal function used by "remove-vlstr", * "compact-del","dense-del",dense-del-to-compact" tests. *------------------------------------------------------------------------- -*/ - + */ static bool -verify_del_one_attr(state_t *s, - hid_t g, - const char *aname, - bool check_storage, - bool is_compact) { - +verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, bool is_compact) +{ htri_t attr_exists = FALSE; /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message + * for a few ticks or stop the test if the received message * is an error message. - */ - if(s->use_named_pipes && true == s->attr_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); goto error2; } decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n",s->np_notify); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); } /* Check if the deleted attribute still exists. */ - attr_exists = H5Aexists_by_name(g,".",aname,H5P_DEFAULT); - if(attr_exists == FALSE) { - dbgf(1,"verify_del_attrs_compact() test: \n"); - dbgf(1," attribute %s is successfully deleted. \n",aname); + attr_exists = H5Aexists_by_name(g, ".", aname, H5P_DEFAULT); + if (attr_exists == FALSE) { + dbgf(1, "verify_del_attrs_compact() test: \n"); + dbgf(1, " attribute %s is successfully deleted. \n", aname); } - else if(attr_exists == TRUE) { - dbgf(1,"verify_del_attrs_compact() test failed \n"); + else if (attr_exists == TRUE) { + dbgf(1, "verify_del_attrs_compact() test failed \n"); goto error; } - else{ - dbgf(1,"H5Aexists_by_name failed \n"); + else { + dbgf(1, "H5Aexists_by_name failed \n"); goto error; } - if(!s->old_style_grp && check_storage == true) { - if(false == check_attr_storage_type(g,is_compact)) { - H5_FAILED(); AT(); + if (!s->old_style_grp && check_storage == true) { + if (false == check_attr_storage_type(g, is_compact)) { + H5_FAILED(); + AT(); printf("The attribute storage type is wrong. \n"); goto error; } dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); - } /* Reader sends an OK message back to the reader */ - if(s->use_named_pipes && s->attr_test == true) { - if(np_rd_send(s)==false) + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) goto error; dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); } return true; -error: +error: /* The reader sends an error message to the writer to stop the test.*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,false); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); error2: return false; @@ -2291,18 +2363,18 @@ error2: /*------------------------------------------------------------------------- * Function: verify_remove_vlstr_attr * - * Purpose: Verify if an variable length string attribute is + * Purpose: Verify if an variable length string attribute is * successfully deleted by the writer. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * the attribute name. * @@ -2315,19 +2387,19 @@ error2: * a variable length attribute is added then * it verifies if it is deleted successfully. *------------------------------------------------------------------------- -*/ + */ static bool -verify_remove_vlstr_attr(state_t* s,hid_t g, unsigned int which) +verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which) { - bool ret = false; - char attrname[VS_ATTR_NAME_LEN]; - const char* aname_format = "attr-%u"; + bool ret = false; + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u"; - ret = verify_group_vlstr_attr(s,g,which,false); - if(ret == true) { - HDsprintf(attrname,aname_format,which); - ret = verify_del_one_attr(s,g,attrname,false,false); + ret = verify_group_vlstr_attr(s, g, which, false); + if (ret == true) { + HDsprintf(attrname, aname_format, which); + ret = verify_del_one_attr(s, g, attrname, false, false); } return ret; } @@ -2335,18 +2407,18 @@ verify_remove_vlstr_attr(state_t* s,hid_t g, unsigned int which) /*------------------------------------------------------------------------- * Function: verify_modify_vlstr_attr * - * Purpose: Verify if an variable length string attribute is + * Purpose: Verify if an variable length string attribute is * successfully modified by the writer. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * the attribute name. * @@ -2359,18 +2431,18 @@ verify_remove_vlstr_attr(state_t* s,hid_t g, unsigned int which) * a variable length attribute is added then * it verifies if it is modified successfully. *------------------------------------------------------------------------- -*/ + */ -static bool -verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which){ +static bool +verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ bool ret = false; - ret = verify_group_vlstr_attr(s,g,which,false); - if(ret == true) - ret = verify_group_vlstr_attr(s,g,which,true); + ret = verify_group_vlstr_attr(s, g, which, false); + if (ret == true) + ret = verify_group_vlstr_attr(s, g, which, true); return ret; - } /*------------------------------------------------------------------------- @@ -2381,7 +2453,7 @@ verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which){ * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2391,9 +2463,9 @@ verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which){ * can hold * * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct the - * attribute names. + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct the + * attribute names. * * * Return: Success: true @@ -2401,39 +2473,38 @@ verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which){ * * Note: This function is used by the "compact" test. *------------------------------------------------------------------------- -*/ + */ -static bool -verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { +static bool +verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ - unsigned u; - bool ret = true; - const char* aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; + unsigned u; + bool ret = true; + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; /* Need to verify the added attribute one by one. */ for (u = 0; u < max_c; u++) { - HDsprintf(attrname, aname_format, which,u); - if(false == vrfy_attr(s,g,u+which,attrname,which,true,true)) { + HDsprintf(attrname, aname_format, which, u); + if (false == vrfy_attr(s, g, u + which, attrname, which, true, true)) { ret = false; break; } - } return ret; - } /*------------------------------------------------------------------------- * Function: verify_attrs_compact_dense * - * Purpose: verify if attributes are successfully added first in the + * Purpose: verify if attributes are successfully added first in the * compact storage then in the dense storage. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2443,7 +2514,7 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { * can hold * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * attribute names. * @@ -2453,26 +2524,25 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { * * Note: This function is used by the "compact-dense" test. *------------------------------------------------------------------------- -*/ - + */ -static bool -verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) { +static bool +verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ - const char* aname_format = "attr-d-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-d-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; - bool ret = verify_attrs_compact(s,g,max_c,which); + bool ret = verify_attrs_compact(s, g, max_c, which); - if(ret == true) { + if (ret == true) { /* Now the storage is in dense. Verify if the * retrieved value is correct. */ - HDsprintf(attrname, aname_format, max_c+which,0); - ret = vrfy_attr(s,g,which+max_c,attrname,which,true,false); - if(ret == false) - dbgf(1,"verify_attrs_compact_dense failed \n"); - + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = vrfy_attr(s, g, which + max_c, attrname, which, true, false); + if (ret == false) + dbgf(1, "verify_attrs_compact_dense failed \n"); } return ret; } @@ -2480,12 +2550,12 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact * - * Purpose: verify if an attribute in compact storage is successfully + * Purpose: verify if an attribute in compact storage is successfully * deleted. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2495,7 +2565,7 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi * can hold * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * attribute names. * @@ -2508,20 +2578,21 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi * attributes are successfully added in compact storage then * it verifies if one added attribute is deleted successfully. *------------------------------------------------------------------------- -*/ + */ -static bool -verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { +static bool +verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ - const char* aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; - bool ret = verify_attrs_compact(s,g,max_c,which); + bool ret = verify_attrs_compact(s, g, max_c, which); - if(ret == true) { + if (ret == true) { /* The writer only deletes the attribute attr-which-0 */ - HDsprintf(attrname,aname_format,which,0); - ret = verify_del_one_attr(s,g,attrname,true,true); + HDsprintf(attrname, aname_format, which, 0); + ret = verify_del_one_attr(s, g, attrname, true, true); } return ret; @@ -2530,12 +2601,12 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact_dense * - * Purpose: verify if an attribute in dense storage is successfully + * Purpose: verify if an attribute in dense storage is successfully * deleted. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2545,7 +2616,7 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which * can hold * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * attribute names. * @@ -2556,33 +2627,29 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which * Note: This function is used by the "dense-del" test. * Also note this function first verifies if * attributes are successfully added in compact storage then - * in dense storage. Afterwards, + * in dense storage. Afterwards, * it verifies if one added attribute is deleted successfully. *------------------------------------------------------------------------- -*/ - + */ -static bool -verify_del_attrs_compact_dense(state_t *s, - hid_t g, - unsigned max_c, - unsigned int which) { +static bool +verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ - const char* aname_format = "attr-d-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-d-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; - bool ret = verify_attrs_compact_dense(s,g,max_c,which); + bool ret = verify_attrs_compact_dense(s, g, max_c, which); - if(ret == true) { + if (ret == true) { /* The writer only deletes the attribute attr-d-which-0 */ - HDsprintf(attrname,aname_format,max_c+which,0); - ret = verify_del_one_attr(s,g,attrname,true,false); + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = verify_del_one_attr(s, g, attrname, true, false); } return ret; - } - + /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact_dense_compact * @@ -2592,7 +2659,7 @@ verify_del_attrs_compact_dense(state_t *s, * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) @@ -2606,7 +2673,7 @@ verify_del_attrs_compact_dense(state_t *s, * dense storage * * unsigned int which - * Use to derieve the expected attribute value added + * Use to derieve the expected attribute value added * by the writer. It is also used to construct * attribute names. * @@ -2617,50 +2684,46 @@ verify_del_attrs_compact_dense(state_t *s, * Note: This function is used by the "dense-del-to-compact" test. * Also note this function first verifies if * attributes are successfully added in compact storage then - * in dense storage. Afterwards, + * in dense storage. Afterwards, * it verifies if some added attributes are deleted successfully * until the storage changes from dense to compact. *------------------------------------------------------------------------- -*/ - + */ -static bool -verify_del_attrs_compact_dense_compact(state_t *s, - hid_t g, - unsigned max_c, - unsigned min_d, - unsigned int which) { +static bool +verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsigned min_d, + unsigned int which) +{ - unsigned u; - const char* aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; + unsigned u; + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; /* Verify the attributes are added correctly from * compact to dense storage*/ - bool ret = verify_attrs_compact_dense(s,g,max_c,which); + bool ret = verify_attrs_compact_dense(s, g, max_c, which); - if(ret == true) { + if (ret == true) { - /* Then verify the deletion of attributes + /* Then verify the deletion of attributes * from dense to compact. */ u = max_c + 1; - for(u--;u>=(min_d-1);u--) { - HDsprintf(attrname, aname_format, which,max_c-u); - if(u==(min_d-1)) - ret = verify_del_one_attr(s,g,attrname,true,true); + for (u--; u >= (min_d - 1); u--) { + HDsprintf(attrname, aname_format, which, max_c - u); + if (u == (min_d - 1)) + ret = verify_del_one_attr(s, g, attrname, true, true); else - ret = verify_del_one_attr(s,g,attrname,true,false); + ret = verify_del_one_attr(s, g, attrname, true, false); } /* Just verify one more deleted attribute by the writer. The storage is still compact. */ - HDsprintf(attrname,aname_format,max_c+which,0); - ret = verify_del_one_attr(s,g,attrname,true,true); + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = verify_del_one_attr(s, g, attrname, true, true); } return ret; - } /*------------------------------------------------------------------------- @@ -2671,14 +2734,14 @@ verify_del_attrs_compact_dense_compact(state_t *s, * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g * HDF5 object ID (in this file: means group ID) * * unsigned int which - * The number of iterations for group creation, use to generate - * group and attribute names. + * The number of iterations for group creation, use to generate + * group and attribute names. * * * Return: Success: true @@ -2686,23 +2749,22 @@ verify_del_attrs_compact_dense_compact(state_t *s, * * Note: This is called by the verify_group() function. *------------------------------------------------------------------------- -*/ - + */ static bool verify_group_attribute(state_t *s, hid_t g, unsigned int which) { - char test_pattern = s->at_pattern; - bool ret = false; - unsigned max_compact = 0; - unsigned min_dense = 0; - hid_t gcpl = H5I_INVALID_HID; + char test_pattern = s->at_pattern; + bool ret = false; + unsigned max_compact = 0; + unsigned min_dense = 0; + hid_t gcpl = H5I_INVALID_HID; /* For tests "compact","compact-to-dense","compact-del", * "dense-del", "dense-del-to-compact", * the maximal number of attributes for the compact storage * and the minimal number of attributes for the dense storage - * are needed. So obtain them here + * are needed. So obtain them here * When testing the old-style group creation case, only max_compact * matters. To reduce the testing time, we set max_compact to 2.*/ switch (test_pattern) { @@ -2711,21 +2773,24 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) case 'C': case 'D': case 'T': - if(s->old_style_grp) + if (s->old_style_grp) max_compact = 2; else { - if((gcpl = H5Gget_create_plist(g)) < 0) { - H5_FAILED(); AT(); + if ((gcpl = H5Gget_create_plist(g)) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_create_plist failed\n"); goto error; } - if (H5Pget_attr_phase_change(gcpl,&max_compact,&min_dense) < 0) { - H5_FAILED(); AT(); + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + H5_FAILED(); + AT(); printf("H5Pget_attr_phase_change failed\n"); goto error; } - if(H5Pclose(gcpl) < 0) { - H5_FAILED(); AT(); + if (H5Pclose(gcpl) < 0) { + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto error; } @@ -2738,7 +2803,7 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) case 'r': case ' ': default: - break; + break; } /* Distribute the verification test. */ @@ -2759,16 +2824,16 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) ret = verify_del_attrs_compact_dense_compact(s, g, max_compact, min_dense, which); break; case 'M': - ret = verify_modify_attr(s, g, which); + ret = verify_modify_attr(s, g, which); break; case 'v': - ret = verify_group_vlstr_attr(s,g, which,false); + ret = verify_group_vlstr_attr(s, g, which, false); break; case 'r': - ret = verify_remove_vlstr_attr(s,g, which); + ret = verify_remove_vlstr_attr(s, g, which); break; case 'm': - ret = verify_modify_vlstr_attr(s,g, which); + ret = verify_modify_vlstr_attr(s, g, which); break; case 'd': case ' ': @@ -2781,9 +2846,9 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) error: /* Still to finish the handshaking */ - if(s->use_named_pipes && s->attr_test == true) { + if (s->use_named_pipes && s->attr_test == true) { np_rd_receive(s); - np_send_error(s,false); + np_send_error(s, false); } return false; } @@ -2791,16 +2856,16 @@ error: /*------------------------------------------------------------------------- * Function: verify_group * - * Purpose: verify the success of group creation and + * Purpose: verify the success of group creation and * carry out the test for attribute operations(add,delete etc.) * according to the attribute test pattern. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -2808,80 +2873,80 @@ error: * * Note: This is called by the main() function. *------------------------------------------------------------------------- -*/ - - + */ static bool verify_group(state_t *s, unsigned int which) { - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - bool result = true; + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + bool result = true; H5G_info_t group_info; /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message + * for a few ticks or stop the test if the received message * is an error message. - */ - if(s->use_named_pipes && true == s->attr_test) { + */ + if (s->use_named_pipes && true == s->attr_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); goto error2; } decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n",s->np_notify); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } esnprintf(name, sizeof(name), "/group-%d", which); - - if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { - H5_FAILED(); AT(); + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gopen failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - - dbgf(2,"Storage info is %d\n",group_info.storage_type); - if(s->old_style_grp) { - if(group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); AT(); + + dbgf(2, "Storage info is %d\n", group_info.storage_type); + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the old-style.\n"); + dbgf(2, "Reader: verify that the group is created with the old-style.\n"); } else { - if(group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); AT(); + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Reader - The created group should NOT be in old-style . \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the new-style.\n"); - + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } /* Reader sends an OK message back to the reader */ - if(s->use_named_pipes && s->attr_test == true) { + if (s->use_named_pipes && s->attr_test == true) { - if(np_rd_send(s)==false) + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } /* Check if we need to skip the attribute test for this group. */ @@ -2891,7 +2956,8 @@ verify_group(state_t *s, unsigned int which) result = true; if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } @@ -2900,52 +2966,53 @@ verify_group(state_t *s, unsigned int which) error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; /* The reader sends an error message to the writer to stop the test.*/ - if(s->use_named_pipes && s->attr_test == true) - np_send_error(s,false); + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); error2: return false; - } int main(int argc, char **argv) { - hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID; - unsigned step; - bool writer = false; - state_t s; - const char *personality; + hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID; + unsigned step; + bool writer = false; + state_t s; + const char * personality; H5F_vfd_swmr_config_t config; - const char *fifo_writer_to_reader = "./fifo_group_writer_to_reader"; - const char *fifo_reader_to_writer = "./fifo_group_reader_to_writer"; - int fd_writer_to_reader = -1, fd_reader_to_writer = -1; - int notify = 0, verify = 0; - bool wg_ret = false; - bool vg_ret = false; + const char * fifo_writer_to_reader = "./fifo_group_writer_to_reader"; + const char * fifo_reader_to_writer = "./fifo_group_reader_to_writer"; + int fd_writer_to_reader = -1, fd_reader_to_writer = -1; + int notify = 0, verify = 0; + bool wg_ret = false; + bool vg_ret = false; if (!state_init(&s, argc, argv)) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("state_init failed\n"); goto error; } personality = HDstrstr(s.progname, "vfd_swmr_group_"); - if (personality != NULL && - HDstrcmp(personality, "vfd_swmr_group_writer") == 0) + if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_writer") == 0) writer = true; - else if (personality != NULL && - HDstrcmp(personality, "vfd_swmr_group_reader") == 0) + else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unknown personality, expected vfd_swmr_group_{reader,writer}\n"); goto error; } @@ -2955,23 +3022,26 @@ main(int argc, char **argv) /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) * as the second parameter of H5Pset_libver_bound() that is called by - * vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST) + * vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST) * should be used as the second parameter of H5Pset_libver_bound(). * Also pass the use_vfd_swmr, only_meta_page, config to vfd_swmr_create_fapl().*/ if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, &config)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("vfd_swmr_create_fapl failed\n"); goto error; } if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pcreate failed\n"); goto error; } if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pset_file_space_strategy failed\n"); goto error; } @@ -2982,7 +3052,8 @@ main(int argc, char **argv) s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); if (s.file < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Fcreate/open failed\n"); goto error; } @@ -2994,50 +3065,53 @@ main(int argc, char **argv) if (s.use_named_pipes && writer) { /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed\n"); goto error; } if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed\n"); goto error; } - } /* Both the writer and reader open the pipes */ if (s.use_named_pipes && (fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDopen failed\n"); goto error; } if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDopen failed\n"); goto error; } /* Pass the named pipe information to the struct of state_t s, for attribute tests.*/ - if(s.use_named_pipes) { + if (s.use_named_pipes) { s.np_fd_w_to_r = fd_writer_to_reader; s.np_fd_r_to_w = fd_reader_to_writer; - s.np_notify = notify; - s.np_verify = verify; - s.tick_len = config.tick_len; - s.max_lag = config.max_lag; + s.np_notify = notify; + s.np_verify = verify; + s.tick_len = config.tick_len; + s.max_lag = config.max_lag; } - /* For attribute test, force the named pipe to communicate in every step. - * This will avoid the fake verification error from the reader when using the named pipe. + /* For attribute test, force the named pipe to communicate in every step. + * This will avoid the fake verification error from the reader when using the named pipe. * If the named pipe is not forced to communicate in every step, the reader may go ahead * to verify the group and the attribute operations before the writer has a chance to * carry out the corresponding operations. */ if (s.at_pattern != ' ') { - s.attr_test = true; - if(s.use_named_pipes) + s.attr_test = true; + if (s.use_named_pipes) s.csteps = 1; } @@ -3047,42 +3121,47 @@ main(int argc, char **argv) wg_ret = write_group(&s, step); - if(wg_ret == false) { - H5_FAILED(); AT(); - printf("write_group failed at step %d\n",step); + if (wg_ret == false) { + H5_FAILED(); + AT(); + printf("write_group failed at step %d\n", step); /* At communication interval, notifies the reader about the failture and quit */ - if (s.use_named_pipes && s.attr_test !=true && step % s.csteps == 0) - np_send_error(&s,true); + if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) + np_send_error(&s, true); goto error; } else { /* At communication interval, notifies the reader and waits for its response */ - if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) { + if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) { - if(np_wr_send_receive(&s) == false) { - H5_FAILED(); AT(); + if (np_wr_send_receive(&s) == false) { + H5_FAILED(); + AT(); dbgf(2, "writer: write group - verification failed.\n"); goto error; } } } } - } else { - for (step = 0; step < s.nsteps;step++) { + } + else { + for (step = 0; step < s.nsteps; step++) { dbgf(1, "reader: step %d\n", step); - /* At communication interval, waits for the writer to finish creation before starting verification */ + /* At communication interval, waits for the writer to finish creation before starting verification + */ if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) { - if(false == np_rd_receive(&s)) { - H5_FAILED(); AT(); + if (false == np_rd_receive(&s)) { + H5_FAILED(); + AT(); goto error; } } /* For the default test, wait for a few ticks for the update to happen */ - if(s.use_named_pipes && s.attr_test== false) + if (s.use_named_pipes && s.attr_test == false) decisleep(config.tick_len * s.update_interval); vg_ret = verify_group(&s, step); @@ -3090,74 +3169,81 @@ main(int argc, char **argv) if (vg_ret == false) { printf("verify_group failed\n"); - H5_FAILED(); AT(); + H5_FAILED(); + AT(); /* At communication interval, tell the writer about the failure and exit */ - if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) - np_send_error(&s,false); + if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) + np_send_error(&s, false); goto error; - } else { /* Send back the same nofity value for acknowledgement to tell the writer * move to the next step. */ - if (s.use_named_pipes && s.attr_test!=true && step % s.csteps == 0) { - if(np_rd_send(&s)==false) + if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) { + if (np_rd_send(&s) == false) goto error; } } - } } if (H5Pclose(fapl) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto error; } if (H5Pclose(fcpl) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto error; } if (H5Sclose(s.one_by_one_sid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Sclose failed\n"); goto error; } if (H5Fclose(s.file) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Fclose failed\n"); goto error; } /* Both the writer and reader close the named pipes */ if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclose failed\n"); goto error; } if (s.use_named_pipes && HDclose(fd_reader_to_writer) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclose failed\n"); goto error; } /* Reader finishes last and deletes the named pipes */ - if(s.use_named_pipes && !writer) { - if(HDremove(fifo_writer_to_reader) != 0) { - H5_FAILED(); AT(); + if (s.use_named_pipes && !writer) { + if (HDremove(fifo_writer_to_reader) != 0) { + H5_FAILED(); + AT(); printf("HDremove failed\n"); goto error; } - if(HDremove(fifo_reader_to_writer) != 0) { - H5_FAILED(); AT(); + if (HDremove(fifo_reader_to_writer) != 0) { + H5_FAILED(); + AT(); printf("HDremove failed\n"); goto error; } @@ -3166,12 +3252,14 @@ main(int argc, char **argv) return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Sclose(s.one_by_one_sid); H5Fclose(s.file); - } H5E_END_TRY; + } + H5E_END_TRY; if (s.use_named_pipes && fd_writer_to_reader >= 0) HDclose(fd_writer_to_reader); @@ -3179,13 +3267,12 @@ error: if (s.use_named_pipes && fd_reader_to_writer >= 0) HDclose(fd_reader_to_writer); - if(s.use_named_pipes && !writer) { + if (s.use_named_pipes && !writer) { HDremove(fifo_writer_to_reader); HDremove(fifo_reader_to_writer); } return EXIT_FAILURE; - } #else /* H5_HAVE_WIN32_API */ diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index 00dcd9e..0cdb669 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -35,23 +35,21 @@ typedef struct _shared_ticks { uint64_t reader_tick; } shared_ticks_t; -int fd_writer_to_reader = -1, fd_reader_to_writer = -1; -const char *fifo_writer_to_reader = "./fifo_writer_to_reader"; -const char *fifo_reader_to_writer = "./fifo_reader_to_writer"; -bool use_vfd_swmr = true; -bool use_named_pipe = true; -bool print_estack = false; +int fd_writer_to_reader = -1, fd_reader_to_writer = -1; +const char * fifo_writer_to_reader = "./fifo_writer_to_reader"; +const char * fifo_reader_to_writer = "./fifo_reader_to_writer"; +bool use_vfd_swmr = true; +bool use_named_pipe = true; +bool print_estack = false; static H5F_vfd_swmr_config_t swmr_config; static bool writer; struct timespec ival = {MAX_READ_LEN_IN_SECONDS, 0}; /* Expected maximal time for reader's validation */ -zoo_config_t config = { - .proc_num = 0 - , .skip_compact = false - , .skip_varlen = true - , .max_pause_msecs = 0 - , .msgival = {.tv_sec = 0, .tv_nsec = 0} -}; +zoo_config_t config = {.proc_num = 0, + .skip_compact = false, + .skip_varlen = true, + .max_pause_msecs = 0, + .msgival = {.tv_sec = 0, .tv_nsec = 0}}; static void #ifndef H5C_COLLECT_CACHE_STATS @@ -85,14 +83,15 @@ usage(const char *progname) { fprintf(stderr, "usage: %s [-C] [-S] [-a] [-e] [-p] [-q] [-v]\n", progname); fprintf(stderr, "\n -C: skip compact dataset tests\n"); - fprintf(stderr, " -S: do not use VFD SWMR\n"); - fprintf(stderr, " -a: run all tests, including variable-length data\n"); - fprintf(stderr, " -e: print error stacks\n"); - fprintf(stderr, " -l tick_num: expected maximal number of ticks from \n"); - fprintf(stderr, " the writer's finishing zoo creation or deletion to the reader's finishing validation\n"); - fprintf(stderr, " -N: do not use named pipes\n"); - fprintf(stderr, " -q: be quiet: few/no progress messages\n"); - fprintf(stderr, " -v: be verbose: most progress messages\n"); + fprintf(stderr, " -S: do not use VFD SWMR\n"); + fprintf(stderr, " -a: run all tests, including variable-length data\n"); + fprintf(stderr, " -e: print error stacks\n"); + fprintf(stderr, " -l tick_num: expected maximal number of ticks from \n"); + fprintf(stderr, + " the writer's finishing zoo creation or deletion to the reader's finishing validation\n"); + fprintf(stderr, " -N: do not use named pipes\n"); + fprintf(stderr, " -q: be quiet: few/no progress messages\n"); + fprintf(stderr, " -v: be verbose: most progress messages\n"); exit(EXIT_FAILURE); } @@ -100,71 +99,74 @@ usage(const char *progname) static int parse_command_line_options(int argc, char **argv) { - int ch; + int ch; unsigned long tmpl; - char *end; + char * end; while ((ch = getopt(argc, argv, "CSael:Nqv")) != -1) { - switch(ch) { - case 'C': - config.skip_compact = true; - break; - case 'S': - use_vfd_swmr = false; - break; - case 'a': - config.skip_varlen = false; - break; - case 'e': - print_estack = true; - break; - case 'l': - /* Expected maximal number of ticks from the writer's finishing zoo creation or deletion - * to the reader's finishing validation of zoo creation or deletion */ - errno = 0; - tmpl = HDstrtoul(optarg, &end, 0); - - if (end == optarg || *end != '\0') { - printf("couldn't parse `-l` argument `%s`", optarg); - goto error; - } else if (errno != 0) { - printf("couldn't parse `-l` argument `%s`", optarg); - goto error; - } else if (tmpl > UINT_MAX) { - printf("`-l` argument `%lu` too large", tmpl); - goto error; - } - - { - /* Translate the tick number to time represented by the timespec struct */ - float time = (float)(((unsigned)tmpl * TICK_LEN) / 10.0); - unsigned sec = (unsigned)time; - unsigned nsec = (unsigned)((time - sec) * 10 * 1000 * 1000); - - ival.tv_sec = sec; - ival.tv_nsec = nsec; - } - break; - case 'N': - /* Disable named pipes, mainly for running the writer and reader seperately */ - use_named_pipe = false; - break; - case 'q': - verbosity = 1; - break; - case 'v': - verbosity = 3; - break; - default: - usage(argv[0]); - break; + switch (ch) { + case 'C': + config.skip_compact = true; + break; + case 'S': + use_vfd_swmr = false; + break; + case 'a': + config.skip_varlen = false; + break; + case 'e': + print_estack = true; + break; + case 'l': + /* Expected maximal number of ticks from the writer's finishing zoo creation or deletion + * to the reader's finishing validation of zoo creation or deletion */ + errno = 0; + tmpl = HDstrtoul(optarg, &end, 0); + + if (end == optarg || *end != '\0') { + printf("couldn't parse `-l` argument `%s`", optarg); + goto error; + } + else if (errno != 0) { + printf("couldn't parse `-l` argument `%s`", optarg); + goto error; + } + else if (tmpl > UINT_MAX) { + printf("`-l` argument `%lu` too large", tmpl); + goto error; + } + + { + /* Translate the tick number to time represented by the timespec struct */ + float time = (float)(((unsigned)tmpl * TICK_LEN) / 10.0); + unsigned sec = (unsigned)time; + unsigned nsec = (unsigned)((time - sec) * 10 * 1000 * 1000); + + ival.tv_sec = sec; + ival.tv_nsec = nsec; + } + break; + case 'N': + /* Disable named pipes, mainly for running the writer and reader seperately */ + use_named_pipe = false; + break; + case 'q': + verbosity = 1; + break; + case 'v': + verbosity = 3; + break; + default: + usage(argv[0]); + break; } } argv += optind; argc -= optind; if (argc > 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unexpected command-line arguments"); goto error; } @@ -183,13 +185,15 @@ create_open_named_pipes(void) /* Writer creates two named pipes(FIFO) to coordinate two-way communication */ if (writer) { if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed"); goto error; } if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed"); goto error; } @@ -197,13 +201,15 @@ create_open_named_pipes(void) /* Both the writer and reader open the pipes */ if ((fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("fifo_writer_to_reader open failed"); goto error; } if ((fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("fifo_reader_to_writer open failed"); goto error; } @@ -219,43 +225,49 @@ error: static int notify_and_wait_for_reader(hid_t fid, int verify) { - int notify; - unsigned int i; + int notify; + unsigned int i; struct timespec last = {0, 0}; /* Get the time when finishing zoo creation */ if (HDclock_gettime(CLOCK_MONOTONIC, &last) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclock_gettime failed"); goto error; } /* Notify the reader of finishing zoo creation by sending the timestamp */ if (HDwrite(fd_writer_to_reader, &last, sizeof(last)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed"); goto error; } /* During the wait, writer makes repeated HDF5 API calls so as to trigger * EOT at approximately the correct time */ - for(i = 0; i < swmr_config.max_lag + 1; i++) { + for (i = 0; i < swmr_config.max_lag + 1; i++) { decisleep(swmr_config.tick_len); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aexists(fid, "nonexistent"); - } H5E_END_TRY; + } + H5E_END_TRY; } /* Wait until the reader finishes validating zoo creation */ if (HDread(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDread failed"); goto error; } if (notify != verify) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("expected %d but read %d", verify, notify); goto error; } @@ -274,14 +286,16 @@ notify_reader(void) /* Get the time when finishing zoo deletion */ if (HDclock_gettime(CLOCK_MONOTONIC, &last) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclock_gettime failed"); goto error; } /* Notify the reader about finishing zoo deletion by sending the timestamp */ if (HDwrite(fd_writer_to_reader, &last, sizeof(last)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed"); goto error; } @@ -299,13 +313,15 @@ reader_verify(int verify) int notify; if (HDread(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDread failed"); goto error; } if (notify != verify) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("expected %d but read %d", verify, notify); goto error; } @@ -327,7 +343,8 @@ reader_check_time_and_notify_writer(int notify) /* Receive the notice of the writer finishing zoo creation (timestamp) */ if (HDread(fd_writer_to_reader, &last, sizeof(last)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDread failed"); goto error; } @@ -342,7 +359,8 @@ reader_check_time_and_notify_writer(int notify) /* Notify the writer that zoo validation is finished */ if (HDwrite(fd_reader_to_writer, ¬ify, sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed"); goto error; } @@ -363,7 +381,8 @@ reader_check_time_after_verify_deletion(void) struct timespec last = {0, 0}; if (HDread(fd_writer_to_reader, &last, sizeof(last)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDread failed"); goto error; } @@ -385,27 +404,31 @@ close_named_pipes(void) { /* Close the named pipes */ if (HDclose(fd_writer_to_reader) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclose failed\n"); goto error; } if (HDclose(fd_reader_to_writer) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDclose failed\n"); goto error; } /* Reader finishes last and deletes the named pipes */ - if(!writer) { - if(HDremove(fifo_writer_to_reader) != 0) { - H5_FAILED(); AT(); + if (!writer) { + if (HDremove(fifo_writer_to_reader) != 0) { + H5_FAILED(); + AT(); printf("HDremove failed\n"); goto error; } - if(HDremove(fifo_reader_to_writer) != 0) { - H5_FAILED(); AT(); + if (HDremove(fifo_reader_to_writer) != 0) { + H5_FAILED(); + AT(); printf("HDremove failed\n"); goto error; } @@ -420,18 +443,19 @@ error: int main(int argc, char **argv) { - hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID, fid = H5I_INVALID_HID; - H5F_t *f; - H5C_t *cache; - struct timespec lastmsgtime = {.tv_sec = 0, .tv_nsec = 0}; - char *progname = NULL; - char *personality; - estack_state_t es; + hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID, fid = H5I_INVALID_HID; + H5F_t * f; + H5C_t * cache; + struct timespec lastmsgtime = {.tv_sec = 0, .tv_nsec = 0}; + char * progname = NULL; + char * personality; + estack_state_t es; H5F_vfd_swmr_config_t vfd_swmr_config; - int notify = 0, verify = 0; + int notify = 0, verify = 0; if (H5_basename(argv[0], &progname) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5_basename failed\n"); goto error; } @@ -443,7 +467,8 @@ main(int argc, char **argv) else if (personality != NULL && strcmp(personality, "vfd_swmr_zoo_reader") == 0) writer = false; else { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unknown personality, expected vfd_swmr_zoo_{reader,writer}"); goto error; } @@ -456,31 +481,36 @@ main(int argc, char **argv) /* ? turn off use latest format argument via 1st argument? since later on it reset to early format */ /* use_latest_format, use_vfd_swmr, only_meta_page, config */ if ((fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, true, &vfd_swmr_config)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("vfd_swmr_create_fapl"); goto error; } if (use_vfd_swmr && H5Pget_vfd_swmr_config(fapl, &swmr_config) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pget_vfd_swmr_config failed"); goto error; } if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pset_libver_bounds failed"); goto error; } if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pcreate failed"); goto error; } if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pset_file_space_strategy failed"); goto error; } @@ -491,13 +521,15 @@ main(int argc, char **argv) fid = H5Fopen("vfd_swmr_zoo.h5", H5F_ACC_RDONLY, fapl); if (fid < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf(writer ? "H5Fcreate failed" : "H5Fopen failed"); goto error; } if ((f = H5VL_object_verify(fid, H5I_FILE)) == NULL) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5VL_object_verify failed"); goto error; } @@ -507,7 +539,8 @@ main(int argc, char **argv) /* Writer creates two named pipes(FIFO) to coordinate two-way communication * between the writer and the reader. Both the writer and reader open the named pipes */ if (use_named_pipe && create_open_named_pipes() < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("create_open_named_pipes failed"); goto error; } @@ -521,14 +554,16 @@ main(int argc, char **argv) /* Writer tells reader to start */ notify = 1; if (use_named_pipe && HDwrite(fd_writer_to_reader, ¬ify, sizeof(int)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDwrite failed"); goto error; } /* Start to create the zoo */ if (!create_zoo(fid, ".", &lastmsgtime, config)) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("create_zoo failed"); goto error; } @@ -537,31 +572,36 @@ main(int argc, char **argv) * and wait for the reader to finish validation before proceeding */ verify = 2; if (use_named_pipe && notify_and_wait_for_reader(fid, verify) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("notify_and_wait_for_reader failed"); goto error; } /* Start to delete the zoo */ if (!delete_zoo(fid, ".", &lastmsgtime, config)) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("delete_zoo failed"); goto error; } /* Notify the reader of finishing zoo deletion by sending the timestamp */ if (use_named_pipe && notify_reader() < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("notify_reader failed"); goto error; } - } else { + } + else { dbgf(2, "Reading zoo...\n"); /* Wait for the writer's notice before starting to zoo validation */ verify = 1; if (use_named_pipe && reader_verify(verify) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("reader_verify failed"); goto error; } @@ -570,14 +610,14 @@ main(int argc, char **argv) while (!validate_zoo(fid, ".", &lastmsgtime, config)) ; - /* Receive the notice of the writer finishing zoo creation (timestamp) * Make sure the zoo validation doesn't take longer than the expected time. * This time period is from the writer finishing zoo creation to the reader finishing * the validation of zoo creation */ notify = 2; if (use_named_pipe && reader_check_time_and_notify_writer(notify) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("reader_check_time_and_notify_writer failed"); goto error; } @@ -591,7 +631,8 @@ main(int argc, char **argv) * This time period is from the writer finishing zoo deletion to the reader finishing * the validation of zoo deletion */ if (use_named_pipe && reader_check_time_after_verify_deletion() < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("reader_check_time_and_notify_writer failed"); goto error; } @@ -599,19 +640,22 @@ main(int argc, char **argv) restore_estack(es); if (H5Pclose(fapl) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pclose failed"); goto error; } if (H5Pclose(fcpl) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pclose failed"); goto error; } if (H5Fclose(fid) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Fclose failed"); goto error; } @@ -620,7 +664,8 @@ main(int argc, char **argv) HDfree(progname); if (use_named_pipe && close_named_pipes() < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("close_named_pipes failed"); goto error; } @@ -628,11 +673,13 @@ main(int argc, char **argv) return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; if (use_named_pipe && fd_writer_to_reader >= 0) HDclose(fd_writer_to_reader); @@ -640,7 +687,7 @@ error: if (use_named_pipe && fd_reader_to_writer >= 0) HDclose(fd_reader_to_writer); - if(use_named_pipe && !writer) { + if (use_named_pipe && !writer) { HDremove(fifo_writer_to_reader); HDremove(fifo_reader_to_writer); } diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h index 7c1ac42..3da2660 100644 --- a/tools/test/perform/pio_standalone.h +++ b/tools/test/perform/pio_standalone.h @@ -356,7 +356,7 @@ H5_DLL int c99_snprintf(char *str, size_t size, const char *format, ...); #endif /* sprintf() variable arguments */ #define HDsprintf sprintf /*varargs*/ -#define HDsqrt(X) sqrt(X) +#define HDsqrt(X) sqrt(X) #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); #define HDsrandom(S) HDsrand(S) @@ -429,25 +429,25 @@ H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); #else #define HDunlink(S) unlink(S) #endif -#define HDutime(S, T) utime(S, T) -#define HDva_arg(A, T) va_arg(A, T) -#define HDva_end(A) va_end(A) -#define HDva_start(A, P) va_start(A, P) -#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) -#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) -#define HDvprintf(FMT, A) vprintf(FMT, A) -#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) +#define HDutime(S, T) utime(S, T) +#define HDva_arg(A, T) va_arg(A, T) +#define HDva_end(A) va_end(A) +#define HDva_start(A, P) va_start(A, P) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) +#define HDvprintf(FMT, A) vprintf(FMT, A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) #ifdef H5_HAVE_WIN32_API H5_DLL int c99_vsnprintf(char *str, size_t size, const char *format, va_list ap); #define HDvsnprintf c99_vsnprintf #else #define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif -#define HDwait(W) wait(W) -#define HDwaitpid(P, W, O) waitpid(P, W, O) -#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) -#define HDwctomb(S, C) wctomb(S, C) -#define HDwrite(F, M, Z) write(F, M, Z) +#define HDwait(W) wait(W) +#define HDwaitpid(P, W, O) waitpid(P, W, O) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) +#define HDwctomb(S, C) wctomb(S, C) +#define HDwrite(F, M, Z) write(F, M, Z) /* * And now for a couple non-Posix functions... Watch out for systems that -- cgit v0.12