summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2011-04-20 20:51:22 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2011-04-20 20:51:22 (GMT)
commit614e46f270a2acc01a9d15c456420320f207086b (patch)
tree284b19d2abb4231f366169835d2965a653de7f93 /tools
parent27be7d1e2d95618c72bbefbed54e644b3b2d21ae (diff)
downloadhdf5-614e46f270a2acc01a9d15c456420320f207086b.zip
hdf5-614e46f270a2acc01a9d15c456420320f207086b.tar.gz
hdf5-614e46f270a2acc01a9d15c456420320f207086b.tar.bz2
[svn-r20577] 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, linew, and amani. Tested CMAKE on jam.
Diffstat (limited to 'tools')
-rw-r--r--tools/h5diff/CMakeLists.txt10
-rw-r--r--tools/h5diff/h5diffgentest.c70
-rw-r--r--tools/h5diff/testfiles/h5diff_208.txt5
-rwxr-xr-xtools/h5diff/testh5diff.sh6
-rw-r--r--tools/h5dump/CMakeLists.txt9
-rw-r--r--tools/h5dump/h5dumpgentest.c41
-rw-r--r--tools/h5dump/testh5dump.sh.in3
-rw-r--r--tools/testfiles/zerodim.ddl19
-rw-r--r--tools/testfiles/zerodim.h5bin0 -> 1528 bytes
9 files changed, 161 insertions, 2 deletions
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: </dset1> or </dset1> is an empty dataset
+Not comparable: </dset2> or </dset2> is an empty dataset
+Not comparable: </dset2> has rank 2, dimensions [0x0], max dimensions [0x0]
+and </dset2> has rank 2, dimensions [0x4], max dimensions [0x4]
+EXIT CODE: 0
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index 1a4d5e8..cb213dc 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
@@ -627,12 +629,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 b732bfe..30b40da 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
@@ -711,6 +713,8 @@ IF (BUILD_TESTING)
tnofilename.out.err
tnullspace.out
tnullspace.out.err
+ zerodim.out
+ zerodim.out.err
tordergr1.out
tordergr1.out.err
tordergr2.out
@@ -1021,6 +1025,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)
@@ -1327,6 +1334,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 ebdff41..d2af91c 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -96,6 +96,7 @@
#define FILE64 "tattrreg.h5"
#define FILE65 "file_space.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
@@ -5103,7 +5109,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
@@ -7144,6 +7184,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 512238d..9b56f7c 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -562,6 +562,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
--- /dev/null
+++ b/tools/testfiles/zerodim.h5
Binary files differ