From 4d0fbe96bc085d53f9964a4801bdb89d69edfed5 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 20 Apr 2011 16:34:49 -0500 Subject: [svn-r20579] Bug 1386 - allowing dimension size to be zero. I added test cases in the tests for h5dump and h5diff. I also added the test cases in the CMAKE script. Tested on jam. But I tested the same change in the trunk with h5committest. --- MANIFEST | 4 +- tools/h5diff/CMakeLists.txt | 10 +++++ tools/h5diff/h5diffgentest.c | 70 +++++++++++++++++++++++++++++++++- tools/h5diff/testfiles/h5diff_208.txt | 5 +++ tools/h5diff/testh5diff.sh | 6 ++- tools/h5dump/CMakeLists.txt | 9 +++++ tools/h5dump/h5dumpgentest.c | 41 ++++++++++++++++++++ tools/h5dump/testh5dump.sh.in | 3 ++ tools/testfiles/zerodim.ddl | 19 +++++++++ tools/testfiles/zerodim.h5 | Bin 0 -> 1528 bytes 10 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 tools/h5diff/testfiles/h5diff_208.txt create mode 100644 tools/testfiles/zerodim.ddl create mode 100644 tools/testfiles/zerodim.h5 diff --git a/MANIFEST b/MANIFEST index 8d3c2d9..43a53dc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1396,7 +1396,8 @@ ./tools/testfiles/tfpformat.h5 # h5dump h5repack validation ./tools/testfiles/h5repack_filters.h5.ddl - +./tools/testfiles/zerodim.ddl +./tools/testfiles/zerodim.h5 # Expected output from h5ls tests ./tools/testfiles/nosuchfile.ls @@ -1624,6 +1625,7 @@ ./tools/h5diff/testfiles/h5diff_205.txt ./tools/h5diff/testfiles/h5diff_206.txt ./tools/h5diff/testfiles/h5diff_207.txt +./tools/h5diff/testfiles/h5diff_208.txt ./tools/h5diff/testfiles/h5diff_300.txt ./tools/h5diff/testfiles/h5diff_400.txt ./tools/h5diff/testfiles/h5diff_401.txt diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 97c3a3c..0969a23 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -69,6 +69,7 @@ IF (BUILD_TESTING) h5diff_205.txt h5diff_206.txt h5diff_207.txt + h5diff_208.txt h5diff_21.txt h5diff_22.txt h5diff_23.txt @@ -209,6 +210,8 @@ IF (BUILD_TESTING) h5diff_extlink_trg.h5 h5diff_ext2softlink_src.h5 h5diff_ext2softlink_trg.h5 + h5diff_dset_zero_dim_size1.h5 + h5diff_dset_zero_dim_size2.h5 h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 h5diff_grp_recurse1.h5 @@ -364,6 +367,8 @@ IF (BUILD_TESTING) SET (FILE16 h5diff_extlink_trg.h5) SET (FILE17 h5diff_ext2softlink_src.h5) SET (FILE18 h5diff_ext2softlink_trg.h5) + SET (FILE19 h5diff_dset_zero_dim_size1.h5) + SET (FILE20 h5diff_dset_zero_dim_size2.h5) SET (DANGLE_LINK_FILE1 h5diff_danglelinks1.h5) SET (DANGLE_LINK_FILE2 h5diff_danglelinks2.h5) SET (GRP_RECURSE_FILE1 h5diff_grp_recurse1.h5) @@ -447,6 +452,8 @@ IF (BUILD_TESTING) h5diff_206.out.err h5diff_207.out h5diff_207.out.err + h5diff_208.out + h5diff_208.out.err h5diff_21.out h5diff_21.out.err h5diff_22.out @@ -994,6 +1001,9 @@ ADD_H5_TEST (h5diff_206 0 -c ${FILE2} ${FILE2} g2/dset7 g2/dset8) ADD_H5_TEST (h5diff_207 0 -c ${FILE2} ${FILE2} g2/dset8 g2/dset9) +# not comparable in dataspace of zero dimension size +ADD_H5_TEST (h5diff_208 0 -c ${FILE19} ${FILE20}) + # ############################################################################## # # Links compare without --follow-symlinks nor --no-dangling-links # ############################################################################## diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 66f1ce8..3363b39 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -53,6 +53,8 @@ #define FILE16 "h5diff_extlink_trg.h5" #define FILE17 "h5diff_ext2softlink_src.h5" #define FILE18 "h5diff_ext2softlink_trg.h5" +#define FILE19 "h5diff_dset_zero_dim_size1.h5" +#define FILE20 "h5diff_dset_zero_dim_size2.h5" #define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" #define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" #define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" @@ -78,8 +80,13 @@ #define STR_SIZE 3 #define GBLL ((unsigned long long) 1024 * 1024 *1024 ) - #define MY_LINKCLASS 187 + +/* Dataspace of 0 dimension size */ +#define SPACE1_RANK 2 +#define SPACE1_DIM1 0 +#define SPACE1_DIM2 0 + /* A UD link traversal function. Shouldn't actually be called. */ static hid_t UD_traverse(UNUSED const char * link_name, UNUSED hid_t cur_group, UNUSED const void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id) @@ -110,6 +117,7 @@ static int test_types(const char *fname); static int test_datatypes(const char *fname); static int test_attributes(const char *fname,int make_diffs); static int test_datasets(const char *fname,int make_diffs); +static int test_special_datasets(const char *fname,int make_diffs); static int test_hyperslab(const char *fname,int make_diffs); static int test_link_name(const char *fname1); static int test_soft_links(const char *fname1); @@ -173,6 +181,10 @@ int main(void) test_ext2soft_links(FILE17, FILE18); + /* generate 2 files, the second call creates a similar file with differences */ + test_special_datasets(FILE19,0); + test_special_datasets(FILE20,1); + test_dangle_links(DANGLE_LINK_FILE1, DANGLE_LINK_FILE2); test_group_recurse(GRP_RECURSE_FILE1, GRP_RECURSE_FILE2); @@ -1250,6 +1262,62 @@ int test_datasets(const char *file, } /*------------------------------------------------------------------------- +* Function: test_special_datasets +* +* Purpose: Check datasets with datasapce of zero dimension size. +*------------------------------------------------------------------------- +*/ +static +int test_special_datasets(const char *file, + int make_diffs /* flag to modify data buffers */) +{ + hid_t fid; + hid_t did; + hid_t sid0, sid; + hsize_t dims0[SPACE1_RANK]={SPACE1_DIM1, SPACE1_DIM2}; + hsize_t dims[SPACE1_RANK]={SPACE1_DIM1, SPACE1_DIM2}; + herr_t status; + + /* Create a file */ + if((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + + /* Create a dataset with zero dimension size */ + sid0 = H5Screate_simple(SPACE1_RANK, dims0, NULL); + did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* close dataset */ + status = H5Dclose(did); + assert(status >= 0); + + /* close dataspace */ + status = H5Sclose(sid0); + assert(status >= 0); + + /* Create a dataset with zero dimension size in one file but the other one + * has a dataset with a non-zero dimension size */ + if(make_diffs) { + dims[1] = SPACE1_DIM2 + 4; + } + + sid = H5Screate_simple(SPACE1_RANK, dims, NULL); + did = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* close dataspace */ + status = H5Sclose(sid); + assert(status >= 0); + + /* close dataset */ + status = H5Dclose(did); + assert(status >= 0); + + /* close file */ + status = H5Fclose(fid); + assert(status >= 0); + return status; +} + +/*------------------------------------------------------------------------- * * Purpose: Create test files to compare links, one has longer name than * the other and short name is subset of long name. diff --git a/tools/h5diff/testfiles/h5diff_208.txt b/tools/h5diff/testfiles/h5diff_208.txt new file mode 100644 index 0000000..783be90 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_208.txt @@ -0,0 +1,5 @@ +Not comparable: or is an empty dataset +Not comparable: or is an empty dataset +Not comparable: has rank 2, dimensions [0x0], max dimensions [0x0] +and has rank 2, dimensions [0x4], max dimensions [0x4] +EXIT CODE: 0 diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index dfa5c972..0314e90 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -52,6 +52,8 @@ FILE15=h5diff_extlink_src.h5 FILE16=h5diff_extlink_trg.h5 FILE17=h5diff_ext2softlink_src.h5 FILE18=h5diff_ext2softlink_trg.h5 +FILE19=h5diff_dset_zero_dim_size1.h5 +FILE20=h5diff_dset_zero_dim_size2.h5 DANGLE_LINK_FILE1=h5diff_danglelinks1.h5 DANGLE_LINK_FILE2=h5diff_danglelinks2.h5 # group recursive @@ -636,12 +638,14 @@ TOOLTEST h5diff_204.txt -c $FILE2 $FILE2 g2/dset4 g2/dset5 TOOLTEST h5diff_205.txt -c $FILE2 $FILE2 g2/dset5 g2/dset6 - # not comparable in compound TOOLTEST h5diff_206.txt -c $FILE2 $FILE2 g2/dset7 g2/dset8 TOOLTEST h5diff_207.txt -c $FILE2 $FILE2 g2/dset8 g2/dset9 +# not comparable in dataspace of zero dimension size +TOOLTEST h5diff_208.txt -c $FILE19 $FILE20 + # ############################################################################## # # Links compare without --follow-symlinks nor --no-dangling-links # ############################################################################## diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 05688ec..2010b5c 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -115,6 +115,7 @@ IF (BUILD_TESTING) tnbit.ddl tnofilename.ddl tnullspace.ddl + zerodim.ddl tordergr1.ddl tordergr2.ddl tordergr3.ddl @@ -287,6 +288,7 @@ IF (BUILD_TESTING) tnamed_dtype_attr.h5 tnestedcomp.h5 tnullspace.h5 + zerodim.h5 torderattr.h5 tordergr.h5 tsaf.h5 @@ -785,6 +787,8 @@ IF (BUILD_TESTING) tnofilename.out.err tnullspace.out tnullspace.out.err + zerodim.out + zerodim.out.err tordergr1.out tordergr1.out.err tordergr2.out @@ -1097,6 +1101,9 @@ IF (BUILD_TESTING) # test for displaying dataset and attribute of null space ADD_H5_TEST (tnullspace 0 tnullspace.h5) + # test for displaying dataset and attribute of space with 0 dimension size + ADD_H5_TEST (zerodim 0 zerodim.h5) + # test for long double (some systems do not have long double) #ADD_H5_TEST (tldouble 0 tldouble.h5) @@ -1582,6 +1589,8 @@ IF (BUILD_TESTING) ##Test dataset and attribute of null space. Commented out: ## wait until the XML schema is updated for null space. ## ADD_XML_H5_TEST (tnullspace.h5 0 tnulspace.h5) + ## So is dataspace with 0 dimension size. + ## ADD_XML_H5_TEST (zerodim.h5 0 zerodim.h5) # other options for xml diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 848006e..452441a 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -96,6 +96,7 @@ #define FILE64 "tarray8.h5" #define FILE65 "tattrreg.h5" #define FILE66 "packedbits.h5" +#define FILE67 "zerodim.h5" @@ -177,6 +178,11 @@ const H5L_class_t UD_link_class[1] = {{ #define CDIM2 DIM2/2 #define RANK 2 +/* Dataspace of 0 dimension size */ +#define SPACE3_RANK 2 +#define SPACE3_DIM1 0 +#define SPACE3_DIM2 0 + /* Element selection information */ #define POINT1_NPOINTS 10 @@ -5094,7 +5100,41 @@ static void gent_null_space(void) H5Fclose(fid); } +/*------------------------------------------------------------------------- + * Function: gent_zero_dim_size + * + * Purpose: generates dataset and attribute with dataspace of 0 dimension size + *------------------------------------------------------------------------- + */ +static void gent_zero_dim_size(void) +{ + hid_t fid, root, dataset, space, attr; + hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; + int dset_buf = 10; + int point = 4; + + fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + root = H5Gopen2(fid, "/", H5P_DEFAULT); + + /* dataspace of 0 dimension size */ + space = H5Screate_simple(SPACE3_RANK, dims1, NULL); + /* dataset */ + dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + /* nothing should be written */ + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); + + /* attribute */ + attr = H5Acreate2(root, "attr of 0 dimension size", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */ + + H5Dclose(dataset); + H5Aclose(attr); + H5Gclose(root); + H5Sclose(space); + H5Fclose(fid); +} /*------------------------------------------------------------------------- * Function: make_dset @@ -7109,6 +7149,7 @@ int main(void) gent_compound_complex(); gent_named_dtype_attr(); gent_null_space(); + gent_zero_dim_size(); gent_filters(); gent_fvalues(); diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 581d19a..e50055a 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -568,6 +568,9 @@ TOOLTEST thyperslab.ddl thyperslab.h5 # test for displaying dataset and attribute of null space TOOLTEST tnullspace.ddl tnullspace.h5 +# test for displaying dataset and attribute of space with 0 dimension size +TOOLTEST zerodim.ddl zerodim.h5 + # test for long double (some systems do not have long double) #TOOLTEST tldouble.ddl tldouble.h5 diff --git a/tools/testfiles/zerodim.ddl b/tools/testfiles/zerodim.ddl new file mode 100644 index 0000000..49c0a4c --- /dev/null +++ b/tools/testfiles/zerodim.ddl @@ -0,0 +1,19 @@ +############################# +Expected output for 'h5dump zerodim.h5' +############################# +HDF5 "zerodim.h5" { +GROUP "/" { + ATTRIBUTE "attr of 0 dimension size" { + DATATYPE H5T_STD_U32LE + DATASPACE SIMPLE { ( 0, 0 ) / ( 0, 0 ) } + DATA { + } + } + DATASET "dset of 0 dimension size" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 0, 0 ) / ( 0, 0 ) } + DATA { + } + } +} +} diff --git a/tools/testfiles/zerodim.h5 b/tools/testfiles/zerodim.h5 new file mode 100644 index 0000000..6939353 Binary files /dev/null and b/tools/testfiles/zerodim.h5 differ -- cgit v0.12