summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in10
-rw-r--r--test/dsets.c42
-rw-r--r--test/dtypes.c16
-rw-r--r--test/extend.c4
-rw-r--r--test/external.c550
-rw-r--r--test/hyperslab.c1369
-rw-r--r--test/testhdf5.c2
-rw-r--r--test/tfile.c4
8 files changed, 1294 insertions, 703 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 3c61e91..826ad23 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -11,7 +11,7 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
-PROGS=testhdf5 hyperslab istore dtypes dsets cmpd_dset extend
+PROGS=testhdf5 hyperslab istore dtypes dsets cmpd_dset extend external
TESTS=$(PROGS)
# Temporary files
@@ -23,7 +23,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
# other source lists are for the individual tests, the files of which may
# overlap with other tests.
PROG_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c dtypes.c \
- hyperslab.c istore.c dsets.c cmpd_dset.c extend.c
+ hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c
PROG_OBJ=$(PROG_SRC:.c=.o)
TESTHDF5_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c
@@ -47,6 +47,9 @@ CMPD_DSET_OBJ=$(CMPD_DSET_SRC:.c=.o)
EXTEND_SRC=extend.c
EXTEND_OBJ=$(EXTEND_SRC:.c=.o)
+EXTERNAL_SRC=external.c
+EXTERNAL_OBJ=$(EXTERNAL_SRC:.c=.o)
+
# Private header files (not to be installed)...
PRIVATE_HDR=testhdf5.h
@@ -72,4 +75,7 @@ cmpd_dset: $(CMPD_DSET_OBJ) ../src/libhdf5.a
extend: $(EXTEND_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(EXTEND_OBJ) ../src/libhdf5.a $(LIBS)
+external: $(EXTERNAL_OBJ) ../src/libhdf5.a
+ $(CC) $(CFLAGS) -o $@ $(EXTERNAL_OBJ) ../src/libhdf5.a $(LIBS)
+
@CONCLUDE@
diff --git a/test/dsets.c b/test/dsets.c
index 8b373b0..df19ba1 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -31,9 +31,9 @@
*
* Purpose: Attempts to create a dataset.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
@@ -56,7 +56,7 @@ test_create(hid_t file)
dims[0] = 256;
dims[1] = 512;
space = H5Screate_simple(2, dims, NULL);
- assert(space != FAIL);
+ assert(space>=0);
/*
* Create a dataset using the default dataset creation properties. We're
@@ -171,10 +171,10 @@ test_create(hid_t file)
goto error;
}
puts(" PASSED");
- return SUCCEED;
+ return 0;
error:
- return FAIL;
+ return -1;
}
/*-------------------------------------------------------------------------
@@ -184,9 +184,9 @@ test_create(hid_t file)
* multi-dimensional array without data type or data space
* conversions, without compression, and stored contiguously.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
@@ -217,7 +217,7 @@ test_simple_io(hid_t file)
dims[0] = 100;
dims[1] = 200;
space = H5Screate_simple(2, dims, NULL);
- assert(space != FAIL);
+ assert(space>=0);
/* Create the dataset */
dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
@@ -264,10 +264,10 @@ test_simple_io(hid_t file)
H5Dclose(dataset);
puts(" PASSED");
- return SUCCEED;
+ return 0;
error:
- return FAIL;
+ return -1;
}
/*-------------------------------------------------------------------------
@@ -275,9 +275,9 @@ test_simple_io(hid_t file)
*
* Purpose: Test some simple data type conversion stuff.
*
- * Return: Success: SUCCEED
+ * Return: Success: 0
*
- * Failure: FAIL
+ * Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, January 14, 1998
@@ -289,8 +289,8 @@ test_simple_io(hid_t file)
static herr_t
test_tconv(hid_t file)
{
- uint8 *out=NULL, *in=NULL;
- intn i;
+ char *out=NULL, *in=NULL;
+ int i;
size_t dims[1];
hid_t space, dataset, type;
herr_t status;
@@ -303,13 +303,17 @@ test_tconv(hid_t file)
printf("%-70s", "Testing data type conversion");
/* Initialize the dataset */
- for (i = 0; i < 1000000; i++)
- ((int32 *) out)[i] = 0x11223344;
+ for (i = 0; i < 1000000; i++) {
+ out[i*4+0] = 0x11;
+ out[i*4+1] = 0x22;
+ out[i*4+2] = 0x33;
+ out[i*4+3] = 0x44;
+ }
/* Create the data space */
dims[0] = 1000000;
space = H5Screate_simple (1, dims, NULL);
- assert(space != FAIL);
+ assert(space >= 0);
/* Create the data set */
dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space,
@@ -351,7 +355,7 @@ test_tconv(hid_t file)
H5Tclose(type);
puts(" PASSED");
- return SUCCEED;
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -375,7 +379,7 @@ main(void)
{
hid_t file;
herr_t status;
- intn nerrors = 0;
+ int nerrors = 0;
status = H5open ();
assert (status>=0);
diff --git a/test/dtypes.c b/test/dtypes.c
index da0076a..0b4ae7b 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -89,7 +89,10 @@ test_classes(void)
static herr_t
test_copy(void)
{
- hid_t a_copy;
+ hid_t a_copy;
+ herr_t status;
+ herr_t (*func)(void*) = NULL;
+ void *client_data = NULL;
printf("%-70s", "Testing H5Tcopy()");
@@ -109,7 +112,14 @@ test_copy(void)
}
goto error;
}
- if (H5Tclose(H5T_NATIVE_CHAR) >= 0) {
+
+ /* Temporarily turn off error reporting. */
+ H5Eget_auto (&func, &client_data);
+ H5Eset_auto (NULL, NULL);
+ status = H5Tclose (H5T_NATIVE_CHAR);
+ H5Eset_auto (func, client_data);
+
+ if (status >= 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -159,7 +169,7 @@ test_compound(void)
}
goto error;
}
- /* Add a coupld fields */
+ /* Add a couple fields */
status = H5Tinsert(complex_id, "real", HOFFSET(tmp, re),
H5T_NATIVE_DOUBLE);
if (status < 0) {
diff --git a/test/extend.c b/test/extend.c
index 2cadb1c..7b6ba60 100644
--- a/test/extend.c
+++ b/test/extend.c
@@ -5,7 +5,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Friday, January 30, 1998
*
- * Purpose: Tests extendable datasets.
+ * Purpose: Tests extendible datasets.
*/
#include <assert.h>
#include <hdf5.h>
@@ -17,7 +17,7 @@
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: Tests extendable datasets
+ * Purpose: Tests extendible datasets
*
* Return: Success: exit(0)
*
diff --git a/test/external.c b/test/external.c
new file mode 100644
index 0000000..36c9cdf
--- /dev/null
+++ b/test/external.c
@@ -0,0 +1,550 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Tuesday, March 3, 1998
+ *
+ * Purpose: Tests datasets stored in external raw files.
+ */
+#include <assert.h>
+#include <fcntl.h>
+#include <hdf5.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/*-------------------------------------------------------------------------
+ * 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 *client_data)
+{
+ puts ("*FAILED*");
+ H5Eprint (stdout);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_1
+ *
+ * Purpose: Describes various external datasets in an HDF5 file without
+ * actually creating the external raw files.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_1 (void)
+{
+ hid_t file, plist, space, dset, grp;
+ herr_t status;
+ size_t size[2], max_size[2];
+ herr_t (*func)(void*) = NULL;
+ void *client_data = NULL;
+ int n;
+
+
+ /*
+ * 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.
+ */
+ file = H5Fcreate ("extern_1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert (file>=0);
+ grp = H5Gcreate (file, "emit-diagnostics", 8);
+ H5Gclose (grp);
+
+ printf ("Testing external storage descriptions...\n");
+
+ /*
+ * A single external file for a non-extendible dataset.
+ */
+ do {
+ printf ("%-70s", "...fixed-size data space, exact storage");
+ fflush (stdout);
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "ext1.data", 0, 400);
+ assert (status>=0);
+
+ size[0] = max_size[0] = 100;
+ space = H5Screate_simple (1, size, max_size);
+ assert (space>=0);
+
+ /* Create the dataset, the `dset1' name is used later too */
+ dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * 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, 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_INT32, space, plist);
+ H5Eset_auto (func, client_data);
+
+ if (dset>=0) {
+ puts ("*FAILED*");
+ printf (" Small external file succeeded instead of failing\n");
+ 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, 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_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+
+ /*
+ * 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, 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_INT32, space, plist);
+ H5Eset_auto (func, client_data);
+
+ if (dset>=0) {
+ puts ("*FAILED*");
+ printf (" Small external file succeeded instead of failing\n");
+ H5Dclose (dset);
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * 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_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * Open one of the previous datasets and make sure it looks the same as
+ * when we wrote it.
+ */
+ do {
+ char name[256];
+ size_t file_offset;
+ size_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_parms (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");
+ 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");
+ break;
+ } else if (file_size!=400) {
+ puts ("*FAILED*");
+ printf (" Wrong file size.\n");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+ H5Dclose (dset);
+
+ /*
+ * Open one of the previous unlimited datasets and make sure it looks the
+ * same as when we wrote it.
+ */
+ do {
+ char name[256];
+ size_t file_offset;
+ size_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_parms (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");
+ 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");
+ break;
+ } else if (H5F_UNLIMITED!=file_size) {
+ puts ("*FAILED*");
+ printf (" Wrong file size.\n");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+ H5Dclose (dset);
+
+ /*
+ * 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, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext2.data", 0, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext3.data", 0, 100);
+ assert (status>=0);
+ status = H5Pset_external (plist, "ext4.data", 0, 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_INT32, space, plist);
+ if (dset<0) break;
+ H5Dclose (dset);
+ puts (" PASSED");
+ } while (0);
+ H5Sclose (space);
+ H5Pclose (plist);
+
+ /*
+ * 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, 100);
+ H5Eset_auto (func, client_data);
+ if (status>=0) {
+ puts ("*FAILED*");
+ puts (" H5Pset_external() succeeded when it should have failed");
+ break;
+ }
+
+ /* 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.");
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+
+ /*
+ * 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, 100);
+ H5Eset_auto (func, client_data);
+ if (status>=0) {
+ puts ("*FAILED*");
+ puts (" H5Pset_external() succeeded when it should have failed");
+ break;
+ }
+ puts (" PASSED");
+ } while (0);
+ H5Pclose (plist);
+
+
+
+ /* END OF TESTS */
+ H5Fclose (file);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_2
+ *
+ * Purpose: Tests reading from an external file set.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, March 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_2 (void)
+{
+ hid_t file, plist, space, dset, grp;
+ herr_t status;
+ int fd,i, j;
+ ssize_t n;
+ char fname[64];
+ int part[25], whole[100];
+ size_t size;
+
+ /* Write the data to external files */
+ printf ("Writing external data...\n");
+ for (i=0; i<4; i++) {
+ for (j=0; j<25; j++) {
+ part[j] = i*25+j;
+ }
+
+ sprintf (fname, "extern_%d.raw", i+1);
+ fd = open (fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ assert (fd>=0);
+ n = write (fd, part, sizeof(part));
+ assert (n==sizeof(part));
+ close (fd);
+ }
+
+ /*
+ * 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.
+ */
+ file = H5Fcreate ("extern_2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert (file>=0);
+ grp = H5Gcreate (file, "emit-diagnostics", 8);
+ H5Gclose (grp);
+ printf ("Testing external data reading...\n");
+
+ /* Create the external file list */
+ plist = H5Pcreate (H5P_DATASET_CREATE);
+ assert (plist>=0);
+ status = H5Pset_external (plist, "extern_1.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_2.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_3.raw", 0, sizeof(part));
+ assert (status>=0);
+ status = H5Pset_external (plist, "extern_4.raw", 0, sizeof(part));
+ assert (status>=0);
+
+ /* Create the data space */
+ size = 100;
+ space = H5Screate_simple (1, &size, NULL);
+ assert (space>=0);
+
+ /* Create the dataset */
+ dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist);
+ assert (dset>=0);
+
+ /*
+ * Read the entire dataset and compare with the original
+ */
+ do {
+ /* Read from the dataset */
+ printf ("%-70s", "...reading entire dataset");
+ fflush (stdout);
+ 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]!=i) {
+ puts ("*FAILED*");
+ puts (" Incorrect value(s) read.");
+ break;
+ }
+ }
+ puts (" PASSED");
+ } while (0);
+
+ H5Dclose (dset);
+ H5Pclose (plist);
+ H5Sclose (space);
+ H5Fclose (file);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Runs external dataset tests.
+ *
+ * Return: Success: exit(0)
+ *
+ * Failure: exit(non-zero)
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 3, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main (void)
+{
+ herr_t status;
+ int nerrors=0;
+
+ H5Eset_auto (display_error_cb, NULL);
+
+ status = test_1 ();
+ nerrors += (status<0 ? 1 : 0);
+
+ status = test_2 ();
+ nerrors += (status<0 ? 1 : 0);
+
+ if (0==nerrors) {
+ printf ("All external storage tests passed.\n");
+ }
+
+ exit (nerrors?1:0);
+}
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 2cc7660..0f9f431 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -1,15 +1,15 @@
/*
* Copyright (C) 1997 NCSA
- * All rights reserved.
+ * All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Friday, October 10, 1997
*
- * Purpose: Hyperslab operations are rather complex, so this file
- * attempts to test them extensively so we can be relatively
- * sure they really work. We only test 1d, 2d, and 3d cases
- * because testing general dimensionalities would require us to
- * rewrite much of the hyperslab stuff.
+ * Purpose: Hyperslab operations are rather complex, so this file
+ * attempts to test them extensively so we can be relatively
+ * sure they really work. We only test 1d, 2d, and 3d cases
+ * because testing general dimensionalities would require us to
+ * rewrite much of the hyperslab stuff.
*/
#include <H5private.h>
#include <H5MMprivate.h>
@@ -19,24 +19,24 @@
#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
-#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
+#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
-#define VARIABLE_SRC 0
-#define VARIABLE_DST 1
-#define VARIABLE_BOTH 2
+#define VARIABLE_SRC 0
+#define VARIABLE_DST 1
+#define VARIABLE_BOTH 2
/*-------------------------------------------------------------------------
- * Function: init_full
+ * Function: init_full
*
- * Purpose: Initialize full array.
+ * Purpose: Initialize full array.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -45,30 +45,30 @@
static uintn
init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
- uint8 acc = 128;
- uintn total = 0;
+ int i, j, k;
+ uint8 acc = 128;
+ uintn total = 0;
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- for (k = 0; k < nz; k++) {
- total += acc;
- *array++ = acc++;
- }
- }
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ total += acc;
+ *array++ = acc++;
+ }
+ }
}
return total;
}
/*-------------------------------------------------------------------------
- * Function: print_array
+ * Function: print_array
*
- * Purpose: Prints the values in an array
+ * Purpose: Prints the values in an array
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -77,39 +77,39 @@ init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
static void
print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
+ int i, j, k;
for (i = 0; i < nx; i++) {
- if (nz > 1) {
- printf("i=%d:\n", i);
- } else {
- printf("%03d:", i);
- }
-
- for (j = 0; j < ny; j++) {
- if (nz > 1)
- printf("%03d:", j);
- for (k = 0; k < nz; k++) {
- printf(" %3d", *array++);
- }
- if (nz > 1)
- printf("\n");
- }
- printf("\n");
+ if (nz > 1) {
+ printf("i=%d:\n", i);
+ } else {
+ printf("%03d:", i);
+ }
+
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ printf("%03d:", j);
+ for (k = 0; k < nz; k++) {
+ printf(" %3d", *array++);
+ }
+ if (nz > 1)
+ printf("\n");
+ }
+ printf("\n");
}
}
/*-------------------------------------------------------------------------
- * Function: print_ref
+ * Function: print_ref
*
- * Purpose: Prints the reference value
+ * Purpose: Prints the reference value
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -118,7 +118,7 @@ print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
static void
print_ref(size_t nx, size_t ny, size_t nz)
{
- uint8 *array;
+ uint8 *array;
array = H5MM_xcalloc(nx * ny * nz, sizeof(uint8));
@@ -128,16 +128,16 @@ print_ref(size_t nx, size_t ny, size_t nz)
}
/*-------------------------------------------------------------------------
- * Function: test_fill
+ * Function: test_fill
*
- * Purpose: Tests the H5V_hyper_fill() function.
+ * Purpose: Tests the H5V_hyper_fill() function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -145,40 +145,40 @@ print_ref(size_t nx, size_t ny, size_t nz)
*/
static herr_t
test_fill(size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *dst = NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz; /*counters */
- size_t u, v, w;
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- uintn fill_value; /*fill value */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz; /*counters */
+ size_t u, v, w;
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ uintn fill_value; /*fill value */
/*
* Dimensionality.
*/
if (0 == nz) {
- if (0 == ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf(dim, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
- }
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
} else {
- ndims = 3;
- sprintf(dim, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
}
- sprintf(s, "Testing hyperslab fill %-11s variable hyperslab ", dim);
+ sprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim);
printf("%-70s", s);
fflush(stdout);
@@ -187,79 +187,87 @@ test_fill(size_t nx, size_t ny, size_t nz,
init_full(dst, nx, ny, nz);
for (i = 0; i < nx; i += di) {
- for (j = 0; j < ny; j += dj) {
- for (k = 0; k < nz; k += dk) {
- for (dx = 1; dx <= nx - i; dx += ddx) {
- for (dy = 1; dy <= ny - j; dy += ddy) {
- for (dz = 1; dz <= nz - k; dz += ddz) {
-
- /* Describe the hyperslab */
- dst_size[0] = nx;
- dst_size[1] = ny;
- dst_size[2] = nz;
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
-
- for (fill_value = 0; fill_value < 256; fill_value += 64) {
- /*
- * Initialize the full array, then subtract the
- * original * fill values and add the new ones.
- */
- ref_value = init_full(dst, nx, ny, nz);
- for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
- for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
- for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
- ref_value -= dst[u * ny * nz + v * nz + w];
- }
- }
- }
- ref_value += fill_value * dx * dy * dz;
-
- /* Fill the hyperslab with some value */
- H5V_hyper_fill(ndims, hs_size, dst_size, dst_offset,
- dst, fill_value);
-
- /*
- * Sum the array and compare it to the reference
- * value.
- */
- acc = 0;
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
-
- if (acc != ref_value) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d, fill=%d\n",
- i, j, k, dx, dy, dz, fill_value);
- print_ref(nx, ny, nz);
- printf("\n Result is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
- }
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /* Describe the hyperslab */
+ dst_size[0] = nx;
+ dst_size[1] = ny;
+ dst_size[2] = nz;
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+
+ for (fill_value=0;
+ fill_value<256;
+ fill_value+=64) {
+ /*
+ * Initialize the full array, then subtract the
+ * original * fill values and add the new ones.
+ */
+ ref_value = init_full(dst, nx, ny, nz);
+ for (u=dst_offset[0];
+ u<dst_offset[0]+dx;
+ u++) {
+ for (v = dst_offset[1];
+ v < dst_offset[1] + dy;
+ v++) {
+ for (w = dst_offset[2];
+ w < dst_offset[2] + dz;
+ w++) {
+ ref_value -= dst[u*ny*nz+v*nz+w];
+ }
+ }
+ }
+ ref_value += fill_value * dx * dy * dz;
+
+ /* Fill the hyperslab with some value */
+ H5V_hyper_fill(ndims, hs_size, dst_size,
+ dst_offset, dst, fill_value);
+
+ /*
+ * Sum the array and compare it to the
+ * reference value.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u*ny*nz + v*nz + w];
+ }
+ }
+ }
+
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output
+ * is going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d, fill=%d\n",
+ i, j, k, dx, dy, dz, fill_value);
+ print_ref(nx, ny, nz);
+ printf("\n Result is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
puts(" PASSED");
H5MM_xfree(dst);
@@ -271,28 +279,28 @@ test_fill(size_t nx, size_t ny, size_t nz,
}
/*-------------------------------------------------------------------------
- * Function: test_copy
+ * Function: test_copy
*
- * Purpose: Tests H5V_hyper_copy().
+ * Purpose: Tests H5V_hyper_copy().
*
- * The NX, NY, and NZ arguments are the size for the source and
- * destination arrays. You map pass zero for NZ or for NY and
- * NZ to test the 2-d and 1-d cases respectively.
+ * The NX, NY, and NZ arguments are the size for the source and
+ * destination arrays. You map pass zero for NZ or for NY and
+ * NZ to test the 2-d and 1-d cases respectively.
*
- * A hyperslab is copied from/to (depending on MODE) various
- * places in SRC and DST beginning at 0,0,0 and increasing
- * location by DI,DJ,DK in the x, y, and z directions.
+ * A hyperslab is copied from/to (depending on MODE) various
+ * places in SRC and DST beginning at 0,0,0 and increasing
+ * location by DI,DJ,DK in the x, y, and z directions.
*
- * For each hyperslab location, various sizes of hyperslabs are
- * tried beginning with 1x1x1 and increasing the size in each
- * dimension by DDX,DDY,DDZ.
+ * For each hyperslab location, various sizes of hyperslabs are
+ * tried beginning with 1x1x1 and increasing the size in each
+ * dimension by DDX,DDY,DDZ.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -300,69 +308,69 @@ test_fill(size_t nx, size_t ny, size_t nz,
*/
static herr_t
test_copy(int mode,
- size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+ size_t nx, size_t ny, size_t nz,
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *src = NULL; /*source array */
- uint8 *dst = NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t src_size[3]; /*source total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- size_t src_offset[3]; /*offset of hyperslab in source */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz; /*counters */
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t src_size[3]; /*source total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ size_t src_offset[3]; /*offset of hyperslab in source */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz; /*counters */
size_t u, v, w;
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- const char *sub;
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ const char *sub;
/*
* Dimensionality.
*/
if (0 == nz) {
- if (0 == ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf(dim, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
- }
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
} else {
- ndims = 3;
- sprintf(dim, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
}
switch (mode) {
case VARIABLE_SRC:
- /*
- * The hyperslab "travels" through the source array but the
- * destination hyperslab is always at the origin of the destination
- * array.
- */
- sub = "variable source";
- break;
+ /*
+ * The hyperslab "travels" through the source array but the
+ * destination hyperslab is always at the origin of the destination
+ * array.
+ */
+ sub = "variable source";
+ break;
case VARIABLE_DST:
- /*
- * We always read a hyperslab from the origin of the source and copy it
- * to a hyperslab at various locations in the destination.
- */
- sub = "variable destination";
- break;
+ /*
+ * We always read a hyperslab from the origin of the source and copy it
+ * to a hyperslab at various locations in the destination.
+ */
+ sub = "variable destination";
+ break;
case VARIABLE_BOTH:
- /*
- * We read the hyperslab from various locations in the source and copy
- * it to the same location in the destination.
- */
- sub = "sync source & dest ";
- break;
+ /*
+ * We read the hyperslab from various locations in the source and copy
+ * it to the same location in the destination.
+ */
+ sub = "sync source & dest ";
+ break;
default:
- abort();
+ abort();
}
sprintf(s, "Testing hyperslab copy %-11s %s", dim, sub);
@@ -377,151 +385,159 @@ test_copy(int mode,
init_full(src, nx, ny, nz);
for (i = 0; i < nx; i += di) {
- for (j = 0; j < ny; j += dj) {
- for (k = 0; k < nz; k += dk) {
- for (dx = 1; dx <= nx - i; dx += ddx) {
- for (dy = 1; dy <= ny - j; dy += ddy) {
- for (dz = 1; dz <= nz - k; dz += ddz) {
-
- /*
- * Describe the source and destination hyperslabs and the
- * arrays to which they belong.
- */
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
- dst_size[0] = src_size[0] = nx;
- dst_size[1] = src_size[1] = ny;
- dst_size[2] = src_size[2] = nz;
- switch (mode) {
- case VARIABLE_SRC:
- dst_offset[0] = 0;
- dst_offset[1] = 0;
- dst_offset[2] = 0;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- case VARIABLE_DST:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = 0;
- src_offset[1] = 0;
- src_offset[2] = 0;
- break;
- case VARIABLE_BOTH:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- default:
- abort();
- }
-
- /*
- * Sum the main array directly to get a reference value
- * to compare against later.
- */
- ref_value = 0;
- for (u = src_offset[0]; u < src_offset[0] + dx; u++) {
- for (v = src_offset[1]; v < src_offset[1] + dy; v++) {
- for (w = src_offset[2]; w < src_offset[2] + dz; w++) {
- ref_value += src[u * ny * nz + v * nz + w];
- }
- }
- }
-
- /*
- * Set all loc values to 1 so we can detect writing
- * outside the hyperslab.
- */
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- dst[u * ny * nz + v * nz + w] = 1;
- }
- }
- }
-
- /*
- * Copy a hyperslab from the global array to the local
- * array.
- */
- H5V_hyper_copy(ndims, hs_size,
- dst_size, dst_offset, dst,
- src_size, src_offset, src);
-
- /*
- * Sum the destination hyperslab. It should be the same
- * as the reference value.
- */
- acc = 0;
- for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
- for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
- for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
- if (acc != ref_value) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref(nx, ny, nz);
- printf("\n Destination array is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- /*
- * Sum the entire array. It should be a fixed amount
- * larger than the reference value since we added the
- * border of 1's to the hyperslab.
- */
- acc = 0;
- for (u = 0; u < nx; u++) {
- for (v = 0; v < ny; v++) {
- for (w = 0; w < nz; w++) {
- acc += dst[u * ny * nz + v * nz + w];
- }
- }
- }
- if (acc != ref_value + nx * ny * nz - dx * dy * dz) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT();
- printf(" acc != ref_value + nx*ny*nz - "
- "dx*dy*dz\n");
- printf(" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref(nx, ny, nz);
- printf("\n Destination array is:\n");
- print_array(dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /*
+ * Describe the source and destination hyperslabs
+ * and the arrays to which they belong.
+ */
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+ dst_size[0] = src_size[0] = nx;
+ dst_size[1] = src_size[1] = ny;
+ dst_size[2] = src_size[2] = nz;
+ switch (mode) {
+ case VARIABLE_SRC:
+ dst_offset[0] = 0;
+ dst_offset[1] = 0;
+ dst_offset[2] = 0;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ case VARIABLE_DST:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = 0;
+ src_offset[1] = 0;
+ src_offset[2] = 0;
+ break;
+ case VARIABLE_BOTH:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ default:
+ abort();
+ }
+
+ /*
+ * Sum the main array directly to get a reference
+ * value to compare against later.
+ */
+ ref_value = 0;
+ for (u=src_offset[0]; u<src_offset[0]+dx; u++) {
+ for (v=src_offset[1];
+ v<src_offset[1]+dy;
+ v++) {
+ for (w=src_offset[2];
+ w<src_offset[2]+dz;
+ w++) {
+ ref_value += src[u*ny*nz + v*nz + w];
+ }
+ }
+ }
+
+ /*
+ * Set all loc values to 1 so we can detect writing
+ * outside the hyperslab.
+ */
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ dst[u * ny * nz + v * nz + w] = 1;
+ }
+ }
+ }
+
+ /*
+ * Copy a hyperslab from the global array to the
+ * local array.
+ */
+ H5V_hyper_copy(ndims, hs_size,
+ dst_size, dst_offset, dst,
+ src_size, src_offset, src);
+
+ /*
+ * Sum the destination hyperslab. It should be
+ * the same as the reference value.
+ */
+ acc = 0;
+ for (u=dst_offset[0]; u<dst_offset[0]+dx; u++) {
+ for (v=dst_offset[1];
+ v<dst_offset[1]+dy;
+ v++) {
+ for (w = dst_offset[2];
+ w < dst_offset[2] + dz;
+ w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is
+ * going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ /*
+ * Sum the entire array. It should be a fixed
+ * amount larger than the reference value since
+ * we added the border of 1's to the hyperslab.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value + nx*ny*nz - dx*dy*dz) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is
+ * going directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value + nx*ny*nz - "
+ "dx*dy*dz\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
}
puts(" PASSED");
H5MM_xfree(src);
@@ -535,20 +551,20 @@ test_copy(int mode,
}
/*-------------------------------------------------------------------------
- * Function: test_multifill
+ * Function: test_multifill
*
- * Purpose: Tests the H5V_stride_copy() function by using it to fill a
- * hyperslab by replicating a multi-byte sequence. This might
- * be useful to initialize an array of structs with a default
- * struct value, or to initialize an array of floating-point
- * values with a default bit-pattern.
+ * Purpose: Tests the H5V_stride_copy() function by using it to fill a
+ * hyperslab by replicating a multi-byte sequence. This might
+ * be useful to initialize an array of structs with a default
+ * struct value, or to initialize an array of floating-point
+ * values with a default bit-pattern.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -557,17 +573,17 @@ test_copy(int mode,
static herr_t
test_multifill(int nx)
{
- int i, j;
- size_t size;
- intn src_stride;
- intn dst_stride;
- char s[64];
+ int i, j;
+ size_t size;
+ ssize_t src_stride;
+ ssize_t dst_stride;
+ char s[64];
struct a_struct {
- int left;
- double mid;
- int right;
- } fill , *src = NULL, *dst = NULL;
+ int left;
+ double mid;
+ int right;
+ } fill , *src = NULL, *dst = NULL;
printf("%-70s", "Testing multi-byte fill value");
fflush(stdout);
@@ -576,16 +592,16 @@ test_multifill(int nx)
src = H5MM_xmalloc(nx * sizeof(*src));
dst = H5MM_xmalloc(nx * sizeof(*dst));
for (i = 0; i < nx; i++) {
- src[i].left = 1111111;
- src[i].mid = 12345.6789;
- src[i].right = 2222222;
- dst[i].left = 3333333;
- dst[i].mid = 98765.4321;
- dst[i].right = 4444444;
+ src[i].left = 1111111;
+ src[i].mid = 12345.6789;
+ src[i].right = 2222222;
+ dst[i].left = 3333333;
+ dst[i].mid = 98765.4321;
+ dst[i].right = 4444444;
}
/*
- * Describe the fill value. The zero stride says to read the same thing
+ * Describe the fill value. The zero stride says to read the same thing
* over and over again.
*/
fill.left = 55555555;
@@ -603,38 +619,38 @@ test_multifill(int nx)
*/
size = nx;
H5V_stride_copy(1, sizeof(double), &size,
- &dst_stride, & (dst[0].mid), &src_stride, &(fill.mid));
+ &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid));
/*
* Check
*/
s[0] = '\0';
for (i = 0; i < nx; i++) {
- if (dst[i].left != 3333333) {
- sprintf(s, "bad dst[%d].left", i);
- } else if (dst[i].mid != fill.mid) {
- sprintf(s, "bad dst[%d].mid", i);
- } else if (dst[i].right != 4444444) {
- sprintf(s, "bad dst[%d].right", i);
- }
- if (s[0]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" fill={%d,%g,%d}\n ",
- fill.left, fill.mid, fill.right);
- for (j = 0; j < sizeof(fill); j++) {
- printf(" %02x", ((uint8 *) &fill)[j]);
- }
- printf("\n dst[%d]={%d,%g,%d}\n ",
- i, dst[i].left, dst[i].mid, dst[i].right);
- for (j = 0; j < sizeof(dst[i]); j++) {
- printf(" %02x", ((uint8 *) (dst + i))[j]);
- }
- printf("\n");
- }
- goto error;
- }
+ if (dst[i].left != 3333333) {
+ sprintf(s, "bad dst[%d].left", i);
+ } else if (dst[i].mid != fill.mid) {
+ sprintf(s, "bad dst[%d].mid", i);
+ } else if (dst[i].right != 4444444) {
+ sprintf(s, "bad dst[%d].right", i);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" fill={%d,%g,%d}\n ",
+ fill.left, fill.mid, fill.right);
+ for (j = 0; j < sizeof(fill); j++) {
+ printf(" %02x", ((uint8 *) &fill)[j]);
+ }
+ printf("\n dst[%d]={%d,%g,%d}\n ",
+ i, dst[i].left, dst[i].mid, dst[i].right);
+ for (j = 0; j < sizeof(dst[i]); j++) {
+ printf(" %02x", ((uint8 *) (dst + i))[j]);
+ }
+ printf("\n");
+ }
+ goto error;
+ }
}
puts(" PASSED");
@@ -649,18 +665,18 @@ test_multifill(int nx)
}
/*-------------------------------------------------------------------------
- * Function: test_endian
+ * Function: test_endian
*
- * Purpose: Tests the H5V_stride_copy() function by using it to copy an
- * array of integers and swap the byte ordering from little
- * endian to big endian or vice versa depending on the hardware.
+ * Purpose: Tests the H5V_stride_copy() function by using it to copy an
+ * array of integers and swap the byte ordering from little
+ * endian to big endian or vice versa depending on the hardware.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -669,12 +685,12 @@ test_multifill(int nx)
static herr_t
test_endian(size_t nx)
{
- uint8 *src = NULL; /*source array */
- uint8 *dst = NULL; /*destination array */
- intn src_stride[2]; /*source strides */
- intn dst_stride[2]; /*destination strides */
- size_t size[2]; /*size vector */
- int i, j;
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ ssize_t src_stride[2]; /*source strides */
+ ssize_t dst_stride[2]; /*destination strides */
+ size_t size[2]; /*size vector */
+ int i, j;
printf("%-70s", "Testing endian conversion by stride");
fflush(stdout);
@@ -697,24 +713,24 @@ test_endian(size_t nx)
/* Compare */
for (i = 0; i < nx; i++) {
- for (j = 0; j < 4; j++) {
- if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- /*
- * Print debugging info unless output is going directly to a
- * terminal.
- */
- AT();
- printf(" i=%d, j=%d\n", i, j);
- printf(" Source array is:\n");
- print_array(src, nx, 4, 1);
- printf("\n Result is:\n");
- print_array(dst, nx, 4, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < 4; j++) {
+ if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going directly
+ * to a terminal.
+ */
+ AT();
+ printf(" i=%d, j=%d\n", i, j);
+ printf(" Source array is:\n");
+ print_array(src, nx, 4, 1);
+ printf("\n Result is:\n");
+ print_array(dst, nx, 4, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -729,17 +745,17 @@ test_endian(size_t nx)
}
/*-------------------------------------------------------------------------
- * Function: test_transpose
+ * Function: test_transpose
*
- * Purpose: Copy a 2d array from here to there and transpose the elements
- * as it's copied.
+ * Purpose: Copy a 2d array from here to there and transpose the elements
+ * as it's copied.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Saturday, October 11, 1997
+ * Programmer: Robb Matzke
+ * Saturday, October 11, 1997
*
* Modifications:
*
@@ -748,24 +764,24 @@ test_endian(size_t nx)
static herr_t
test_transpose(size_t nx, size_t ny)
{
- intn *src = NULL;
- intn *dst = NULL;
- int i, j;
- intn src_stride[2], dst_stride[2];
- size_t size[2];
- char s[256];
+ intn *src = NULL;
+ intn *dst = NULL;
+ int i, j;
+ ssize_t src_stride[2], dst_stride[2];
+ size_t size[2];
+ char s[256];
sprintf(s, "Testing 2d transpose by stride %4lux%-lud",
- (unsigned long) nx, (unsigned long) ny);
+ (unsigned long) nx, (unsigned long) ny);
printf("%-70s", s);
fflush(stdout);
/* Initialize */
src = H5MM_xmalloc(nx * ny * sizeof(*src));
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- src[i * ny + j] = (intn)(i * ny + j);
- }
+ for (j = 0; j < ny; j++) {
+ src[i * ny + j] = (intn)(i * ny + j);
+ }
}
dst = H5MM_xcalloc(nx * ny, sizeof(*dst));
@@ -774,48 +790,48 @@ test_transpose(size_t nx, size_t ny)
size[1] = ny;
src_stride[0] = 0;
src_stride[1] = sizeof(*src);
- dst_stride[0] = (intn)((1 - nx * ny) * sizeof(*src));
- dst_stride[1] = (intn)(nx * sizeof(*src));
+ dst_stride[0] = (1 - nx * ny) * sizeof(*src);
+ dst_stride[1] = nx * sizeof(*src);
/* Copy and transpose */
if (nx == ny) {
- H5V_stride_copy(2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
} else {
- H5V_stride_copy(2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
}
/* Check */
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (src[i * ny + j] != dst[j * nx + i]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" diff at i=%d, j=%d\n", i, j);
- printf(" Source is:\n");
- for (i = 0; i < nx; i++) {
- printf("%3d:", i);
- for (j = 0; j < ny; j++) {
- printf(" %6d", src[i * ny + j]);
- }
- printf("\n");
- }
- printf("\n Destination is:\n");
- for (i = 0; i < ny; i++) {
- printf("%3d:", i);
- for (j = 0; j < nx; j++) {
- printf(" %6d", dst[i * nx + j]);
- }
- printf("\n");
- }
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (src[i * ny + j] != dst[j * nx + i]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" diff at i=%d, j=%d\n", i, j);
+ printf(" Source is:\n");
+ for (i = 0; i < nx; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < ny; j++) {
+ printf(" %6d", src[i * ny + j]);
+ }
+ printf("\n");
+ }
+ printf("\n Destination is:\n");
+ for (i = 0; i < ny; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < nx; j++) {
+ printf(" %6d", dst[i * nx + j]);
+ }
+ printf("\n");
+ }
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -830,19 +846,19 @@ test_transpose(size_t nx, size_t ny)
}
/*-------------------------------------------------------------------------
- * Function: test_sub_super
+ * Function: test_sub_super
*
- * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
- * by copying half the pixels in the X and Y directions. Then
- * we use the small image and duplicate every pixel to result in
- * a 2x2 square.
+ * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
+ * by copying half the pixels in the X and Y directions. Then
+ * we use the small image and duplicate every pixel to result in
+ * a 2x2 square.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Monday, October 13, 1997
+ * Programmer: Robb Matzke
+ * Monday, October 13, 1997
*
* Modifications:
*
@@ -851,18 +867,18 @@ test_transpose(size_t nx, size_t ny)
static herr_t
test_sub_super(size_t nx, size_t ny)
{
- uint8 *full = NULL; /*original image */
- uint8 *half = NULL; /*image at 1/2 resolution */
- uint8 *twice = NULL; /*2x2 pixels */
- intn src_stride[4]; /*source stride info */
- intn dst_stride[4]; /*destination stride info */
- size_t size[4]; /*number of sample points */
- int i, j;
- char s[256];
+ uint8 *full = NULL; /*original image */
+ uint8 *half = NULL; /*image at 1/2 resolution */
+ uint8 *twice = NULL; /*2x2 pixels */
+ ssize_t src_stride[4]; /*source stride info */
+ ssize_t dst_stride[4]; /*destination stride info */
+ size_t size[4]; /*number of sample points */
+ int i, j;
+ char s[256];
sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long) (2 * nx), (unsigned long) (2 * ny),
- (unsigned long) nx, (unsigned long) ny);
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny),
+ (unsigned long) nx, (unsigned long) ny);
printf("%-70s", s);
fflush(stdout);
@@ -875,31 +891,32 @@ test_sub_super(size_t nx, size_t ny)
/* Setup */
size[0] = nx;
size[1] = ny;
- src_stride[0] = (intn)(2 * ny);
+ src_stride[0] = 2 * ny;
src_stride[1] = 2;
dst_stride[0] = 0;
dst_stride[1] = 1;
/* Copy */
H5V_stride_copy(2, sizeof(uint8), size,
- dst_stride, half, src_stride, full);
+ dst_stride, half, src_stride, full);
/* Check */
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" full[%d][%d] != half[%d][%d]\n", i * 2, j * 2, i, j);
- printf(" full is:\n");
- print_array(full, 2 * nx, 2 * ny, 1);
- printf("\n half is:\n");
- print_array(half, nx, ny, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" full[%d][%d] != half[%d][%d]\n",
+ i*2, j*2, i, j);
+ printf(" full is:\n");
+ print_array(full, 2 * nx, 2 * ny, 1);
+ printf("\n half is:\n");
+ print_array(half, nx, ny, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -908,8 +925,8 @@ test_sub_super(size_t nx, size_t ny)
* dimension.
*/
sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long) nx, (unsigned long) ny,
- (unsigned long) (2 * nx), (unsigned long) (2 * ny));
+ (unsigned long) nx, (unsigned long) ny,
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny));
printf("%-70s", s);
fflush(stdout);
@@ -922,40 +939,44 @@ test_sub_super(size_t nx, size_t ny)
src_stride[1] = 1;
src_stride[2] = 0;
src_stride[3] = 0;
- dst_stride[0] = (intn)(2 * ny);
- dst_stride[1] = (intn)(2 * sizeof(uint8) - 4 * ny);
- dst_stride[2] = (intn)(2 * ny - 2 * sizeof(uint8));
+ dst_stride[0] = 2 * ny;
+ dst_stride[1] = 2 * sizeof(uint8) - 4 * ny;
+ dst_stride[2] = 2 * ny - 2 * sizeof(uint8);
dst_stride[3] = sizeof(uint8);
/* Copy */
H5V_stride_copy(4, sizeof(uint8), size,
- dst_stride, twice, src_stride, half);
+ dst_stride, twice, src_stride, half);
/* Check */
s[0] = '\0';
for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (half[i * ny + j] != twice[4 * i * ny + 2 * j]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j);
- } else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j + 1);
- } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j);
- } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) {
- sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j + 1);
- }
- if (s[0]) {
- puts("*FAILED*");
- if (!isatty(1)) {
- AT();
- printf(" %s\n Half is:\n", s);
- print_array(half, nx, ny, 1);
- printf("\n Twice is:\n");
- print_array(twice, 2 * nx, 2 * ny, 1);
- }
- goto error;
- }
- }
+ for (j = 0; j < ny; j++) {
+ if (half[i*ny+j] != twice[4*i*ny + 2*j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i, 2 * j);
+ } else if (half[i*ny + j] != twice[4*i*ny + 2*j + 1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i, 2 * j + 1);
+ } else if (half[i*ny + j] != twice[(2*i +1)*2*ny + 2*j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i + 1, 2 * j);
+ } else if (half[i*ny + j] != twice[(2*i+1)*2*ny + 2*j+1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]",
+ i, j, 2 * i + 1, 2 * j + 1);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" %s\n Half is:\n", s);
+ print_array(half, nx, ny, 1);
+ printf("\n Twice is:\n");
+ print_array(twice, 2 * nx, 2 * ny, 1);
+ }
+ goto error;
+ }
+ }
}
puts(" PASSED");
@@ -972,18 +993,18 @@ test_sub_super(size_t nx, size_t ny)
}
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Test various hyperslab operations. Give the words
- * `small' and/or `medium' on the command line or only `small'
- * is assumed.
+ * Purpose: Test various hyperslab operations. Give the words
+ * `small' and/or `medium' on the command line or only `small'
+ * is assumed.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(non-zero)
+ * Failure: exit(non-zero)
*
- * Programmer: Robb Matzke
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke
+ * Friday, October 10, 1997
*
* Modifications:
*
@@ -992,31 +1013,31 @@ test_sub_super(size_t nx, size_t ny)
int
main(int argc, char *argv[])
{
- herr_t status;
- int nerrors = 0;
- uintn size_of_test;
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
/* Parse arguments or assume `small' */
if (1 == argc) {
- size_of_test = TEST_SMALL;
+ size_of_test = TEST_SMALL;
} else {
- intn i;
- for (i = 1, size_of_test = 0; i < argc; i++) {
- if (!strcmp(argv[i], "small")) {
- size_of_test |= TEST_SMALL;
- } else if (!strcmp(argv[i], "medium")) {
- size_of_test |= TEST_MEDIUM;
- } else {
- printf("unrecognized argument: %s\n", argv[i]);
- exit(1);
- }
- }
+ intn i;
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "small")) {
+ size_of_test |= TEST_SMALL;
+ } else if (!strcmp(argv[i], "medium")) {
+ size_of_test |= TEST_MEDIUM;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
}
printf("Test sizes: ");
if (size_of_test & TEST_SMALL)
- printf(" SMALL");
+ printf(" SMALL");
if (size_of_test & TEST_MEDIUM)
- printf(" MEDIUM");
+ printf(" MEDIUM");
printf("\n");
/*
@@ -1025,20 +1046,20 @@ main(int argc, char *argv[])
*------------------------------
*/
if (size_of_test & TEST_SMALL) {
- status = test_fill(11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_fill(11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_fill(113, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(15, 11, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_fill(5, 7, 7, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_fill(113, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(15, 11, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(5, 7, 7, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/*------------------------------
* TEST HYPERSLAB COPY OPERATION
@@ -1047,63 +1068,63 @@ main(int argc, char *argv[])
/* exhaustive, one-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* exhaustive, two-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* sparse, two-dimensional test */
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/* exhaustive, three-dimensional test */
if (size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
}
/*---------------------
* TEST MULTI-BYTE FILL
@@ -1111,12 +1132,12 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_multifill(10);
- nerrors += status < 0 ? 1 : 0;
+ status = test_multifill(10);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_multifill(500000);
- nerrors += status < 0 ? 1 : 0;
+ status = test_multifill(500000);
+ nerrors += status < 0 ? 1 : 0;
}
/*---------------------------
* TEST TRANSLATION OPERATORS
@@ -1124,20 +1145,20 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_endian(10);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(9, 9);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(3, 11);
- nerrors += status < 0 ? 1 : 0;
+ status = test_endian(10);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(9, 9);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(3, 11);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_endian(800000);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(1200, 1200);
- nerrors += status < 0 ? 1 : 0;
- status = test_transpose(800, 1800);
- nerrors += status < 0 ? 1 : 0;
+ status = test_endian(800000);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(1200, 1200);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(800, 1800);
+ nerrors += status < 0 ? 1 : 0;
}
/*-------------------------
* TEST SAMPLING OPERATIONS
@@ -1145,23 +1166,23 @@ main(int argc, char *argv[])
*/
if (size_of_test & TEST_SMALL) {
- status = test_sub_super(5, 10);
- nerrors += status < 0 ? 1 : 0;
+ status = test_sub_super(5, 10);
+ nerrors += status < 0 ? 1 : 0;
}
if (size_of_test & TEST_MEDIUM) {
- status = test_sub_super(480, 640);
- nerrors += status < 0 ? 1 : 0;
+ status = test_sub_super(480, 640);
+ nerrors += status < 0 ? 1 : 0;
}
/*--- END OF TESTS ---*/
if (nerrors) {
- printf("***** %d HYPERSLAB TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
- if (isatty(1)) {
- printf("(Redirect output to a pager or a file to see "
- "debug output)\n");
- }
- exit(1);
+ printf("***** %d HYPERSLAB TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ if (isatty(1)) {
+ printf("(Redirect output to a pager or a file to see "
+ "debug output)\n");
+ }
+ exit(1);
}
printf("All hyperslab tests passed.\n");
return 0;
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 40abfb5..85cc2bf 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -171,7 +171,7 @@ main(int argc, char *argv[])
H5version(&major, &minor, &release, &patch);
print_func("\nFor help use: testhdf5 -help\n");
- print_func("Linked with HDF %u.%u.%u%c\n\n", (unsigned) major,
+ print_func("Linked with hdf5-%u.%u.%u%c\n\n", (unsigned) major,
(unsigned) minor, (unsigned) release, 'a' + patch);
for (CLLoop = 1; CLLoop < argc; CLLoop++) {
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
diff --git a/test/tfile.c b/test/tfile.c
index 1daca76..ffb399e 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -32,8 +32,8 @@ static char RcsId[] = "$Revision$";
#include <H5Mprivate.h>
#define F1_USERBLOCK_SIZE 0
-#define F1_OFFSET_SIZE 4
-#define F1_LENGTH_SIZE 4
+#define F1_OFFSET_SIZE sizeof(size_t)
+#define F1_LENGTH_SIZE sizeof(size_t)
#define F1_SYM_LEAF_K 4
#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"