diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-20 20:51:22 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-20 20:51:22 (GMT) |
commit | 614e46f270a2acc01a9d15c456420320f207086b (patch) | |
tree | 284b19d2abb4231f366169835d2965a653de7f93 /tools/h5diff/h5diffgentest.c | |
parent | 27be7d1e2d95618c72bbefbed54e644b3b2d21ae (diff) | |
download | hdf5-614e46f270a2acc01a9d15c456420320f207086b.zip hdf5-614e46f270a2acc01a9d15c456420320f207086b.tar.gz hdf5-614e46f270a2acc01a9d15c456420320f207086b.tar.bz2 |
[svn-r20577] Bug 1386 - allowing dimension size to be zero. I added test cases in the tests for h5dump and h5diff. I also added the
test cases in the CMAKE script.
Tested on jam, linew, and amani. Tested CMAKE on jam.
Diffstat (limited to 'tools/h5diff/h5diffgentest.c')
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 66f1ce8..3363b39 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -53,6 +53,8 @@ #define FILE16 "h5diff_extlink_trg.h5" #define FILE17 "h5diff_ext2softlink_src.h5" #define FILE18 "h5diff_ext2softlink_trg.h5" +#define FILE19 "h5diff_dset_zero_dim_size1.h5" +#define FILE20 "h5diff_dset_zero_dim_size2.h5" #define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" #define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" #define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" @@ -78,8 +80,13 @@ #define STR_SIZE 3 #define GBLL ((unsigned long long) 1024 * 1024 *1024 ) - #define MY_LINKCLASS 187 + +/* Dataspace of 0 dimension size */ +#define SPACE1_RANK 2 +#define SPACE1_DIM1 0 +#define SPACE1_DIM2 0 + /* A UD link traversal function. Shouldn't actually be called. */ static hid_t UD_traverse(UNUSED const char * link_name, UNUSED hid_t cur_group, UNUSED const void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id) @@ -110,6 +117,7 @@ static int test_types(const char *fname); static int test_datatypes(const char *fname); static int test_attributes(const char *fname,int make_diffs); static int test_datasets(const char *fname,int make_diffs); +static int test_special_datasets(const char *fname,int make_diffs); static int test_hyperslab(const char *fname,int make_diffs); static int test_link_name(const char *fname1); static int test_soft_links(const char *fname1); @@ -173,6 +181,10 @@ int main(void) test_ext2soft_links(FILE17, FILE18); + /* generate 2 files, the second call creates a similar file with differences */ + test_special_datasets(FILE19,0); + test_special_datasets(FILE20,1); + test_dangle_links(DANGLE_LINK_FILE1, DANGLE_LINK_FILE2); test_group_recurse(GRP_RECURSE_FILE1, GRP_RECURSE_FILE2); @@ -1250,6 +1262,62 @@ int test_datasets(const char *file, } /*------------------------------------------------------------------------- +* Function: test_special_datasets +* +* Purpose: Check datasets with datasapce of zero dimension size. +*------------------------------------------------------------------------- +*/ +static +int test_special_datasets(const char *file, + int make_diffs /* flag to modify data buffers */) +{ + hid_t fid; + hid_t did; + hid_t sid0, sid; + hsize_t dims0[SPACE1_RANK]={SPACE1_DIM1, SPACE1_DIM2}; + hsize_t dims[SPACE1_RANK]={SPACE1_DIM1, SPACE1_DIM2}; + herr_t status; + + /* Create a file */ + if((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + + /* Create a dataset with zero dimension size */ + sid0 = H5Screate_simple(SPACE1_RANK, dims0, NULL); + did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* close dataset */ + status = H5Dclose(did); + assert(status >= 0); + + /* close dataspace */ + status = H5Sclose(sid0); + assert(status >= 0); + + /* Create a dataset with zero dimension size in one file but the other one + * has a dataset with a non-zero dimension size */ + if(make_diffs) { + dims[1] = SPACE1_DIM2 + 4; + } + + sid = H5Screate_simple(SPACE1_RANK, dims, NULL); + did = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* close dataspace */ + status = H5Sclose(sid); + assert(status >= 0); + + /* close dataset */ + status = H5Dclose(did); + assert(status >= 0); + + /* close file */ + status = H5Fclose(fid); + assert(status >= 0); + return status; +} + +/*------------------------------------------------------------------------- * * Purpose: Create test files to compare links, one has longer name than * the other and short name is subset of long name. |