summaryrefslogtreecommitdiffstats
path: root/tools/h5diff
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2011-05-10 16:11:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2011-05-10 16:11:11 (GMT)
commitacf8608ce6e64ab46b7242889c359cf40f2f82e7 (patch)
tree0afef4957af90ec6227af1e1bf2717dce7660e8d /tools/h5diff
parent49d12a044ce33b9765e6b20c2e761cd9990e6e9b (diff)
downloadhdf5-acf8608ce6e64ab46b7242889c359cf40f2f82e7.zip
hdf5-acf8608ce6e64ab46b7242889c359cf40f2f82e7.tar.gz
hdf5-acf8608ce6e64ab46b7242889c359cf40f2f82e7.tar.bz2
[svn-r20789] Merged 20724 and 20756 from the trunk to fix HDFFV-7527 concerning
invalid enum value comparisons. Tested on: h5committest
Diffstat (limited to 'tools/h5diff')
-rw-r--r--tools/h5diff/h5diffgentest.c89
-rw-r--r--tools/h5diff/testfiles/h5diff_30.txt9
-rwxr-xr-xtools/h5diff/testfiles/h5diff_enum_invalid_values.h5bin0 -> 2192 bytes
-rwxr-xr-xtools/h5diff/testh5diff.sh12
4 files changed, 110 insertions, 0 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 3ef01a0..2f65fca 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -75,6 +75,8 @@
/* attribute compre with verbose level */
#define ATTR_VERBOSE_LEVEL_FILE1 "h5diff_attr_v_level1.h5"
#define ATTR_VERBOSE_LEVEL_FILE2 "h5diff_attr_v_level2.h5"
+/* file containing valid/invalid enum value mix */
+#define ENUM_INVALID_VALUES "h5diff_enum_invalid_values.h5"
#define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */
#define STR_SIZE 3
@@ -131,6 +133,7 @@ static int test_exclude_obj1(const char *fname1, const char *fname2);
static int test_exclude_obj2(const char *fname1, const char *fname2);
static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new);
static int test_attributes_verbose_level(const char *fname1, const char *fname2);
+static int test_enums(const char *fname);
/* called by test_attributes() and test_datasets() */
static void write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs);
@@ -197,6 +200,13 @@ int main(void)
test_comp_vlen_strings(COMP_VL_STRS_FILE, "group", 1);
test_comp_vlen_strings(COMP_VL_STRS_FILE, "group_copy", 0);
+ /* diff when invalid enum values are present.
+ * This will probably grow to involve more extensive testing of
+ * enums so it has been given its own test file and test (apart
+ * from the basic type testing).
+ */
+ test_enums(ENUM_INVALID_VALUES);
+
return 0;
}
@@ -4021,6 +4031,85 @@ out:
return status;
}
+
+/*-------------------------------------------------------------------------
+*
+* Purpose: Test diffs of enum values which may include invalid values.
+*
+* Programmer: Dana Robinson
+*
+*-------------------------------------------------------------------------*/
+
+static int
+test_enums(const char *fname)
+{
+ hid_t fid = -1;
+
+ hid_t tid = -1;
+ int enum_val = -1;
+
+ /* The data in the two arrays cover the following cases:
+ *
+ * V = valid enum value, I = invalid enum value
+ *
+ * 0: I-I (same value)
+ * 1: V-I
+ * 2: I-V
+ * 3: V-V (same value)
+ * 4: I-I (different values) SKIPPED FOR NOW
+ * 5: V-V (different values)
+ */
+ /* *** NOTE ***
+ *
+ * There is a bug in H5Dread() where invalid enum values are always
+ * returned as -1 so two different invalid enum values cannot be
+ * properly compared. Test 4 has been adjusted to pass here
+ * while we fix the issue.
+ */
+ int data1[6] = {9, 0, 9, 0, 9, 0};
+ /*int data1[6] = {9, 0, 9, 0, 8, 0}; */
+ int data2[6] = {9, 9, 0, 0, 9, 1};
+
+ hsize_t dims = 6;
+
+ herr_t status = SUCCEED;
+
+ /*-----------------------------------------------------------------------
+ * Create the file
+ *---------------------------------------------------------------------*/
+
+ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*-----------------------------------------------------------------------
+ * Create enum types
+ *---------------------------------------------------------------------*/
+
+ tid = H5Tenum_create(H5T_NATIVE_INT);
+ enum_val = 0;
+ status = H5Tenum_insert(tid, "YIN", &enum_val);
+ enum_val = 1;
+ status = H5Tenum_insert(tid, "YANG", &enum_val);
+
+ /*-----------------------------------------------------------------------
+ * Create datasets containing enum data.
+ *---------------------------------------------------------------------*/
+
+ status = write_dset(fid, 1, &dims, "dset1", tid, data1);
+ status = write_dset(fid, 1, &dims, "dset2", tid, data2);
+
+out:
+ /*-----------------------------------------------------------------------
+ * Close
+ *---------------------------------------------------------------------*/
+ if(fid)
+ H5Fclose(fid);
+ if(tid)
+ H5Tclose(tid);
+
+ return status;
+}
+
+
/*-------------------------------------------------------------------------
* Function: write_attr_in
*
diff --git a/tools/h5diff/testfiles/h5diff_30.txt b/tools/h5diff/testfiles/h5diff_30.txt
new file mode 100644
index 0000000..187589a
--- /dev/null
+++ b/tools/h5diff/testfiles/h5diff_30.txt
@@ -0,0 +1,9 @@
+dataset: </dset1> and </dset2>
+size: [6] [6]
+position dset1 dset2 difference
+------------------------------------------------------------
+[ 1 ] YIN **INVALID VALUE**
+[ 2 ] **INVALID VALUE** YIN
+[ 5 ] YIN YANG
+3 differences found
+EXIT CODE: 1
diff --git a/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5 b/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5
new file mode 100755
index 0000000..dd02db9
--- /dev/null
+++ b/tools/h5diff/testfiles/h5diff_enum_invalid_values.h5
Binary files differ
diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh
index 192ca30..7803022 100755
--- a/tools/h5diff/testh5diff.sh
+++ b/tools/h5diff/testh5diff.sh
@@ -76,6 +76,9 @@ COMP_VL_STRS_FILE=h5diff_comp_vl_strs.h5
ATTR_VERBOSE_LEVEL_FILE1=h5diff_attr_v_level1.h5
ATTR_VERBOSE_LEVEL_FILE2=h5diff_attr_v_level2.h5
+# test enum types which may have invalid values
+ENUM_INVALID_VALUES=h5diff_enum_invalid_values.h5
+
TESTNAME=h5diff
EXIT_SUCCESS=0
EXIT_FAILURE=1
@@ -341,6 +344,15 @@ TOOLTEST h5diff_27.txt -v $FILE3 $FILE3 t1 t2
TOOLTEST h5diff_28.txt -v $FILE3 $FILE3 l1 l2
+# ##############################################################################
+# # Enum value tests (may become more comprehensive in the future)
+# ##############################################################################
+
+# 3.0
+TOOLTEST h5diff_30.txt -v $ENUM_INVALID_VALUES $ENUM_INVALID_VALUES dset1 dset2
+
+
+
# ##############################################################################
# # Dataset datatypes