diff options
author | Muqun Yang <myang6@hdfgroup.org> | 2021-04-26 21:24:23 (GMT) |
---|---|---|
committer | Muqun Yang <myang6@hdfgroup.org> | 2021-04-26 21:24:23 (GMT) |
commit | e70444ccd2ccc474f221114e6dc74dfa0695063d (patch) | |
tree | 51c900fc4e73377501e66d655af2227b45d3615c /test | |
parent | 7aa93ccf61135780210e539dde4e1eb6c7d22c3e (diff) | |
download | hdf5-e70444ccd2ccc474f221114e6dc74dfa0695063d.zip hdf5-e70444ccd2ccc474f221114e6dc74dfa0695063d.tar.gz hdf5-e70444ccd2ccc474f221114e6dc74dfa0695063d.tar.bz2 |
Add the old-styled group creation attribute tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/testvfdswmr.sh.in | 67 | ||||
-rw-r--r-- | test/vfd_swmr_common.c | 4 | ||||
-rw-r--r-- | test/vfd_swmr_group_writer.c | 153 |
3 files changed, 184 insertions, 40 deletions
diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 9e75aeb..06b1023 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -156,7 +156,7 @@ if [ $rc -ne 0 ] ; then fi all_tests="generator expand shrink expand_shrink sparse vlstr_null vlstr_oob zoo groups attrdset" -all_tests="${all_tests} groups_attrs few_big many_small" +all_tests="${all_tests} groups_attrs os_groups_attrs few_big many_small" tests=${all_tests} if [ $# -gt 0 ]; then @@ -787,6 +787,71 @@ for options in ${grp_attr_list[*]}; do rm -f vfd_swmr_group_reader.*.{out,rc} done +# The following tests are for add/del/modify attributes for +# groups created with the old-style. +# Check https://portal.hdfgroup.org/display/HDF5/Groups for +# the detailed group implementation note. +# The 'compact' and 'compact-del' are the attribute addition +# and deletion tests. Other test names have the same meaning +# as those of the new-style group tests. +# +os_grp_attr_list=( + "compact" + "compact-del" + "modify" + "vstr" + "remove-vstr" + "modify-vstr" + ) +os_grp_sub_attr_list=( + "modify" + "remove-vstr" + "modify-vstr" + ) +if [[ "$HDF5TestExpress" -gt 0 ]] ; then #Setting for standard run + os_grp_attr_list=("${os_grp_sub_attr_list[@]}") +fi + +for options in ${os_grp_attr_list[*]}; do + if [ ${do_os_groups_attrs:-no} = no ]; then + continue + fi + echo launch vfd_swmr_group attribute with old-style group: $options + catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -G -c 1 -n $GROUP_attr_n -a 1 -A $options & + pid_writer=$! + + catch_out_err_and_rc vfd_swmr_group_reader \ + ../vfd_swmr_group_reader -q -G -c 1 -n $GROUP_attr_n -a 1 -A $options & + pid_reader=$! + + # Wait for the reader to finish before signalling the + # writer to quit: the writer holds the file open so that the + # reader will find the shadow file when it opens + # the .h5 file. + wait $pid_reader + wait $pid_writer + + # Collect exit code of the reader + if [ $(cat vfd_swmr_group_reader.rc) -ne 0 ]; then + echo reader had error + nerrors=$((nerrors + 1)) + fi + + # Collect exit code of the writer + if [ $(cat vfd_swmr_group_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) + fi + + # Clean up output files + rm -f vfd_swmr_group_writer.{out,rc} + rm -f vfd_swmr_group_reader.*.{out,rc} +done + + + + for options in "-d 1" "-d 1 -F" "-d 2" "-d 2 -F" "-d 1 -V" "-d 1 -M" "-d 1 -V -F" "-d 1 -M -F"; do if [ ${do_many_small:-no} = no ]; then continue diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index 68e0b9c..aed9cbe 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -391,6 +391,10 @@ 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.*/ + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + return H5I_INVALID_HID; + } /* Enable page buffering */ if (H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index fc21e68..2477c2e 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -35,6 +35,7 @@ typedef struct { 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; @@ -52,6 +53,7 @@ typedef struct { .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 \ @@ -67,10 +69,11 @@ typedef struct { static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-a steps] [-b] [-c]\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" @@ -127,11 +130,14 @@ state_init(state_t *s, int argc, char **argv) if (tfile) HDfree(tfile); - while ((ch = getopt(argc, argv, "Sa:bc:n:Nqu:A:")) != -1) { + while ((ch = getopt(argc, argv, "SGa:bc:n:Nqu:A:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; break; + case 'G': + s->old_style_grp = true; + break; case 'a': case 'c': case 'n': @@ -1080,13 +1086,17 @@ add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) { unsigned min_dense = 0; const char* aname_format="attr-%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(); - printf("H5Pget_attr_phase_change() failed\n"); - goto error; + 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(); + printf("H5Pget_attr_phase_change() failed\n"); + goto error; + } } /* Add max_compact attributes, these attributes are stored in @@ -1580,6 +1590,7 @@ write_group(state_t *s, unsigned int which) 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(); @@ -1589,20 +1600,24 @@ write_group(state_t *s, unsigned int which) esnprintf(name, sizeof(name), "/group-%d", which); - gcpl = H5Pcreate(H5P_GROUP_CREATE); - 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) { + if(s->old_style_grp) + gcpl = H5P_DEFAULT; + else { + gcpl = H5Pcreate(H5P_GROUP_CREATE); + if(gcpl <0) { H5_FAILED(); AT(); - printf("H5Pset_attr_phase_change failed for the dense storage.\n"); + 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(); + printf("H5Pset_attr_phase_change failed for the dense storage.\n"); + goto error; + } + } } if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, @@ -1612,6 +1627,29 @@ write_group(state_t *s, unsigned int which) goto error; } + 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(); + 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"); + } + else { + 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"); + + } /* 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 @@ -1639,7 +1677,7 @@ write_group(state_t *s, unsigned int which) goto error; } - if(H5Pclose(gcpl) <0) { + if(!s->old_style_grp && H5Pclose(gcpl) <0) { H5_FAILED(); AT(); printf("H5Pclose failed\n"); goto error; @@ -1656,7 +1694,8 @@ error2: H5E_BEGIN_TRY { H5Gclose(g); - H5Pclose(gcpl); + if(!s->old_style_grp) + H5Pclose(gcpl); } H5E_END_TRY; return false; @@ -2571,27 +2610,33 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) * "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) { case 'c': case 't': case 'C': case 'D': case 'T': - 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(); - printf("H5Pget_attr_phase_change failed\n"); - goto error; - } - if(H5Pclose(gcpl) < 0) { - H5_FAILED(); AT(); - printf("H5Pclose failed\n"); - goto error; + if(s->old_style_grp) + max_compact = 2; + else { + 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(); + printf("H5Pget_attr_phase_change failed\n"); + goto error; + } + if(H5Pclose(gcpl) < 0) { + H5_FAILED(); AT(); + printf("H5Pclose failed\n"); + goto error; + } } break; case 'v': @@ -2681,6 +2726,7 @@ verify_group(state_t *s, unsigned int which) 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 @@ -2712,6 +2758,31 @@ verify_group(state_t *s, unsigned int which) goto error; } + 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(); + 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"); + } + else { + 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"); + + } + /* Reader sends an OK message back to the reader */ if(s->use_named_pipes && s->attr_test == true) { @@ -2790,8 +2861,12 @@ main(int argc, char **argv) /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-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 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) + * 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(); printf("vfd_swmr_create_fapl failed\n"); goto error; |