summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-07-10 17:12:06 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-07-10 17:12:06 (GMT)
commit87fe8971ed82bf82b74ff91c3f77b0eb02848ed6 (patch)
tree9ac3726898740f0e4cdad05144b03e54b1a17e6b /tools/h5dump
parentbb696c61acd4b092a3239ee026dd0df0fdc781c3 (diff)
downloadhdf5-87fe8971ed82bf82b74ff91c3f77b0eb02848ed6.zip
hdf5-87fe8971ed82bf82b74ff91c3f77b0eb02848ed6.tar.gz
hdf5-87fe8971ed82bf82b74ff91c3f77b0eb02848ed6.tar.bz2
[svn-r22544] Add test to verify use of named datatypes
HDFFV-2687 Tested: local linux with cmake
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt31
-rw-r--r--tools/h5dump/h5dumpgentest.c148
-rw-r--r--tools/h5dump/testh5dump.sh.in5
3 files changed, 184 insertions, 0 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index 339a31f..2af52b7 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -69,6 +69,7 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-3.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr-4_be.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tattrintsize.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattrreg.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tattrregR.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tbin1.ddl
@@ -82,6 +83,8 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tboot2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tchar1.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tchunked.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdattrintsize.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdintsize.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tcomp-1.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tcomp-2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tcomp-3.ddl
@@ -133,6 +136,7 @@ IF (BUILD_TESTING)
#${HDF5_TOOLS_SRC_DIR}/testfiles/tstarfile.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tnamed_dtype_attr.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tnestcomp-1.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tnestedcmpddt.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tnbit.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tno-subset.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tnullspace.ddl
@@ -146,6 +150,8 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/torderattr2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/torderattr3.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/torderattr4.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tordercontents1.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tordercontents2.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tperror.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/treference.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.ddl
@@ -258,10 +264,13 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr2.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tattr4_be.h5
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tattrintsize.h5
${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/tchar.h5
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdattrintsize.h5
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tcmpdintsize.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tcompound.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tcompound_complex.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tdatareg.h5
@@ -304,6 +313,7 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tmulti-s.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tnamed_dtype_attr.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tnestedcomp.h5
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tnestedcmpddt.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tno-subset.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tnullspace.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/zerodim.h5
@@ -748,6 +758,8 @@ IF (BUILD_TESTING)
tattr-3.out.err
tattr-4_be.out
tattr-4_be.out.err
+ tattrintsize.out
+ tattrintsize.out.err
tattrreg.out
tattrreg.out.err
tattrregR.out
@@ -764,6 +776,10 @@ IF (BUILD_TESTING)
tchar1.out.err
tchunked.out
tchunked.out.err
+ tcmpdattrintsize.out
+ tcmpdattrintsize.out.err
+ tcmpdintsize.out
+ tcmpdintsize.out.err
tcomp-1.out
tcomp-1.out.err
tcomp-2.out
@@ -866,6 +882,8 @@ IF (BUILD_TESTING)
tnamed_dtype_attr.out.err
tnestcomp-1.out
tnestcomp-1.out.err
+ tnestedcmpddt.out
+ tnestedcmpddt.out.err
tnbit.out
tnbit.out.err
tno-subset.out
@@ -892,6 +910,10 @@ IF (BUILD_TESTING)
torderattr3.out.err
torderattr4.out
torderattr4.out.err
+ tordercontents1.out
+ tordercontents1.out.err
+ tordercontents2.out
+ tordercontents2.out.err
tperror.out
tperror.out.err
treference.out
@@ -953,6 +975,12 @@ IF (BUILD_TESTING)
# test for signed/unsigned datasets
ADD_H5_TEST (packedbits 0 --enable-error-stack packedbits.h5)
+ # test for compound signed/unsigned datasets
+ ADD_H5_TEST (tcmpdintsize 0 --enable-error-stack tcmpdintsize.h5)
+ # test for signed/unsigned attributes
+ ADD_H5_TEST (tattrintsize 0 --enable-error-stack tattrintsize.h5)
+ # test for compound signed/unsigned attributes
+ ADD_H5_TEST (tcmpdattrintsize 0 --enable-error-stack tcmpdattrintsize.h5)
# test for displaying groups
ADD_H5_TEST (tgroup-1 0 --enable-error-stack tgroup.h5)
# test for displaying the selected groups
@@ -1004,6 +1032,7 @@ IF (BUILD_TESTING)
#test for the nested compound type
ADD_H5_TEST (tnestcomp-1 0 --enable-error-stack tnestedcomp.h5)
+ ADD_H5_TEST (tnestedcmpddt 0 --enable-error-stack tnestedcmpddt.h5)
# test for options
# JIRA HDFFV-7936 ADD_H5_MASK_TEST (tall-1 0 --enable-error-stack tall.h5)
@@ -1096,6 +1125,8 @@ IF (BUILD_TESTING)
# test for file contents
ADD_H5_TEST (tcontents 0 --enable-error-stack -n tfcontents1.h5)
+ ADD_H5_TEST (tordercontents1 0 --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5)
+ ADD_H5_TEST (tordercontents2 0 --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5)
# tests for storage layout
# compact
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index e240232..d7dfdbc 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -101,6 +101,7 @@
#define FILE69 "tattrintsize.h5"
#define FILE70 "tcmpdintsize.h5"
#define FILE71 "tcmpdattrintsize.h5"
+#define FILE72 "tnestedcmpddt.h5"
/*-------------------------------------------------------------------------
* prototypes
@@ -7946,6 +7947,151 @@ static void gent_compound_attr_intsizes(void) {
HDassert(status >= 0);
}
+static void gent_nested_compound_dt(void) { /* test nested data type */
+ hid_t fid, group, dataset, space, type, create_plist, type1, type2;
+ hid_t array_dt, enum_dt;
+ enumtype val;
+
+ typedef struct {
+ int a;
+ float b;
+ } dset1_t;
+ dset1_t dset1[10];
+
+ typedef struct {
+ int a;
+ float b;
+ enumtype c;
+ } dset2_t;
+ dset2_t dset2[10];
+
+ typedef struct {
+ int a[4];
+ float b[5][6];
+ dset1_t c;
+ } dset3_t;
+ dset3_t dset3[10];
+
+ enumtype dset4[] = {RED, GREEN, BLUE, GREEN, WHITE, BLUE};
+ dset1_t dset5[10];
+
+ int i;
+ unsigned ndims;
+ hsize_t dim[2];
+
+ hsize_t sdim, maxdim;
+
+ sdim = 10;
+ for(i = 0; i < (int)sdim; i++) {
+ dset1[i].a = i;
+ dset1[i].b = (float)(i*i);
+
+ dset2[i].a = i;
+ dset2[i].b = (float)(i+ i*0.1);
+ dset2[i].c = GREEN;
+
+ dset3[i].a[0] = i;
+ dset3[i].b[0][0] = (float)(i*1.0);
+ dset3[i].c.a = i;
+ dset3[i].c.b = (float)(i*1.0);
+ }
+
+ fid = H5Fcreate(FILE72, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ create_plist = H5Pcreate(H5P_DATASET_CREATE);
+
+ sdim = 2;
+ H5Pset_chunk(create_plist, 1, &sdim);
+
+
+ sdim = 6;
+ maxdim = H5S_UNLIMITED;
+
+ space = H5Screate_simple(1, &sdim, &maxdim);
+
+ type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0]));
+ H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE);
+ H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE);
+
+ dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT);
+
+ H5Dwrite(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1);
+
+ H5Tclose(type);
+ H5Dclose(dataset);
+
+ /* Create the shared enumerated datatype. */
+ enum_dt = H5Tenum_create (H5T_NATIVE_INT);
+ val = (enumtype) RED;
+ H5Tenum_insert (enum_dt, "Red", &val);
+ val = (enumtype) GREEN;
+ H5Tenum_insert (enum_dt, "Green", &val);
+ val = (enumtype) BLUE;
+ H5Tenum_insert (enum_dt, "Blue", &val);
+ val = (enumtype) WHITE;
+ H5Tenum_insert (enum_dt, "White", &val);
+ val = (enumtype) BLACK;
+ H5Tenum_insert (enum_dt, "Black", &val);
+ H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2[0]));
+
+ H5Tinsert(type2, "a_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT);
+ H5Tinsert(type2, "b_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT);
+ H5Tinsert(type2, "c_name", HOFFSET(dset2_t, c), enum_dt);
+
+ dataset = H5Dcreate2(fid, "/dset2", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT);
+
+ H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2);
+
+ H5Tclose(type2);
+
+ dataset = H5Dcreate2(fid, "/dset4", enum_dt, space, H5P_DEFAULT, create_plist, H5P_DEFAULT);
+ H5Dwrite(dataset, enum_dt, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4);
+
+ H5Tclose(enum_dt);
+ H5Dclose(dataset);
+
+ /* shared data type 1 */
+ type1 = H5Tcreate(H5T_COMPOUND, sizeof(dset1_t));
+ H5Tinsert(type1, "int_name", HOFFSET(dset1_t, a), H5T_STD_I32BE);
+ H5Tinsert(type1, "float_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE);
+ H5Tcommit2(fid, "type1", type1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t));
+
+ ndims = 1; dim[0] = 4;
+ array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim);
+ H5Tinsert(type2, "int_name", HOFFSET(dset3_t, a), array_dt);
+ H5Tclose(array_dt);
+
+ ndims = 2; dim[0] = 5; dim[1] = 6;
+ array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim);
+ H5Tinsert(type2, "float_name", HOFFSET(dset3_t, b), array_dt);
+ H5Tclose(array_dt);
+
+ H5Tinsert (type2, "cmpd_name", HOFFSET (dset3_t, c), type1);
+
+ dataset = H5Dcreate2(group, "dset3", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT);
+
+ H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3);
+
+ dataset = H5Dcreate2(fid, "/dset5", type1, space, H5P_DEFAULT, create_plist, H5P_DEFAULT);
+ H5Dwrite(dataset, type1, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset5);
+
+ H5Tclose(type1);
+ H5Tclose(type2);
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+ H5Pclose(create_plist);
+
+ H5Fclose(fid);
+
+}
/*-------------------------------------------------------------------------
* Function: main
@@ -8028,6 +8174,8 @@ int main(void)
gent_compound_intsizes();
gent_compound_attr_intsizes();
+ gent_nested_compound_dt();
+
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 8c7d754..2b7250d 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -142,6 +142,7 @@ $SRC_H5DUMP_TESTFILES/tmulti-r.h5
$SRC_H5DUMP_TESTFILES/tmulti-s.h5
$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.h5
$SRC_H5DUMP_TESTFILES/tnestedcomp.h5
+$SRC_H5DUMP_TESTFILES/tnestedcmpddt.h5
$SRC_H5DUMP_TESTFILES/tno-subset.h5
$SRC_H5DUMP_TESTFILES/tnullspace.h5
$SRC_H5DUMP_TESTFILES/zerodim.h5
@@ -258,6 +259,7 @@ $SRC_H5DUMP_TESTFILES/tqmarkfile.ddl
$SRC_H5DUMP_TESTFILES/tstarfile.ddl
$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.ddl
$SRC_H5DUMP_TESTFILES/tnestcomp-1.ddl
+$SRC_H5DUMP_TESTFILES/tnestedcmpddt.ddl
$SRC_H5DUMP_TESTFILES/tnbit.ddl
$SRC_H5DUMP_TESTFILES/tno-subset.ddl
$SRC_H5DUMP_TESTFILES/tnullspace.ddl
@@ -271,6 +273,8 @@ $SRC_H5DUMP_TESTFILES/torderattr1.ddl
$SRC_H5DUMP_TESTFILES/torderattr2.ddl
$SRC_H5DUMP_TESTFILES/torderattr3.ddl
$SRC_H5DUMP_TESTFILES/torderattr4.ddl
+$SRC_H5DUMP_TESTFILES/tordercontents1.ddl
+$SRC_H5DUMP_TESTFILES/tordercontents2.ddl
$SRC_H5DUMP_TESTFILES/tperror.ddl
$SRC_H5DUMP_TESTFILES/treference.ddl
$SRC_H5DUMP_TESTFILES/tsaf.ddl
@@ -629,6 +633,7 @@ TOOLTEST tcomp-4.ddl --enable-error-stack tcompound_complex.h5
#test for the nested compound type
TOOLTEST tnestcomp-1.ddl --enable-error-stack tnestedcomp.h5
+TOOLTEST tnestedcmpddt.ddl --enable-error-stack tnestedcmpddt.h5
# test for options
# JIRA HDFFV-7936 TOOLTEST tall-1.ddl --enable-error-stack tall.h5