diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2018-07-18 22:06:59 (GMT) |
---|---|---|
committer | Larry Knox <lrknox@hdfgroup.org> | 2018-07-18 22:06:59 (GMT) |
commit | 3c6654921000a8659276f1fcb32dd0ada1353558 (patch) | |
tree | 5255646f9764b9d04974f516b2134d3af6dcccab /tools/test/h5dump/h5dumpgentest.c | |
parent | 892252106a1517a4cd715fa6257201e89fb25564 (diff) | |
parent | d95f36686b2a68bcd848d68bcb81be520d01f037 (diff) | |
download | hdf5-3c6654921000a8659276f1fcb32dd0ada1353558.zip hdf5-3c6654921000a8659276f1fcb32dd0ada1353558.tar.gz hdf5-3c6654921000a8659276f1fcb32dd0ada1353558.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/~lrknox/hdf5_lrk into develop
Diffstat (limited to 'tools/test/h5dump/h5dumpgentest.c')
-rw-r--r-- | tools/test/h5dump/h5dumpgentest.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 9358fbb..9e9f6f1 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -113,6 +113,7 @@ #define FILE83 "tvlenstr_array.h5" #define FILE84 "tudfilter.h5" #define FILE85 "tgrpnullspace.h5" +#define FILE86 "err_attr_dspace.h5" /*------------------------------------------------------------------------- * prototypes @@ -10476,6 +10477,89 @@ static void gent_null_space_group(void) H5Fclose(fid); } +/*------------------------------------------------------------------------- + * Function: gent_err_attr_dspace + * + * Purpose: Generate a file with shared dataspace message. + * Then write an illegal version to the shared dataspace message + * to trigger the error. + * This is to verify HDFFV-10333 that h5dump will exit + * gracefully when encountered error similar to + * H5O_attr_decode in the jira issue. + * + *------------------------------------------------------------------------- + */ +static void +gent_err_attr_dspace() +{ + hid_t fid = -1; /* File identifier */ + hid_t fcpl = -1; /* File access property list */ + hid_t sid = -1; /* Dataspace identifier */ + hid_t aid = -1; /* Attribute identifier */ + hsize_t dims = 2; /* Dimensino size */ + int wdata[2] = {7, 42}; /* The buffer to write */ + int fd = -1; /* The file descriptor */ + char val = 6; /* An invalid version */ + + /* Create an fcpl */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Set up the dataspace message to be shared */ + if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + goto error; + if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_SDSPACE_FLAG, 1) < 0) + goto error; + + /* Create the file with the shared message setting */ + if((fid = H5Fcreate(FILE86, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + goto error; + + /* Create the dataspace */ + if((sid = H5Screate_simple(1, &dims, &dims)) < 0) + goto error; + + /* Create an attribute with shared dataspace */ + if((aid = H5Acreate2(fid, "attribute", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Awrite(aid, H5T_NATIVE_INT, wdata) < 0) + goto error; + + /* Closing */ + if(H5Aclose(aid) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + /* This section of code will write an illegal version to the "version" field + of the shared dataspace message */ + if((fd = HDopen(FILE86, O_RDWR, 0633)) < 0) + goto error; + + /* Offset of the "version" field to modify is as follows: */ + /* 1916: offset of the object header containing the attribute message */ + /* 32: offset of the attribute message in the object header */ + /* 30: offset in the attribute message containing the version of the shared dataspace message */ + if(HDlseek(fd, 1916+32+30, SEEK_SET) < 0) + goto error; + if(HDwrite(fd, &val, 1) < 0) + goto error; + if(HDclose(fd) < 0) + goto error; + +error: + H5E_BEGIN_TRY { + H5Pclose(fcpl); + H5Aclose(aid); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; +} /* gen_err_attr_dspace() */ + int main(void) { gent_group(); @@ -10569,6 +10653,8 @@ int main(void) gent_udfilter(); + gent_err_attr_dspace(); + return 0; } |