diff options
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/CMakeLists.txt | 36 | ||||
-rw-r--r-- | tools/h5diff/h5diff_common.c | 38 | ||||
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 293 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_480.txt | 17 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_481.txt | 30 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_482.txt | 17 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_483.txt | 18 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_exclude1-1.h5 | bin | 0 -> 5064 bytes | |||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_exclude1-2.h5 | bin | 0 -> 5064 bytes | |||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_exclude2-1.h5 | bin | 0 -> 5064 bytes | |||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_exclude2-2.h5 | bin | 0 -> 6056 bytes | |||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 25 |
12 files changed, 474 insertions, 0 deletions
diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index c31f650..a22e0e3 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -114,6 +114,10 @@ IF (BUILD_TESTING) h5diff_457.txt h5diff_458.txt h5diff_459.txt + h5diff_480.txt + h5diff_481.txt + h5diff_482.txt + h5diff_483.txt h5diff_50.txt h5diff_51.txt h5diff_52.txt @@ -190,6 +194,10 @@ IF (BUILD_TESTING) h5diff_danglelinks2.h5 h5diff_grp_recurse1.h5 h5diff_grp_recurse2.h5 + h5diff_exclude1-1.h5 + h5diff_exclude1-2.h5 + h5diff_exclude2-1.h5 + h5diff_exclude2-2.h5 ) FOREACH (txt_file ${HDF5_REFERENCE_FILES}) @@ -296,6 +304,13 @@ SET (DANGLE_LINK_FILE1 h5diff_danglelinks1.h5) SET (DANGLE_LINK_FILE2 h5diff_danglelinks2.h5) SET (GRP_RECURSE_FILE1 h5diff_grp_recurse1.h5) SET (GRP_RECURSE_FILE2 h5diff_grp_recurse2.h5) +# same structure, same obj name with different value +SET (EXCLUDE_FILE1_1 h5diff_exclude1-1.h5) +SET (EXCLUDE_FILE1_2 h5diff_exclude1-2.h5) +# different structure and obj names +SET (EXCLUDE_FILE2_1 h5diff_exclude2-1.h5) +SET (EXCLUDE_FILE2_2 h5diff_exclude2-2.h5) + # ############################################################################ # # Common usage @@ -716,6 +731,27 @@ ADD_H5_TEST (h5diff_512 -v --follow-symlinks ${GRP_RECURSE_FILE1} ${GRP_RECURSE_ # circled soft2ext-link vs soft2ext-link ADD_H5_TEST (h5diff_513 -v ${GRP_RECURSE_FILE1} ${GRP_RECURSE_FILE2} /slink_grp10 /slink_grp11) ADD_H5_TEST (h5diff_514 -v --follow-symlinks ${GRP_RECURSE_FILE1} ${GRP_RECURSE_FILE2} /slink_grp10 /slink_grp11) + + +# ############################################################################## +# # Exclude path (--exclude-path) +# ############################################################################## +# +# Same structure, same names and different value. +# +# Exclude the object with different value. Expect return - same +ADD_H5_TEST (h5diff_480 0 -v --exclude-path /group1/dset3 ${EXCLUDE_FILE1_1} ${EXCLUDE_FILE1_2}) +# Verify different by not excluding. Expect return - diff +ADD_H5_TEST (h5diff_481 1 -v ${EXCLUDE_FILE1_1} ${EXCLUDE_FILE1_2}) + +# +# Different structure, different names. +# +# Exclude all the different objects. Expect return - same +ADD_H5_TEST (h5diff_482 0 -v --exclude-path "/group1" --exclude-path "/dset1" ${EXCLUDE_FILE2_1} ${EXCLUDE_FILE2_2}) +# Exclude only some different objects. Expect return - diff +ADD_H5_TEST (h5diff_483 1 -v --exclude-path "/group1" ${EXCLUDE_FILE2_1} ${EXCLUDE_FILE2_2}) + ENDIF (BUILD_TESTING) diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index b897a7f..a678b2f 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -42,6 +42,7 @@ static struct long_options l_opts[] = { { "use-system-epsilon", no_arg, 'e' }, { "follow-symlinks", no_arg, 'l' }, { "no-dangling-links", no_arg, 'x' }, + { "exclude-path", require_arg, 'E' }, { NULL, 0, '\0' } }; @@ -64,6 +65,7 @@ void parse_command_line(int argc, { int opt; + struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node; /* process the command-line */ memset(options, 0, sizeof (diff_opt_t)); @@ -74,6 +76,9 @@ void parse_command_line(int argc, /* NaNs are handled by default */ options->do_nans = 1; + /* init for exclude-path option */ + exclude_head = NULL; + /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { @@ -104,6 +109,35 @@ void parse_command_line(int argc, case 'x': options->no_dangle_links = 1; break; + case 'E': + options->exclude_path = 1; + + /* create linked list of excluding objects */ + if( (exclude_node = (struct exclude_path_list*) malloc(sizeof(struct exclude_path_list))) == NULL) + { + printf("Error: lack of memory!\n"); + h5diff_exit(EXIT_FAILURE); + } + + /* init */ + exclude_node->obj_path = opt_arg; + exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; + exclude_prev = exclude_head; + + if (NULL == exclude_head) + { + exclude_head = exclude_node; + exclude_head->next = NULL; + } + else + { + while(NULL != exclude_prev->next) + exclude_prev=exclude_prev->next; + + exclude_node->next = NULL; + exclude_prev->next = exclude_node; + } + break; case 'd': options->d=1; @@ -163,6 +197,10 @@ void parse_command_line(int argc, } } + /* if exclude-path option is used, keep the exclude path list */ + if (options->exclude_path) + options->exclude = exclude_head; + /* if use system epsilon, unset -p and -d option */ if (options->use_system_epsilon) options->d = options->p = 0; diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 1f6cb2a..20797f4 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -57,6 +57,12 @@ #define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" #define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" #define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" +/* same structure, same obj name with different value */ +#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" +#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" +/* different structure and obj names */ +#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" +#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 @@ -102,6 +108,8 @@ static int test_external_links(const char *fname1, const char *fname2); static int test_ext2soft_links(const char *fname1, const char *fname2); static int test_dangle_links(const char *fname1, const char *fname2); static int test_group_recurse(const char *fname1, const char *fname2); +static int test_exclude_obj1(const char *fname1, const char *fname2); +static int test_exclude_obj2(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); @@ -153,6 +161,10 @@ int main(void) test_group_recurse(GRP_RECURSE_FILE1, GRP_RECURSE_FILE2); + test_exclude_obj1(EXCLUDE_FILE1_1, EXCLUDE_FILE1_2); + test_exclude_obj2(EXCLUDE_FILE2_1, EXCLUDE_FILE2_2); + + return 0; } @@ -2292,6 +2304,287 @@ out: } /*------------------------------------------------------------------------- +* +* Purpose: Create test files for excluding obj. +* Same structure, same obj names +* Test : exclude obj with different value to verify the rest are same +* +* Programmer: Jonathan Kim (July, 21, 2010) +* +*-------------------------------------------------------------------------*/ +static int test_exclude_obj1(const char *fname1, const char *fname2) +{ + hid_t fid1=0; + hid_t fid2=0; + hid_t gid1=0; + hid_t gid2=0; + hsize_t dims2[2] = {2,4}; + int data1[4][2] = {{0,0},{0,0},{0,0},{0,0}}; + int data2[4][2] = {{0,1},{2,3},{1,2},{3,4}}; + 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; + } + + /* file2 */ + gid2 = H5Gcreate2(fid2, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + if (gid2 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + 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,"dset2",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,"dset3",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; + } + + status = write_dset(gid2,2,dims2,"dset2",H5T_NATIVE_INT,data1); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + status = FAIL; + goto out; + } + + status = write_dset(gid2,2,dims2,"dset3",H5T_NATIVE_INT,data2); + 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); + if(gid2) + H5Gclose(gid2); + + return status; +} + +/*------------------------------------------------------------------------- +* +* Purpose: Create test files for excluding obj. +* different structure and name +* Test : exclude different objs to verify the rest are same +* +* Programmer: Jonathan Kim (July, 21, 2010) +* +*-------------------------------------------------------------------------*/ +static int test_exclude_obj2(const char *fname1, const char *fname2) +{ + hid_t fid1=0; + hid_t fid2=0; + hid_t gid1=0; + hid_t gid2=0; + hid_t gid3=0; + hsize_t dims2[2] = {2,4}; + int data1[4][2] = {{0,0},{0,0},{0,0},{0,0}}; + int data2[4][2] = {{0,1},{2,3},{1,2},{3,4}}; + 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, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid1 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + status = FAIL; + goto out; + } + + /* file2 */ + gid2 = H5Gcreate2(fid2, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + if (gid2 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + status = FAIL; + goto out; + } + + /* subset name from group10 */ + gid3 = H5Gcreate2(fid2, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + if (gid3 < 0) + { + fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + status = FAIL; + goto out; + } + + + /*----------------------------------------------------------------------- + * Datasets + *------------------------------------------------------------------------*/ + /* file1 */ + status = write_dset(fid1,2,dims2,"dset10",H5T_NATIVE_INT,data1); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + status = FAIL; + goto out; + } + + 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,"dset2",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,"dset10",H5T_NATIVE_INT,data1); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + status = FAIL; + goto out; + } + + status = write_dset(gid2,2,dims2,"dset2",H5T_NATIVE_INT,data1); + if (status == FAIL) + { + fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + status = FAIL; + goto out; + } + + status = write_dset(gid3,2,dims2,"dset3",H5T_NATIVE_INT,data2); + 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); + if(gid2) + H5Gclose(gid2); + if(gid3) + H5Gclose(gid3); + + return status; +} + +/*------------------------------------------------------------------------- * Function: write_attr_in * * Purpose: write attributes in LOC_ID (dataset, group, named datatype) diff --git a/tools/h5diff/testfiles/h5diff_480.txt b/tools/h5diff/testfiles/h5diff_480.txt new file mode 100644 index 0000000..3e1f900 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_480.txt @@ -0,0 +1,17 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset1 + x x /group1 + x x /group1/dset2 + +group : </> and </> +0 differences found +dataset: </dset1> and </dset1> +0 differences found +group : </group1> and </group1> +0 differences found +dataset: </group1/dset2> and </group1/dset2> +0 differences found +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_481.txt b/tools/h5diff/testfiles/h5diff_481.txt new file mode 100644 index 0000000..c4f2448 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_481.txt @@ -0,0 +1,30 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset1 + x x /group1 + x x /group1/dset2 + x x /group1/dset3 + +group : </> and </> +0 differences found +dataset: </dset1> and </dset1> +0 differences found +group : </group1> and </group1> +0 differences found +dataset: </group1/dset2> and </group1/dset2> +0 differences found +dataset: </group1/dset3> and </group1/dset3> +size: [2x4] [2x4] +position dset3 dset3 difference +------------------------------------------------------------ +[ 0 1 ] 0 1 1 +[ 0 2 ] 0 2 2 +[ 0 3 ] 0 3 3 +[ 1 0 ] 0 1 1 +[ 1 1 ] 0 2 2 +[ 1 2 ] 0 3 3 +[ 1 3 ] 0 4 4 +7 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_482.txt b/tools/h5diff/testfiles/h5diff_482.txt new file mode 100644 index 0000000..5b3c8c1 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_482.txt @@ -0,0 +1,17 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset10 + x x /group10 + x x /group10/dset2 + +group : </> and </> +0 differences found +dataset: </dset10> and </dset10> +0 differences found +group : </group10> and </group10> +0 differences found +dataset: </group10/dset2> and </group10/dset2> +0 differences found +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_483.txt b/tools/h5diff/testfiles/h5diff_483.txt new file mode 100644 index 0000000..a45e928 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_483.txt @@ -0,0 +1,18 @@ + +file1 file2 +--------------------------------------- + x x / + x /dset1 + x x /dset10 + x x /group10 + x x /group10/dset2 + +group : </> and </> +0 differences found +dataset: </dset10> and </dset10> +0 differences found +group : </group10> and </group10> +0 differences found +dataset: </group10/dset2> and </group10/dset2> +0 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_exclude1-1.h5 b/tools/h5diff/testfiles/h5diff_exclude1-1.h5 Binary files differnew file mode 100644 index 0000000..8b675ea --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_exclude1-1.h5 diff --git a/tools/h5diff/testfiles/h5diff_exclude1-2.h5 b/tools/h5diff/testfiles/h5diff_exclude1-2.h5 Binary files differnew file mode 100644 index 0000000..78854cd --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_exclude1-2.h5 diff --git a/tools/h5diff/testfiles/h5diff_exclude2-1.h5 b/tools/h5diff/testfiles/h5diff_exclude2-1.h5 Binary files differnew file mode 100644 index 0000000..8923111 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_exclude2-1.h5 diff --git a/tools/h5diff/testfiles/h5diff_exclude2-2.h5 b/tools/h5diff/testfiles/h5diff_exclude2-2.h5 Binary files differnew file mode 100644 index 0000000..9e42007 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_exclude2-2.h5 diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index f9d58c2..71d78e7 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -56,6 +56,12 @@ DANGLE_LINK_FILE1=h5diff_danglelinks1.h5 DANGLE_LINK_FILE2=h5diff_danglelinks2.h5 GRP_RECURSE_FILE1=h5diff_grp_recurse1.h5 GRP_RECURSE_FILE2=h5diff_grp_recurse2.h5 +# same structure, same obj name with different value +EXCLUDE_FILE1_1=h5diff_exclude1-1.h5 +EXCLUDE_FILE1_2=h5diff_exclude1-2.h5 +# different structure and obj names +EXCLUDE_FILE2_1=h5diff_exclude2-1.h5 +EXCLUDE_FILE2_2=h5diff_exclude2-2.h5 TESTNAME=h5diff EXIT_SUCCESS=0 @@ -727,6 +733,25 @@ TOOLTEST h5diff_512.txt -v --follow-symlinks $GRP_RECURSE_FILE1 $GRP_RECURSE_FIL TOOLTEST h5diff_513.txt -v $GRP_RECURSE_FILE1 $GRP_RECURSE_FILE2 /slink_grp10 /slink_grp11 TOOLTEST h5diff_514.txt -v --follow-symlinks $GRP_RECURSE_FILE1 $GRP_RECURSE_FILE2 /slink_grp10 /slink_grp11 +# ############################################################################## +# # Exclude objects (--exclude-path) +# ############################################################################## +# +# Same structure, same names and different value. +# +# Exclude the object with different value. Expect return - same +TOOLTEST h5diff_480.txt -v --exclude-path /group1/dset3 $EXCLUDE_FILE1_1 $EXCLUDE_FILE1_2 +# Verify different by not excluding. Expect return - diff +TOOLTEST h5diff_481.txt -v $EXCLUDE_FILE1_1 $EXCLUDE_FILE1_2 + +# +# Different structure, different names. +# +# Exclude all the different objects. Expect return - same +TOOLTEST h5diff_482.txt -v --exclude-path "/group1" --exclude-path "/dset1" $EXCLUDE_FILE2_1 $EXCLUDE_FILE2_2 +# Exclude only some different objects. Expect return - diff +TOOLTEST h5diff_483.txt -v --exclude-path "/group1" $EXCLUDE_FILE2_1 $EXCLUDE_FILE2_2 + # ############################################################################## |