diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-04-02 18:44:12 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-04-02 18:44:12 (GMT) |
commit | febe7d0bd9c74b3e238870e6ce50b1b1a8258221 (patch) | |
tree | a14aaeea6f7a356f018f3d2978de0f7f696f7c8e /tools/h5diff | |
parent | 18b98b4298afd4beacf3ddca70f87c104d2002b3 (diff) | |
download | hdf5-febe7d0bd9c74b3e238870e6ce50b1b1a8258221.zip hdf5-febe7d0bd9c74b3e238870e6ce50b1b1a8258221.tar.gz hdf5-febe7d0bd9c74b3e238870e6ce50b1b1a8258221.tar.bz2 |
[svn-r6563] Purpose:
added test script for h5diff
code cleaning for alpha release
makefile now generates the h5difftst.c program that generates 2 .h5 files for testing
Description:
the .sh script runs several runs of h5diff and compares the output
with a predifined output located in /tools/testfiles (.txt files)
righ now it has only one test
Solution:
Platforms tested:
linux (other platforms later , ok !? )
Misc. update:
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/Makefile.in | 12 | ||||
-rw-r--r-- | tools/h5diff/h5diff.c | 695 | ||||
-rw-r--r-- | tools/h5diff/h5difftst.c | 388 | ||||
-rw-r--r-- | tools/h5diff/h5trav.c | 71 | ||||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 53 |
5 files changed, 485 insertions, 734 deletions
diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in index a48f41d..4a56caa 100644 --- a/tools/h5diff/Makefile.in +++ b/tools/h5diff/Makefile.in @@ -26,8 +26,8 @@ CPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/src -I$(top_srcdir)/src \ ## Test programs and scripts. ## -TEST_PROGS= -TEST_SCRIPTS= +TEST_PROGS=h5difftst +TEST_SCRIPTS=$(srcdir)/testh5diff.sh ## These are our main targets: library and tools. ## @@ -44,10 +44,10 @@ PUB_LIB= ## Source and object files for programs... ## -PROG_SRC=h5diff.c h5trav.c +PROG_SRC=h5diff.c h5trav.c h5difftst.c PROG_OBJ=$(PROG_SRC:.c=.lo) -PRIVATE_HDR= +PRIVATE_HDR=h5trav.h ## Source and object files for the tests ## @@ -66,4 +66,8 @@ $(PROGS): $(LIBTOOLS) $(LIBHDF5) h5diff: h5diff.lo h5trav.lo @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5diff.lo h5trav.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) +h5difftst: h5difftst.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ h5difftst.lo $(LIBTOOLS) $(LIBHDF5) $(LDFLAGS) $(LIBS) + + @CONCLUDE@ diff --git a/tools/h5diff/h5diff.c b/tools/h5diff/h5diff.c index 011d151..5b12ec7 100644 --- a/tools/h5diff/h5diff.c +++ b/tools/h5diff/h5diff.c @@ -1,4 +1,18 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include <stdio.h> #include <stdlib.h> @@ -10,38 +24,11 @@ #include "hdf5.h" #include "h5trav.h" - -/* - -dset1 dset2 h5diff_test1.h5 h5diff_test2.h5 -dset1 dset2 -l h5diff_test1.h5 h5diff_test2.h5 -h5diff_test1.h5 h5diff_test2.h5 -dset1 dset2 -r h5diff_test1.h5 h5diff_test2.h5 -dset1 dset2 -n 2 h5diff_test1.h5 h5diff_test2.h5 -dset3 dset4 -d 0.01 h5diff_test1.h5 h5diff_test2.h5 -dset5 dset6 -p 0.05 h5diff_test1.h5 h5diff_test2.h5 -dset5 dset7 h5diff_test1.h5 h5diff_test2.h5 -dset8 dset9 h5diff_test2.h5 h5diff_test2.h5 -dset11 dset12 h5diff_test1.h5 h5diff_test2.h5 -DATASET=HISTORY/DN wrfout_01_0hdf5.h5 wrfout_phdf5.h5 -cmp-1-x.h5 cmp-1-y.h5 -*/ - - #define FFORMAT "%-15g %-15g %-15g\n" #define IFORMAT "%-15d %-15d %-15d\n" #define SPACES " " - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - typedef struct options_t { int l_; /* list */ @@ -55,7 +42,6 @@ typedef struct options_t } options_t; int do_test_files(); - int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, char *obj2_name, options_t options ); int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank, @@ -65,18 +51,14 @@ void print_pos( int *ph, int curr_pos, int *acc, void print_class( H5T_class_t tclass, char *sclass ); hid_t fixtype( hid_t f_type ); void list( const char *filename, int nobjects, info_t *info ); - void diff( hid_t file1_id, char *obj1_name, hid_t file2_id, char *obj2_name, options_t options, int type ); - - void compare( hid_t file1_id, char *obj1_name, int nobjects1, info_t *info1, hid_t file2_id, char *obj2_name, int nobjects2, info_t *info2, options_t options ); void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, hid_t file2_id, char *file2_name, int nobjects2, info_t *info2, options_t options ); - int check_n_input( char * ); int check_f_input( char * ); @@ -124,9 +106,9 @@ void usage( const char *progname ) /*------------------------------------------------------------------------- * Function: main * - * Purpose: H5diff + * Purpose: H5diff main program * - * Return: Success: 0, Failure: 1 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -161,19 +143,12 @@ int main(int argc, const char *argv[]) char *obj1_name = NULL; char *obj2_name = NULL; - - -#if 1 - do_test_files(); -#endif - - /*------------------------------------------------------------------------- * parse command line options *------------------------------------------------------------------------- */ - if (argc < 2) { + if (argc < 3) { usage( progname ); exit(EXIT_FAILURE); } @@ -445,9 +420,6 @@ int check_f_input( char *str ) return 1; } - - - /*------------------------------------------------------------------------- * Function: list * @@ -674,7 +646,6 @@ int compare_object( char *obj1, char *obj2 ) } - /*------------------------------------------------------------------------- * Function: match * @@ -708,7 +679,7 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, cmp = compare_object( info1[curr1].name, info2[curr2].name ); if ( cmp == 0 ) { - printf( "%s found in file 1 <%s> and %s found in file 2 <%s>\n", + printf( "<%s> found in <%s> and <%s> found in <%s>\n", info1[curr1].name, file1_name, info2[curr2].name, file2_name); /* do the diff */ @@ -722,14 +693,14 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, } else if ( cmp < 0 ) { - printf( "%s is in file 1 <%s>, but not in file 2 <%s>\n", info1[curr1].name, + printf( "<%s> is in <%s>, but not in <%s>\n", info1[curr1].name, file1_name, file2_name); curr1++; } else { - printf( "%s is in file 2 <%s>, but not in file 1 <%s>\n", info2[curr2].name, - file1_name, file2_name); + printf( "<%s> is in <%s>, but not in <%s>\n", info2[curr2].name, + file2_name, file1_name); curr2++; } @@ -743,7 +714,7 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, { while ( curr1<nobjects1 ) { - printf( "%s is in file 1 <%s>, but not in file 2 <%s>\n", info1[curr1].name, + printf( "<%s> is in <%s>, but not in <%s>\n", info1[curr1].name, file1_name, file2_name); curr1++; } @@ -754,7 +725,7 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, { while ( curr2<nobjects2 ) { - printf( "%s is in file 2 <%s>, but not in file 1 <%s>\n", info2[curr2].name, + printf( "<%s> is in <%s>, but not in <%s>\n", info2[curr2].name, file1_name, file2_name); curr2++; } @@ -763,7 +734,6 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, } - /*------------------------------------------------------------------------- * Function: diff_dataset * @@ -782,8 +752,6 @@ void match( hid_t file1_id, char *file1_name, int nobjects1, info_t *info1, *------------------------------------------------------------------------- */ - - int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, char *obj2_name, options_t options ) { @@ -811,7 +779,6 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, H5Eget_auto(&func, &edata); H5Eset_auto(NULL, NULL); - /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- @@ -892,13 +859,11 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, goto out; } - /*------------------------------------------------------------------------- * check for non supported classes *------------------------------------------------------------------------- */ - switch (tclass1) { case H5T_TIME: @@ -930,9 +895,6 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, goto out; } - - - /*------------------------------------------------------------------------- * check for the same rank *------------------------------------------------------------------------- @@ -955,7 +917,6 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, goto out; } - /*------------------------------------------------------------------------- * check for the same dimensionality *------------------------------------------------------------------------- @@ -1004,9 +965,6 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, goto out; } - - - /*------------------------------------------------------------------------- * memory type *------------------------------------------------------------------------- @@ -1037,13 +995,11 @@ int diff_dataset( hid_t file1_id, hid_t file2_id, char *obj1_name, free((char *) buf1); free((char *) buf2); - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - out: /* Close */ @@ -1058,14 +1014,12 @@ out: } - - /*------------------------------------------------------------------------- * Function: array_diff * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -1077,7 +1031,6 @@ out: * *------------------------------------------------------------------------- */ - int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank, hsize_t *dims, options_t options, char *obj1, char *obj2 ) @@ -1628,8 +1581,6 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank dptr1++; dptr2++; } - - break; default: @@ -1638,7 +1589,6 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank } /*switch*/ - break; /* H5T_FLOAT 8 */ @@ -1667,8 +1617,6 @@ int array_diff( void *buf1, void *buf2, hsize_t tot_cnt, hid_t type_id, int rank *------------------------------------------------------------------------- */ - - void print_pos( int *ph, int curr_pos, int *acc, int *pos, int rank, char *obj1, char *obj2 ) { @@ -1698,16 +1646,12 @@ void print_pos( int *ph, int curr_pos, int *acc, printf("%d ", pos[i] ); } printf("]" ); - - } - - /*------------------------------------------------------------------------- * Function: print_class * - * Purpose: + * Purpose: print the class name * * Return: * @@ -1841,592 +1785,3 @@ hid_t fixtype(hid_t f_type) } -/*------------------------------------------------------------------------- - * do some test files - *------------------------------------------------------------------------- - */ - -int do_test_files() -{ - - hid_t file1_id, file2_id; - hid_t dataset_id; - hid_t space_id; - hid_t group_id, group2_id; - hid_t type_id; - hsize_t dims [1] = { 7 }; - hsize_t dims2 [2] = { 3,2 }; - hsize_t dims3 [2] = { 3,3 }; - int data1[7] = {1,1,1,1,1,1,1}; - int data2[7] = {1,1,1,4,5,6,7}; - float data3[7] = {1,1,3,4,5,6,7}; - float data4[7] = {1,1,3.02f,4.002f,5.00002f,6,7}; - float data5[3][2] = {1,1,3,4,5,6}; - float data6[3][2] = {1,1.1f,3.02f,4.002f,5.00002f,6}; - float data7[3][3] = {1,1,3,4,5,6,7,8,9}; - double data8[3][2] = {1,1,3.40505e-9,4,5,6}; - double data9[3][2] = {1,1,3.58911e-9,4,5,6}; - char data10[] = {"A string"}; - long data11[7] = {1,1,1,1,1,1,1}; - long data12[7] = {1,1,1,4,5,6,7}; - herr_t status; - -/*------------------------------------------------------------------------- - * Create two files - *------------------------------------------------------------------------- - */ - - /* Create a file */ - file1_id = H5Fcreate ("h5diff_test1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create a file */ - file2_id = H5Fcreate ("h5diff_test2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - -/*------------------------------------------------------------------------- - * Make dataset "dset1" on file1 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset1" */ - dataset_id = H5Dcreate(file1_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset3" on file1 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset3" */ - dataset_id = H5Dcreate(file1_id,"dset3",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data3); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - - -/*------------------------------------------------------------------------- - * Make dataset "g1/dset1" on file1 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a group. */ - group_id = H5Gcreate(file1_id, "g1", 0); - - /* Create a dataset "g1/dset1" */ - dataset_id = H5Dcreate(group_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Gclose(group_id); - status = H5Sclose(space_id); - - -/*------------------------------------------------------------------------- - * Make dataset "dset1" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset1" */ - dataset_id = H5Dcreate(file2_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - - -/*------------------------------------------------------------------------- - * Make dataset "dset2" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset1" */ - dataset_id = H5Dcreate(file2_id,"dset2",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - - -/*------------------------------------------------------------------------- - * Make dataset "g1/dset1" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a group. */ - group_id = H5Gcreate(file2_id, "g1", 0); - - /* Create a dataset "g1/dset1" */ - dataset_id = H5Dcreate(group_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Gclose(group_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make group "g2/g1" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a group. */ - group_id = H5Gcreate(file2_id, "g2", 0); - group2_id = H5Gcreate(group_id, "g1", 0); - - /* Close */ - status = H5Gclose(group_id); - status = H5Gclose(group2_id); - -#if 1 - -/*------------------------------------------------------------------------- - * Make dataset "dset4" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset4",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data4); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset5" on file1 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(2,dims2,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file1_id,"dset5",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data5); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset6" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(2,dims2,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset6",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data6); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset7" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(2,dims3,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset7",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data7); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset8" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(2,dims2,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset8",H5T_NATIVE_DOUBLE,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,data8); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset9" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(2,dims2,NULL); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset9",H5T_NATIVE_DOUBLE,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,data9); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset10" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate(H5S_SCALAR); - - /* Make a string type */ - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size (type_id, strlen(data10)); - - /* Create a dataset "dset" */ - dataset_id = H5Dcreate(file2_id,"dset10",type_id,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,data10); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - status = H5Tclose(type_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset11" on file1 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset1" */ - dataset_id = H5Dcreate(file1_id,"dset11",H5T_NATIVE_LONG,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,data11); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -/*------------------------------------------------------------------------- - * Make dataset "dset12" on file2 - *------------------------------------------------------------------------- - */ - - /* Create a data space */ - space_id = H5Screate_simple(1,dims,NULL); - - /* Create a dataset "dset12" */ - dataset_id = H5Dcreate(file2_id,"dset12",H5T_NATIVE_LONG,space_id,H5P_DEFAULT); - - /* Write the data */ - status = H5Dwrite(dataset_id,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,data12); - - /* Close */ - status = H5Dclose(dataset_id); - status = H5Sclose(space_id); - -#endif - - -/*------------------------------------------------------------------------- - * Close files - *------------------------------------------------------------------------- - */ - status = H5Fclose(file1_id); - status = H5Fclose(file2_id); - - - return 0; - - -} - - - -#if 0 - - -/*------------------------------------------------------------------------- - * Function: compare_uni - * - * Purpose: - * - * Return: - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 10, 2003 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -void compare_uni( hid_t file1_id, char *obj1_name, int nobjects1, info_t *info1, - hid_t file2_id, char *obj2_name, int nobjects2, info_t *info2, - options_t options ) -{ - char *pdest; - int result; - int len; - int i, j; - - int obj1_found = 0; - int obj2_found = 0; - -/*------------------------------------------------------------------------- - * object name was supplied - *------------------------------------------------------------------------- - */ - - /* object name was supplied, find obj1_name */ - if ( obj1_name ) - { - - for ( i = 0; i < nobjects1; i++) - { - - pdest = strstr( info1[i].name, obj1_name ); - result = pdest - info1[i].name; - len = strlen(obj1_name); - - /* found at position result */ - if( pdest != NULL && - /* check if it is not a substring */ - info1[i].name[result-1] == '/' && - /* check if it is the last or in the middle */ - (info1[i].name[result+len]=='/' || - info1[i].name[result+len]=='\0') ) - { - printf( "%s found in file 1 <%s>\n", info1[i].name, file1_name); - - obj1_found = 1; - - /* go to second file and find obj2_name */ - for ( j = 0; j < nobjects2; j++) - { - - pdest = strstr( info2[j].name, obj2_name ); - result = pdest - info2[j].name; - - len = strlen(obj2_name); - - /* found at position result */ - if( pdest != NULL && - /* check if it is not a substring */ - info2[j].name[result-1] == '/' && - /* check if it is the last or in the middle */ - (info2[j].name[result+len]=='/' || info2[j].name[result+len]=='\0') ) - { - - obj2_found = 1; - /* objects are the same type */ - if ( info1[i].type == info2[j].type ) - { - - switch ( info1[i].type ) - { - - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - - case H5G_GROUP: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - - break; - - /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - - case H5G_DATASET: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - /* match with the absolute name */ - diff_dataset(file1_id,file2_id,info1[i].name,info2[j].name,options); - printf("\n"); - break; - - /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - - case H5G_TYPE: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - - break; - - } /* switch */ - } - - } - - } /* j */ - - if ( obj2_found == 0 ) - printf( "%s was not found in file 2 <%s>\n", obj2_name, file2_name); - - } - - } /* i */ - - if ( obj1_found == 0 ) - printf( "%s was not found in file 1 <%s>\n", obj1_name, file1_name); - - - } - -/*------------------------------------------------------------------------- - * match all datasets - *------------------------------------------------------------------------- - */ - - else - - { - for ( i = 0; i < nobjects1; i++) - { - obj1_name = info1[i].name; - len = strlen(obj1_name); - - printf( "%s found in file 1 <%s>\n", info1[i].name, file1_name); - - obj2_found = 0; - for ( j = 0; j < nobjects2; j++) - { - /* find an object in file2 with same name as in file 1 */ - - pdest = strstr( info2[j].name, obj1_name ); - result = pdest - info2[j].name; - - obj2_name = info2[j].name; - - /* found at position result */ - if( pdest != NULL && - /* check if it is not a substring */ - info2[j].name[result] == '/' && - /* check if it is the last or in the middle */ - (info2[j].name[result+len]=='/' || info2[j].name[result+len]=='\0') && - /* objects are the same type */ - info1[i].type == info2[j].type ) - { - - obj2_found = 1; - switch ( info1[i].type ) - { - - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - - case H5G_GROUP: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - - break; - - /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - - case H5G_DATASET: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - /* match with the absolute name */ - diff_dataset(file1_id,file2_id,info1[i].name,info2[j].name,options); - printf("\n"); - break; - - /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - - case H5G_TYPE: - - printf( "%s found in file 2 <%s>\n", info2[j].name, file2_name ); - - break; - } /* switch */ - } /* if */ - } /* j */ - - if ( obj2_found == 0 ) - printf( "%s is in file 1 <%s>, but not in file 2 <%s>\n", obj1_name, file1_name, file2_name); - - } /* i */ - - } - -} - -#endif
\ No newline at end of file diff --git a/tools/h5diff/h5difftst.c b/tools/h5diff/h5difftst.c index b839511..6e2b54f 100644 --- a/tools/h5diff/h5difftst.c +++ b/tools/h5diff/h5difftst.c @@ -1,16 +1,402 @@ - +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <stdio.h> #include <stdlib.h> #include "hdf5.h" +int do_test_files(); int main(int argc, const char *argv[]) { + do_test_files(); + return 0; +} + + + + +/*------------------------------------------------------------------------- + * do some test files + *------------------------------------------------------------------------- + */ + +/* +dset1 dset2 h5diff_test1.h5 h5diff_test2.h5 +dset1 dset2 -l h5diff_test1.h5 h5diff_test2.h5 +h5diff_test1.h5 h5diff_test2.h5 +dset1 dset2 -r h5diff_test1.h5 h5diff_test2.h5 +dset1 dset2 -n 2 h5diff_test1.h5 h5diff_test2.h5 +dset3 dset4 -d 0.01 h5diff_test1.h5 h5diff_test2.h5 +dset5 dset6 -p 0.05 h5diff_test1.h5 h5diff_test2.h5 +dset5 dset7 h5diff_test1.h5 h5diff_test2.h5 +dset8 dset9 h5diff_test2.h5 h5diff_test2.h5 +dset11 dset12 h5diff_test1.h5 h5diff_test2.h5 +*/ + + +int do_test_files() +{ + + hid_t file1_id, file2_id; + hid_t dataset_id; + hid_t space_id; + hid_t group_id, group2_id; + hid_t type_id; + hsize_t dims [1] = { 7 }; + hsize_t dims2 [2] = { 3,2 }; + hsize_t dims3 [2] = { 3,3 }; + int data1[7] = {1,1,1,1,1,1,1}; + int data2[7] = {1,1,1,4,5,6,7}; + float data3[7] = {1,1,3,4,5,6,7}; + float data4[7] = {1,1,3.02f,4.002f,5.00002f,6,7}; + float data5[3][2] = {1,1,3,4,5,6}; + float data6[3][2] = {1,1.1f,3.02f,4.002f,5.00002f,6}; + float data7[3][3] = {1,1,3,4,5,6,7,8,9}; + double data8[3][2] = {1,1,3.40505e-9,4,5,6}; + double data9[3][2] = {1,1,3.58911e-9,4,5,6}; + char data10[] = {"A string"}; + long data11[7] = {1,1,1,1,1,1,1}; + long data12[7] = {1,1,1,4,5,6,7}; + herr_t status; + +/*------------------------------------------------------------------------- + * Create two files + *------------------------------------------------------------------------- + */ + + /* Create a file */ + file1_id = H5Fcreate ("h5diff_test1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create a file */ + file2_id = H5Fcreate ("h5diff_test2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + +/*------------------------------------------------------------------------- + * Make dataset "dset1" on file1 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset1" */ + dataset_id = H5Dcreate(file1_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset3" on file1 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset3" */ + dataset_id = H5Dcreate(file1_id,"dset3",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data3); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + + +/*------------------------------------------------------------------------- + * Make dataset "g1/dset1" on file1 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a group. */ + group_id = H5Gcreate(file1_id, "g1", 0); + + /* Create a dataset "g1/dset1" */ + dataset_id = H5Dcreate(group_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data1); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Gclose(group_id); + status = H5Sclose(space_id); + + +/*------------------------------------------------------------------------- + * Make dataset "dset1" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset1" */ + dataset_id = H5Dcreate(file2_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + + +/*------------------------------------------------------------------------- + * Make dataset "dset2" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset1" */ + dataset_id = H5Dcreate(file2_id,"dset2",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + + +/*------------------------------------------------------------------------- + * Make dataset "g1/dset1" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a group. */ + group_id = H5Gcreate(file2_id, "g1", 0); + + /* Create a dataset "g1/dset1" */ + dataset_id = H5Dcreate(group_id,"dset1",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data2); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Gclose(group_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make group "g2/g1" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a group. */ + group_id = H5Gcreate(file2_id, "g2", 0); + group2_id = H5Gcreate(group_id, "g1", 0); + + /* Close */ + status = H5Gclose(group_id); + status = H5Gclose(group2_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset4" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset4",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data4); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset5" on file1 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(2,dims2,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file1_id,"dset5",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data5); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset6" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(2,dims2,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset6",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data6); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset7" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(2,dims3,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset7",H5T_NATIVE_FLOAT,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_FLOAT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data7); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset8" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(2,dims2,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset8",H5T_NATIVE_DOUBLE,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,data8); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset9" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(2,dims2,NULL); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset9",H5T_NATIVE_DOUBLE,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,data9); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset10" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate(H5S_SCALAR); + + /* Make a string type */ + type_id = H5Tcopy(H5T_C_S1); + status = H5Tset_size (type_id, strlen(data10)); + + /* Create a dataset "dset" */ + dataset_id = H5Dcreate(file2_id,"dset10",type_id,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,data10); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset11" on file1 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset1" */ + dataset_id = H5Dcreate(file1_id,"dset11",H5T_NATIVE_LONG,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,data11); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * Make dataset "dset12" on file2 + *------------------------------------------------------------------------- + */ + + /* Create a data space */ + space_id = H5Screate_simple(1,dims,NULL); + + /* Create a dataset "dset12" */ + dataset_id = H5Dcreate(file2_id,"dset12",H5T_NATIVE_LONG,space_id,H5P_DEFAULT); + + /* Write the data */ + status = H5Dwrite(dataset_id,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,data12); + + /* Close */ + status = H5Dclose(dataset_id); + status = H5Sclose(space_id); + + +/*------------------------------------------------------------------------- + * Close files + *------------------------------------------------------------------------- + */ + status = H5Fclose(file1_id); + status = H5Fclose(file2_id); + + return 0; + + } diff --git a/tools/h5diff/h5trav.c b/tools/h5diff/h5trav.c index dad344d..039db0f 100644 --- a/tools/h5diff/h5trav.c +++ b/tools/h5diff/h5trav.c @@ -1,12 +1,24 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include <stdio.h> #include <stdlib.h> #include "hdf5.h" #include "h5trav.h" - - #ifndef FALSE #define FALSE 0 #endif @@ -18,8 +30,6 @@ #define FAIL -1 #endif - - /* functions for traversal */ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info, int *idx ); herr_t get_nobjects( hid_t loc_id, const char *group_name ); @@ -32,14 +42,12 @@ int table_search(unsigned long *objno, table_t *table ); void table_add(unsigned long *objno, char *objname, table_t *table ); - - /*------------------------------------------------------------------------- * Function: H5get_object_info * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -72,9 +80,6 @@ int H5get_object_info( hid_t file_id, info_t *info ) } - - - /*------------------------------------------------------------------------- * Function: count_objects * @@ -105,9 +110,6 @@ static herr_t count_objects( hid_t loc_id, const char *name, void *op_data) return 0; } - - - /*------------------------------------------------------------------------- * Function: get_nobjects * @@ -141,7 +143,6 @@ herr_t get_nobjects( hid_t loc_id, const char *group_name ) } - /*------------------------------------------------------------------------- * Function: opget_info * @@ -209,18 +210,12 @@ herr_t get_name_type( hid_t loc_id, const char *group_name, int idx, char **name return 0; } - - - - - - /*------------------------------------------------------------------------- * Function: traverse * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -233,8 +228,6 @@ herr_t get_name_type( hid_t loc_id, const char *group_name, int idx, char **name *------------------------------------------------------------------------- */ - - int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info, int *idx ) { @@ -267,8 +260,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info strcat( path, "/" ); strcat( path, name ); - - /* disable error reporting */ H5Eget_auto(&func, &edata); H5Eset_auto(NULL, NULL); @@ -326,10 +317,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info } } - - - - break; @@ -340,8 +327,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info case H5G_DATASET: - - /* increment */ inserted_objs++; @@ -381,8 +366,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info case H5G_TYPE: - - /* increment */ inserted_objs++; @@ -404,8 +387,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info case H5G_LINK: - - /* increment */ inserted_objs++; @@ -442,7 +423,7 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -472,7 +453,7 @@ int table_search(unsigned long *objno, table_t *table ) * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -485,8 +466,6 @@ int table_search(unsigned long *objno, table_t *table ) *------------------------------------------------------------------------- */ - - void table_add(unsigned long *objno, char *objname, table_t *table) { int i; @@ -518,7 +497,7 @@ void table_add(unsigned long *objno, char *objname, table_t *table) * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -557,7 +536,7 @@ void table_init( table_t **tbl ) * * Purpose: * - * Return: Success: 0, Failure: -11 + * Return: * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -575,16 +554,6 @@ void table_free( table_t *table ) int i; - -#if 0 - printf("Table: # of entries = %d\n", table->nobjs); - for ( i = 0; i < table->nobjs; i++) - printf("%lu %lu %s %d %d\n", table->objs[i].objno[0], - table->objs[i].objno[1], - table->objs[i].objname, - table->objs[i].displayed, table->objs[i].recorded); -#endif - for ( i = 0; i < table->nobjs; i++) free( table->objs[i].objname ); diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index d65fdfd..e597979 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -14,8 +14,8 @@ # # Tests for the h5diff tool -DUMPER=h5diff # The tool name -DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary +H5DIFF=h5diff # The tool name +H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary CMP='cmp -s' DIFF='diff -c' @@ -28,6 +28,7 @@ if test -z "$srcdir"; then srcdir=. fi +test -d ../testfiles || mkdir ../testfiles # Print a line-line message left justified in a field of 70 characters # beginning with the word "Testing". @@ -35,7 +36,6 @@ fi TESTING() { SPACES=" " echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' - echo '\n' } # Run a test and print PASS or *FAIL*. If a test fails then increment @@ -47,18 +47,55 @@ TESTING() { # non-zero value. # TOOLTEST() { + expect="$srcdir/../testfiles/$1" + actual="../testfiles/`basename $1 .txt`.out" + actual_err="../testfiles/`basename $1 .txt`.err" + shift + # Run test. - TESTING $DUMPER $@ - $RUNSERIAL $DUMPER_BIN "$@" + # Tflops interprets "$@" as "" when no parameter is given (e.g., the + # case of missing file name). Changed it to use $@ till Tflops fixes it. + TESTING $H5DIFF $@ + ( + echo "#############################" + echo "Expected output for '$H5DIFF $@'" + echo "#############################" + cd $srcdir/../testfiles + if [ "`uname -s`" = "TFLOPS O/S" ]; then + $RUNSERIAL $H5DIFF_BIN $@ + else + $RUNSERIAL $H5DIFF_BIN "$@" + fi + ) >$actual 2>$actual_err + cat $actual_err >> $actual + + if $CMP $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.txt) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file +# if test -z "$HDF5_NOCLEANUP"; then +# rm -f $actual $actual_err +# fi } ############################################################################## ############################################################################## -### T H E T E S T S ### +### T H E T E S T S ### ############################################################################## ############################################################################## -# test -TOOLTEST -v h5diff_test1.h5 h5diff_test2.h5 +# test1: Check if the command line number of arguments is less than 3 +TOOLTEST h5diff_1.txt h5diff_test1.h5 + + +if test $nerrors -eq 0 ; then + echo "All $H5DIFF tests passed." +fi exit $nerrors |