summaryrefslogtreecommitdiffstats
path: root/tools/h5diff/h5diffgentest.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r--tools/h5diff/h5diffgentest.c263
1 files changed, 257 insertions, 6 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 0b5d68f..eb4931d 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -79,6 +79,9 @@ hsize_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024);
/* different structure and obj names */
#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5"
#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5"
+/* only one file has unique objs */
+#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5"
+#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5"
/* compound type with multiple vlen string types */
#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5"
/* attribute compre with verbose level */
@@ -146,6 +149,7 @@ static int test_group_recurse(const char *fname1, const char *fname2);
static int test_group_recurse2(void);
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_exclude_obj3(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);
@@ -153,7 +157,8 @@ static void test_comps_array (const char *fname, const char *dset, const char *a
static void test_comps_vlen (const char *fname, const char *dset,const char *attr, int diff, int is_file_new);
static void test_comps_array_vlen (const char *fname, const char *dset, const char *attr, int diff, int is_file_new);
static void test_comps_vlen_arry (const char *fname, const char *dset,const char *attr, int diff, int is_file_new);
-static void test_non_comparables (const char *fname, int diff);
+static void test_data_nocomparables (const char *fname, int diff);
+static void test_objs_nocomparables (const char *fname1, const char *fname2);
/* 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);
@@ -225,6 +230,7 @@ int main(void)
test_exclude_obj1(EXCLUDE_FILE1_1, EXCLUDE_FILE1_2);
test_exclude_obj2(EXCLUDE_FILE2_1, EXCLUDE_FILE2_2);
+ test_exclude_obj3(EXCLUDE_FILE3_1, EXCLUDE_FILE3_2);
/* diff various multiple vlen and fixlen string types in a compound dataset */
test_comp_vlen_strings(COMP_VL_STRS_FILE, "group", 1);
@@ -257,8 +263,11 @@ int main(void)
* comparable datasets and attributes. All the comparables should display
* differences.
*/
- test_non_comparables(NON_COMPARBLES1,0);
- test_non_comparables(NON_COMPARBLES2,5);
+ test_data_nocomparables(NON_COMPARBLES1,0);
+ test_data_nocomparables(NON_COMPARBLES2,5);
+
+ /* common objects (same name) with different object types. HDFFV-7644 */
+ test_objs_nocomparables(NON_COMPARBLES1, NON_COMPARBLES2);
return 0;
}
@@ -3445,6 +3454,100 @@ out:
/*-------------------------------------------------------------------------
*
+* Purpose: Create test files for excluding obj.
+* Only one file contains unique objs. Common objs are same.
+* Test : exclude unique objs to verify the rest are same
+* - HDFFV-7837
+*
+* Programmer: Jonathan Kim (Mar, 19, 2012)
+*
+*-------------------------------------------------------------------------*/
+static int test_exclude_obj3(const char *fname1, const char *fname2)
+{
+ hid_t fid1=0;
+ hid_t fid2=0;
+ hid_t gid1=0;
+ hsize_t dims2[2] = {2,4};
+ int data1[4][2] = {{0,0},{0,0},{0,0},{0,0}};
+ herr_t status = SUCCEED;
+
+ /*-----------------------------------------------------------------------
+ * Create file(s)
+ *------------------------------------------------------------------------*/
+ fid1 = H5Fcreate (fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ fid2 = H5Fcreate (fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if (fid2 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+
+ /*-----------------------------------------------------------------------
+ * Group
+ *------------------------------------------------------------------------*/
+ /* file1 */
+ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (gid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /*-----------------------------------------------------------------------
+ * Datasets
+ *------------------------------------------------------------------------*/
+ /* file1 */
+ status = write_dset(fid1,2,dims2,"dset1",H5T_NATIVE_INT,data1);
+ if (status == FAIL)
+ {
+ fprintf(stderr, "Error: %s> write_dset failed\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ status = write_dset(gid1,2,dims2,"dset",H5T_NATIVE_INT,data1);
+ if (status == FAIL)
+ {
+ fprintf(stderr, "Error: %s> write_dset failed\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /* file2 */
+ status = write_dset(fid2,2,dims2,"dset1",H5T_NATIVE_INT,data1);
+ if (status == FAIL)
+ {
+ fprintf(stderr, "Error: %s> write_dset failed\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+out:
+ /*-----------------------------------------------------------------------
+ * Close
+ *-----------------------------------------------------------------------*/
+ if(fid1)
+ H5Fclose(fid1);
+ if(fid2)
+ H5Fclose(fid2);
+ if(gid1)
+ H5Gclose(gid1);
+
+ return status;
+}
+
+/*-------------------------------------------------------------------------
+*
* Purpose: Create test files for multiple variable length string/string array
* along with fixed length string/string array types in
* a compound type dataset.
@@ -4789,7 +4892,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch
/*-------------------------------------------------------------------------
-* Function: test_non_comparables
+* Function: test_data_nocomparables
*
* Purpose:
* Create test files with non-comparable dataset and attributes with
@@ -4798,7 +4901,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch
*
*-------------------------------------------------------------------------*/
#define DIM_ARRY 3
-static void test_non_comparables (const char * fname, int make_diffs)
+static void test_data_nocomparables (const char * fname, int make_diffs)
{
hid_t fid=0;
hid_t gid1=0;
@@ -4818,7 +4921,6 @@ static void test_non_comparables (const char * fname, int make_diffs)
int rank_attr;
char data1_str[DIM_ARRY][STR_SIZE]= {"ab","cd","ef"};
herr_t status = SUCCEED;
- int i;
void *dset_data_ptr1=NULL;
void *dset_data_ptr2=NULL;
void *dset_data_ptr3=NULL;
@@ -5001,6 +5103,155 @@ out:
}
/*-------------------------------------------------------------------------
+* Function: test_objs_nocomparables
+*
+* Purpose:
+* Create test files with common objects (same name) but different object
+* types.
+* h5diff should show non-comparable output from these common objects.
+*-------------------------------------------------------------------------*/
+static void test_objs_nocomparables(const char *fname1, const char *fname2)
+{
+ herr_t status = SUCCEED;
+ hid_t fid1=0;
+ hid_t fid2=0;
+ hid_t topgid1=0;
+ hid_t topgid2=0;
+ hid_t gid1=0;
+ hid_t did1=0;
+ hid_t tid1=0;
+ hid_t gid2=0;
+ hid_t did2=0;
+ hid_t tid2=0;
+ hsize_t dims[1] = {DIM_ARRY};
+ int data1[DIM_ARRY] = {1,1,1};
+ int data2[DIM_ARRY] = {2,2,2};
+
+ /*-----------------------------------------------------------------------
+ * Open file(s) to add objects
+ *------------------------------------------------------------------------*/
+ /* file1 */
+ fid1 = H5Fopen (fname1, H5F_ACC_RDWR, H5P_DEFAULT);
+ if (fid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /* file2 */
+ fid2 = H5Fopen (fname2, H5F_ACC_RDWR, H5P_DEFAULT);
+ if (fid2 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+ /*-----------------------------------------------------------------------
+ * in file1 : add member objects
+ *------------------------------------------------------------------------*/
+ /* parent group */
+ topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (topgid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /* dataset */
+ status = write_dset(topgid1, 1, dims,"obj1", H5T_NATIVE_INT, data1);
+ if (status == FAIL)
+ {
+ fprintf(stderr, "Error: %s> write_dset failed\n", fname1);
+ goto out;
+ }
+
+ /* group */
+ gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (gid1 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1);
+ status = FAIL;
+ goto out;
+ }
+
+ /* committed type */
+ tid1 = H5Tcopy(H5T_NATIVE_INT);
+ status = H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (status < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1);
+ goto out;
+ }
+
+ /*-----------------------------------------------------------------------
+ * in file2 : add member objects
+ *------------------------------------------------------------------------*/
+ /* parent group */
+ topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (topgid2 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+ /* group */
+ gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (gid2 < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2);
+ status = FAIL;
+ goto out;
+ }
+
+ /* committed type */
+ tid2 = H5Tcopy(H5T_NATIVE_INT);
+ status = H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (status < 0)
+ {
+ fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2);
+ goto out;
+ }
+
+ /* dataset */
+ status = write_dset(topgid2, 1, dims,"obj3", H5T_NATIVE_INT, data2);
+ if (status == FAIL)
+ {
+ fprintf(stderr, "Error: %s> write_dset failed\n", fname2);
+ goto out;
+ }
+
+out:
+ /*-----------------------------------------------------------------------
+ * Close IDs
+ *-----------------------------------------------------------------------*/
+ if(fid1)
+ H5Fclose(fid1);
+ if(fid2)
+ H5Fclose(fid2);
+ if(topgid1)
+ H5Gclose(topgid1);
+ if(topgid2)
+ H5Gclose(topgid2);
+ if(did1)
+ H5Dclose(did1);
+ if(did2)
+ H5Dclose(did2);
+ if(gid1)
+ H5Gclose(gid1);
+ if(gid2)
+ H5Gclose(gid2);
+ if(tid1)
+ H5Tclose(tid1);
+ if(tid2)
+ H5Tclose(tid2);
+
+}
+
+/*-------------------------------------------------------------------------
* Function: write_attr_in
*
* Purpose: write attributes in LOC_ID (dataset, group, named datatype)