summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
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/h5diff
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/h5diff')
-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
4 files changed, 89 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
# ##############################################################################