diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2014-11-19 00:29:26 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2014-11-19 00:29:26 (GMT) |
commit | a00ad64f468e8ea4d19c17675258694a06febe32 (patch) | |
tree | e9213dd225503dc1806dc4b326b565567f9671ef /tools/h5dump | |
parent | 5a3e6cf0800219816b018baf50b7133baa73bc68 (diff) | |
download | hdf5-a00ad64f468e8ea4d19c17675258694a06febe32.zip hdf5-a00ad64f468e8ea4d19c17675258694a06febe32.tar.gz hdf5-a00ad64f468e8ea4d19c17675258694a06febe32.tar.bz2 |
[svn-r25825] Bring revisions #25509 - #25762 from trunk to revise_chunks.
h5committested.
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/CMakeTests.cmake | 6 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 154 |
2 files changed, 160 insertions, 0 deletions
diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake index f9ebc32..afb482e 100644 --- a/tools/h5dump/CMakeTests.cmake +++ b/tools/h5dump/CMakeTests.cmake @@ -50,6 +50,7 @@ ${HDF5_TOOLS_SRC_DIR}/testfiles/tbin4.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tbigdims.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/tbitnopaque.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tboot1.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tboot2.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tboot2A.ddl @@ -206,6 +207,7 @@ ${HDF5_TOOLS_SRC_DIR}/testfiles/tattrreg.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tbigdims.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinary.h5 + ${HDF5_TOOLS_SRC_DIR}/testfiles/tbitnopaque.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tchar.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdattrintsize.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdintarray.h5 @@ -805,6 +807,8 @@ tbinregR.out.err tbigdims.out tbigdims.out.err + tbitnopaque.out + tbitnopaque.out.err tboot1.out tboot1.out.err tboot2.out @@ -1147,6 +1151,8 @@ ADD_H5ERR_MASK_TEST (tcomp-3 0 "--enable-error-stack;-t;/#6632;-g;/group2;tcompound.h5") # test complicated compound datatype ADD_H5_TEST (tcomp-4 0 --enable-error-stack tcompound_complex.h5) + # tests for bitfields and opaque data types + ADD_H5_TEST (tbitnopaque 0 --enable-error-stack tbitnopaque.h5) #test for the nested compound type ADD_H5_TEST (tnestcomp-1 0 --enable-error-stack tnestedcomp.h5) diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index bf3c97d..0857d80 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -110,6 +110,7 @@ #define FILE77 "tcmpdints.h5" #define FILE78 "tscalarintattrsize.h5" #define FILE79 "tintsattrs.h5" +#define FILE80 "tbitnopaque.h5" /*------------------------------------------------------------------------- * prototypes @@ -360,6 +361,8 @@ typedef struct s1_t { #define F77_DATASETNAME2 "CompoundRInts" #define F77_LENGTH 64 +#define F80_DIM32 32 + static void gent_group(void) { @@ -9667,6 +9670,156 @@ gent_intsattrs(void) H5Fclose(fid); } +static void gent_bitnopaquefields(void) +{ + /* Compound datatype */ + typedef struct s_t + { + unsigned char a; + unsigned int b; + unsigned long c; + unsigned long long d; + } s_t; + hid_t file, grp=-1, type=-1, space=-1, dset=-1; + size_t i; + hsize_t nelmts = F80_DIM32; + unsigned char buf[F80_DIM32]; /* bitfield, opaque */ + unsigned int buf2[F80_DIM32]; /* bitfield, opaque */ + unsigned long buf3[F80_DIM32]; /* bitfield, opaque */ + unsigned long long buf4[F80_DIM32]; /* bitfield, opaque */ + s_t buf5[F80_DIM32]; /* compound */ + + file = H5Fcreate(FILE80, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + if ((grp = H5Gcreate2(file, "bittypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + /* bitfield_1 */ + if ((type = H5Tcopy(H5T_STD_B8LE)) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { + buf[i] = (unsigned char)0xff ^ (unsigned char)i; + } + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Dclose(dset); + } + H5Sclose(space); + } + H5Tclose(type); + } + + /* bitfield_2 */ + if ((type = H5Tcopy(H5T_STD_B16LE)) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { + buf2[i] = (unsigned int)0xffff ^ (unsigned int)(i * 16); + } + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); + H5Dclose(dset); + } + H5Sclose(space); + } + H5Tclose(type); + } + + /* bitfield_3 */ + if ((type = H5Tcopy(H5T_STD_B32LE)) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { + buf3[i] = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + } + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf3); + H5Dclose(dset); + } + H5Sclose(space); + } + H5Tclose(type); + } + + /* bitfield_4 */ + if ((type = H5Tcopy(H5T_STD_B64LE)) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { + buf4[i] = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf4); + H5Dclose(dset); + } + H5Sclose(space); + } + H5Tclose(type); + } + + H5Gclose(grp); + } + + if ((grp = H5Gcreate2(file, "opaquetypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + /* opaque_1 */ + if ((type = H5Tcreate(H5T_OPAQUE, 1)) >= 0) { + if ((H5Tset_tag(type, "1-byte opaque type")) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for(i = 0; i < nelmts; i++) + buf[i] = (unsigned char)0xff ^ (unsigned char)i; + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Dclose(dset); + } + H5Sclose(space); + } + } + H5Tclose(type); + } + + /* opaque_2 */ + if ((type = H5Tcreate(H5T_OPAQUE, 2)) >= 0) { + if ((H5Tset_tag(type, "2-byte opaque type")) >= 0) { + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for(i = 0; i < nelmts; i++) + buf2[i] = (unsigned int)0xffff ^ (unsigned int)(i * 16); + + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); + H5Dclose(dset); + } + H5Sclose(space); + } + } + H5Tclose(type); + } + H5Gclose(grp); + } + + if ((grp = H5Gcreate2(file, "cmpdtypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + /* compound_1 */ + if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + for(i = 0; i < nelmts; i++) { + buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } + + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); + } + H5Tclose(type); + } + H5Gclose(grp); + } + + H5Fclose(file); +} + /*------------------------------------------------------------------------- * Function: main @@ -9758,6 +9911,7 @@ int main(void) gent_compound_ints(); gent_intattrscalars(); gent_intsattrs(); + gent_bitnopaquefields(); return 0; } |