diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-08-05 19:35:46 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-08-05 19:35:46 (GMT) |
commit | e46107ca75c83c11759defaeb4d1ce5630b91656 (patch) | |
tree | 03c1a3b05d271302168e927282eba62021812686 /tools/h5diff/h5diffgentest.c | |
parent | d364dc74a48d3e406d61920e1c3cccdf961b24d8 (diff) | |
download | hdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.zip hdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.tar.gz hdf5-e46107ca75c83c11759defaeb4d1ce5630b91656.tar.bz2 |
[svn-r15433] http://bugzilla.hdfgroup.uiuc.edu/show_bug.cgi?id=1170
Summary: when using h5diff to compare the results of h5repack (or other tools that copy one HDF5 file to another), a new option is needed to allow h5diff to make an "absolute" comparison of the 2 files. This is the "contents" mode explained in the usage below.
If this mode is present, objects in both files must match (must be exactly the same). If this does not happen, the tool returns an error code of 1 (instead of the success code of 0)
Changes to the h5repack test script: the call to h5diff was changed to include -c (maintaining the previous -q).
tested: windows, linux
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 111 |
1 files changed, 39 insertions, 72 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 74b3aa2..e1a554e 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -146,7 +146,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) fprintf(stderr, "empty file (%s) close failed.\n", fname3); goto out; } - + /*------------------------------------------------------------------------- * create two files *------------------------------------------------------------------------- @@ -265,7 +265,6 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) */ { -#if 1 float data15[6]; float data16[6]; @@ -285,48 +284,9 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1,1,dims1,"fp15",H5T_NATIVE_FLOAT,data15); write_dset(gid1,1,dims1,"fp16",H5T_NATIVE_FLOAT,data16); -#else - -#define NU_ELMTS 1000000 - - hsize_t i; - - hsize_t dims2[1] = { NU_ELMTS }; - - float *data15 = malloc (NU_ELMTS * sizeof(float) ); - float *data16 = malloc (NU_ELMTS * sizeof(float) ); - - data15[0] = (float) sqrt( (double)-1 ); - data15[1] = 1; - data15[2] = (float) sqrt( (double)-1 ); - data15[3] = 1; - data15[4] = 1; - data15[5] = 1; - - data16[0] = (float) sqrt( (double)-1 ); - data16[1] = (float) sqrt( (double)-1 ); - data16[2] = 1; - data16[3] = 1; - data16[4] = 1; - data16[5] = 1; - - for ( i = 6; i < NU_ELMTS; i++ ) - { - data15[i] = /*data15[0];*/ 2; - data16[i] = 1; - } - - write_dset(gid1,1,dims2,"fp15",H5T_NATIVE_FLOAT,data15); - write_dset(gid1,1,dims2,"fp16",H5T_NATIVE_FLOAT,data16); - - free( data15 ); - free( data16 ); -#endif } - - /*------------------------------------------------------------------------- * NaNs in H5T_NATIVE_DOUBLE *------------------------------------------------------------------------- @@ -354,9 +314,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1,1,dims1,"fp18",H5T_NATIVE_DOUBLE,data18); } - - - + /*------------------------------------------------------------------------- * close @@ -783,13 +741,13 @@ int test_datasets(const char *file, write_dset_in(gid,"/dset",fid,make_diffs); - /* Close */ + /* close */ status = H5Dclose(did); assert(status >= 0); status = H5Gclose(gid); assert(status >= 0); - /* Close file */ + /* close file */ status = H5Fclose(fid); assert(status >= 0); return status; @@ -2666,31 +2624,35 @@ int write_attr(hid_t loc_id, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; - - /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) - goto out; - - /* create the attribute */ - if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* write */ - if(buf) - if(H5Awrite(aid, tid, buf) < 0) - goto out; - - /* close */ - H5Aclose(aid); - H5Sclose(sid); - - return SUCCEED; - + hid_t aid=-1; + hid_t sid=-1; + + /* create a space */ + if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + goto out; + + /* create the attribute */ + if((aid = H5Acreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* write */ + if(buf) + { + if(H5Awrite(aid, tid, buf) < 0) + goto out; + } + + /* close */ + H5Aclose(aid); + H5Sclose(sid); + + return SUCCEED; + out: - - return FAIL; + + H5Aclose(aid); + H5Sclose(sid); + return FAIL; } /*------------------------------------------------------------------------- @@ -2708,8 +2670,8 @@ int write_dset( hid_t loc_id, hid_t tid, void *buf ) { - hid_t did; - hid_t sid; + hid_t did=-1; + hid_t sid=-1; /* create a space */ if((sid = H5Screate_simple(rank, dims, NULL)) < 0) @@ -2721,8 +2683,10 @@ int write_dset( hid_t loc_id, /* write */ if(buf) + { if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; + } /* close */ H5Dclose(did); @@ -2731,6 +2695,9 @@ int write_dset( hid_t loc_id, return SUCCEED; out: + + H5Dclose(did); + H5Sclose(sid); return FAIL; } |