From 1dad73cae06c8dcc396db690b9d0ebb28fa8cd65 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 8 Apr 2004 16:23:19 -0500 Subject: [svn-r8331] Purpose: Last step of check-in for Null dataspace Description: Mainly are header message changes for dataspace. In last round of check-in, a new header message for dataspace to created, which is not a good way. Now, there will be no new message for dataspace, but just add the type of dataspace in the message while increment its version number. Backward compatibility is addressed. The attribute design is modified accordingly. Took out Null dataspace test from tmisc.c and put it in th5s.c. Platforms tested: h5committest --- test/th5s.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/tmisc.c | 82 --------------------------------------- 2 files changed, 122 insertions(+), 82 deletions(-) diff --git a/test/th5s.c b/test/th5s.c index 570583a..2cdab33 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -29,6 +29,9 @@ #define TESTFILE "th5s.h5" #define DATAFILE "th5s1.h5" +#define NULLFILE "th5s2.h5" +#define NULLDATASET "null_dataset" +#define NULLATTR "null_attribute" /* 3-D dataset with fixed dimensions */ #define SPACE1_NAME "Space1" @@ -194,6 +197,124 @@ test_h5s_basic(void) /**************************************************************** ** +** test_h5s_null(): Test NULL data space +** +****************************************************************/ +static void +test_h5s_null(void) +{ + hid_t fid; /* File ID */ + hid_t sid, sid2; /* Dataspace IDs */ + hid_t dset_sid, dset_sid2; /* Dataspace IDs */ + hid_t attr_sid; /* Dataspace IDs */ + hid_t did; /* Dataset ID */ + hid_t attr; /*Attribute ID */ + H5S_class_t class; /* dataspace type */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Null Dataspace\n")); + + /* Create the file */ + fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + + sid = H5Screate(H5S_NULL); + CHECK(sid, FAIL, "H5Screate"); + + /* Create first dataset */ + did = H5Dcreate(fid, NULLDATASET, H5T_STD_U32LE, sid, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate"); + + /* Create an attribute for the group */ + attr=H5Acreate(did,NULLATTR,H5T_NATIVE_INT,sid,H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Close attribute */ + ret=H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /*============================================ + * Reopen the file to check the data space + *============================================ + */ + fid = H5Fopen(NULLFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Reopen the dataset */ + did = H5Dopen(fid, NULLDATASET); + CHECK(did, FAIL, "H5Dopen"); + + /* Get the space of the dataset */ + dset_sid = H5Dget_space(did); + CHECK(dset_sid, FAIL, "H5Dget_space"); + + /* Query the NULL dataspace */ + dset_sid2 = H5Scopy(dset_sid); + CHECK(dset_sid2, FAIL, "H5Scopy"); + + /* Verify the class type of dataspace */ + class = H5Sget_simple_extent_type(dset_sid2); + VERIFY(class, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Verify there is zero element in the dataspace */ + ret = H5Sget_simple_extent_npoints(dset_sid2); + VERIFY(ret, 0, "H5Sget_simple_extent_npoints"); + + /* Close the dataspace */ + ret = H5Sclose(dset_sid); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(dset_sid2); + CHECK(ret, FAIL, "H5Sclose"); + + /* Open the attribute for the dataset */ + attr=H5Aopen_name(did,NULLATTR); + CHECK(attr, FAIL, "H5Aopen_name"); + + /* Get the space of the dataset */ + attr_sid = H5Aget_space(attr); + CHECK(attr_sid, FAIL, "H5Aget_space"); + + /* Verify the class type of dataspace */ + class = H5Sget_simple_extent_type(attr_sid); + VERIFY(class, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Verify there is zero element in the dataspace */ + ret = H5Sget_simple_extent_npoints(attr_sid); + VERIFY(ret, 0, "H5Sget_simple_extent_npoints"); + + /* Close the dataspace */ + ret = H5Sclose(attr_sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close attribute */ + ret=H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_misc20() */ + +/**************************************************************** +** ** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code. ** ****************************************************************/ @@ -566,6 +687,7 @@ test_h5s(void) MESSAGE(5, ("Testing Dataspaces\n")); test_h5s_basic(); /* Test basic H5S code */ + test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_scalar_write(); /* Test scalar H5S writing code */ test_h5s_scalar_read(); /* Test scalar H5S reading code */ test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ diff --git a/test/tmisc.c b/test/tmisc.c index 92dc2de..87534fa 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -217,10 +217,6 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC19_ATTR_NAME "Attribute" #define MISC19_GROUP_NAME "Group" -/* Definitions for misc. test #20 */ -#define MISC20_FILE "tmisc20.h5" -#define MISC20_DSET_NAME "Dataset" - /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -3289,83 +3285,6 @@ test_misc19(void) VERIFY(ret, FAIL, "H5Eclose_stack"); } /* end test_misc19() */ - -/**************************************************************** -** -** test_misc20(): Test NULL data space -** -****************************************************************/ -static void -test_misc20(void) -{ - hid_t fid; /* File ID */ - hid_t sid, sid2; /* Dataspace IDs */ - hid_t did; /* Dataset ID */ - H5S_class_t class; /* dataspace type */ - herr_t ret; /* Generic return value */ - - /* Create the file */ - fid = H5Fcreate(MISC20_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fcreate"); - - sid = H5Screate(H5S_NULL); - CHECK(sid, FAIL, "H5Screate"); - - /* Create first dataset */ - did = H5Dcreate(fid, MISC20_DSET_NAME, H5T_STD_U32LE, sid, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate"); - - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); - - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - - /* Reopen the file to check the data space */ - fid = H5Fopen(MISC20_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fopen"); - - /* Reopen the dataset */ - did = H5Dopen(fid, MISC20_DSET_NAME); - CHECK(did, FAIL, "H5Dopen"); - - /* Get the space of the dataset */ - sid = H5Dget_space(did); - CHECK(sid, FAIL, "H5Dget_space"); - - /* Query the NULL dataspace */ - sid2 = H5Scopy(sid); - CHECK(sid2, FAIL, "H5Scopy"); - - /* Verify the class type of dataspace */ - class = H5Sget_simple_extent_type(sid2); - VERIFY(class, H5S_NULL, "H5Sget_simple_extent_type"); - - /* Verify there is zero element in the dataspace */ - ret = H5Sget_simple_extent_npoints(sid2); - VERIFY(ret, 0, "H5Sget_simple_extent_npoints"); - - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); - - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - - ret = H5Sclose(sid2); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); -} /* end test_misc20() */ /**************************************************************** ** @@ -3397,7 +3316,6 @@ test_misc(void) test_misc17(); /* Test array of ASCII character */ test_misc18(); /* Test new object header information in H5G_stat_t struct */ test_misc19(); /* Test incrementing & decrementing ref count on IDs */ - test_misc20(); /* Test NULL data space */ } /* test_misc() */ -- cgit v0.12