diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-17 20:33:56 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-17 20:33:56 (GMT) |
commit | 8b0d7dc95ae11d9d213b8a38ccc73b741690c96d (patch) | |
tree | c4ee856e15994747cf6acfa46b35ef9d60983618 | |
parent | 014319c70488e9d50848af147fdb4832d4e1b1c6 (diff) | |
download | hdf5-8b0d7dc95ae11d9d213b8a38ccc73b741690c96d.zip hdf5-8b0d7dc95ae11d9d213b8a38ccc73b741690c96d.tar.gz hdf5-8b0d7dc95ae11d9d213b8a38ccc73b741690c96d.tar.bz2 |
[svn-r8381] Purpose:
Added new files
Description:
Added backward compatibility test for new version of dataspace information.
Platforms tested:
FreeBSD 4.9 (sleipnir)
h5committest
Misc. update:
-rw-r--r-- | test/gen_nullspace.c | 87 | ||||
-rw-r--r-- | test/th5s.c | 68 | ||||
-rw-r--r-- | test/tnullspace.h5 | bin | 0 -> 3624 bytes |
3 files changed, 155 insertions, 0 deletions
diff --git a/test/gen_nullspace.c b/test/gen_nullspace.c new file mode 100644 index 0000000..5892443 --- /dev/null +++ b/test/gen_nullspace.c @@ -0,0 +1,87 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Saturday, April 17, 2004 + * + * Purpose: Create a dataset with a null dataspace and an attribute + * with a null dataspace. + * This program is used to create the test file `tnullspace.h5' which + * has dataspaces stored in the newer (version 2) style in the object headers. + * To build the test file, this program MUST be compiled and linked with + * the hdf5-1.7+ series of libraries and the generated test file must be + * put into the 'test' directory in the 1.6.x branch of the library. + */ + +#include "hdf5.h" +#include <assert.h> + +#define NULLFILE "tnullspace.h5" +#define NULLDATASET "null_dataset" +#define NULLATTR "null_attribute" + +int +main(void) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t attr; /* Attribute ID */ + herr_t ret; /* Generic return value */ + + /* Create the file */ + fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + assert(fid>0); + + sid = H5Screate(H5S_NULL); + assert(sid>0); + + /* Create dataset */ + did = H5Dcreate(fid, NULLDATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT); + assert(did>0); + + /* Close the dataset */ + ret = H5Dclose(did); + assert(ret>=0); + + /* Open the root group */ + gid = H5Gopen(fid,"/"); + assert(gid>0); + + /* Create an attribute for the group */ + attr=H5Acreate(gid,NULLATTR,H5T_NATIVE_INT,sid,H5P_DEFAULT); + assert(attr>0); + + /* Close attribute */ + ret=H5Aclose(attr); + assert(ret>=0); + + /* Close the group */ + ret = H5Gclose(gid); + assert(ret>=0); + + /* Close the dataspace */ + ret = H5Sclose(sid); + assert(ret>=0); + + /* Close the file */ + ret = H5Fclose(fid); + assert(ret>=0); + + return 0; +} + + diff --git a/test/th5s.c b/test/th5s.c index 95681c2..a6b6fb4 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -29,6 +29,7 @@ #define TESTFILE "th5s.h5" #define DATAFILE "th5s1.h5" +#define NULLFILE "tnullspace.h5" /* 3-D dataset with fixed dimensions */ #define SPACE1_NAME "Space1" @@ -72,6 +73,10 @@ struct space4_struct { char c2; } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */ +/* NULL dataspace info */ +#define NULLDATASET "null_dataset" +#define NULLATTR "null_attribute" + /**************************************************************** ** ** test_h5s_basic(): Test basic H5S (dataspace) code. @@ -557,6 +562,66 @@ test_h5s_chunk(void) /**************************************************************** ** +** test_h5s_null_space(): Attempt to access dataset and attribute +** with null dataspace. This should fail, since the 1.6.x +** branch doesn't understand null dataspaces. +** +****************************************************************/ +static void +test_h5s_null_space(void) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t aid; /* Attribute ID */ + hid_t did; /* Dataset ID */ + char testfile[512]=""; /* Character buffer for corrected test file name */ + char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Attempting to Read NULL Dataspaces\n")); + + /* Generate the correct name for the test file, by prepending the source path */ + if (srcdir && ((HDstrlen(srcdir) + HDstrlen(NULLFILE) + 1) < sizeof(testfile))) { + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); + } + HDstrcat(testfile, NULLFILE); + + /* Open the testfile */ + fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK_I(fid, "H5Fopen"); + + /* Only try to proceed if the file is around */ + if (fid >= 0) { + /* Open the root group */ + gid = H5Gopen(fid,"/"); + CHECK_I(gid, "H5Gopen"); + + /* Attempt to open attribute w/NULL dataspace */ + H5E_BEGIN_TRY { + aid=H5Aopen_name(gid,NULLATTR); + } H5E_END_TRY; + VERIFY(aid, FAIL, "H5Aopen_name"); + + /* Attempt to open dataset w/NULL dataspace */ + H5E_BEGIN_TRY { + did=H5Dopen(fid,NULLDATASET); + } H5E_END_TRY; + VERIFY(did, FAIL, "H5Dopen"); + + /* Close open objects */ + ret=H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } /* end if */ + else + printf("***cannot open the pre-created NULL dataspace test file (%s)\n",testfile); +} /* test_h5s_null_space() */ + +/**************************************************************** +** ** test_h5s(): Main H5S (dataspace) testing routine. ** ****************************************************************/ @@ -574,6 +639,9 @@ test_h5s(void) /* This test was added later to exercise a bug in chunked I/O */ test_h5s_chunk(); /* Exercise bug fix for chunked I/O */ + + /* This test is specific to the 1.6.x branch, to test backward compatibility w/null dataspaces */ + test_h5s_null_space(); } /* test_h5s() */ diff --git a/test/tnullspace.h5 b/test/tnullspace.h5 Binary files differnew file mode 100644 index 0000000..542c9d7 --- /dev/null +++ b/test/tnullspace.h5 |