summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-11-23 20:40:35 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-11-23 20:40:35 (GMT)
commitdedc8c37b4fd21a657313a6ecd43318fa4b0fa5c (patch)
treec7ba6d465bfe7ccf19bbac452d81d40358f9241b /test
parentae8f25bd43666b75275f6cb9e2bf0c084f8cea5e (diff)
downloadhdf5-dedc8c37b4fd21a657313a6ecd43318fa4b0fa5c.zip
hdf5-dedc8c37b4fd21a657313a6ecd43318fa4b0fa5c.tar.gz
hdf5-dedc8c37b4fd21a657313a6ecd43318fa4b0fa5c.tar.bz2
[svn-r944] Changes since 19981120
---------------------- ./MANIFEST ./test/Makefile.in ./test/shtype.c [REMOVED] Removed shtype.c because it was all commented out. Besides, these tests are done in dtypes.c now anyway. ./test/external.c ./test/fillval.c ./test/flush1.c ./test/flush2.c ./test/links.c ./test/mount.c ./test/mtime.c ./test/unlink.c The tests that check the HDF5 API use the h5test support functions. For one thing, that means that you can specify the file driver that thay use by the HDF5_DRIVER environment variable. Possible values are: HDF5_DRIVER='sec2' Use read() and write() HDF5_DRIVER='stdio' Use fread() and fwrite() HDF5_DRIVER='core' Use malloc() and free() HDF5_DRIVER='split' Split meta and raw data HDF5_DRIVER='family N' Use file families with each member being N megabytes (N can be fractional, defaults to one). Some tests might fail for certain drivers: for instance, the mount and link tests fail for the `core' driver because they must be able to close and then reopen a file.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in21
-rw-r--r--test/external.c1251
-rw-r--r--test/fillval.c254
-rw-r--r--test/flush1.c75
-rw-r--r--test/flush2.c93
-rw-r--r--test/links.c153
-rw-r--r--test/mount.c390
-rw-r--r--test/mtime.c112
-rw-r--r--test/shtype.c349
-rw-r--r--test/unlink.c169
10 files changed, 1096 insertions, 1771 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index b8d00ab..44218d5 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -14,8 +14,7 @@ LIBS=libh5test.a ../src/libhdf5.a @LIBS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
TEST_PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset \
- extend external shtype links unlink big mtime fillval mount flush1 \
- flush2
+ extend external links unlink big mtime fillval mount flush1 flush2
TIMINGS=iopipe chunk ragged overhead
# The libh5test.a library provides common support code for the tests.
@@ -29,11 +28,10 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
extern_1.h5 extern_2.h5 extern_3.h5 extern_1.raw extern_1b.raw \
extern_2.raw extern_2b.raw extern_3.raw extern_3b.raw \
extern_4.raw extern_4b.raw iopipe.raw iopipe.h5 gheap0.h5 \
- gheap1.h5 gheap2.h5 gheap3.h5 gheap4.h5 shtype0.h5 shtype1.h5 \
- shtype2a.h5 shtype2b.h5 shtype3.h5 links.h5 chunk.h5 big.data \
- big[0-9][0-9][0-9][0-9][0-9].h5 dtypes1.h5 dtypes2.h5 tattr.h5 \
- tselect.h5 mtime.h5 ragged.h5 grptime.h5 unlink.h5 overhead.h5 \
- fillval_[0-9].h5 mount_[0-9].h5 trefer.h5 flush.h5
+ gheap1.h5 gheap2.h5 gheap3.h5 gheap4.h5 links.h5 chunk.h5 \
+ big.data big[0-9][0-9][0-9][0-9][0-9].h5 dtypes1.h5 dtypes2.h5 \
+ tattr.h5 tselect.h5 mtime.h5 ragged.h5 grptime.h5 unlink.h5 \
+ overhead.h5 fillval_[0-9].h5 mount_[0-9].h5 trefer.h5 flush.h5
CLEAN=$(TIMINGS)
# Source and object files for programs... The TEST_SRC list contains all the
@@ -42,9 +40,9 @@ CLEAN=$(TIMINGS)
# overlap with other tests.
TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c trefer.c \
tselect.c tstab.c th5s.c dtypes.c hyperslab.c istore.c dsets.c \
- cmpd_dset.c extend.c external.c iopipe.c gheap.c shtype.c big.c links.c \
- chunk.c bittests.c mtime.c ragged.c unlink.c overhead.c fillval.c \
- mount.c flush1.c flush2.c
+ cmpd_dset.c extend.c external.c iopipe.c gheap.c big.c links.c chunk.c \
+ bittests.c mtime.c ragged.c unlink.c overhead.c fillval.c mount.c \
+ flush1.c flush2.c
TEST_OBJ=$(TEST_SRC:.c=.o)
# Private header files (not to be installed)...
@@ -93,9 +91,6 @@ extend: extend.o
external: external.o
$(CC) $(CFLAGS) -o $@ external.o $(LDFLAGS) $(LIBS)
-shtype: shtype.o
- $(CC) $(CFLAGS) -o $@ shtype.o $(LDFLAGS) $(LIBS)
-
iopipe: iopipe.o
$(CC) $(CFLAGS) -o $@ iopipe.o $(LDFLAGS) $(LIBS)
diff --git a/test/external.c b/test/external.c
index cfb413a..b17df58 100644
--- a/test/external.c
+++ b/test/external.c
@@ -7,10 +7,6 @@
*
* Purpose: Tests datasets stored in external raw files.
*/
-#if 1 /* have to go, and this is only half baked.... 19981120 rpm*/
-int main(void) {return 0;}
-#else
-
#include <h5test.h>
const char *FILENAME[] = {
@@ -20,8 +16,6 @@ const char *FILENAME[] = {
NULL
};
-static int nerrors_g = 0;
-
/*-------------------------------------------------------------------------
* Function: same_contents
@@ -71,373 +65,478 @@ same_contents (const char *name1, const char *name2)
/*-------------------------------------------------------------------------
- * Function: test_1
+ * Function: test_1a
+ *
+ * Purpose: Tests a non-extendible dataset with a single external file.
*
- * Purpose: Describes various external datasets in an HDF5 file without
- * actually creating the external raw files.
+ * Return: Success: 0
*
- * Return: void
+ * Failure: number of errors
*
* Programmer: Robb Matzke
- * Tuesday, March 3, 1998
+ * Monday, November 23, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void
-test_1 (hid_t fapl)
+static int
+test_1a(hid_t file)
{
- hid_t file, plist, space, dset, grp;
- herr_t status;
- hsize_t size[2], max_size[2];
- herr_t (*func)(void*) = NULL;
- void *client_data = NULL;
- int n;
- char filename[1024];
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*data space current size */
+ hsize_t max_size[1]; /*data space maximum size */
+ int n; /*number of external files */
+ char name[256]; /*external file name */
+ off_t file_offset; /*external file offset */
+ hsize_t file_size; /*sizeof external file segment */
- /*
- * Create the file and an initial group. This causes messages about
- * debugging to be emitted before we start playing games with what the
- * output looks like.
- */
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, fapl))<0) goto error;
- if ((grp = H5Gcreate (file, "emit-diagnostics", 8))<0) goto error;
- if (H5Gclose (grp)<0) goto error;
-
- /*
- * A single external file for a non-extendible dataset.
- */
TESTING("fixed-size data space, exact storage");
- if ((plist = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
- if (H5Pset_external (plist, "ext1.data", 0, (hsize_t)400)<0) goto error;
-
- size[0] = max_size[0] = 100;
- if ((space = H5Screate_simple (1, size, max_size))<0) goto error;
- /* Create the dataset, the `dset1' name is used later too */
- if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist))<0)
+ /* Create the dataset */
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)400)<0) goto error;
+ cur_size[0] = max_size[0] = 100;
+ if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
+ if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, dcpl))<0)
goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Sclose (space)<0) goto error;
- if (H5Pclose (plist)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+
+ /* Read dataset creation information */
+ if ((dset = H5Dopen (file, "dset1"))<0) goto error;
+ if ((dcpl = H5Dget_create_plist (dset))<0) goto error;
+ if ((n=H5Pget_external_count (dcpl))<0) goto error;
+ if (1!=n) {
+ FAILED();
+ puts(" Returned external count is wrong.");
+ printf(" got: %d\n ans: 1\n", n);
+ goto error;
+ }
+ strcpy (name+sizeof(name)-4, "...");
+ if (H5Pget_external (dcpl, 0, sizeof(name)-4, name, &file_offset,
+ &file_size)<0) goto error;
+ if (file_offset!=0) {
+ FAILED();
+ puts(" Wrong file offset.");
+ printf(" got: %lu\n ans: 0\n", (unsigned long)file_offset);
+ goto error;
+ }
+ if (file_size!=400) {
+ FAILED();
+ puts(" Wrong file size.");
+ printf(" got: %lu\n ans: 400\n", (unsigned long)file_size);
+ goto error;
+ }
+ if (H5Pclose (dcpl)<0) goto error;
+ if (H5Dclose (dset)<0) goto error;
PASSED();
+ return 0;
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ H5Dclose(dset);
+ } H5E_END_TRY;
+ return 1;
+}
- /*
- * A single external file which is too small to represent all the data.
- */
- do {
- printf ("%-70s", "...external storage is too small");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)399);
- assert (status>=0);
-
- size[0] = max_size[0] = 100;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
-
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- dset = H5Dcreate (file, "dset2", H5T_NATIVE_INT, space, plist);
- H5Eset_auto (func, client_data);
-
- if (dset>=0) {
- puts ("*FAILED*");
- printf (" Small external file succeeded instead of failing\n");
- nerrors_g++;
- H5Dclose (dset);
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
-
- /*
- * A single external file which is large enough to represent the current
- * data and large enough to represent the eventual size of the data.
- */
- do {
- printf ("%-70s", "...extendible dataspace, exact external size");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)800);
- assert (status>=0);
-
- size[0] = 100;
- max_size[0] = 200;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
-
- dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT, space, plist);
- if (dset<0) break;
- H5Dclose (dset);
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1b
+ *
+ * Purpose: Test a single external file which is too small to represent
+ * all the data.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1b(hid_t file)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*current data space size */
+ hsize_t max_size[1]; /*maximum data space size */
+
+ TESTING("external storage is too small");
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external (dcpl, "ext1.data", 0, (hsize_t)399)<0) goto error;
+ cur_size[0] = max_size[0] = 100;
+ if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
+ H5E_BEGIN_TRY {
+ dset = H5Dcreate (file, "dset2", H5T_NATIVE_INT, space, dcpl);
+ } H5E_END_TRY;
+ if (dset>=0) {
+ FAILED();
+ puts(" Small external file succeeded instead of failing.");
+ goto error;
+ }
+ if (H5Sclose (space)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+ PASSED();
+ return 0;
+ error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Pclose(dcpl);
+ H5Dclose(dset);
+ } H5E_END_TRY;
+ return 1;
+}
- /*
- * A single external file which is large enough for the current data size
- * but not large enough for the eventual size.
- */
- do {
- printf ("%-70s", "...extendible dataspace, "
- "external storage is too small");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)799);
- assert (status>=0);
-
- size[0] = 100;
- max_size[0] = 200;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
-
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- dset = H5Dcreate (file, "dset4", H5T_NATIVE_INT, space, plist);
- H5Eset_auto (func, client_data);
-
- if (dset>=0) {
- puts ("*FAILED*");
- printf (" Small external file succeeded instead of failing\n");
- H5Dclose (dset);
- nerrors_g++;
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1c
+ *
+ * Purpose: Test a single external file which is large enough to
+ * represent the current data and large enough to represent the
+ * eventual size of the data.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1c(hid_t file)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*current data space size */
+ hsize_t max_size[1]; /*maximum data space size */
+
+ TESTING("extendible dataspace, exact external size");
+ if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external (dcpl, "ext1.data", 0, (hsize_t)800)<0) goto error;
+ cur_size[0] = 100;
+ max_size[0] = 200;
+ if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
+ if ((dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT, space, dcpl))<0)
+ goto error;
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Sclose (space)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+ PASSED();
+ return 0;
- /*
- * A single external file of unlimited size and an unlimited data space.
- */
- do {
- printf ("%-70s", "...unlimited dataspace, unlimited external storage");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED);
- assert (status>=0);
-
- size[0] = 100;
- max_size[0] = H5S_UNLIMITED;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
-
- /* Create the dataset, the `dset5' name is used later too */
- dset = H5Dcreate (file, "dset5", H5T_NATIVE_INT, space, plist);
- if (dset<0) break;
- H5Dclose (dset);
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return 1;
+}
- /*
- * Open one of the previous datasets and make sure it looks the same as
- * when we wrote it.
- */
- do {
- char name[256];
- off_t file_offset;
- hsize_t file_size;
-
- printf ("%-70s", "...opening a dataset and reading the storage info");
- fflush (stdout);
-
- dset = H5Dopen (file, "dset1");
- assert (dset>=0);
- plist = H5Dget_create_plist (dset);
- assert (plist>=0);
-
- n = H5Pget_external_count (plist);
- if (n<0) break;
- if (1!=n) {
- puts ("*FAILED*");
- printf (" Returned external count is wrong.\n");
- nerrors_g++;
- break;
- }
- strcpy (name+sizeof(name)-4, "...");
- status = H5Pget_external (plist, 0, sizeof(name)-4, name,
- &file_offset, &file_size);
- if (status<0) {
- printf (" Unable to read first extern file info.\n");
- break;
- } else if (file_offset!=0) {
- puts ("*FAILED*");
- printf (" Wrong file offset.\n");
- nerrors_g++;
- break;
- } else if (file_size!=400) {
- puts ("*FAILED*");
- printf (" Wrong file size.\n");
- nerrors_g++;
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Pclose (plist);
- H5Dclose (dset);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1d
+ *
+ * Purpose: Test a single external file which is large enough for the
+ * current data size but not large enough for the eventual size.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1d(hid_t file)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*current data space size */
+ hsize_t max_size[1]; /*maximum data space size */
+
+ TESTING("extendible dataspace, external storage is too small");
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)799)<0) goto error;
+ cur_size[0] = 100;
+ max_size[0] = 200;
+ if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
+ H5E_BEGIN_TRY {
+ dset = H5Dcreate (file, "dset4", H5T_NATIVE_INT, space, dcpl);
+ } H5E_END_TRY;
+ if (dset>=0) {
+ FAILED();
+ puts(" Small external file succeeded instead of failing.");
+ goto error;
+ }
+ if (H5Sclose (space)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+ PASSED();
+ return 0;
- /*
- * Open one of the previous unlimited datasets and make sure it looks the
- * same as when we wrote it.
- */
- do {
- char name[256];
- off_t file_offset;
- hsize_t file_size;
-
- printf ("%-70s", "...opening an unlimited dataset and reading the "
- "storage info");
- fflush (stdout);
-
- dset = H5Dopen (file, "dset5");
- assert (dset>=0);
- plist = H5Dget_create_plist (dset);
- assert (plist>=0);
-
- n = H5Pget_external_count (plist);
- if (n<0) break;
- if (1!=n) {
- puts ("*FAILED*");
- printf (" Returned external count is wrong.\n");
- nerrors_g++;
- break;
- }
- strcpy (name+sizeof(name)-4, "...");
- status = H5Pget_external (plist, 0, sizeof(name)-4, name,
- &file_offset, &file_size);
- if (status<0) {
- printf (" Unable to read first extern file info.\n");
- break;
- } else if (file_offset!=0) {
- puts ("*FAILED*");
- printf (" Wrong file offset.\n");
- nerrors_g++;
- break;
- } else if (H5F_UNLIMITED!=file_size) {
- puts ("*FAILED*");
- printf (" Wrong file size.\n");
- nerrors_g++;
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Pclose (plist);
- H5Dclose (dset);
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return 1;
+}
- /*
- * Multiple external files for a dataset.
- */
- do {
- printf ("%-70s", "...multiple external files");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)100);
- assert (status>=0);
- status = H5Pset_external (plist, "ext2.data", 0, (hsize_t)100);
- assert (status>=0);
- status = H5Pset_external (plist, "ext3.data", 0, (hsize_t)100);
- assert (status>=0);
- status = H5Pset_external (plist, "ext4.data", 0, (hsize_t)100);
- assert (status>=0);
-
- size[0] = max_size[0] = 100;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
-
- dset = H5Dcreate (file, "dset6", H5T_NATIVE_INT, space, plist);
- if (dset<0) break;
- H5Dclose (dset);
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1e
+ *
+ * Purpose: Test a single external file of unlimited size and an
+ * unlimited data space.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1e(hid_t file)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*data space current size */
+ hsize_t max_size[1]; /*data space maximum size */
+ int n; /*number of external files */
+ char name[256]; /*external file name */
+ off_t file_offset; /*external file offset */
+ hsize_t file_size; /*sizeof external file segment */
+
+ TESTING("unlimited dataspace, unlimited external storage");
+
+ /* Create dataset */
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED)<0) goto error;
+ cur_size[0] = 100;
+ max_size[0] = H5S_UNLIMITED;
+ if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
+ if ((dset=H5Dcreate(file, "dset5", H5T_NATIVE_INT, space, dcpl))<0)
+ goto error;
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Sclose (space)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+
+ /* Read dataset creation information */
+ if ((dset = H5Dopen (file, "dset5"))<0) goto error;
+ if ((dcpl = H5Dget_create_plist (dset))<0) goto error;
+ if ((n = H5Pget_external_count (dcpl))<0) goto error;
+ if (1!=n) {
+ FAILED();
+ puts(" Returned external count is wrong.");
+ printf(" got: %d\n ans: 1\n", n);
+ goto error;
+ }
+ strcpy (name+sizeof(name)-4, "...");
+ if (H5Pget_external (dcpl, 0, sizeof(name)-4, name, &file_offset,
+ &file_size)<0) goto error;
+ if (file_offset!=0) {
+ FAILED();
+ puts(" Wrong file offset.");
+ printf(" got: %lu\n ans: 0\n", (unsigned long)file_offset);
+ goto error;
+ }
+ if (H5F_UNLIMITED!=file_size) {
+ FAILED();
+ puts(" Wrong file size.");
+ printf(" got: %lu\n ans: INF\n", (unsigned long)file_size);
+ goto error;
+ }
+ if (H5Pclose (dcpl)<0) goto error;
+ if (H5Dclose (dset)<0) goto error;
+ PASSED();
+ return 0;
- /*
- * It should be impossible to define an unlimited external file and then
- * follow it with another external file.
- */
- do {
- printf ("%-70s", "...external file following unlimited file");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED);
- assert (status>=0);
-
- /* Next function should fail */
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- status = H5Pset_external (plist, "ext2.data", 0, (hsize_t)100);
- H5Eset_auto (func, client_data);
- if (status>=0) {
- puts ("*FAILED*");
- puts (" H5Pset_external() succeeded when it should have failed");
- nerrors_g++;
- break;
- }
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return 1;
+}
- /* Check the number of files */
- n = H5Pget_external_count (plist);
- if (n<0) break;
- if (1!=n) {
- puts ("*FAILED*");
- puts (" Wrong external file count returned.");
- nerrors_g++;
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Pclose (plist);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1f
+ *
+ * Purpose: Test multiple external files for a dataset.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1f(hid_t file)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hsize_t cur_size[1]; /*data space current size */
+ hsize_t max_size[1]; /*data space maximum size */
+
+ TESTING("multiple external files");
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)100)<0) goto error;
+ if (H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)100)<0) goto error;
+ if (H5Pset_external(dcpl, "ext3.data", 0, (hsize_t)100)<0) goto error;
+ if (H5Pset_external(dcpl, "ext4.data", 0, (hsize_t)100)<0) goto error;
+ cur_size[0] = max_size[0] = 100;
+ if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
+ if ((dset=H5Dcreate(file, "dset6", H5T_NATIVE_INT, space, dcpl))<0)
+ goto error;
+ if (H5Dclose(dset)<0) goto error;
+ if (H5Sclose(space)<0) goto error;
+ if (H5Pclose(dcpl)<0) goto error;
+ PASSED();
+ return 0;
- /*
- * It should be impossible to create a set of external files whose total
- * size overflows a size_t integer.
- */
- do {
- printf ("%-70s", "...address overflow in external files");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, H5F_UNLIMITED-1);
- assert (status>=0);
-
- /* Next function should fail */
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- status = H5Pset_external (plist, "ext2.data", 0, (hsize_t)100);
- H5Eset_auto (func, client_data);
- if (status>=0) {
- puts ("*FAILED*");
- puts (" H5Pset_external() succeeded when it should have failed");
- nerrors_g++;
- break;
- }
- puts (" PASSED");
- } while (0);
- H5Pclose (plist);
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ } H5E_END_TRY;
+ return 1;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_1g
+ *
+ * Purpose: It should be impossible to define an unlimited external file
+ * and then follow it with another external file.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1g(void)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ herr_t status; /*function return status */
+ int n; /*number of external files */
+
+ TESTING("external file following unlimited file");
+ if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED)<0) goto error;
+ H5E_BEGIN_TRY {
+ status = H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)100);
+ } H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" H5Pset_external() succeeded when it should have failed.");
+ goto error;
+ }
+ if ((n = H5Pget_external_count(dcpl))<0) goto error;
+ if (1!=n) {
+ FAILED();
+ puts(" Wrong external file count returned.");
+ goto error;
+ }
+ if (H5Pclose(dcpl)<0) goto error;
+ PASSED();
+ return 0;
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ } H5E_END_TRY;
+ return 1;
+}
- /* END OF TESTS */
- H5Fclose (file);
+
+/*-------------------------------------------------------------------------
+ * Function: test_1h
+ *
+ * Purpose: It should be impossible to create a set of external files
+ * whose total size overflows a size_t integer.
+ *
+ * Return: Success: 0
+ *
+ * Failure: number of errors
+ *
+ * Programmer: Robb Matzke
+ * Monday, November 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_1h(void)
+{
+ hid_t dcpl=-1; /*dataset creation properties */
+ herr_t status; /*return status */
+
+ TESTING("address overflow in external files");
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED-1)<0) goto error;
+ H5E_BEGIN_TRY {
+ status = H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)100);
+ } H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts(" H5Pset_external() succeeded when it should have failed.");
+ goto error;
+ }
+ if (H5Pclose(dcpl)<0) goto error;
+ PASSED();
+ return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ } H5E_END_TRY;
+ return 1;
}
@@ -446,7 +545,9 @@ test_1 (hid_t fapl)
*
* Purpose: Tests reading from an external file set.
*
- * Return: void
+ * Return: Success: 0
+ *
+ * Failure: number of errors
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
@@ -455,26 +556,33 @@ test_1 (hid_t fapl)
*
*-------------------------------------------------------------------------
*/
-static void
-test_2 (void)
+static int
+test_2 (hid_t fapl)
{
- hid_t file, plist, space, dset, grp;
- herr_t status;
- int fd;
- hsize_t i, j;
- hssize_t n;
- char fname[64];
- int part[25], whole[100];
- hsize_t size;
-
- /* Write the data to external files */
+ hid_t file=-1; /*file to write to */
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t space=-1; /*data space */
+ hid_t dset=-1; /*dataset */
+ hid_t grp=-1; /*group to emit diagnostics */
+ int fd; /*external file descriptors */
+ hsize_t i, j; /*miscellaneous counters */
+ hssize_t n; /*bytes of I/O */
+ char filename[1024]; /*file names */
+ int part[25], whole[100]; /*raw data buffers */
+ hsize_t cur_size; /*current data space size */
+ hid_t hs_space; /*hyperslab data space */
+ hssize_t hs_start = 30; /*hyperslab starting offset */
+ hsize_t hs_count = 25; /*hyperslab size */
+
+ TESTING("read external dataset");
+
+ /* Write the data to external files directly */
for (i=0; i<4; i++) {
for (j=0; j<25; j++) {
part[j] = (int)(i*25+j);
}
-
- sprintf (fname, "extern_%lu.raw", (unsigned long)i+1);
- fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ sprintf (filename, "extern_%lua.raw", (unsigned long)i+1);
+ fd = open (filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
assert (fd>=0);
n = lseek (fd, (off_t)(i*10), SEEK_SET);
assert (n>=0 && (size_t)n==i*10);
@@ -488,115 +596,71 @@ test_2 (void)
* debugging to be emitted before we start playing games with what the
* output looks like.
*/
- file = H5Fcreate (TEST_FILE_NAME2, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT);
- assert (file>=0);
- grp = H5Gcreate (file, "emit-diagnostics", 8);
- H5Gclose (grp);
-
- /* Create the external file list */
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "extern_1.raw", 0,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_2.raw", 10,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_3.raw", 20,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_4.raw", 30,
- (hsize_t)sizeof(part));
- assert (status>=0);
-
- /* Create the data space */
- size = 100;
- space = H5Screate_simple (1, &size, NULL);
- assert (space>=0);
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
+ if ((grp=H5Gcreate(file, "emit-diagnostics", 8))<0) goto error;
+ if (H5Gclose(grp)<0) goto error;
/* Create the dataset */
- dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist);
- assert (dset>=0);
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external (dcpl, "extern_1a.raw", 0, (hsize_t)sizeof part)<0 ||
+ H5Pset_external (dcpl, "extern_2a.raw", 10, (hsize_t)sizeof part)<0 ||
+ H5Pset_external (dcpl, "extern_3a.raw", 20, (hsize_t)sizeof part)<0 ||
+ H5Pset_external (dcpl, "extern_4a.raw", 30, (hsize_t)sizeof part)<0)
+ goto error;
+ cur_size = 100;
+ if ((space=H5Screate_simple (1, &cur_size, NULL))<0) goto error;
+ if ((dset=H5Dcreate(file, "dset1", H5T_NATIVE_INT, space, dcpl))<0)
+ goto error;
/*
* Read the entire dataset and compare with the original
*/
- do {
- /* Read from the dataset */
- printf ("%-70s", "...reading entire dataset");
- fflush (stdout);
-
- memset (whole, 0, sizeof(whole));
- status = H5Dread (dset, H5T_NATIVE_INT, space, space,
- H5P_DEFAULT, whole);
- if (status<0) {
- puts (" Failed to read dataset");
- break;
- }
-
- for (i=0; i<100; i++) {
- if (whole[i]!=(signed)i) {
- puts ("*FAILED*");
- puts (" Incorrect value(s) read.");
- nerrors_g++;
- break;
- }
+ memset (whole, 0, sizeof(whole));
+ if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole)<0)
+ goto error;
+ for (i=0; i<100; i++) {
+ if (whole[i]!=(signed)i) {
+ FAILED();
+ puts(" Incorrect value(s) read.");
+ goto error;
}
- puts (" PASSED");
- } while (0);
-
+ }
-
/*
* Read the middle of the dataset
*/
- do {
- hid_t hs_space;
- hssize_t hs_start = 30;
- hsize_t hs_count = 25;
-
- /* Read from the dataset */
- printf ("%-70s", "...reading partial dataset");
- fflush (stdout);
-
- hs_space = H5Scopy (space);
- assert (hs_space>=0);
- status = H5Sselect_hyperslab (hs_space, H5S_SELECT_SET, &hs_start,
- NULL, &hs_count, NULL);
- assert (status>=0);
-
- memset (whole, 0, sizeof(whole));
- status = H5Dread (dset, H5T_NATIVE_INT, hs_space, hs_space,
- H5P_DEFAULT, whole);
- H5Sclose (hs_space);
- if (status<0) {
- puts (" Failed to read dataset");
- break;
+ if ((hs_space=H5Scopy(space))<0) goto error;
+ if (H5Sselect_hyperslab(hs_space, H5S_SELECT_SET, &hs_start, NULL,
+ &hs_count, NULL)<0) goto error;
+ memset(whole, 0, sizeof(whole));
+ if (H5Dread (dset, H5T_NATIVE_INT, hs_space, hs_space, H5P_DEFAULT,
+ whole)<0) goto error;
+ if (H5Sclose (hs_space)<0) goto error;
+ for (i=hs_start; i<hs_start+hs_count; i++) {
+ if (whole[i]!=(signed)i) {
+ FAILED();
+ puts(" Incorrect value(s) read.");
+ goto error;
}
-
-#if 0
- for (i=0; i<100; i++) {
- printf (" #%02d %3d %s\n",
- i, whole[i], whole[i]==i?"":" <------------------------");
- }
-#endif
-
- for (i=hs_start; i<hs_start+hs_count; i++) {
- if (whole[i]!=(signed)i) {
- puts ("*FAILED*");
- puts (" Incorrect value(s) read.");
- nerrors_g++;
- break;
- }
- }
- puts (" PASSED");
- } while (0);
+ }
- H5Dclose (dset);
- H5Pclose (plist);
- H5Sclose (space);
- H5Fclose (file);
+ if (H5Dclose(dset)<0) goto error;
+ if (H5Pclose(dcpl)<0) goto error;
+ if (H5Sclose(space)<0) goto error;
+ if (H5Fclose(file)<0) goto error;
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return 1;
}
@@ -605,7 +669,9 @@ test_2 (void)
*
* Purpose: Tests writing to an external file set.
*
- * Return: void
+ * Return: Success: 0
+ *
+ * Failure: number of errors
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
@@ -614,159 +680,100 @@ test_2 (void)
*
*-------------------------------------------------------------------------
*/
-static void
-test_3 (void)
+static int
+test_3 (hid_t fapl)
{
- hid_t file, plist, mem_space, file_space, dset;
- herr_t status;
- unsigned i;
- int fd;
- int part[25], whole[100];
- hssize_t hs_start=100;
- hsize_t size=100, max_size=200, hs_count=100;
-
- /*
- * Create another file
- */
- file = H5Fcreate (TEST_FILE_NAME3, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT);
- assert (file>=0);
+ hid_t file=-1; /*file to which to write */
+ hid_t dcpl=-1; /*dataset creation properties */
+ hid_t mem_space=-1; /*memory data space */
+ hid_t file_space=-1; /*file data space */
+ hid_t dset=-1; /*dataset */
+ unsigned i; /*miscellaneous counters */
+ int fd; /*external file descriptor */
+ int part[25], whole[100]; /*raw data buffers */
+ hsize_t cur_size=100; /*current data space size */
+ hsize_t max_size=200; /*maximum data space size */
+ hssize_t hs_start=100; /*hyperslab starting offset */
+ hsize_t hs_count=100; /*hyperslab size */
+ char filename[1024]; /*file name */
+
+ TESTING("write external dataset");
+
+ /* Create another file */
+ h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT,
+ fapl))<0) goto error;
/* Create the external file list */
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "extern_1b.raw", 0,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_2b.raw", 10,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_3b.raw", 20,
- (hsize_t)sizeof(part));
- assert (status>=0);
- status = H5Pset_external (plist, "extern_4b.raw", 30,
- H5F_UNLIMITED);
- assert (status>=0);
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external(dcpl, "extern_1b.raw", 0, (hsize_t)sizeof part)<0 ||
+ H5Pset_external(dcpl, "extern_2b.raw", 10, (hsize_t)sizeof part)<0 ||
+ H5Pset_external(dcpl, "extern_3b.raw", 20, (hsize_t)sizeof part)<0 ||
+ H5Pset_external(dcpl, "extern_4b.raw", 30, H5F_UNLIMITED)<0)
+ goto error;
/* Make sure the output files are fresh*/
- fd = open ("extern_1b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666);
- close (fd);
- fd = open ("extern_2b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666);
- close (fd);
- fd = open ("extern_3b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666);
- close (fd);
- fd = open ("extern_4b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666);
- close (fd);
-
- /* Create the data space */
- mem_space = H5Screate_simple (1, &size, &max_size);
- assert (mem_space>=0);
- file_space = H5Scopy (mem_space);
+ for (i=1; i<=4; i++) {
+ sprintf(filename, "extern_%db.raw", i);
+ if ((fd= open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) {
+ FAILED();
+ printf(" cannot open %s: %s\n", filename, strerror(errno));
+ goto error;
+ }
+ close (fd);
+ }
/* Create the dataset */
- dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, file_space, plist);
- assert (dset>=0);
+ if ((mem_space=H5Screate_simple(1, &cur_size, &max_size))<0) goto error;
+ if ((file_space=H5Scopy(mem_space))<0) goto error;
+ if ((dset=H5Dcreate(file, "dset1", H5T_NATIVE_INT, file_space, dcpl))<0)
+ goto error;
- /*
- * Write the entire dataset and compare with the original
- */
- do {
- printf ("%-70s", "...writing entire dataset");
- fflush (stdout);
-
- for (i=0; i<size; i++) whole[i] = i;
- status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, file_space,
- H5P_DEFAULT, whole);
- if (status<0) break;
- for (i=0; i<4; i++) {
- char name1[64], name2[64];
- sprintf (name1, "extern_%d.raw", i+1);
- sprintf (name2, "extern_%db.raw", i+1);
- if (!same_contents (name1, name2)) {
- puts ("*FAIL*");
- puts (" Output differs from expected value.");
- nerrors_g++;
- break;
- }
+ /* Write the entire dataset and compare with the original */
+ for (i=0; i<cur_size; i++) whole[i] = i;
+ if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT,
+ whole)<0) goto error;
+ for (i=0; i<4; i++) {
+ char name1[64], name2[64];
+ sprintf (name1, "extern_%da.raw", i+1);
+ sprintf (name2, "extern_%db.raw", i+1);
+ if (!same_contents (name1, name2)) {
+ FAILED();
+ puts (" Output differs from expected value.");
+ goto error;
}
- puts (" PASSED");
- } while (0);
-
- /*
- * Extend the dataset by another 100 elements
- */
- do {
- printf ("%-70s", "...extending external contiguous dataset");
- fflush (stdout);
-
- if (H5Dextend (dset, &max_size)<0) break;
- H5Sclose (file_space);
- file_space = H5Dget_space (dset);
- puts (" PASSED");
- } while (0);
-
- /*
- * Write second half of dataset
- */
- do {
- printf ("%-70s", "...writing to extended part of dataset");
- fflush (stdout);
+ }
- for (i=0; i<hs_count; i++) {
- whole[i] = 100+i;
- }
- status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL);
- assert (status>=0);
- status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, file_space,
- H5P_DEFAULT, whole);
- if (status<0) break;
- puts (" PASSED");
- } while (0);
-
+ /* Extend the dataset by another 100 elements */
+ if (H5Dextend(dset, &max_size)<0) goto error;
+ if (H5Sclose(file_space)<0) goto error;
+ if ((file_space=H5Dget_space(dset))<0) goto error;
+ /* Write second half of dataset */
+ for (i=0; i<hs_count; i++) whole[i] = 100+i;
+ if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, &hs_start, NULL,
+ &hs_count, NULL)<0) goto error;
+ if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT,
+ whole)<0) goto error;
- H5Dclose (dset);
- H5Pclose (plist);
- H5Sclose (mem_space);
- H5Sclose (file_space);
- H5Fclose (file);
-}
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Pclose (dcpl)<0) goto error;
+ if (H5Sclose (mem_space)<0) goto error;
+ if (H5Sclose (file_space)<0) goto error;
+ if (H5Fclose (file)<0) goto error;
+ PASSED();
+ return 0;
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME1);
- remove(TEST_FILE_NAME2);
- remove(TEST_FILE_NAME3);
- /* not sure if the following file names can be #defined */
- /* because some of them are created during runtime. */
- /* List them out this way for now. */
- remove("extern_1.raw");
- remove("extern_1b.raw");
- remove("extern_2.raw");
- remove("extern_2b.raw");
- remove("extern_3.raw");
- remove("extern_3b.raw");
- remove("extern_4.raw");
- remove("extern_4b.raw");
- }
+ error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Pclose(dcpl);
+ H5Sclose(mem_space);
+ H5Sclose(file_space);
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return 1;
}
@@ -789,19 +796,55 @@ cleanup(void)
int
main (void)
{
- H5Eset_auto (display_error_cb, NULL);
-
- test_1 ();
- test_2 ();
- test_3 ();
+ hid_t fapl=-1; /*file access properties */
+ hid_t file=-1; /*file for test_1* functions */
+ char filename[1024]; /*file name for test_1* funcs */
+ hid_t grp=-1; /*group to emit diagnostics */
+ int nerrors=0; /*number of errors */
+
+ h5_reset();
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT,
+ fapl))<0) goto error;
+ if ((grp=H5Gcreate(file, "emit-diagnostics", 8))<0) goto error;
+ if (H5Gclose (grp)<0) goto error;
- if (0==nerrors_g) {
- printf ("All external storage tests passed.\n");
- cleanup();
- } else {
- printf ("%d TEST%s FAILED.\n", nerrors_g, 1==nerrors_g?"":"s");
+ nerrors += test_1a(file);
+ nerrors += test_1b(file);
+ nerrors += test_1c(file);
+ nerrors += test_1d(file);
+ nerrors += test_1e(file);
+ nerrors += test_1f(file);
+ nerrors += test_1g();
+ nerrors += test_1h();
+ nerrors += test_2(fapl);
+ nerrors += test_3(fapl);
+ if (nerrors>0) goto error;
+
+ if (H5Fclose(file)<0) goto error;
+ puts("All external storage tests passed.");
+ h5_cleanup(fapl);
+
+ /* cleanup external files */
+ if (!getenv("HDF5_NOCLEANUP")) {
+ remove("extern_1a.raw");
+ remove("extern_1b.raw");
+ remove("extern_2a.raw");
+ remove("extern_2b.raw");
+ remove("extern_3a.raw");
+ remove("extern_3b.raw");
+ remove("extern_4a.raw");
+ remove("extern_4b.raw");
}
+ return 0;
- return (nerrors_g?1:0);
+ error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+ nerrors = MAX(1, nerrors);
+ printf ("%d TEST%s FAILED.\n", nerrors, 1==nerrors?"":"s");
+ return 1;
}
-#endif
diff --git a/test/fillval.c b/test/fillval.c
index 93643eb..71aa7fb 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -7,20 +7,7 @@
*
* Purpose: Tests dataset fill values.
*/
-
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <fcntl.h>
-# include <stdlib.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif
+#include <h5test.h>
/*
* Define NO_FILLING if you want to compare how this test works when there is
@@ -28,77 +15,18 @@
*/
/* #define NO_FILLING */
+const char *FILENAME[] = {
+ "fillval_1",
+ "fillval_2",
+ "fillval_3",
+ "fillval_4",
+ "fillval_5",
+ "fillval_6",
+ NULL
+};
-#define FILE_NAME_1 "fillval_1.h5"
-#define FILE_NAME_2 "fillval_2.h5"
-#define FILE_NAME_3 "fillval_3.h5"
-#define FILE_NAME_4 "fillval_4.h5"
-#define FILE_NAME_5 "fillval_5.h5"
-#define FILE_NAME_6 "fillval_6.h5"
#define FILE_NAME_RAW "fillval.raw"
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv("HDF5_NOCLEANUP")) {
- remove(FILE_NAME_1);
- remove(FILE_NAME_2);
- remove(FILE_NAME_3);
- remove(FILE_NAME_4);
- remove(FILE_NAME_5);
- remove(FILE_NAME_6);
- remove(FILE_NAME_RAW);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb(void __unused__ *client_data)
-{
- puts("*FAILED*");
- H5Eprint(stdout);
- return 0;
-}
-
/*-------------------------------------------------------------------------
* Function: test_getset
@@ -121,9 +49,9 @@ static int
test_getset(void)
{
herr_t status;
- hid_t dcpl;
+ hid_t dcpl=-1;
int fill_i;
- hid_t type_ss, type_si;
+ hid_t type_ss=-1, type_si=-1;
struct fill_si {
int v1, v2;
} fill_si;
@@ -131,8 +59,7 @@ test_getset(void)
short v1, v2;
} fill_ss, fill_ss_rd;
- printf("%-70s", "Testing property lists");
- fflush(stdout);
+ TESTING("property lists");
/*
* Create the dataset creation property list and the data types that will
@@ -162,8 +89,8 @@ test_getset(void)
status = H5Pget_fill_value(dcpl, H5T_NATIVE_INT, &fill_i);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" H5Pget_fill_value() should have been negative");
+ FAILED();
+ puts(" H5Pget_fill_value() should have been negative");
goto error;
}
@@ -179,9 +106,9 @@ test_getset(void)
*/
if (H5Pget_fill_value(dcpl, type_ss, &fill_ss_rd)<0) goto error;
if (fill_ss.v1!=fill_ss_rd.v1 || fill_ss.v2!=fill_ss_rd.v2) {
- puts("*FAILED*");
- puts(" Failed to get fill value using same data type that was used");
- puts(" to set the fill value.");
+ FAILED();
+ puts(" Failed to get fill value using same data type that was ");
+ puts(" used to set the fill value.");
goto error;
}
@@ -190,9 +117,9 @@ test_getset(void)
*/
if (H5Pget_fill_value(dcpl, type_si, &fill_si)<0) goto error;
if (fill_ss.v1!=fill_si.v1 || fill_ss.v2!=fill_si.v2) {
- puts("*FAILED*");
- puts(" Failed to get fill value using a data type other than what");
- puts(" was used to set the fill value.");
+ FAILED();
+ puts(" Failed to get fill value using a data type other than what");
+ puts(" was used to set the fill value.");
goto error;
}
@@ -202,18 +129,24 @@ test_getset(void)
if (H5Pset_fill_value(dcpl, type_si, &fill_si)<0) goto error;
if (H5Pget_fill_value(dcpl, type_ss, &fill_ss)<0) goto error;
if (fill_si.v1!=fill_ss.v1 || fill_si.v2!=fill_ss.v2) {
- puts("*FAILED*");
- puts(" Resetting the fill value was unsuccessful.");
+ FAILED();
+ puts(" Resetting the fill value was unsuccessful.");
goto error;
}
/* Success */
if (H5Pclose(dcpl)<0) goto error;
- puts(" PASSED");
+ if (H5Tclose(type_si)<0) goto error;
+ if (H5Tclose(type_ss)<0) goto error;
+ PASSED();
return 0;
error:
- H5Pclose(dcpl);
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Tclose(type_si);
+ H5Tclose(type_ss);
+ } H5E_END_TRY;
return 1;
}
@@ -235,30 +168,29 @@ test_getset(void)
*-------------------------------------------------------------------------
*/
static int
-test_create(const char *filename, H5D_layout_t layout)
+test_create(hid_t fapl, const char *basename, H5D_layout_t layout)
{
hid_t file=-1, space=-1, dcpl=-1, dset1=-1, dset2=-1, dset3=-1;
hsize_t cur_size[5] = {32, 16, 8, 4, 2};
hsize_t ch_size[5] = {1, 1, 1, 4, 2};
short rd_s, fill_s = 0x1234;
long rd_l, fill_l = 0x4321;
- char test[256];
+ char filename[1024];
if (H5D_CHUNKED==layout) {
- strcpy(test, "Testing chunked dataset creation");
+ TESTING("chunked dataset creation");
} else {
- strcpy(test, "Testing contiguous dataset creation");
+ TESTING("contiguous dataset creation");
}
- printf("%-70s", test);
- fflush(stdout);
/*
* Create a file and three datasets. The three datasets test three fill
* conversion paths: small to large, large to small, and no conversion.
* They depend on `short' being smaller than `long'.
*/
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ h5_fixname(basename, fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if ((space=H5Screate_simple(5, cur_size, cur_size))<0) goto error;
if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5D_CHUNKED==layout) {
@@ -295,7 +227,7 @@ test_create(const char *filename, H5D_layout_t layout)
if (H5Fclose(file)<0) goto error;
/* Open the file and get the dataset fill value from each dataset */
- if ((file=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0)
goto error;
/* Large to small conversion */
@@ -305,9 +237,9 @@ test_create(const char *filename, H5D_layout_t layout)
#ifndef NO_FILLING
if (H5Pget_fill_value(dcpl, H5T_NATIVE_SHORT, &rd_s)<0) goto error;
if (rd_s!=fill_s) {
- puts("*FAILED*");
- puts(" Got a different fill value than what was set.");
- printf(" Got %d, set %d\n", rd_s, fill_s);
+ FAILED();
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %d, set %d\n", rd_s, fill_s);
goto error;
}
#endif
@@ -320,9 +252,9 @@ test_create(const char *filename, H5D_layout_t layout)
#ifndef NO_FILLING
if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
if (rd_l!=fill_l) {
- puts("*FAILED*");
- puts(" Got a different fill value than what was set.");
- printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ FAILED();
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
goto error;
}
#endif
@@ -335,9 +267,9 @@ test_create(const char *filename, H5D_layout_t layout)
#ifndef NO_FILLING
if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
if (rd_l!=fill_l) {
- puts("*FAILED*");
- puts(" Got a different fill value than what was set.");
- printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ FAILED();
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
goto error;
}
#endif
@@ -346,7 +278,7 @@ test_create(const char *filename, H5D_layout_t layout)
if (H5Fclose(file)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -379,7 +311,7 @@ test_create(const char *filename, H5D_layout_t layout)
*-------------------------------------------------------------------------
*/
static int
-test_rdwr(const char *filename, H5D_layout_t layout)
+test_rdwr(hid_t fapl, const char *basename, H5D_layout_t layout)
{
hid_t file=-1, fspace=-1, mspace=-1, dcpl=-1, dset=-1;
hsize_t cur_size[5] = {32, 16, 8, 4, 2};
@@ -394,19 +326,18 @@ test_rdwr(const char *filename, H5D_layout_t layout)
#endif
int val_rd, should_be;
int i, j, *buf=NULL, odd;
- char test[256];
+ char filename[1024];
if (H5D_CHUNKED==layout) {
- strcpy(test, "Testing chunked dataset I/O");
+ TESTING("chunked dataset I/O");
} else {
- strcpy(test, "Testing contiguous dataset I/O");
+ TESTING("contiguous dataset I/O");
}
- printf("%-70s", test);
- fflush(stdout);
/* Create a file and dataset */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ h5_fixname(basename, fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if ((fspace=H5Screate_simple(5, cur_size, cur_size))<0) goto error;
if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5D_CHUNKED==layout) {
@@ -429,9 +360,9 @@ test_rdwr(const char *filename, H5D_layout_t layout)
if (H5Dread(dset, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT,
&val_rd)<0) goto error;
if (val_rd!=fillval) {
- puts("*FAILED*");
- puts(" Value read was not a fill value.");
- printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
+ FAILED();
+ puts(" Value read was not a fill value.");
+ printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
"Fill value: %u\n",
(long)hs_offset[0], (long)hs_offset[1],
(long)hs_offset[2], (long)hs_offset[3],
@@ -473,9 +404,9 @@ test_rdwr(const char *filename, H5D_layout_t layout)
&val_rd)<0) goto error;
if (val_rd!=should_be) {
- puts("*FAILED*");
- puts(" Value read was not correct.");
- printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
+ FAILED();
+ puts(" Value read was not correct.");
+ printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
"should be: %u\n",
(long)hs_offset[0], (long)hs_offset[1],
(long)hs_offset[2], (long)hs_offset[3],
@@ -491,7 +422,7 @@ test_rdwr(const char *filename, H5D_layout_t layout)
if (H5Sclose(fspace)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Fclose(file)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -523,7 +454,7 @@ test_rdwr(const char *filename, H5D_layout_t layout)
*-------------------------------------------------------------------------
*/
static int
-test_extend(const char *filename, H5D_layout_t layout)
+test_extend(hid_t fapl, const char *basename, H5D_layout_t layout)
{
hid_t file=-1, fspace=-1, mspace=-1, dcpl=-1, dset=-1;
hsize_t cur_size[5] = {32, 16, 8, 4, 2};
@@ -539,15 +470,13 @@ test_extend(const char *filename, H5D_layout_t layout)
#endif
int val_rd, should_be;
int i, j, *buf=NULL, odd, fd;
- char test[256];
+ char filename[1024];
if (H5D_CHUNKED==layout) {
- strcpy(test, "Testing chunked dataset extend");
+ TESTING("chunked dataset extend");
} else {
- strcpy(test, "Testing contiguous dataset extend");
+ TESTING("contiguous dataset extend");
}
- printf("%-70s", test);
- fflush(stdout);
if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5D_CHUNKED==layout) {
@@ -603,15 +532,16 @@ test_extend(const char *filename, H5D_layout_t layout)
* errors described above or `unable to select fill value region'.
*/
if (H5D_CONTIGUOUS==layout) {
- puts(" SKIP");
- puts(" Not implemented yet -- needs H5S_SELECT_DIFF operator");
+ SKIPPED();
+ puts(" Not implemented yet -- needs H5S_SELECT_DIFF operator");
return 0;
}
#endif
/* Create a file and dataset */
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ h5_fixname(basename, fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if ((fspace=H5Screate_simple(5, cur_size, max_size))<0) goto error;
if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_INT, fspace, dcpl))<0)
goto error;
@@ -627,9 +557,9 @@ test_extend(const char *filename, H5D_layout_t layout)
if (H5Dread(dset, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT,
&val_rd)<0) goto error;
if (val_rd!=fillval) {
- puts("*FAILED*");
- puts(" Value read was not a fill value.");
- printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
+ FAILED();
+ puts(" Value read was not a fill value.");
+ printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
"Fill value: %u\n",
(long)hs_offset[0], (long)hs_offset[1],
(long)hs_offset[2], (long)hs_offset[3],
@@ -671,9 +601,9 @@ test_extend(const char *filename, H5D_layout_t layout)
&val_rd)<0) goto error;
if (val_rd!=should_be) {
- puts("*FAILED*");
- puts(" Value read was not correct.");
- printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
+ FAILED();
+ puts(" Value read was not correct.");
+ printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
"should be: %u\n",
(long)hs_offset[0], (long)hs_offset[1],
(long)hs_offset[2], (long)hs_offset[3],
@@ -707,9 +637,9 @@ test_extend(const char *filename, H5D_layout_t layout)
&val_rd)<0) goto error;
if (val_rd!=should_be) {
- puts("*FAILED*");
- puts(" Value read was not correct.");
- printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
+ FAILED();
+ puts(" Value read was not correct.");
+ printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, "
"should be: %u\n",
(long)hs_offset[0], (long)hs_offset[1],
(long)hs_offset[2], (long)hs_offset[3],
@@ -723,7 +653,7 @@ test_extend(const char *filename, H5D_layout_t layout)
if (H5Sclose(fspace)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Fclose(file)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -759,6 +689,7 @@ int
main(int argc, char *argv[])
{
int nerrors=0, argno, test_contig=1, test_chunk=1;
+ hid_t fapl=-1;
if (argc>=2) {
test_contig = test_chunk = 0;
@@ -773,29 +704,30 @@ main(int argc, char *argv[])
}
}
}
-
- H5Eset_auto(display_error_cb, NULL);
+ h5_reset();
+ fapl = h5_fileaccess();
nerrors += test_getset();
/* Chunked storage layout tests */
if (test_chunk) {
- nerrors += test_create(FILE_NAME_1, H5D_CHUNKED);
- nerrors += test_rdwr(FILE_NAME_3, H5D_CHUNKED);
- nerrors += test_extend(FILE_NAME_5, H5D_CHUNKED);
+ nerrors += test_create(fapl, FILENAME[0], H5D_CHUNKED);
+ nerrors += test_rdwr (fapl, FILENAME[2], H5D_CHUNKED);
+ nerrors += test_extend(fapl, FILENAME[4], H5D_CHUNKED);
}
/* Contiguous storage layout tests */
if (test_contig) {
- nerrors += test_create(FILE_NAME_2, H5D_CONTIGUOUS);
- nerrors += test_rdwr(FILE_NAME_4, H5D_CONTIGUOUS);
- nerrors += test_extend(FILE_NAME_6, H5D_CONTIGUOUS);
+ nerrors += test_create(fapl, FILENAME[1], H5D_CONTIGUOUS);
+ nerrors += test_rdwr (fapl, FILENAME[3], H5D_CONTIGUOUS);
+ nerrors += test_extend(fapl, FILENAME[5], H5D_CONTIGUOUS);
}
if (nerrors) goto error;
puts("All fill value tests passed.");
- cleanup();
+ h5_cleanup(fapl);
+ if (!getenv("HDF5_NOCLEANUP")) remove(FILE_NAME_RAW);
return 0;
error:
diff --git a/test/flush1.c b/test/flush1.c
index f353100..7ffcec3 100644
--- a/test/flush1.c
+++ b/test/flush1.c
@@ -11,57 +11,12 @@
* calling _exit(0) since this doesn't flush HDF5 caches but
* still exits with success.
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <stdio.h>
-# include <stdlib.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-
-#define FILE_NAME_1 "flush.h5" /*do not clean up*/
-
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
+const char *FILENAME[] = {
+ "flush",
+ NULL
+};
/*-------------------------------------------------------------------------
@@ -83,20 +38,21 @@ display_error_cb (void __unused__ *client_data)
int
main(void)
{
- hid_t file, dcpl, space, dset, groups, grp;
+ hid_t fapl, file, dcpl, space, dset, groups, grp;
hsize_t ds_size[2] = {100, 100};
hsize_t ch_size[2] = {5, 5};
double the_data[100][100];
hsize_t i, j;
- char name[256];
+ char name[1024];
- printf("%-70s", "Testing H5Fflush (part1)");
- fflush(stdout);
- H5Eset_auto(display_error_cb, NULL);
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ TESTING("H5Fflush (part1)");
/* Create the file */
- if ((file=H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ h5_fixname(FILENAME[0], fapl, name, sizeof name);
+ if ((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error;
/* Create a chunked dataset */
if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
@@ -129,14 +85,13 @@ main(void)
/* Flush and exit without closing the library */
if (H5Fflush(file, H5F_SCOPE_GLOBAL)<0) goto error;
- puts(" PASSED");
+ PASSED();
fflush(stdout);
fflush(stderr);
_exit(0);
error:
- printf("*FAILED*");
- return 1;
+ _exit(1);
}
diff --git a/test/flush2.c b/test/flush2.c
index 42fcdab..582a729 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -10,77 +10,12 @@
* as the file was flushed first. This half tries to read the
* file created by the first half.
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <math.h>
-# include <stdio.h>
-# include <stdlib.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-
-#define FILE_NAME_1 "flush.h5"
-
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup (void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove (FILE_NAME_1);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
+const char *FILENAME[] = {
+ "flush",
+ NULL
+};
/*-------------------------------------------------------------------------
@@ -102,18 +37,19 @@ display_error_cb (void __unused__ *client_data)
int
main(void)
{
- hid_t file, space, dset, groups, grp;
+ hid_t fapl, file, space, dset, groups, grp;
hsize_t ds_size[2];
double the_data[100][100], error;
hsize_t i, j;
- char name[256];
+ char name[1024];
- printf("%-70s", "Testing H5Fflush (part2)");
- fflush(stdout);
- H5Eset_auto(display_error_cb, NULL);
+ h5_reset();
+ fapl = h5_fileaccess();
+ TESTING("H5Fflush (part2)");
/* Open the file */
- if ((file=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0) goto error;
+ h5_fixname(FILENAME[0], fapl, name, sizeof name);
+ if ((file=H5Fopen(name, H5F_ACC_RDONLY, fapl))<0) goto error;
/* Open the dataset */
if ((dset=H5Dopen(file, "dset"))<0) goto error;
@@ -147,12 +83,11 @@ main(void)
if (H5Gclose(groups)<0) goto error;
if (H5Dclose(dset)<0) goto error;
if (H5Fclose(file)<0) goto error;
- puts(" PASSED");
- cleanup();
+ PASSED();
+ h5_cleanup(fapl);
return 0;
error:
- printf("*FAILED*");
return 1;
}
diff --git a/test/links.c b/test/links.c
index 648f357..ce4dcad 100644
--- a/test/links.c
+++ b/test/links.c
@@ -7,76 +7,12 @@
*
* Purpose: Tests hard and soft (symbolic) links.
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-#define TEST_FILE_NAME "links.h5"
-
-#define FALSE 0
-#define TRUE 1
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
+const char *FILENAME[] = {
+ "links",
+ NULL
+};
/*-------------------------------------------------------------------------
@@ -96,16 +32,17 @@ display_error_cb (void __unused__ *client_data)
*-------------------------------------------------------------------------
*/
static int
-mklinks(void)
+mklinks(hid_t fapl)
{
hid_t file, scalar, grp, d1;
static hsize_t size[1] = {1};
+ char filename[1024];
- printf("%-70s", "Testing link creation");
+ TESTING("link creation");
/* Create a file */
- if ((file=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) {
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) {
goto error;
}
if ((scalar=H5Screate_simple (1, size, size))<0) goto error;
@@ -139,7 +76,7 @@ mklinks(void)
if (H5Sclose (scalar)<0) goto error;
if (H5Fclose (file)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -165,18 +102,19 @@ mklinks(void)
*-------------------------------------------------------------------------
*/
static int
-cklinks(void)
+cklinks(hid_t fapl)
{
hid_t file;
H5G_stat_t sb1, sb2;
char linkval[1024];
+ char filename[1024];
herr_t status;
- printf("%-70s", "Testing link queries");
- fflush(stdout);
+ TESTING("link queries");
/* Open the file */
- if ((file=H5Fopen(TEST_FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT))<0) {
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) {
goto error;
}
@@ -184,36 +122,36 @@ cklinks(void)
if (H5Gget_objinfo(file, "d1", TRUE, &sb1)<0) goto error;
if (H5Gget_objinfo(file, "grp1/hard", TRUE, &sb2)<0) goto error;
if (H5G_DATASET!=sb2.type) {
- puts("*FAILED*");
- puts(" Unexpected object type should have been a dataset");
+ FAILED();
+ puts(" Unexpected object type should have been a dataset");
goto error;
}
if (sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1]) {
- puts("*FAILED*");
- puts(" Hard link test failed. Link seems not to point to the ");
- puts(" expected file location.");
+ FAILED();
+ puts(" Hard link test failed. Link seems not to point to the ");
+ puts(" expected file location.");
goto error;
}
/* Symbolic link */
if (H5Gget_objinfo(file, "grp1/soft", TRUE, &sb2)<0) goto error;
if (H5G_DATASET!=sb2.type) {
- puts("*FAILED*");
- puts(" Unexpected object type should have been a dataset");
+ FAILED();
+ puts(" Unexpected object type should have been a dataset");
goto error;
}
if (sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1]) {
- puts("*FAILED*");
- puts(" Soft link test failed. Link seems not to point to the ");
- puts(" expected file location.");
+ FAILED();
+ puts(" Soft link test failed. Link seems not to point to the ");
+ puts(" expected file location.");
goto error;
}
if (H5Gget_linkval(file, "grp1/soft", sizeof linkval, linkval)<0) {
goto error;
}
if (strcmp(linkval, "/d1")) {
- puts("*FAILED*");
- puts(" Soft link test failed. Wrong link value");
+ FAILED();
+ puts(" Soft link test failed. Wrong link value");
goto error;
}
@@ -222,22 +160,22 @@ cklinks(void)
status = H5Gget_objinfo(file, "grp1/dangle", TRUE, &sb2);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" H5Gget_objinfo() should have failed for a dangling link.");
+ FAILED();
+ puts(" H5Gget_objinfo() should have failed for a dangling link.");
goto error;
}
if (H5Gget_objinfo(file, "grp1/dangle", FALSE, &sb2)<0) goto error;
if (H5G_LINK!=sb2.type) {
- puts("*FAILED*");
- puts(" Unexpected object type should have been a symbolic link");
+ FAILED();
+ puts(" Unexpected object type should have been a symbolic link");
goto error;
}
if (H5Gget_linkval(file, "grp1/dangle", sizeof linkval, linkval)<0) {
goto error;
}
if (strcmp(linkval, "foobar")) {
- puts("*FAILED*");
- puts(" Dangling link test failed. Wrong link value");
+ FAILED();
+ puts(" Dangling link test failed. Wrong link value");
goto error;
}
@@ -246,28 +184,28 @@ cklinks(void)
status = H5Gget_objinfo(file, "grp1/recursive", TRUE, &sb2);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" H5Gget_objinfo() should have failed for a recursive link.");
+ FAILED();
+ puts(" H5Gget_objinfo() should have failed for a recursive link.");
goto error;
}
if (H5Gget_objinfo(file, "grp1/recursive", FALSE, &sb2)<0) goto error;
if (H5G_LINK!=sb2.type) {
- puts("*FAILED*");
- puts(" Unexpected object type should have been a symbolic link");
+ FAILED();
+ puts(" Unexpected object type should have been a symbolic link");
goto error;
}
if (H5Gget_linkval(file, "grp1/recursive", sizeof linkval, linkval)<0) {
goto error;
}
if (strcmp(linkval, "/grp1/recursive")) {
- puts("*FAILED*");
+ FAILED();
puts(" Recursive link test failed. Wrong link value");
goto error;
}
/* Cleanup */
if (H5Fclose(file)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -295,13 +233,14 @@ int
main(void)
{
int nerrors = 0;
+ hid_t fapl;
- /* Set error handling to print `*FAILED*' before the error stack */
- H5Eset_auto(display_error_cb, NULL);
+ h5_reset();
+ fapl = h5_fileaccess();
/* The tests... */
- nerrors += mklinks() < 0 ? 1 : 0;
- nerrors += cklinks() < 0 ? 1 : 0;
+ nerrors += mklinks(fapl) < 0 ? 1 : 0;
+ nerrors += cklinks(fapl) < 0 ? 1 : 0;
/* Results */
if (nerrors) {
@@ -310,6 +249,6 @@ main(void)
exit(1);
}
printf("All link tests passed.\n");
- cleanup();
+ h5_cleanup(fapl);
return 0;
}
diff --git a/test/mount.c b/test/mount.c
index 1acd1e7..e5887a0 100644
--- a/test/mount.c
+++ b/test/mount.c
@@ -7,79 +7,14 @@
*
* Purpose: Tests file mounting.
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#endif
-
-#define FALSE 0
-#define TRUE 1
-
-#define FILE_NAME_1 "mount_1.h5"
-#define FILE_NAME_2 "mount_2.h5"
-#define FILE_NAME_3 "mount_3.h5"
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv("HDF5_NOCLEANUP")) {
- remove(FILE_NAME_1);
- remove(FILE_NAME_2);
- remove(FILE_NAME_3);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb(void __unused__ *client_data)
-{
- puts("*FAILED*");
- H5Eprint(stdout);
- return 0;
-}
+const char *FILENAME[] = {
+ "mount_1",
+ "mount_2",
+ "mount_3",
+ NULL
+};
/*-------------------------------------------------------------------------
@@ -99,13 +34,15 @@ display_error_cb(void __unused__ *client_data)
*-------------------------------------------------------------------------
*/
static int
-setup(void)
+setup(hid_t fapl)
{
hid_t file=-1;
+ char filename[1024];
/* file 1 */
- if ((file=H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT,
- H5P_DEFAULT))<0) goto error;
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if (H5Gclose(H5Gcreate(file, "/mnt1", 0))<0) goto error;
if (H5Gclose(H5Gcreate(file, "/mnt1/file1", 0))<0) goto error;
if (H5Gclose(H5Gcreate(file, "/mnt_unlink", 0))<0) goto error;
@@ -115,8 +52,9 @@ setup(void)
if (H5Fclose(file)<0) goto error;
/* file 2 */
- if ((file=H5Fcreate(FILE_NAME_2, H5F_ACC_TRUNC, H5P_DEFAULT,
- H5P_DEFAULT))<0) goto error;
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if (H5Gclose(H5Gcreate(file, "/file2", 0))<0) goto error;
if (H5Gclose(H5Gcreate(file, "/rename_a", 0))<0) goto error;
if (H5Gclose(H5Gcreate(file, "/rename_b", 0))<0) goto error;
@@ -124,8 +62,9 @@ setup(void)
if (H5Fclose(file)<0) goto error;
/* file 3 */
- if ((file=H5Fcreate(FILE_NAME_3, H5F_ACC_TRUNC, H5P_DEFAULT,
- H5P_DEFAULT))<0) goto error;
+ h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
if (H5Fclose(file)<0) goto error;
return 0;
@@ -156,15 +95,17 @@ setup(void)
*-------------------------------------------------------------------------
*/
static int
-test_basic(void)
+test_basic(hid_t fapl)
{
hid_t file1=-1, file2=-1, grp=-1;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing basic functionality");
- fflush(stdout);
+ TESTING("basic functionality");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
if ((grp=H5Gopen(file1, "/mnt1/file2"))<0) goto error;
@@ -173,7 +114,7 @@ test_basic(void)
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -203,18 +144,22 @@ test_basic(void)
*-------------------------------------------------------------------------
*/
static int
-test_illegal(void)
+test_illegal(hid_t fapl)
{
hid_t file1=-1, file2=-1, file3=-1, mnt=-1;
herr_t status;
+ char filename1[1024], filename2[1024], filename3[1024];
- printf("%-70s", "Testing illegal mount operations");
- fflush(stdout);
+ TESTING("illegal mount operations");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
+ h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3);
+
/* Open the files */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file3=H5Fopen(FILE_NAME_3, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0 ||
+ (file3=H5Fopen(filename3, H5F_ACC_RDONLY, fapl))<0)
goto error;
/* Try mounting a file on itself */
@@ -222,8 +167,8 @@ test_illegal(void)
status = H5Fmount(file1, "/mnt1", file1, H5P_DEFAULT);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Mounting a file on itself should have failed.");
+ FAILED();
+ puts(" Mounting a file on itself should have failed.");
goto error;
}
@@ -238,8 +183,8 @@ test_illegal(void)
status = H5Fmount(mnt, ".", file3, H5P_DEFAULT);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Mounting two files at one mount point should have failed.");
+ FAILED();
+ puts(" Mounting two files at one mount point should have failed.");
goto error;
}
if (H5Funmount(mnt, ".")<0) goto error;
@@ -250,7 +195,7 @@ test_illegal(void)
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
if (H5Fclose(file3)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -283,16 +228,18 @@ test_illegal(void)
*-------------------------------------------------------------------------
*/
static int
-test_hide(void)
+test_hide(hid_t fapl)
{
hid_t file1=-1, file2=-1, grp=-1;
H5G_stat_t sb1, sb2;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing name hiding under mount point");
- fflush(stdout);
+ TESTING("name hiding under mount point");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
/* Get information about file1:/mnt1/file1 for later */
@@ -306,8 +253,8 @@ test_hide(void)
grp = H5Gopen(file1, "/mnt1/file1");
} H5E_END_TRY;
if (grp>=0) {
- puts("*FAILED*");
- puts(" Name is still accessible under mount point.");
+ FAILED();
+ puts(" Name is still accessible under mount point.");
goto error;
}
@@ -318,8 +265,8 @@ test_hide(void)
if (H5Gget_objinfo(file1, "/file1", TRUE, &sb2)<0) goto error;
if (sb1.fileno[0]!=sb2.fileno[0] || sb1.fileno[1]!=sb2.fileno[1] ||
sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1]) {
- puts("*FAILED*");
- puts(" Hard link failed for hidden object.");
+ FAILED();
+ puts(" Hard link failed for hidden object.");
goto error;
}
@@ -327,7 +274,7 @@ test_hide(void)
if (H5Funmount(file1, "/mnt1")<0) goto error;
H5Fclose(file1);
H5Fclose(file2);
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -358,17 +305,19 @@ test_hide(void)
*-------------------------------------------------------------------------
*/
static int
-test_assoc(void)
+test_assoc(hid_t fapl)
{
hid_t file1=-1, file2=-1;
H5G_stat_t sb1, sb2;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing mount point open");
- fflush(stdout);
+ TESTING("mount point open");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Open the files */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
/* Get information about the root of file2 */
@@ -384,8 +333,8 @@ test_assoc(void)
if (H5Gget_objinfo(file1, "/mnt1", TRUE, &sb2)<0) goto error;
if (sb1.fileno[0]!=sb2.fileno[0] || sb1.fileno[1]!=sb2.fileno[1] ||
sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1]) {
- puts("*FAILED*");
- puts(" Association failed.");
+ FAILED();
+ puts(" Association failed.");
goto error;
}
@@ -393,7 +342,7 @@ test_assoc(void)
if (H5Funmount(file1, "/mnt1_link")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -424,16 +373,19 @@ test_assoc(void)
*-------------------------------------------------------------------------
*/
static int
-test_mntlnk(void)
+test_mntlnk(hid_t fapl)
{
hid_t file1=-1, file2=-1, grp=-1;
+ char filename1[1024], filename2[1024];
+
+ TESTING("multi-linked mount point");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
- printf("%-70s", "Testing multi-linked mount point");
- fflush(stdout);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -450,7 +402,7 @@ test_mntlnk(void)
if (H5Funmount(file1, "/mnt1_link")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -482,17 +434,19 @@ test_mntlnk(void)
*-------------------------------------------------------------------------
*/
static int
-test_move(void)
+test_move(hid_t fapl)
{
hid_t file1=-1, file2=-1;
herr_t status;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing object renaming");
- fflush(stdout);
+ TESTING("object renaming");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -502,8 +456,8 @@ test_move(void)
status = H5Gmove(file1, "/mnt1/rename_b/y", "/y");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Moving an object across files should not have been possible");
+ FAILED();
+ puts(" Moving an object across files should't have been possible");
goto error;
}
@@ -511,7 +465,7 @@ test_move(void)
if (H5Funmount(file1, "/mnt1")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -541,15 +495,17 @@ test_move(void)
*-------------------------------------------------------------------------
*/
static int
-test_preopen(void)
+test_preopen(hid_t fapl)
{
hid_t file1=-1, file2=-1, grp=-1;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing preopening objects under the mount point");
- fflush(stdout);
+ TESTING("preopening objects under the mount point");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
/* Open something under the mount point */
@@ -566,7 +522,7 @@ test_preopen(void)
if (H5Gclose(grp)<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -598,17 +554,19 @@ test_preopen(void)
*-------------------------------------------------------------------------
*/
static int
-test_postopen(void)
+test_postopen(hid_t fapl)
{
hid_t file1=-1, file2=-1, grp=-1;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing open object access after unmount");
- fflush(stdout);
+ TESTING("open object access after unmount");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Create the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -628,7 +586,7 @@ test_postopen(void)
if (H5Gclose(grp)<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -660,17 +618,19 @@ test_postopen(void)
*-------------------------------------------------------------------------
*/
static int
-test_unlink(void)
+test_unlink(hid_t fapl)
{
hid_t file1=-1, file2=-1, mnt=-1, root=-1;
herr_t status;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing mount point unlinking");
- fflush(stdout);
+ TESTING("mount point unlinking");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Open files */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
/*
@@ -696,8 +656,8 @@ test_unlink(void)
status = H5Gget_objinfo(mnt, "file2", TRUE, NULL);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Incorrect traversal from mount point!");
+ FAILED();
+ puts(" Incorrect traversal from mount point!");
goto error;
}
@@ -713,16 +673,16 @@ test_unlink(void)
status = H5Gget_objinfo(mnt, "file2", TRUE, NULL);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Traversal through mount point should not have worked!");
+ FAILED();
+ puts(" Traversal through mount point should not have worked!");
goto error;
}
H5E_BEGIN_TRY {
status = H5Gget_objinfo(file2, "/mnt_unlink/file2", TRUE, NULL);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Traversal through mount point should not have worked!");
+ FAILED();
+ puts(" Traversal through mount point should not have worked!");
goto error;
}
@@ -735,16 +695,16 @@ test_unlink(void)
status = H5Funmount(file1, "/mnt_unlink");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Unmount by name should not have been allowed!");
+ FAILED();
+ puts(" Unmount by name should not have been allowed!");
goto error;
}
H5E_BEGIN_TRY {
status = H5Funmount(file2, "/");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Unmount by name should not have been allowed!");
+ FAILED();
+ puts(" Unmount by name should not have been allowed!");
goto error;
}
if (H5Funmount(mnt, ".")<0) goto error;
@@ -754,7 +714,7 @@ test_unlink(void)
if (H5Gclose(root)<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -785,16 +745,18 @@ test_unlink(void)
*-------------------------------------------------------------------------
*/
static int
-test_mvmpt(void)
+test_mvmpt(hid_t fapl)
{
hid_t file1=-1, file2=-1;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing mount point renaming");
- fflush(stdout);
+ TESTING("mount point renaming");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt_move_a", file2, H5P_DEFAULT)<0) goto error;
@@ -808,7 +770,7 @@ test_mvmpt(void)
if (H5Funmount(file1, "/mnt_move_b")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -837,18 +799,20 @@ test_mvmpt(void)
*-------------------------------------------------------------------------
*/
static int
-test_interlink(void)
+test_interlink(hid_t fapl)
{
hid_t file1=-1, file2=-1, type=-1, space=-1, dset=-1;
+ char filename1[1024], filename2[1024];
herr_t status;
hsize_t cur_dims[1] = {2};
- printf("%-70s", "Testing interfile hard links");
- fflush(stdout);
+ TESTING("interfile hard links");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -857,8 +821,8 @@ test_interlink(void)
status = H5Glink(file1, H5G_LINK_HARD, "/mnt1/file2", "/file2");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Interfile hard link should not have been allowed!");
+ FAILED();
+ puts(" Interfile hard link should not have been allowed!");
goto error;
}
@@ -867,8 +831,8 @@ test_interlink(void)
status = H5Gmove(file1, "/mnt1/file2", "/file2");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Interfile renaming should not have been allowed!");
+ FAILED();
+ puts(" Interfile renaming should not have been allowed!");
goto error;
}
@@ -880,8 +844,8 @@ test_interlink(void)
dset = H5Dcreate(file1, "/mnt1/file2/dset", type, space, H5P_DEFAULT);
} H5E_END_TRY;
if (dset>=0) {
- puts("*FAILED*");
- puts(" Dataset and shared type must be in the same file!");
+ FAILED();
+ puts(" Dataset and shared type must be in the same file!");
goto error;
}
@@ -891,7 +855,7 @@ test_interlink(void)
if (H5Funmount(file1, "/mnt1")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -924,16 +888,18 @@ test_interlink(void)
*-------------------------------------------------------------------------
*/
static int
-test_uniformity(void)
+test_uniformity(hid_t fapl)
{
hid_t file1=-1, file2=-1;
+ char filename1[1024], filename2[1024];
- printf("%-70s", "Testing file handle uniformity");
- fflush(stdout);
+ TESTING("file handle uniformity");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -955,7 +921,7 @@ test_uniformity(void)
if (H5Funmount(file1, "/mnt1")<0) goto error;
if (H5Fclose(file1)<0) goto error;
if (H5Fclose(file2)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -984,17 +950,19 @@ test_uniformity(void)
*-------------------------------------------------------------------------
*/
static int
-test_close(void)
+test_close(hid_t fapl)
{
hid_t file1=-1, file2=-1;
+ char filename1[1024], filename2[1024];
herr_t status;
- printf("%-70s", "Testing file handle close");
- fflush(stdout);
+ TESTING("file handle close");
+ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Build the virtual file */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -1008,15 +976,15 @@ test_close(void)
status = H5Gget_objinfo(file2, "/mnt1", TRUE, NULL);
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" File1 contents are still accessible!");
+ FAILED();
+ puts(" File1 contents are still accessible!");
goto error;
}
if (H5Fclose(file2)<0) goto error;
/* Build the virtual file again */
- if ((file1=H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT))<0 ||
- (file2=H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT))<0)
+ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
+ (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
goto error;
if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
@@ -1028,7 +996,7 @@ test_close(void)
if (H5Fclose(file1)<0) goto error;
/* Shut down */
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -1061,30 +1029,32 @@ int
main(void)
{
int nerrors = 0;
-
- H5Eset_auto(display_error_cb, NULL);
- if (setup()<0) goto error;
-
- nerrors += test_basic();
- nerrors += test_illegal();
- nerrors += test_hide();
- nerrors += test_assoc();
- nerrors += test_mntlnk();
- nerrors += test_unlink();
- nerrors += test_move();
- nerrors += test_mvmpt();
- nerrors += test_preopen();
- nerrors += test_postopen();
- nerrors += test_interlink();
- nerrors += test_uniformity();
- nerrors += test_close();
+ hid_t fapl = -1;
+
+ h5_reset();
+ fapl = h5_fileaccess();
+ if (setup(fapl)<0) goto error;
+
+ nerrors += test_basic(fapl);
+ nerrors += test_illegal(fapl);
+ nerrors += test_hide(fapl);
+ nerrors += test_assoc(fapl);
+ nerrors += test_mntlnk(fapl);
+ nerrors += test_unlink(fapl);
+ nerrors += test_move(fapl);
+ nerrors += test_mvmpt(fapl);
+ nerrors += test_preopen(fapl);
+ nerrors += test_postopen(fapl);
+ nerrors += test_interlink(fapl);
+ nerrors += test_uniformity(fapl);
+ nerrors += test_close(fapl);
if (nerrors) goto error;
puts("All mount tests passed.");
- cleanup();
- return(0);
+ h5_cleanup(fapl);
+ return 0;
error:
puts("***** MOUNT ERRORS *****");
- return(1);
+ return 1;
}
diff --git a/test/mtime.c b/test/mtime.c
index 6fadbfd..54188ca 100644
--- a/test/mtime.c
+++ b/test/mtime.c
@@ -10,61 +10,12 @@
* very OS-dependent and this test tries to figure out if it's
* working properly.
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-#include <H5private.h> /*for HDdifftime() and __unused__ */
-
-#define FILE_NAME_1 "mtime.h5"
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup (void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove (FILE_NAME_1);
- }
-}
+const char *FILENAME[] = {
+ "mtime",
+ NULL
+};
/*-------------------------------------------------------------------------
@@ -86,22 +37,25 @@ cleanup (void)
int
main(void)
{
- hid_t file, space, dset;
+ hid_t fapl, file, space, dset;
hsize_t size[1] = {2};
time_t now;
struct tm *tm;
H5G_stat_t sb1, sb2;
- char buf1[32], buf2[32];
+ char buf1[32], buf2[32], filename[1024];
- H5Eset_auto(display_error_cb, NULL);
- printf("%-70s", "Testing modification time messages");
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ TESTING("modification time messages");
/* Create the file, create a dataset, then close the file */
- file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (file<0) return 1;
- if ((space = H5Screate_simple(1, size, NULL))<0) return 1;
- dset = H5Dcreate(file, "dset", H5T_NATIVE_CHAR, space, H5P_DEFAULT);
- if (dset<0) return 1;
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ return 1;
+ if ((space=H5Screate_simple(1, size, NULL))<0) return 1;
+ if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_CHAR, space, H5P_DEFAULT))<0)
+ return 1;
now = time(NULL);
if (H5Dclose(dset)<0) return 1;
if (H5Sclose(space)<0) return 1;
@@ -109,10 +63,11 @@ main(void)
/*
* Open the file and get the modification time. We'll test the new
- * H5Gget_objinfo() arguments too: being able to stat something without knowing
- * its name.
+ * H5Gget_objinfo() arguments too: being able to stat something without
+ * knowing its name.
*/
- if ((file = H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0) return 1;
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) return 1;
if (H5Gget_objinfo(file, "dset", TRUE, &sb1)<0) return 1;
if ((dset=H5Dopen(file, "dset"))<0) return 1;
if (H5Gget_objinfo(dset, ".", TRUE, &sb2)<0) return 1;
@@ -122,33 +77,34 @@ main(void)
/* Compare times from the two ways of calling H5Gget_objinfo() */
if (sb1.objno[0]!=sb2.objno[0] || sb1.objno[1]!=sb2.objno[1] ||
sb1.mtime!=sb2.mtime) {
- puts("*FAILED*");
- puts(" Calling H5Gget_objinfo() with the dataset ID returned different");
- puts(" values than calling it with a file and dataset name.");
+ FAILED();
+ puts(" Calling H5Gget_objinfo() with the dataset ID returned");
+ puts(" different values than calling it with a file and dataset");
+ puts(" name.");
return 1;
}
/* Compare times -- they must be within 60 seconds of one another */
if (0==sb1.mtime) {
- puts("--SKIP--");
- puts(" The modification time could not be decoded on this OS.");
- puts(" Modification times will be mantained in the file but cannot");
- puts(" be queried on this system. See H5O_mtime_decode().");
+ SKIPPED();
+ puts(" The modification time could not be decoded on this OS.");
+ puts(" Modification times will be mantained in the file but");
+ puts(" cannot be queried on this system. See H5O_mtime_decode().");
return 0;
} else if (fabs(HDdifftime(now, sb1.mtime))>60.0) {
- puts("*FAILED*");
+ FAILED();
tm = localtime(&(sb1.mtime));
strftime(buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm);
tm = localtime(&now);
strftime(buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm);
- printf(" Got %s instead of %s\n", buf1, buf2);
+ printf(" got: %s\n ans: %s\n", buf1, buf2);
return 1;
}
/* All looks good */
- puts(" PASSED");
- printf("All modification time tests passed.\n");
- cleanup();
+ PASSED();
+ puts("All modification time tests passed.");
+ h5_cleanup(fapl);
return 0;
}
diff --git a/test/shtype.c b/test/shtype.c
deleted file mode 100644
index 98fcd7e..0000000
--- a/test/shtype.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Copyright (C) 1998 NCSA
- * All rights reserved.
- *
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, April 2, 1998
- *
- * Purpose: Tests datasets with shared data types.
- */
-
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <stdlib.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-#define TEST_FILE_NAME0 "shtype0.h5"
-#define TEST_FILE_NAME1 "shtype1.h5"
-#define TEST_FILE_NAME2A "shtype2a.h5"
-#define TEST_FILE_NAME2B "shtype2b.h5"
-#define TEST_FILE_NAME3 "shtype3.h5"
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: test_1
- *
- * Purpose: Create a shared data type and use it to create a dataset.
- * Then query that dataset's type and use it to create a second
- * dataset. Both datasets should share a single data type.
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_1 (void)
-{
-#if 0
- hid_t f, d1, d2, s1, t1, t2;
- hsize_t size[1] = {1};
-
- printf ("%-70s", "...creating/quering datasets with shared type");
- fflush (stdout);
-
- f = H5Fcreate (TEST_FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (f<0) goto error;
- if ((s1 = H5Screate_simple (1, size, size))<0) goto error;
- if ((t1 = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
- if (H5Tshare (f, t1)<0) goto error;
-
- /* Create the first dataset */
- if ((d1 = H5Dcreate (f, "d1", t1, s1, H5P_DEFAULT))<0) goto error;
- if (H5Dclose (d1)<0) goto error;
-
- /* Get the type of the first dataset to use for the second */
- if ((d1 = H5Dopen (f, "d1"))<0) goto error;
- if ((t2 = H5Dget_type (d1))<0) goto error;
- if (H5Dclose (d1)<0) goto error;
-
- /* Create the second datatype */
- if ((d2 = H5Dcreate (f, "d2", t2, s1, H5P_DEFAULT))<0) goto error;
- if (H5Dclose (d2)<0) goto error;
-
- if (H5Sclose (s1)<0) goto error;
- if (H5Fclose (f)<0) goto error;
-
- puts (" PASSED");
- return 0;
-
- error:
- return -1;
-#else
- return 0;
-#endif
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: test_2
- *
- * Purpose: Create lots of datasets that have their own types, then
- * create another file with lots of datasets that share a type
- * and compare the file sizes.
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_2 (void)
-{
-#if 0
- hid_t f1, f2, t1, t2, s1, d1, d2;
- hsize_t size[1] = {1};
- char buf[32];
- int i;
-
- printf ("%-70s", "...compare shared and unshared types");
- fflush (stdout);
-
- f1 = H5Fcreate (TEST_FILE_NAME2A, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (f1<0) goto error;
- f2 = H5Fcreate (TEST_FILE_NAME2B, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (f2<0) goto error;
- s1 = H5Screate_simple (1, size, size);
- if (s1<0) goto error;
-
- /* Create a large compound type */
- if ((t1 = H5Tcreate (H5T_COMPOUND, 100))<0) goto error;
- for (i=0; i<10; i++) {
- sprintf (buf, "member-%d", i);
- if (H5Tinsert (t1, buf, i*sizeof(int), H5T_NATIVE_INT)<0) goto error;
- }
-
- /* Create a shared version of that type for file #2 */
- if ((t2 = H5Tcopy (t1))<0) goto error;
- if (H5Tshare (f2, t2)<0) goto error;
-
- /* Create the datasets */
- for (i=0; i<1000; i++) {
- sprintf (buf, "dset%04d", i);
- d1 = H5Dcreate (f1, buf, t1, s1, H5P_DEFAULT);
- if (d1<0) goto error;
- if (H5Dclose (d1)<0) goto error;
- d2 = H5Dcreate (f2, buf, t2, s1, H5P_DEFAULT);
- if (d2<0) goto error;
- if (H5Dclose (d2)<0) goto error;
- }
-
- /* Close things */
- if (H5Sclose (s1)<0) goto error;
- if (H5Tclose (t1)<0) goto error;
- if (H5Tclose (t2)<0) goto error;
- if (H5Fclose (f1)<0) goto error;
- if (H5Fclose (f2)<0) goto error;
-
- puts (" PASSED");
- return 0;
-
- error:
- return -1;
-#else
- return 0;
-#endif
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: test_3
- *
- * Purpose: Tries to create a shared type in a read-only file.
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Friday, April 3, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-test_3 (void)
-{
-#if 0
- hid_t f1, s1, t1, d1;
- hsize_t size[1] = {1};
- herr_t status, (*ef)(void*)=NULL;
- void *ed = NULL;
-
- printf ("%-70s", "...shared types and read-only files");
- fflush (stdout);
-
- /*
- * Create the file first since we can't create a file for read-only
- * access. Add a dataset with a shared type. Then close it and open it
- * for read-only. The shared type causes a global heap to be allocated.
- */
- f1 = H5Fcreate (TEST_FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (f1<0) goto error;
- if ((s1 = H5Screate_simple (1, size, size))<0) goto error;
- if ((t1 = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
- if (H5Tshare (f1, t1)<0) goto error;
- if ((d1 = H5Dcreate (f1, "d1", t1, s1, H5P_DEFAULT))<0) goto error;
- if (H5Sclose (s1)<0) goto error;
- if (H5Dclose (d1)<0) goto error;
- if (H5Fclose (f1)<0) goto error;
- f1 = H5Fopen (TEST_FILE_NAME3, H5F_ACC_RDONLY, H5P_DEFAULT);
- if (f1<0) goto error;
- assert (0==H5Tis_shared (f1, t1));
-
- /*
- * Create a shared data type. We know that H5MF_alloc() will fail on a
- * read-only file so there's not much point in trying to create a global
- * heap. But what happens if we modify a global heap in the cache? So
- * lets try to get a collection loaded into memory by reading the shared
- * type. Then creating another shared type will just upate memory unless
- * an error is correctly detected.
- */
- if ((d1 = H5Dopen (f1, "d1"))<0) goto error;
- if (H5Dclose (d1)<0) goto error;
- if (H5Eget_auto (&ef, &ed)<0) goto error;
- if (H5Eset_auto (NULL, NULL)<0) goto error;
- status = H5Tshare (f1, t1);
- if (H5Eset_auto (ef, ed)<0) goto error;
- if (status>=0) {
- puts ("*FAILED*");
- puts (" H5Tshare() should have failed but didn't.");
- goto error;
- }
-
- /* Close the file */
- if (H5Fclose (f1)<0) goto error;
-
- puts (" PASSED");
- return 0;
-
- error:
- return -1;
-#else
- return 0;
-#endif
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME0);
- remove(TEST_FILE_NAME1);
- remove(TEST_FILE_NAME2A);
- remove(TEST_FILE_NAME2B);
- remove(TEST_FILE_NAME3);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose:
- *
- * Return: Success:
- *
- * Failure:
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-main (void)
-{
- int nerrors = 0;
- hid_t f1, g1;
-
- /* Make sure diagnostics get emitted before we start doing real stuff */
- f1 = H5Fcreate (TEST_FILE_NAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- g1 = H5Gcreate (f1, "howdy", 0);
- H5Gclose (g1);
- H5Fclose (f1);
-
- /* Set the error handler */
- H5Eset_auto (display_error_cb, NULL);
-
- /* Run the tests */
- nerrors += test_1()<0 ? 1 : 0;
- nerrors += test_2()<0 ? 1 : 0;
- nerrors += test_3()<0 ? 1 : 0;
-
- /* Report results */
- if (nerrors) {
- puts ("*** Shared data type test(s) failed ***");
- } else {
- puts ("All shared data type tests passed.");
- cleanup();
- }
- return nerrors ? 1 : 0;
-}
diff --git a/test/unlink.c b/test/unlink.c
index fcc9b2f..ca66c74 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -7,76 +7,17 @@
*
* Purpose: Test H5Gunlink().
*/
+#include <h5test.h>
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
+const char *FILENAME[] = {
+ "unlink",
+ NULL
+};
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-#define FILE_NAME_1 "unlink.h5"
#define THE_OBJECT "/foo"
/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup (void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove (FILE_NAME_1);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: test_one
*
* Purpose: Creates a group that has just one entry and then unlinks that
@@ -96,48 +37,49 @@ display_error_cb (void __unused__ *client_data)
static int
test_one(hid_t file)
{
- hid_t work, grp;
+ hid_t work=-1, grp=-1;
herr_t status;
/* Create a test group */
if ((work=H5Gcreate(file, "/test_one", 0))<0) goto error;
/* Delete by absolute name */
- printf("%-70s", "Testing unlink by absolute name");
- fflush(stdout);
+ TESTING("unlink by absolute name");
if ((grp=H5Gcreate(work, "foo", 0))<0) goto error;
if (H5Gclose(grp)<0) goto error;
if (H5Gunlink(file, "/test_one/foo")<0) goto error;
- puts(" PASSED");
+ PASSED();
/* Delete by local name */
- printf("%-70s", "Testing unlink by local name");
- fflush(stdout);
+ TESTING("unlink by local name");
if ((grp=H5Gcreate(work, "foo", 0))<0) goto error;
if (H5Gclose(grp)<0) goto error;
if (H5Gunlink(work, "foo")<0) goto error;
- puts(" PASSED");
+ PASSED();
/* Delete directly - should fail */
- printf("%-70s", "Testing unlink without a name");
- fflush(stdout);
+ TESTING("unlink without a name");
if ((grp=H5Gcreate(work, "foo", 0))<0) goto error;
H5E_BEGIN_TRY {
status = H5Gunlink(grp, ".");
} H5E_END_TRY;
if (status>=0) {
- puts("*FAILED*");
- puts(" Unlinking object w/o a name should have failed.");
+ FAILED();
+ puts(" Unlinking object w/o a name should have failed.");
goto error;
}
if (H5Gclose(grp)<0) goto error;
- puts(" PASSED");
+ PASSED();
/* Cleanup */
if (H5Gclose(work)<0) goto error;
return 0;
+
error:
- H5Gclose(work);
+ H5E_BEGIN_TRY {
+ H5Gclose(work);
+ H5Gclose(grp);
+ } H5E_END_TRY;
return 1;
}
@@ -161,7 +103,7 @@ test_one(hid_t file)
static int
test_many(hid_t file)
{
- hid_t work, grp;
+ hid_t work=-1, grp=-1;
int i;
const int how_many=500;
char name[32];
@@ -172,8 +114,7 @@ test_many(hid_t file)
if (H5Gclose(grp)<0) goto error;
/* Create a bunch of names and unlink them in order */
- printf("%-70s", "Testing forward unlink");
- fflush(stdout);
+ TESTING("forward unlink");
for (i=0; i<how_many; i++) {
sprintf(name, "obj_%05d", i);
if (H5Glink(work, H5G_LINK_HARD, "/test_many_foo", name)<0) goto error;
@@ -182,11 +123,10 @@ test_many(hid_t file)
sprintf(name, "obj_%05d", i);
if (H5Gunlink(work, name)<0) goto error;
}
- puts(" PASSED");
+ PASSED();
/* Create a bunch of names and unlink them in reverse order */
- printf("%-70s", "Testing backward unlink");
- fflush(stdout);
+ TESTING("backward unlink");
for (i=0; i<how_many; i++) {
sprintf(name, "obj_%05d", i);
if (H5Glink(work, H5G_LINK_HARD, "/test_many_foo", name)<0) goto error;
@@ -195,11 +135,10 @@ test_many(hid_t file)
sprintf(name, "obj_%05d", i);
if (H5Gunlink(work, name)<0) goto error;
}
- puts(" PASSED");
+ PASSED();
/* Create a bunch of names and unlink them from both directions */
- printf("%-70s", "Testing inward unlink");
- fflush(stdout);
+ TESTING("inward unlink");
for (i=0; i<how_many; i++) {
sprintf(name, "obj_%05d", i);
if (H5Glink(work, H5G_LINK_HARD, "/test_many_foo", name)<0) goto error;
@@ -212,11 +151,10 @@ test_many(hid_t file)
}
if (H5Gunlink(work, name)<0) goto error;
}
- puts(" PASSED");
+ PASSED();
/* Create a bunch of names and unlink them from the midle */
- printf("%-70s", "Testing outward unlink");
- fflush(stdout);
+ TESTING("outward unlink");
for (i=0; i<how_many; i++) {
sprintf(name, "obj_%05d", i);
if (H5Glink(work, H5G_LINK_HARD, "/test_many_foo", name)<0) goto error;
@@ -229,14 +167,18 @@ test_many(hid_t file)
}
if (H5Gunlink(work, name)<0) goto error;
}
- puts(" PASSED");
+ PASSED();
/* Cleanup */
if (H5Gclose(work)<0) goto error;
return 0;
+
error:
- H5Gclose(work);
+ H5E_BEGIN_TRY {
+ H5Gclose(work);
+ H5Gclose(grp);
+ } H5E_END_TRY;
return 1;
}
@@ -260,10 +202,9 @@ test_many(hid_t file)
static int
test_symlink(hid_t file)
{
- hid_t work;
+ hid_t work=-1;
- printf("%-70s", "Testing symlink removal");
- fflush(stdout);
+ TESTING("symlink removal");
/* Create a test group and symlink */
if ((work=H5Gcreate(file, "/test_symlink", 0))<0) goto error;
@@ -272,10 +213,13 @@ test_symlink(hid_t file)
/* Cleanup */
if (H5Gclose(work)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
+
error:
- H5Gclose(work);
+ H5E_BEGIN_TRY {
+ H5Gclose(work);
+ } H5E_END_TRY;
return 1;
}
@@ -299,12 +243,10 @@ test_symlink(hid_t file)
static int
test_rename(hid_t file)
{
- hid_t work, foo, inner;
+ hid_t work=-1, foo=-1, inner=-1;
-
/* Create a test group and rename something */
- printf("%-70s", "Testing object renaming");
- fflush(stdout);
+ TESTING("object renaming");
if ((work=H5Gcreate(file, "/test_rename", 0))<0) goto error;
if ((foo=H5Gcreate(work, "foo", 0))<0) goto error;
if (H5Gmove(work, "foo", "bar")<0) goto error;
@@ -313,20 +255,24 @@ test_rename(hid_t file)
if (H5Gclose(foo)<0) goto error;
if ((inner=H5Gopen(work, "bar/inner"))<0) goto error;
if (H5Gclose(inner)<0) goto error;
- puts(" PASSED");
+ PASSED();
/* Try renaming a symlink */
- printf("%-70s", "Testing symlink renaming");
- fflush(stdout);
+ TESTING("symlink renaming");
if (H5Glink(work, H5G_LINK_SOFT, "link_value", "link_one")<0) goto error;
if (H5Gmove(work, "link_one", "link_two")<0) goto error;
- puts(" PASSED");
+ PASSED();
/* Cleanup */
if (H5Gclose(work)<0) goto error;
return 0;
+
error:
- H5Gclose(work);
+ H5E_BEGIN_TRY {
+ H5Gclose(work);
+ H5Gclose(foo);
+ H5Gclose(inner);
+ } H5E_END_TRY;
return 1;
}
@@ -351,13 +297,16 @@ test_rename(hid_t file)
int
main(void)
{
- hid_t file;
+ hid_t fapl, file;
int nerrors = 0;
+ char filename[1024];
/* Open */
- H5Eset_auto(display_error_cb, NULL);
- if ((file=H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ h5_reset();
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ goto error;
/* Tests */
nerrors += test_one(file);
@@ -372,7 +321,7 @@ main(void)
exit(1);
}
puts("All unlink tests passed.");
- cleanup();
+ h5_cleanup(fapl);
return 0;
error:
return 1;