summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-01-16 22:23:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-01-16 22:23:43 (GMT)
commitc2c94c31878dc42926661c9cb7e71be620196fc1 (patch)
treeee9ce2ae309882348dc1eafc1d105b5e6646605e /test
parent903e677366a86ea385d5cfe1241f3f53132941de (diff)
downloadhdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.zip
hdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.tar.gz
hdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.tar.bz2
[svn-r157] Reformatted code with indent...
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c656
-rw-r--r--test/dspace.c5
-rw-r--r--test/dtypes.c341
-rw-r--r--test/hyperslab.c1989
-rw-r--r--test/istore.c1079
-rw-r--r--test/testhdf5.c322
-rw-r--r--test/testhdf5.h77
-rw-r--r--test/tfile.c258
-rw-r--r--test/th5p.c127
-rw-r--r--test/theap.c102
-rw-r--r--test/tmeta.c129
-rw-r--r--test/tohdr.c269
-rw-r--r--test/tstab.c415
13 files changed, 2825 insertions, 2944 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 9e024af..1d88cff 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -5,7 +5,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, December 9, 1997
*
- * Purpose: Tests the dataset interface (H5D)
+ * Purpose: Tests the dataset interface (H5D)
*/
#include <assert.h>
#include <hdf5.h>
@@ -16,25 +16,24 @@
#ifndef HAVE_FUNCTION
#define __FUNCTION__ ""
#endif
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, __FUNCTION__);
-
-#define DSET_DEFAULT_NAME "default"
-#define DSET_CHUNKED_NAME "chunked"
-#define DSET_SIMPLE_IO_NAME "simple_io"
-#define DSET_TCONV_NAME "tconv"
+#define AT() printf (" at %s:%d in %s()...\n", \
+ __FILE__, __LINE__, __FUNCTION__);
+#define DSET_DEFAULT_NAME "default"
+#define DSET_CHUNKED_NAME "chunked"
+#define DSET_SIMPLE_IO_NAME "simple_io"
+#define DSET_TCONV_NAME "tconv"
/*-------------------------------------------------------------------------
- * Function: test_create
+ * Function: test_create
*
- * Purpose: Attempts to create a dataset.
+ * Purpose: Attempts to create a dataset.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -42,158 +41,144 @@
*-------------------------------------------------------------------------
*/
static herr_t
-test_create (hid_t file)
+test_create(hid_t file)
{
- hid_t dataset, space, create_parms;
- size_t dims[2];
- herr_t status;
- size_t csize[2];
-
- printf ("%-70s", "Testing create/open/close");
-
-
- /* Create the data space */
- space = H5Pcreate (H5P_SIMPLE);
- dims[0] = 256;
- dims[1] = 512;
- status = H5Pset_space (space, 2, dims);
- assert (status>=0);
-
- /*
- * Create a dataset using the default dataset creation properties. We're
- * not sure what they are, so we won't check.
- */
- dataset = H5Dcreate (file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
- H5C_DEFAULT);
- if (dataset<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create initial dataset.\n");
- }
- goto error;
- }
-
- /* Close the dataset */
- if (H5Dclose (dataset)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot close initial dataset.\n");
- }
- goto error;
- }
-
- /*
- * Try creating a dataset that already exists. This should fail since a
- * dataset can only be created once.
- */
- dataset = H5Dcreate (file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
- H5C_DEFAULT);
- if (dataset>=0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Library allowed overwrite of existing dataset.\n");
- }
- goto error;
- }
-
- /*
- * Open the dataset we created above and then close it. This is how
- * existing datasets are accessed.
- */
- dataset = H5Dopen (file, DSET_DEFAULT_NAME);
- if (dataset<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot open dataset `%s'.\n", DSET_DEFAULT_NAME);
- }
- goto error;
- }
- if (H5Dclose (dataset)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot close dataset.\n");
- }
- goto error;
- }
-
- /*
- * Try opening a non-existent dataset. This should fail since new datasets
- * cannot be created with this function.
- */
- dataset = H5Dopen (file, "does_not_exist");
- if (dataset>=0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Opened a non-existent dataset.\n");
- }
- goto error;
- }
-
- /*
- * Create a new dataset that uses chunked storage instead of the default
- * layout.
- */
- create_parms = H5Ccreate (H5C_DATASET_CREATE);
- assert (create_parms>=0);
- csize[0] = 5;
- csize[1] = 100;
- status = H5Cset_chunk (create_parms, 2, csize);
- assert (status>=0);
-
- dataset = H5Dcreate (file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space,
- create_parms);
- if (dataset<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Could not create a chunked dataset.\n");
- }
- goto error;
- }
-
- /*
- * Close the chunked dataset.
- */
- if (H5Dclose (dataset)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot close chunked dataset.\n");
- }
- goto error;
- }
-
-
-
-
-
- puts (" PASSED");
- return SUCCEED;
-
- error:
- return FAIL;
+ hid_t dataset, space, create_parms;
+ size_t dims[2];
+ herr_t status;
+ size_t csize[2];
+
+ printf("%-70s", "Testing create/open/close");
+
+ /* Create the data space */
+ space = H5Pcreate(H5P_SIMPLE);
+ dims[0] = 256;
+ dims[1] = 512;
+ status = H5Pset_space(space, 2, dims);
+ assert(status >= 0);
+
+ /*
+ * Create a dataset using the default dataset creation properties. We're
+ * not sure what they are, so we won't check.
+ */
+ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
+ H5C_DEFAULT);
+ if (dataset < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create initial dataset.\n");
+ }
+ goto error;
+ }
+ /* Close the dataset */
+ if (H5Dclose(dataset) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot close initial dataset.\n");
+ }
+ goto error;
+ }
+ /*
+ * Try creating a dataset that already exists. This should fail since a
+ * dataset can only be created once.
+ */
+ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
+ H5C_DEFAULT);
+ if (dataset >= 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Library allowed overwrite of existing dataset.\n");
+ }
+ goto error;
+ }
+ /*
+ * Open the dataset we created above and then close it. This is how
+ * existing datasets are accessed.
+ */
+ dataset = H5Dopen(file, DSET_DEFAULT_NAME);
+ if (dataset < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot open dataset `%s'.\n", DSET_DEFAULT_NAME);
+ }
+ goto error;
+ }
+ if (H5Dclose(dataset) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot close dataset.\n");
+ }
+ goto error;
+ }
+ /*
+ * Try opening a non-existent dataset. This should fail since new datasets
+ * cannot be created with this function.
+ */
+ dataset = H5Dopen(file, "does_not_exist");
+ if (dataset >= 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Opened a non-existent dataset.\n");
+ }
+ goto error;
+ }
+ /*
+ * Create a new dataset that uses chunked storage instead of the default
+ * layout.
+ */
+ create_parms = H5Ccreate(H5C_DATASET_CREATE);
+ assert(create_parms >= 0);
+ csize[0] = 5;
+ csize[1] = 100;
+ status = H5Cset_chunk(create_parms, 2, csize);
+ assert(status >= 0);
+
+ dataset = H5Dcreate(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space,
+ create_parms);
+ if (dataset < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Could not create a chunked dataset.\n");
+ }
+ goto error;
+ }
+ /*
+ * Close the chunked dataset.
+ */
+ if (H5Dclose(dataset) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot close chunked dataset.\n");
+ }
+ goto error;
+ }
+ puts(" PASSED");
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_simple_io
+ * Function: test_simple_io
*
- * Purpose: Tests simple I/O. That is, reading and writing a complete
- * multi-dimensional array without data type or data space
- * conversions, without compression, and stored contiguously.
+ * Purpose: Tests simple I/O. That is, reading and writing a complete
+ * multi-dimensional array without data type or data space
+ * conversions, without compression, and stored contiguously.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
@@ -201,94 +186,91 @@ test_create (hid_t file)
*-------------------------------------------------------------------------
*/
static herr_t
-test_simple_io (hid_t file)
+test_simple_io(hid_t file)
{
- hid_t dataset, space;
- herr_t status;
- int points[100][200], check[100][200];
- int i, j, n;
- size_t dims[2];
-
- printf ("%-70s", "Testing simple I/O");
-
- /* Initialize the dataset */
- for (i=n=0; i<100; i++) {
- for (j=0; j<100; j++) {
- points[i][j] = n++;
- }
- }
-
- /* Create the data space */
- space = H5Pcreate (H5P_SIMPLE);
- dims[0] = 100;
- dims[1] = 200;
- status = H5Pset_space (space, 2, dims);
- assert (status>=0);
-
- /* Create the dataset */
- dataset = H5Dcreate (file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
- H5C_DEFAULT);
- assert (dataset>=0);
-
- /* Write the data to the dataset */
- status = H5Dwrite (dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL,
- H5C_DEFAULT, points);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" H5Dwrite() failed\n");
- }
- goto error;
- }
-
- /* Read the dataset back */
- status = H5Dread (dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL,
- H5C_DEFAULT, check);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" H5Dread() failed\n");
- }
- goto error;
- }
-
- /* Check that the values read are the same as the values written */
- for (i=0; i<100; i++) {
- for (j=0; j<200; j++) {
- if (points[i][j]!=check[i][j]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read different values than written.\n");
- printf (" At index %d,%d\n", i, j);
- }
- goto error;
- }
- }
- }
-
- H5Dclose (dataset);
-
- puts (" PASSED");
- return SUCCEED;
-
- error:
- return FAIL;
+ hid_t dataset, space;
+ herr_t status;
+ int points[100][200], check[100][200];
+ int i, j, n;
+ size_t dims[2];
+
+ printf("%-70s", "Testing simple I/O");
+
+ /* Initialize the dataset */
+ for (i = n = 0; i < 100; i++) {
+ for (j = 0; j < 100; j++) {
+ points[i][j] = n++;
+ }
+ }
+
+ /* Create the data space */
+ space = H5Pcreate(H5P_SIMPLE);
+ dims[0] = 100;
+ dims[1] = 200;
+ status = H5Pset_space(space, 2, dims);
+ assert(status >= 0);
+
+ /* Create the dataset */
+ dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
+ H5C_DEFAULT);
+ assert(dataset >= 0);
+
+ /* Write the data to the dataset */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL,
+ H5C_DEFAULT, points);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5Dwrite() failed\n");
+ }
+ goto error;
+ }
+ /* Read the dataset back */
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL,
+ H5C_DEFAULT, check);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5Dread() failed\n");
+ }
+ goto error;
+ }
+ /* Check that the values read are the same as the values written */
+ for (i = 0; i < 100; i++) {
+ for (j = 0; j < 200; j++) {
+ if (points[i][j] != check[i][j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ }
+ goto error;
+ }
+ }
+ }
+
+ H5Dclose(dataset);
+
+ puts(" PASSED");
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * Function: test_tconv
+ * Function: test_tconv
*
- * Purpose: Test some simple data type conversion stuff.
+ * Purpose: Test some simple data type conversion stuff.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 14, 1998
*
* Modifications:
@@ -296,83 +278,81 @@ test_simple_io (hid_t file)
*-------------------------------------------------------------------------
*/
static herr_t
-test_tconv (hid_t file)
+test_tconv(hid_t file)
{
- uint8 out[4*1000000];
- uint8 in[4*1000000];
- intn i;
- size_t dims[1];
- hid_t space, dataset, type;
- herr_t status;
-
- printf ("%-70s", "Testing data type conversion");
-
- /* Initialize the dataset */
- for (i=0; i<1000000; i++) ((int32*)out)[i] = 0x11223344;
-
- /* Create the data space */
- space = H5Pcreate (H5P_SIMPLE);
- assert (space>=0);
- dims[0] = 1000000;
- status = H5Pset_space (space, 1, dims);
- assert (status>=0);
-
- /* Create the data set */
- dataset = H5Dcreate (file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space,
- H5C_DEFAULT);
- assert (dataset>=0);
-
- /* Write the data to the dataset */
- status = H5Dwrite (dataset, H5T_NATIVE_INT32, H5P_ALL, H5P_ALL,
- H5C_DEFAULT, out);
- assert (status>=0);
-
- /* Create a new type with the opposite byte order */
- type = H5Tcopy (H5T_NATIVE_INT32);
- switch (H5Tget_order (type)) {
- case H5T_ORDER_BE:
- H5Tset_order (type, H5T_ORDER_LE);
- break;
- case H5T_ORDER_LE:
- H5Tset_order (type, H5T_ORDER_BE);
- break;
- default:
- assert ("funny byte order" && 0);
- break;
- }
-
- /* Read data with byte order conversion */
- status = H5Dread (dataset, type, H5P_ALL, H5P_ALL, H5C_DEFAULT, in);
- assert (status>=0);
-
- /* Check */
- for (i=0; i<1000000; i++) {
- assert (in[4*i+0] == out[4*i+3]);
- assert (in[4*i+1] == out[4*i+2]);
- assert (in[4*i+2] == out[4*i+1]);
- assert (in[4*i+3] == out[4*i+0]);
- }
-
- H5Dclose (dataset);
- H5Tclose (type);
-
- puts (" PASSED");
- return SUCCEED;
+ uint8 out[4 * 1000000];
+ uint8 in[4 * 1000000];
+ intn i;
+ size_t dims[1];
+ hid_t space, dataset, type;
+ herr_t status;
+
+ printf("%-70s", "Testing data type conversion");
+
+ /* Initialize the dataset */
+ for (i = 0; i < 1000000; i++)
+ ((int32 *) out)[i] = 0x11223344;
+
+ /* Create the data space */
+ space = H5Pcreate(H5P_SIMPLE);
+ assert(space >= 0);
+ dims[0] = 1000000;
+ status = H5Pset_space(space, 1, dims);
+ assert(status >= 0);
+
+ /* Create the data set */
+ dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space,
+ H5C_DEFAULT);
+ assert(dataset >= 0);
+
+ /* Write the data to the dataset */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5P_ALL, H5P_ALL,
+ H5C_DEFAULT, out);
+ assert(status >= 0);
+
+ /* Create a new type with the opposite byte order */
+ type = H5Tcopy(H5T_NATIVE_INT32);
+ switch (H5Tget_order(type)) {
+ case H5T_ORDER_BE:
+ H5Tset_order(type, H5T_ORDER_LE);
+ break;
+ case H5T_ORDER_LE:
+ H5Tset_order(type, H5T_ORDER_BE);
+ break;
+ default:
+ assert("funny byte order" && 0);
+ break;
+ }
+
+ /* Read data with byte order conversion */
+ status = H5Dread(dataset, type, H5P_ALL, H5P_ALL, H5C_DEFAULT, in);
+ assert(status >= 0);
+
+ /* Check */
+ for (i = 0; i < 1000000; i++) {
+ assert(in[4 * i + 0] == out[4 * i + 3]);
+ assert(in[4 * i + 1] == out[4 * i + 2]);
+ assert(in[4 * i + 2] == out[4 * i + 1]);
+ assert(in[4 * i + 3] == out[4 * i + 0]);
+ }
+
+ H5Dclose(dataset);
+ H5Tclose(type);
+
+ puts(" PASSED");
+ return SUCCEED;
}
-
-
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Tests the dataset interface (H5D)
+ * Purpose: Tests the dataset interface (H5D)
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(1)
+ * Failure: exit(1)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -380,38 +360,36 @@ test_tconv (hid_t file)
*-------------------------------------------------------------------------
*/
int
-main (void)
+main(void)
{
- hid_t file;
- herr_t status;
- intn nerrors = 0;
-
-
- unlink ("dataset.h5");
- file = H5Fcreate ("dataset.h5", H5ACC_DEFAULT, H5C_DEFAULT, H5C_DEFAULT);
- assert (file>=0);
-
- status = test_create (file);
- nerrors += status<0 ? 1 : 0;
-
- status = test_simple_io (file);
- nerrors += status<0 ? 1 : 0;
-
- status = test_tconv (file);
- nerrors += status<0 ? 1 : 0;
-
- status = H5Fclose (file);
-
- if (nerrors) {
- printf ("***** %d DATASET 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 dataset tests passed.\n");
- exit (0);
+ hid_t file;
+ herr_t status;
+ intn nerrors = 0;
+
+ unlink("dataset.h5");
+ file = H5Fcreate("dataset.h5", H5ACC_DEFAULT, H5C_DEFAULT, H5C_DEFAULT);
+ assert(file >= 0);
+
+ status = test_create(file);
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_simple_io(file);
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_tconv(file);
+ nerrors += status < 0 ? 1 : 0;
+
+ status = H5Fclose(file);
+
+ if (nerrors) {
+ printf("***** %d DATASET 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 dataset tests passed.\n");
+ exit(0);
}
diff --git a/test/dspace.c b/test/dspace.c
index 2d6f54f..54fa17f 100644
--- a/test/dspace.c
+++ b/test/dspace.c
@@ -5,10 +5,9 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, December 9, 1997
*
- * Purpose: Tests the data space interface (H5P).
+ * Purpose: Tests the data space interface (H5P).
*/
int
-main (void)
+main(void)
{
-
diff --git a/test/dtypes.c b/test/dtypes.c
index bd180e0..263ebb7 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -5,7 +5,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, December 9, 1997
*
- * Purpose: Tests the data type interface (H5T)
+ * Purpose: Tests the data type interface (H5T)
*/
#include <hdf5.h>
#include <stdio.h>
@@ -13,29 +13,27 @@
#include <H5Tprivate.h>
-
#ifndef HAVE_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__);
typedef struct complex_t {
- double re;
- double im;
+ double re;
+ double im;
} complex_t;
-
/*-------------------------------------------------------------------------
- * Function: test_classes
+ * Function: test_classes
*
- * Purpose: Test type classes
+ * Purpose: Test type classes
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -43,51 +41,45 @@ typedef struct complex_t {
*-------------------------------------------------------------------------
*/
static herr_t
-test_classes (void)
+test_classes(void)
{
- H5T_class_t type_class;
-
- printf ("%-70s", "Testing H5Tget_class()");
-
- if (H5T_INTEGER!=(type_class=H5Tget_class (H5T_NATIVE_INT))) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Invalid type class for H5T_NATIVE_INT\n");
- }
- goto error;
- }
-
- if (H5T_FLOAT!=(type_class=H5Tget_class (H5T_NATIVE_DOUBLE))) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Invalid type class for H5T_NATIVE_DOUBLE\n");
- }
- goto error;
- }
-
-
-
- puts (" PASSED");
- return SUCCEED;
-
- error:
- return FAIL;
+ H5T_class_t type_class;
+
+ printf("%-70s", "Testing H5Tget_class()");
+
+ if (H5T_INTEGER != (type_class = H5Tget_class(H5T_NATIVE_INT))) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Invalid type class for H5T_NATIVE_INT\n");
+ }
+ goto error;
+ }
+ if (H5T_FLOAT != (type_class = H5Tget_class(H5T_NATIVE_DOUBLE))) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Invalid type class for H5T_NATIVE_DOUBLE\n");
+ }
+ goto error;
+ }
+ puts(" PASSED");
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_copy
+ * Function: test_copy
*
- * Purpose: Are we able to copy a data type?
+ * Purpose: Are we able to copy a data type?
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -95,57 +87,53 @@ test_classes (void)
*-------------------------------------------------------------------------
*/
static herr_t
-test_copy (void)
+test_copy(void)
{
- hid_t a_copy;
-
- printf ("%-70s", "Testing H5Tcopy()");
-
- if ((a_copy=H5Tcopy (H5T_NATIVE_SHORT))<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot copy a builtin type.\n");
- }
- goto error;
- }
-
- if (H5Tclose (a_copy)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot close the copied type.\n");
- }
- goto error;
- }
-
- if (H5Tclose (H5T_NATIVE_CHAR)>=0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Was able to free a built-in type.\n");
- }
- goto error;
- }
-
- puts (" PASSED");
- return SUCCEED;
-
- error:
- return FAIL;
+ hid_t a_copy;
+
+ printf("%-70s", "Testing H5Tcopy()");
+
+ if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot copy a builtin type.\n");
+ }
+ goto error;
+ }
+ if (H5Tclose(a_copy) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot close the copied type.\n");
+ }
+ goto error;
+ }
+ if (H5Tclose(H5T_NATIVE_CHAR) >= 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Was able to free a built-in type.\n");
+ }
+ goto error;
+ }
+ puts(" PASSED");
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * Function: test_compound
+ * Function: test_compound
*
- * Purpose: Tests various things about compound data types.
+ * Purpose: Tests various things about compound data types.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -153,75 +141,67 @@ test_copy (void)
*-------------------------------------------------------------------------
*/
static herr_t
-test_compound (void)
+test_compound(void)
{
- complex_t tmp;
- hid_t complex_id;
- herr_t status;
-
- printf ("%-70s", "Testing compound data types");
-
- /* Create the empty type */
- complex_id = H5Tcreate (H5T_COMPOUND, sizeof tmp);
- if (complex_id<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create empty compound data type.\n");
- }
- goto error;
- }
-
- /* Add a coupld fields */
- status = H5Tinsert (complex_id, "real", HOFFSET (tmp, re),
- H5T_NATIVE_DOUBLE);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot insert real component.\n");
- }
- goto error;
- }
-
- status = H5Tinsert (complex_id, "imaginary", HOFFSET (tmp, im),
- H5T_NATIVE_DOUBLE);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot insert imaginary component.\n");
- }
- goto error;
- }
-
- puts (" PASSED");
-
- /* Just for debugging... */
- H5T_debug (H5Aatom_object (complex_id), stdout);
- printf ("\n");
-
-
- return SUCCEED;
-
- error:
- return FAIL;
+ complex_t tmp;
+ hid_t complex_id;
+ herr_t status;
+
+ printf("%-70s", "Testing compound data types");
+
+ /* Create the empty type */
+ complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp);
+ if (complex_id < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create empty compound data type.\n");
+ }
+ goto error;
+ }
+ /* Add a coupld fields */
+ status = H5Tinsert(complex_id, "real", HOFFSET(tmp, re),
+ H5T_NATIVE_DOUBLE);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot insert real component.\n");
+ }
+ goto error;
+ }
+ status = H5Tinsert(complex_id, "imaginary", HOFFSET(tmp, im),
+ H5T_NATIVE_DOUBLE);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot insert imaginary component.\n");
+ }
+ goto error;
+ }
+ puts(" PASSED");
+
+ /* Just for debugging... */
+ H5T_debug(H5Aatom_object(complex_id), stdout);
+ printf("\n");
+
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Test the data type interface.
+ * Purpose: Test the data type interface.
*
- * Return: Success:
+ * Return: Success:
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -229,34 +209,31 @@ test_compound (void)
*-------------------------------------------------------------------------
*/
int
-main (void)
+main(void)
{
- herr_t status;
- intn nerrors = 0;
-
- H5init ();
-
- status = test_classes ();
- nerrors += status<0 ? 1 : 0;
-
- status = test_copy ();
- nerrors += status<0 ? 1 : 0;
-
- status = test_compound ();
- nerrors += status<0 ? 1 : 0;
-
-
- if (nerrors) {
- printf ("***** %d DATA TYPE 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 data type tests passed.\n");
- exit (0);
+ herr_t status;
+ intn nerrors = 0;
+
+ H5init();
+
+ status = test_classes();
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_copy();
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_compound();
+ nerrors += status < 0 ? 1 : 0;
+
+ if (nerrors) {
+ printf("***** %d DATA TYPE 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 data type tests passed.\n");
+ exit(0);
}
-
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 64c731e..82f78c4 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -2,14 +2,14 @@
* Copyright (C) 1997 NCSA
* 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>
@@ -20,22 +20,21 @@
#endif
#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
-
-#define VARIABLE_SRC 0
-#define VARIABLE_DST 1
-#define VARIABLE_BOTH 2
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
+#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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -43,33 +42,31 @@
*-------------------------------------------------------------------------
*/
static uintn
-init_full (uint8 *array, size_t nx, size_t ny, size_t nz)
+init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- 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++;
- }
- }
- }
- return total;
+ 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++;
+ }
+ }
+ }
+ 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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -77,40 +74,40 @@ 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)
+print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- 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");
- }
+ 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");
+ }
}
-
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -118,28 +115,27 @@ 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)
+print_ref(size_t nx, size_t ny, size_t nz)
{
- uint8 *array;
+ uint8 *array;
- array = H5MM_xcalloc (nx*ny*nz, sizeof(uint8));
+ array = H5MM_xcalloc(nx * ny * nz, sizeof(uint8));
- printf ("Reference array:\n");
- init_full (array, nx, ny, nz);
- print_array (array, nx, ny, nz);
+ printf("Reference array:\n");
+ init_full(array, nx, ny, nz);
+ print_array(array, nx, ny, 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
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -147,156 +143,153 @@ 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)
+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)
{
- 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, u, v, w; /*counters */
- 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);
- }
- } else {
- 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);
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Allocate array */
- dst = H5MM_xcalloc (nx*ny*nz, 1);
- 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;
- }
- }
- }
- }
- }
- }
- }
- }
- puts (" PASSED");
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (dst);
- return FAIL;
+ 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, u, v, w; /*counters */
+ 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);
+ }
+ } else {
+ 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);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Allocate array */
+ dst = H5MM_xcalloc(nx * ny * nz, 1);
+ 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;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ puts(" PASSED");
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -304,257 +297,254 @@ 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)
+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)
{
- 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, u, v, w; /*counters */
- 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);
- }
- } else {
- 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;
- 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;
- 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;
- default:
- abort ();
- }
-
- sprintf (s, "Testing hyperslab copy %-11s %s", dim, sub);
- printf ("%-70s", s);
- fflush (stdout);
-
- /*
- * Allocate arrays
- */
- src = H5MM_xcalloc (nx*ny*nz, 1);
- dst = H5MM_xcalloc (nx*ny*nz, 1);
- 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;
- }
- }
- }
- }
- }
- }
- }
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ 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, u, v, w; /*counters */
+ 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);
+ }
+ } else {
+ 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;
+ 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;
+ 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;
+ default:
+ abort();
+ }
+
+ sprintf(s, "Testing hyperslab copy %-11s %s", dim, sub);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /*
+ * Allocate arrays
+ */
+ src = H5MM_xcalloc(nx * ny * nz, 1);
+ dst = H5MM_xcalloc(nx * ny * nz, 1);
+ 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;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -562,112 +552,111 @@ test_copy (int mode,
*-------------------------------------------------------------------------
*/
static herr_t
-test_multifill (int nx)
+test_multifill(int nx)
{
- int i, j;
- size_t size;
- intn src_stride;
- intn dst_stride;
- char s[64];
-
- struct a_struct {
- int left;
- double mid;
- int right;
- } fill, *src=NULL, *dst=NULL;
-
- printf ("%-70s", "Testing multi-byte fill value");
- fflush (stdout);
-
- /* Initialize the source and destination */
- 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;
- }
-
- /*
- * Describe the fill value. The zero stride says to read the same thing
- * over and over again.
- */
- fill.left = 55555555;
- fill.mid = 3.1415927;
- fill.right = 66666666;
- src_stride = 0;
-
- /*
- * The destination stride says to fill in one value per array element
- */
- dst_stride = sizeof(fill);
-
- /*
- * Copy the fill value into each element
- */
- size = nx;
- H5V_stride_copy (1, sizeof(double), &size,
- &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;
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ int i, j;
+ size_t size;
+ intn src_stride;
+ intn dst_stride;
+ char s[64];
+
+ struct a_struct {
+ int left;
+ double mid;
+ int right;
+ } fill , *src = NULL, *dst = NULL;
+
+ printf("%-70s", "Testing multi-byte fill value");
+ fflush(stdout);
+
+ /* Initialize the source and destination */
+ 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;
+ }
+
+ /*
+ * Describe the fill value. The zero stride says to read the same thing
+ * over and over again.
+ */
+ fill.left = 55555555;
+ fill.mid = 3.1415927;
+ fill.right = 66666666;
+ src_stride = 0;
+
+ /*
+ * The destination stride says to fill in one value per array element
+ */
+ dst_stride = sizeof(fill);
+
+ /*
+ * Copy the fill value into each element
+ */
+ size = nx;
+ H5V_stride_copy(1, sizeof(double), &size,
+ &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;
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -675,80 +664,78 @@ test_multifill (int nx)
*-------------------------------------------------------------------------
*/
static herr_t
-test_endian (size_t nx)
+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;
-
- printf ("%-70s", "Testing endian conversion by stride");
- fflush (stdout);
-
- /* Initialize arrays */
- src = H5MM_xmalloc (nx*4);
- init_full (src, nx, 4, 1);
- dst = H5MM_xcalloc (nx, 4);
-
- /* Initialize strides */
- src_stride[0] = 0;
- src_stride[1] = 1;
- dst_stride[0] = 8;
- dst_stride[1] = -1;
- size[0] = nx;
- size[1] = 4;
-
- /* Copy the array */
- H5V_stride_copy (2, 1, size, dst_stride, dst+3, src_stride, src);
-
- /* 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;
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ 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;
+
+ printf("%-70s", "Testing endian conversion by stride");
+ fflush(stdout);
+
+ /* Initialize arrays */
+ src = H5MM_xmalloc(nx * 4);
+ init_full(src, nx, 4, 1);
+ dst = H5MM_xcalloc(nx, 4);
+
+ /* Initialize strides */
+ src_stride[0] = 0;
+ src_stride[1] = 1;
+ dst_stride[0] = 8;
+ dst_stride[1] = -1;
+ size[0] = nx;
+ size[1] = 4;
+
+ /* Copy the array */
+ H5V_stride_copy(2, 1, size, dst_stride, dst + 3, src_stride, src);
+
+ /* 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;
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -756,105 +743,102 @@ test_endian (size_t nx)
*-------------------------------------------------------------------------
*/
static herr_t
-test_transpose (size_t nx, size_t ny)
+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];
-
- sprintf (s, "Testing 2d transpose by stride %4lux%-lud",
- (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] = i*ny + j;
- }
- }
- dst = H5MM_xcalloc (nx*ny, sizeof(*dst));
-
- /* Build stride info */
- size[0] = nx;
- size[1] = ny;
- src_stride[0] = 0;
- src_stride[1] = 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);
- } else {
- 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;
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ intn *src = NULL;
+ intn *dst = NULL;
+ int i, j;
+ intn 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);
+ 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] = i * ny + j;
+ }
+ }
+ dst = H5MM_xcalloc(nx * ny, sizeof(*dst));
+
+ /* Build stride info */
+ size[0] = nx;
+ size[1] = ny;
+ src_stride[0] = 0;
+ src_stride[1] = 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);
+ } else {
+ 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;
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Monday, October 13, 1997
*
* Modifications:
@@ -862,143 +846,140 @@ test_transpose (size_t nx, size_t ny)
*-------------------------------------------------------------------------
*/
static herr_t
-test_sub_super (size_t nx, size_t ny)
+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];
-
- sprintf (s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long)(2*nx), (unsigned long)(2*ny),
- (unsigned long)nx, (unsigned long)ny);
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Initialize */
- full = H5MM_xmalloc (4*nx*ny);
- init_full (full, 2*nx, 2*ny, 1);
- half = H5MM_xcalloc (nx*ny, 1);
- twice = H5MM_xcalloc (4*nx*ny, 1);
-
- /* Setup */
- size[0] = nx;
- size[1] = 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);
-
- /* 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;
- }
- }
- }
- puts (" PASSED");
-
-
- /*
- * Test replicating pixels to produce an image twice as large in each
- * 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));
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Setup stride */
- size[0] = nx;
- size[1] = ny;
- size[2] = 2;
- size[3] = 2;
- src_stride[0] = 0;
- src_stride[1] = 1;
- src_stride[2] = 0;
- src_stride[3] = 0;
- 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);
-
- /* 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;
- }
- }
- }
- puts (" PASSED");
-
-
- H5MM_xfree (full);
- H5MM_xfree (half);
- H5MM_xfree (twice);
- return SUCCEED;
-
- error:
- H5MM_xfree (full);
- H5MM_xfree (half);
- H5MM_xfree (twice);
- return FAIL;
+ 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];
+
+ sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny),
+ (unsigned long) nx, (unsigned long) ny);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Initialize */
+ full = H5MM_xmalloc(4 * nx * ny);
+ init_full(full, 2 * nx, 2 * ny, 1);
+ half = H5MM_xcalloc(nx * ny, 1);
+ twice = H5MM_xcalloc(4 * nx * ny, 1);
+
+ /* Setup */
+ size[0] = nx;
+ size[1] = 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);
+
+ /* 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;
+ }
+ }
+ }
+ puts(" PASSED");
+
+ /*
+ * Test replicating pixels to produce an image twice as large in each
+ * 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));
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Setup stride */
+ size[0] = nx;
+ size[1] = ny;
+ size[2] = 2;
+ size[3] = 2;
+ src_stride[0] = 0;
+ src_stride[1] = 1;
+ src_stride[2] = 0;
+ src_stride[3] = 0;
+ 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);
+
+ /* 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;
+ }
+ }
+ }
+ puts(" PASSED");
+
+ H5MM_xfree(full);
+ H5MM_xfree(half);
+ H5MM_xfree(twice);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(full);
+ H5MM_xfree(half);
+ H5MM_xfree(twice);
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -1006,195 +987,179 @@ test_sub_super (size_t nx, size_t ny)
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- herr_t status;
- int nerrors=0;
- uintn size_of_test;
-
- /* Parse arguments or assume `small' */
- if (1==argc) {
- 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);
- }
- }
- }
- printf ("Test sizes: ");
- if (size_of_test & TEST_SMALL) printf (" SMALL");
- if (size_of_test & TEST_MEDIUM) printf (" MEDIUM");
- printf ("\n");
-
-
-
- /*
- *------------------------------
- * TEST HYPERSLAB FILL OPERATION
- *------------------------------
- */
- 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;
- }
- 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;
- }
-
-
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
+
+ /* Parse arguments or assume `small' */
+ if (1 == argc) {
+ 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);
+ }
+ }
+ }
+ printf("Test sizes: ");
+ if (size_of_test & TEST_SMALL)
+ printf(" SMALL");
+ if (size_of_test & TEST_MEDIUM)
+ printf(" MEDIUM");
+ printf("\n");
+
+ /*
+ *------------------------------
+ * TEST HYPERSLAB FILL OPERATION
+ *------------------------------
+ */
+ 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;
+ }
+ 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;
+ }
/*------------------------------
* TEST HYPERSLAB COPY OPERATION
*------------------------------
*/
- /* 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;
- }
- 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;
- }
-
- /* 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;
- }
- 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;
- }
-
- /* 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;
- }
-
-
- /* 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;
- }
- 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;
- }
-
-
+ /* 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;
+ }
+ 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;
+ }
+ /* 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;
+ }
+ 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;
+ }
+ /* 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;
+ }
+ /* 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;
+ }
+ 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;
+ }
/*---------------------
* TEST MULTI-BYTE FILL
*---------------------
*/
- if (size_of_test & TEST_SMALL) {
- status = test_multifill (10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_multifill (500000);
- nerrors += status<0 ? 1 : 0;
- }
-
-
+ if (size_of_test & TEST_SMALL) {
+ status = test_multifill(10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_multifill(500000);
+ nerrors += status < 0 ? 1 : 0;
+ }
/*---------------------------
* TEST TRANSLATION OPERATORS
*---------------------------
*/
- 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;
- }
- 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;
- }
-
-
+ 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;
+ }
+ 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;
+ }
/*-------------------------
* TEST SAMPLING OPERATIONS
*-------------------------
*/
-
- if (size_of_test & TEST_SMALL) {
- 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;
- }
-
-
-
- /*--- 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 ("All hyperslab tests passed.\n");
- exit (0);
+
+ if (size_of_test & TEST_SMALL) {
+ 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;
+ }
+/*--- 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("All hyperslab tests passed.\n");
+ exit(0);
}
diff --git a/test/istore.c b/test/istore.c
index 8f246c8..6115a5f 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -2,10 +2,10 @@
* Copyright (C) 1997 NCSA
* All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Wednesday, October 15, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Wednesday, October 15, 1997
*
- * Purpose: Tests various aspects of indexed raw data storage.
+ * Purpose: Tests various aspects of indexed raw data storage.
*/
#include <H5private.h>
#include <H5Cprivate.h>
@@ -16,38 +16,38 @@
#include <H5Vprivate.h>
#if 1
-# define FILETYPE H5F_LOW_DFLT
-# define FILENAME "istore.h5"
+# define FILETYPE H5F_LOW_DFLT
+# define FILENAME "istore.h5"
#elif 0
-# define FILETYPE H5F_LOW_FAM
-# define FILENAME "istore-%05d.h5"
-# define TEST_FAMILY 1
+# define FILETYPE H5F_LOW_FAM
+# define FILENAME "istore-%05d.h5"
+# define TEST_FAMILY 1
#else
-# define FILETYPE H5F_LOW_SPLIT
-# define FILENAME "istore-split"
+# define FILETYPE H5F_LOW_SPLIT
+# define FILENAME "istore-split"
#endif
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
-#define TEST_LARGE 0x0004
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
+#define TEST_LARGE 0x0004
#ifndef HAVE_FUNCTION
#define __FUNCTION__ ""
#endif
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, __FUNCTION__);
-
-size_t align_g[3] = {50, 50, 50};
+#define AT() printf (" at %s:%d in %s()...\n", \
+ __FILE__, __LINE__, __FUNCTION__);
+size_t align_g[3] =
+{50, 50, 50};
/*-------------------------------------------------------------------------
- * 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
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -55,41 +55,41 @@ size_t align_g[3] = {50, 50, 50};
*-------------------------------------------------------------------------
*/
static void
-print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
+print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- 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");
- }
+ 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");
+ }
}
-
-
/*-------------------------------------------------------------------------
- * Function: new_object
+ * Function: new_object
*
- * Purpose: Creates a new object that refers to a indexed storage of raw
- * data. No raw data is stored.
+ * Purpose: Creates a new object that refers to a indexed storage of raw
+ * data. No raw data is stored.
*
- * Return: Success: Handle to a new open object.
+ * Return: Success: Handle to a new open object.
*
- * Failure: NULL, error message printed.
+ * Failure: NULL, error message printed.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -97,69 +97,65 @@ print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static int
-new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
+new_object(H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent /*out */ )
{
- H5O_layout_t layout;
- intn i;
-
- /* Create the object header */
- if (H5O_create (f, 64, ent)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" H5O_create() = NULL\n");
- }
- return -1;
- }
-
- /* create chunked storage */
- layout.type = H5D_CHUNKED;
- layout.ndims = ndims;
- for (i=0; i<ndims; i++) {
- if (i<NELMTS (align_g)) {
- layout.dim[i] = align_g[i];
- } else {
- layout.dim[i] = 2;
- }
- }
- H5F_arr_create (f, &layout/*in,out*/);
- if (H5O_modify (ent, H5O_LAYOUT, H5O_NEW_MESG, 0, &layout)<0) {
- printf ("*FAILED*\n");
- if (!isatty (1)) {
- AT();
- printf (" H5O_modify istore message failure\n");
- }
- return -1;
- }
-
- /* Give the object header a name */
- if (H5G_insert (name, ent)<0) {
- printf ("*FAILED*\n");
- if (!isatty (1)) {
- AT ();
- printf (" H5G_insert(f, name=\"%s\", ent) failed\n", name);
- }
- return -1;
- }
-
- /* Close the header */
- H5O_close (ent);
-
- return 0;
+ H5O_layout_t layout;
+ intn i;
+
+ /* Create the object header */
+ if (H5O_create(f, 64, ent)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5O_create() = NULL\n");
+ }
+ return -1;
+ }
+ /* create chunked storage */
+ layout.type = H5D_CHUNKED;
+ layout.ndims = ndims;
+ for (i = 0; i < ndims; i++) {
+ if (i < NELMTS(align_g)) {
+ layout.dim[i] = align_g[i];
+ } else {
+ layout.dim[i] = 2;
+ }
+ }
+ H5F_arr_create(f, &layout /*in,out */ );
+ if (H5O_modify(ent, H5O_LAYOUT, H5O_NEW_MESG, 0, &layout) < 0) {
+ printf("*FAILED*\n");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5O_modify istore message failure\n");
+ }
+ return -1;
+ }
+ /* Give the object header a name */
+ if (H5G_insert(name, ent) < 0) {
+ printf("*FAILED*\n");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5G_insert(f, name=\"%s\", ent) failed\n", name);
+ }
+ return -1;
+ }
+ /* Close the header */
+ H5O_close(ent);
+
+ return 0;
}
-
/*-------------------------------------------------------------------------
- * Function: test_create
+ * Function: test_create
*
- * Purpose: Creates a named object that refers to indexed storage of raw
- * data. No raw data is stored.
+ * Purpose: Creates a named object that refers to indexed storage of raw
+ * data. No raw data is stored.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -167,37 +163,36 @@ new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
*-------------------------------------------------------------------------
*/
static herr_t
-test_create (H5F_t *f, const char *prefix)
+test_create(H5F_t *f, const char *prefix)
{
- H5G_entry_t handle;
- intn i;
- char name[256];
-
- printf ("%-70s", "Testing istore create");
-
- for (i=1; i<=H5O_LAYOUT_NDIMS; i++) {
- sprintf (name, "%s_%02d", prefix, i);
- if (new_object (f, name, i, &handle)<0) return FAIL;
- }
-
- puts (" PASSED");
- return SUCCEED;
-}
+ H5G_entry_t handle;
+ intn i;
+ char name[256];
+ printf("%-70s", "Testing istore create");
+ for (i = 1; i <= H5O_LAYOUT_NDIMS; i++) {
+ sprintf(name, "%s_%02d", prefix, i);
+ if (new_object(f, name, i, &handle) < 0)
+ return FAIL;
+ }
+
+ puts(" PASSED");
+ return SUCCEED;
+}
/*-------------------------------------------------------------------------
- * Function: test_extend
+ * Function: test_extend
*
- * Purpose: Creates an empty object and then writes to it in such a way
- * as to always extend the object's domain without creating
- * holes and without causing the object to become concave.
+ * Purpose: Creates an empty object and then writes to it in such a way
+ * as to always extend the object's domain without creating
+ * holes and without causing the object to become concave.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -205,214 +200,217 @@ test_create (H5F_t *f, const char *prefix)
*-------------------------------------------------------------------------
*/
static herr_t
-test_extend (H5F_t *f, const char *prefix,
- size_t nx, size_t ny, size_t nz)
+test_extend(H5F_t *f, const char *prefix,
+ size_t nx, size_t ny, size_t nz)
{
- H5G_entry_t handle;
- int i, j, k, ndims, ctr;
- uint8 *buf=NULL, *check=NULL, *whole=NULL;
- char dims[64], s[256], name[256];
- size_t offset[3];
- size_t max_corner[3];
- size_t size[3];
- size_t whole_size[3];
- size_t nelmts;
- H5O_layout_t layout;
-
- if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dims, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dims, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
-
-
- sprintf (s, "Testing istore extend: %s", dims);
- printf ("%-70s", s);
- buf = H5MM_xmalloc (nx*ny*nz);
- check = H5MM_xmalloc (nx*ny*nz);
- whole = H5MM_xcalloc (nx*ny*nz, 1);
-
- /* Build the new empty object */
- sprintf (name, "%s_%s", prefix, dims);
- if (new_object (f, name, ndims, &handle)<0) {
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create %d-d object `%s'\n", ndims, name);
- }
- goto error;
- }
- if (NULL==H5O_read (&handle, H5O_LAYOUT, 0, &layout)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Unable to read istore message\n");
- }
- goto error;
- }
- if (ndims!=layout.ndims) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Header read error: istore.ndims != %d\n", ndims);
- }
- goto error;
- }
-
- whole_size[0] = nx;
- whole_size[1] = ny;
- whole_size[2] = nz;
- max_corner[0] = 0;
- max_corner[1] = 0;
- max_corner[2] = 0;
-
- for (ctr=0; H5V_vector_lt (ndims, max_corner, whole_size); ctr++) {
-
- /* Size and location */
- if (0==ctr) {
- offset[0] = offset[1] = offset[2] = 0;
- size[0] = size[1] = size[2] = 1;
- nelmts = 1;
- } else {
- for (i=0, nelmts=1; i<ndims; i++) {
- if (ctr % ndims == i) {
- offset[i] = max_corner[i];
- size[i] = MIN (1, whole_size[i]-offset[i]);
- } else {
- offset[i] = 0;
- size[i] = max_corner[i];
- }
- nelmts *= size[i];
- }
- }
+ H5G_entry_t handle;
+ int i, j, k, ndims, ctr;
+ uint8 *buf = NULL, *check = NULL, *whole = NULL;
+ char dims[64], s[256], name[256];
+ size_t offset[3];
+ size_t max_corner[3];
+ size_t size[3];
+ size_t whole_size[3];
+ size_t nelmts;
+ H5O_layout_t layout;
+
+ if (!nz) {
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dims, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dims, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+
+ sprintf(s, "Testing istore extend: %s", dims);
+ printf("%-70s", s);
+ buf = H5MM_xmalloc(nx * ny * nz);
+ check = H5MM_xmalloc(nx * ny * nz);
+ whole = H5MM_xcalloc(nx * ny * nz, 1);
+
+ /* Build the new empty object */
+ sprintf(name, "%s_%s", prefix, dims);
+ if (new_object(f, name, ndims, &handle) < 0) {
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create %d-d object `%s'\n", ndims, name);
+ }
+ goto error;
+ }
+ if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Unable to read istore message\n");
+ }
+ goto error;
+ }
+ if (ndims != layout.ndims) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Header read error: istore.ndims != %d\n", ndims);
+ }
+ goto error;
+ }
+ whole_size[0] = nx;
+ whole_size[1] = ny;
+ whole_size[2] = nz;
+ max_corner[0] = 0;
+ max_corner[1] = 0;
+ max_corner[2] = 0;
+
+ for (ctr = 0; H5V_vector_lt(ndims, max_corner, whole_size); ctr++) {
+
+ /* Size and location */
+ if (0 == ctr) {
+ offset[0] = offset[1] = offset[2] = 0;
+ size[0] = size[1] = size[2] = 1;
+ nelmts = 1;
+ } else {
+ for (i = 0, nelmts = 1; i < ndims; i++) {
+ if (ctr % ndims == i) {
+ offset[i] = max_corner[i];
+ size[i] = MIN(1, whole_size[i] - offset[i]);
+ } else {
+ offset[i] = 0;
+ size[i] = max_corner[i];
+ }
+ nelmts *= size[i];
+ }
+ }
#if 0
- if (0==ctr) printf ("\n");
- printf (" Insert: ctr=%d, corner=(%d", ctr, offset[0]);
- if (ndims>1) printf (",%d", offset[1]);
- if (ndims>2) printf (",%d", offset[2]);
- printf ("), size=(%d", size[0]);
- if (ndims>1) printf (",%d", size[1]);
- if (ndims>2) printf (",%d", size[2]);
- printf ("), %d element%s", nelmts, 1==nelmts?"":"s");
- if (0==nelmts) printf (" *SKIPPED*");
- printf ("\n");
+ if (0 == ctr)
+ printf("\n");
+ printf(" Insert: ctr=%d, corner=(%d", ctr, offset[0]);
+ if (ndims > 1)
+ printf(",%d", offset[1]);
+ if (ndims > 2)
+ printf(",%d", offset[2]);
+ printf("), size=(%d", size[0]);
+ if (ndims > 1)
+ printf(",%d", size[1]);
+ if (ndims > 2)
+ printf(",%d", size[2]);
+ printf("), %d element%s", nelmts, 1 == nelmts ? "" : "s");
+ if (0 == nelmts)
+ printf(" *SKIPPED*");
+ printf("\n");
#endif
-
- /* Fill the source array */
- if (0==nelmts) continue;
- memset (buf, 128+ctr, nelmts);
-
- /* Write to disk */
- if (H5F_arr_write (f, &layout, offset, size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Write failed: ctr=%d\n", ctr);
- }
- goto error;
- }
-
- /* Read from disk */
- memset (check, 0xff, nelmts);
- if (H5F_arr_read (f, &layout, offset, size, check)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read failed: ctr=%d\n", ctr);
- }
- goto error;
- }
- if (memcmp (buf, check, nelmts)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read check failed: ctr=%d\n", ctr);
- printf (" Wrote:\n");
- print_array (buf, size[0], size[1], size[2]);
- printf (" Read:\n");
- print_array (check, size[0], size[1], size[2]);
- }
- goto error;
- }
-
- /* Write to `whole' buffer for later checking */
- H5V_hyper_copy (ndims, size,
- whole_size, offset, whole, /*dst*/
- size, H5V_ZERO, buf); /*src*/
-
- /* Update max corner */
- for (i=0; i<ndims; i++) {
- max_corner[i] = MAX (max_corner[i], offset[i]+size[i]);
- }
- }
-
- /* Now read the entire array back out and check it */
- memset (buf, 0xff, nx*ny*nz);
- if (H5F_arr_read (f, &layout, H5V_ZERO, whole_size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read failed for whole array\n");
- }
- goto error;
- }
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- for (k=0; k<nz; k++) {
- if (whole[i*ny*nz + j*nz + k] != buf[i*ny*nz + j*nz + k]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Check failed at i=%d", i);
- if (ndims>1) printf (", j=%d", j);
- if (ndims>2) printf (", k=%d", k);
- printf ("\n Check array is:\n");
- print_array (whole, nx, ny, nz);
- printf (" Value read is:\n");
- print_array (buf, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (buf);
- H5MM_xfree (check);
- H5MM_xfree (whole);
- return SUCCEED;
-
- error:
- H5MM_xfree (buf);
- H5MM_xfree (check);
- H5MM_xfree (whole);
- return FAIL;
-}
-
+ /* Fill the source array */
+ if (0 == nelmts)
+ continue;
+ memset(buf, 128 + ctr, nelmts);
+
+ /* Write to disk */
+ if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Write failed: ctr=%d\n", ctr);
+ }
+ goto error;
+ }
+ /* Read from disk */
+ memset(check, 0xff, nelmts);
+ if (H5F_arr_read(f, &layout, offset, size, check) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read failed: ctr=%d\n", ctr);
+ }
+ goto error;
+ }
+ if (memcmp(buf, check, nelmts)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read check failed: ctr=%d\n", ctr);
+ printf(" Wrote:\n");
+ print_array(buf, size[0], size[1], size[2]);
+ printf(" Read:\n");
+ print_array(check, size[0], size[1], size[2]);
+ }
+ goto error;
+ }
+ /* Write to `whole' buffer for later checking */
+ H5V_hyper_copy(ndims, size,
+ whole_size, offset, whole, /*dst */
+ size, H5V_ZERO, buf); /*src */
+
+ /* Update max corner */
+ for (i = 0; i < ndims; i++) {
+ max_corner[i] = MAX(max_corner[i], offset[i] + size[i]);
+ }
+ }
+
+ /* Now read the entire array back out and check it */
+ memset(buf, 0xff, nx * ny * nz);
+ if (H5F_arr_read(f, &layout, H5V_ZERO, whole_size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read failed for whole array\n");
+ }
+ goto error;
+ }
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ if (whole[i * ny * nz + j * nz + k] != buf[i * ny * nz + j * nz + k]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Check failed at i=%d", i);
+ if (ndims > 1)
+ printf(", j=%d", j);
+ if (ndims > 2)
+ printf(", k=%d", k);
+ printf("\n Check array is:\n");
+ print_array(whole, nx, ny, nz);
+ printf(" Value read is:\n");
+ print_array(buf, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(buf);
+ H5MM_xfree(check);
+ H5MM_xfree(whole);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(buf);
+ H5MM_xfree(check);
+ H5MM_xfree(whole);
+ return FAIL;
+}
/*-------------------------------------------------------------------------
- * Function: test_sparse
+ * Function: test_sparse
*
- * Purpose: Creates a sparse matrix consisting of NBLOCKS randomly placed
- * blocks each of size NX,NY,NZ.
+ * Purpose: Creates a sparse matrix consisting of NBLOCKS randomly placed
+ * blocks each of size NX,NY,NZ.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -420,108 +418,109 @@ test_extend (H5F_t *f, const char *prefix,
*-------------------------------------------------------------------------
*/
static herr_t
-test_sparse (H5F_t *f, const char *prefix, size_t nblocks,
- size_t nx, size_t ny, size_t nz)
+test_sparse(H5F_t *f, const char *prefix, size_t nblocks,
+ size_t nx, size_t ny, size_t nz)
{
- intn ndims, ctr;
- char dims[64], s[256], name[256];
- size_t offset[3], size[3], total=0;
- H5G_entry_t handle;
- H5O_layout_t layout;
- uint8 *buf = NULL;
-
- if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dims, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dims, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
-
- sprintf (s, "Testing istore sparse: %s", dims);
- printf ("%-70s", s);
- buf = H5MM_xmalloc (nx*ny*nz);
-
- /* Build the new empty object */
- sprintf (name, "%s_%s", prefix, dims);
- if (new_object (f, name, ndims, &handle)<0) {
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create %d-d object `%s'\n", ndims, name);
- }
- goto error;
- }
- if (NULL==H5O_read (&handle, H5O_LAYOUT, 0, &layout)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Unable to read istore message\n");
- }
- goto error;
- }
-
- for (ctr=0; ctr<nblocks; ctr++) {
- offset[0] = rand () % 1000000;
- offset[1] = rand () % 1000000;
- offset[2] = rand () % 1000000;
- size[0] = nx;
- size[1] = ny;
- size[2] = nz;
- memset (buf, 128+ctr, nx*ny*nz);
-
- /* write to disk */
- if (H5F_arr_write (f, &layout, offset, size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Write failed: ctr=%d\n", ctr);
- printf (" offset=(%lu", (unsigned long)(offset[0]));
- if (ndims>1) printf (",%lu", (unsigned long)(offset[1]));
- if (ndims>2) printf (",%lu", (unsigned long)(offset[2]));
- printf ("), size=(%lu", (unsigned long)(size[0]));
- if (ndims>1) printf (",%lu", (unsigned long)(size[1]));
- if (ndims>2) printf (",%lu", (unsigned long)(size[2]));
- printf (")\n");
- }
- goto error;
- }
- total += nx*ny*nz;
+ intn ndims, ctr;
+ char dims[64], s[256], name[256];
+ size_t offset[3], size[3], total = 0;
+ H5G_entry_t handle;
+ H5O_layout_t layout;
+ uint8 *buf = NULL;
+
+ if (!nz) {
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dims, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dims, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+
+ sprintf(s, "Testing istore sparse: %s", dims);
+ printf("%-70s", s);
+ buf = H5MM_xmalloc(nx * ny * nz);
+
+ /* Build the new empty object */
+ sprintf(name, "%s_%s", prefix, dims);
+ if (new_object(f, name, ndims, &handle) < 0) {
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create %d-d object `%s'\n", ndims, name);
+ }
+ goto error;
+ }
+ if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Unable to read istore message\n");
+ }
+ goto error;
+ }
+ for (ctr = 0; ctr < nblocks; ctr++) {
+ offset[0] = rand() % 1000000;
+ offset[1] = rand() % 1000000;
+ offset[2] = rand() % 1000000;
+ size[0] = nx;
+ size[1] = ny;
+ size[2] = nz;
+ memset(buf, 128 + ctr, nx * ny * nz);
+
+ /* write to disk */
+ if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Write failed: ctr=%d\n", ctr);
+ printf(" offset=(%lu", (unsigned long) (offset[0]));
+ if (ndims > 1)
+ printf(",%lu", (unsigned long) (offset[1]));
+ if (ndims > 2)
+ printf(",%lu", (unsigned long) (offset[2]));
+ printf("), size=(%lu", (unsigned long) (size[0]));
+ if (ndims > 1)
+ printf(",%lu", (unsigned long) (size[1]));
+ if (ndims > 2)
+ printf(",%lu", (unsigned long) (size[2]));
+ printf(")\n");
+ }
+ goto error;
+ }
+ total += nx * ny * nz;
#if 0
- printf ("ctr: ctr=%d, total=%lu\n", ctr, (unsigned long)total);
+ printf("ctr: ctr=%d, total=%lu\n", ctr, (unsigned long) total);
#endif
- /* We don't test reading yet.... */
- }
-
-
- puts (" PASSED");
- H5MM_xfree (buf);
- return SUCCEED;
-
- error:
- H5MM_xfree (buf);
- return FAIL;
-}
+ /* We don't test reading yet.... */
+ }
+ puts(" PASSED");
+ H5MM_xfree(buf);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(buf);
+ return FAIL;
+}
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Tests indexed storage stuff.
+ * Purpose: Tests indexed storage stuff.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(non-zero)
+ * Failure: exit(non-zero)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -529,136 +528,134 @@ test_sparse (H5F_t *f, const char *prefix, size_t nblocks,
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- H5F_t *f;
- herr_t status;
- int nerrors = 0;
- uintn size_of_test;
- hid_t template_id;
- H5F_create_t *creation_template = NULL;
- H5G_t *dir = NULL;
-
- setbuf (stdout, NULL);
-
- /* Parse arguments or assume `small' */
- if (1==argc) {
- 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 if (!strcmp (argv[i], "large")) {
- size_of_test |= TEST_LARGE;
- } else {
- printf ("unrecognized argument: %s\n", argv[i]);
- exit (1);
- }
- }
- }
- printf ("Test sizes: ");
- if (size_of_test & TEST_SMALL) printf (" SMALL");
- if (size_of_test & TEST_MEDIUM) printf (" MEDIUM");
- if (size_of_test & TEST_LARGE) printf (" LARGE");
- printf ("\n");
-
- /*
- * Use larger file addresses...
- */
- template_id = H5Ccreate (H5C_FILE_CREATE);
- H5Cset_sizes (template_id, 8, 0);
- creation_template = H5Aatom_object (template_id);
-
- /* Create the test file */
- if (NULL==(f=H5F_open (FILETYPE, FILENAME,
- (H5F_ACC_CREAT|H5F_ACC_WRITE|H5F_ACC_TRUNC|
- H5F_ACC_DEBUG),
- creation_template))) {
- printf ("Cannot create file %s; test aborted\n", FILENAME);
- exit (1);
- }
-
+ H5F_t *f;
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
+ hid_t template_id;
+ H5F_create_t *creation_template = NULL;
+ H5G_t *dir = NULL;
+
+ setbuf(stdout, NULL);
+
+ /* Parse arguments or assume `small' */
+ if (1 == argc) {
+ 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 if (!strcmp(argv[i], "large")) {
+ size_of_test |= TEST_LARGE;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
+ }
+ printf("Test sizes: ");
+ if (size_of_test & TEST_SMALL)
+ printf(" SMALL");
+ if (size_of_test & TEST_MEDIUM)
+ printf(" MEDIUM");
+ if (size_of_test & TEST_LARGE)
+ printf(" LARGE");
+ printf("\n");
+
+ /*
+ * Use larger file addresses...
+ */
+ template_id = H5Ccreate(H5C_FILE_CREATE);
+ H5Cset_sizes(template_id, 8, 0);
+ creation_template = H5Aatom_object(template_id);
+
+ /* Create the test file */
+ if (NULL == (f = H5F_open(FILETYPE, FILENAME,
+ (H5F_ACC_CREAT | H5F_ACC_WRITE | H5F_ACC_TRUNC |
+ H5F_ACC_DEBUG),
+ creation_template))) {
+ printf("Cannot create file %s; test aborted\n", FILENAME);
+ exit(1);
+ }
#ifdef TEST_FAMILY
- {
- /*
- * For testing file families, fool the library into thinking it already
- * allocated a whole bunch of data.
- */
- haddr_t addr;
- addr.offset = 8 * ((uint64)1<<30); /*8 GB*/
- H5F_low_seteof (f->shared->lf, &addr);
- }
+ {
+ /*
+ * For testing file families, fool the library into thinking it already
+ * allocated a whole bunch of data.
+ */
+ haddr_t addr;
+ addr.offset = 8 * ((uint64) 1 << 30); /*8 GB */
+ H5F_low_seteof(f->shared->lf, &addr);
+ }
#endif
- /*
- * By creating a group we cause the library to emit it's debugging
- * diagnostic messages before we begin testing...
- */
- dir = H5G_create (f, "flushing_diagnostics", 0);
- H5G_close (dir);
- dir = NULL;
-
-
- /*
- * Creation test: Creates empty objects with various raw data sizes
- * and alignments.
- */
- status = test_create (f, "create");
- nerrors += status<0 ? 1 : 0;
-
- if (size_of_test & TEST_SMALL) {
- status = test_extend (f, "extend", 10, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 10, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 10, 10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_extend (f, "extend", 10000, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 2500, 10, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 400, 10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_SMALL) {
- status = test_sparse (f, "sparse", 100, 5, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 100, 3, 4, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 100, 2, 3, 4);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_sparse (f, "sparse", 1000, 30, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 2000, 7, 3, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 2000, 4, 2, 3);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_LARGE) {
- status = test_sparse (f, "sparse", 800, 50, 50, 50);
- nerrors += status<0 ? 1 : 0;
- }
-
-
- /* Close the test file and exit */
- H5F_close (f);
- if (nerrors) {
- printf ("***** %d I-STORE 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 i-store tests passed.\n");
- exit (0);
+ /*
+ * By creating a group we cause the library to emit it's debugging
+ * diagnostic messages before we begin testing...
+ */
+ dir = H5G_create(f, "flushing_diagnostics", 0);
+ H5G_close(dir);
+ dir = NULL;
+
+ /*
+ * Creation test: Creates empty objects with various raw data sizes
+ * and alignments.
+ */
+ status = test_create(f, "create");
+ nerrors += status < 0 ? 1 : 0;
+
+ if (size_of_test & TEST_SMALL) {
+ status = test_extend(f, "extend", 10, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 10, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 10, 10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_extend(f, "extend", 10000, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 2500, 10, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 400, 10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_SMALL) {
+ status = test_sparse(f, "sparse", 100, 5, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 100, 3, 4, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 100, 2, 3, 4);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_sparse(f, "sparse", 1000, 30, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 2000, 7, 3, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 2000, 4, 2, 3);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_LARGE) {
+ status = test_sparse(f, "sparse", 800, 50, 50, 50);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ /* Close the test file and exit */
+ H5F_close(f);
+ if (nerrors) {
+ printf("***** %d I-STORE 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 i-store tests passed.\n");
+ exit(0);
}
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 93e059a..b59c3ab 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -11,31 +11,31 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
/*
FILE
- testhdf5.c - HDF5 testing framework main file.
+ testhdf5.c - HDF5 testing framework main file.
REMARKS
- General test wrapper for HDF5 base library test programs
+ General test wrapper for HDF5 base library test programs
DESIGN
- Each test function should be implemented as function having no
- parameters and returning void (i.e. no return value). They should be put
- into the list of InitTest() calls in main() below. Functions which depend
- on other functionality should be placed below the InitTest() call for the
- base functionality testing.
- Each test module should include testhdf5.h and define a unique set of
- names for test files they create.
+ Each test function should be implemented as function having no
+ parameters and returning void (i.e. no return value). They should be put
+ into the list of InitTest() calls in main() below. Functions which depend
+ on other functionality should be placed below the InitTest() call for the
+ base functionality testing.
+ Each test module should include testhdf5.h and define a unique set of
+ names for test files they create.
BUGS/LIMITATIONS
EXPORTED ROUTINES/VARIABLES:
- Two variables are exported: num_errs, and Verbosity.
+ Two variables are exported: num_errs, and Verbosity.
*/
@@ -49,35 +49,33 @@ static char RcsId[] = "@(#)$Revision$";
#define HDF5_TEST_MASTER
/* Internal Variables */
-static int Index = 0;
+static int Index = 0;
/* Global variables */
-int num_errs;
-int Verbosity;
+int num_errs;
+int Verbosity;
/* ANY new test needs to have a prototype in tproto.h */
#include <testhdf5.h>
-struct TestStruct
- {
- int NumErrors;
- char Description[64];
- int SkipFlag;
- char Name[16];
- VOID (*Call) (void);
- }
- Test[MAXNUMOFTESTS];
+struct TestStruct {
+ int NumErrors;
+ char Description[64];
+ int SkipFlag;
+ char Name[16];
+ VOID(*Call) (void);
+} Test[MAXNUMOFTESTS];
-static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr);
-static void usage(void);
+static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr);
+static void usage(void);
-static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr)
+static void
+InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr)
{
- if (Index >= MAXNUMOFTESTS)
- {
- print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n");
- exit(0);
- } /* end if */
+ if (Index >= MAXNUMOFTESTS) {
+ print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n");
+ exit(0);
+ } /* end if */
HDstrcpy(Test[Index].Description, TheDescr);
HDstrcpy(Test[Index].Name, TheName);
Test[Index].Call = TheCall;
@@ -86,9 +84,10 @@ static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *The
Index++;
}
-static void usage(void)
+static void
+usage(void)
{
- intn i;
+ intn i;
print_func("Usage: testhdf5 [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n");
print_func(" [-[e]x[clude] name+] \n");
@@ -114,32 +113,34 @@ static void usage(void)
for (i = 0; i < Index; i++)
print_func("%16s %s\n", Test[i].Name, Test[i].Description);
print_func("\n\n");
-} /* end usage() */
+} /* end usage() */
/*
* This routine is designed to provide equivalent functionality to 'printf'
* and allow easy replacement for environments which don't have stdin/stdout
* available. (i.e. Windows & the Mac)
*/
-int print_func(const char *format, ...)
+int
+print_func(const char *format,...)
{
- va_list arglist;
- int ret_value;
+ va_list arglist;
+ int ret_value;
va_start(arglist, format);
- ret_value=vprintf(format, arglist);
+ ret_value = vprintf(format, arglist);
va_end(arglist);
- return(ret_value);
+ return (ret_value);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
- int CLLoop; /* Command Line Loop */
- int Loop, Loop1;
- int Summary = 0;
- int CleanUp = 1;
- int Cache = 1;
- uintn major, minor, release, patch;
+ int CLLoop; /* Command Line Loop */
+ int Loop, Loop1;
+ int Summary = 0;
+ int CleanUp = 1;
+ int Cache = 1;
+ uintn major, minor, release, patch;
#if defined __MWERKS__
argc = ccommand(&argv);
@@ -159,112 +160,97 @@ int main(int argc, char *argv[])
InitTest("stab", test_stab, "Symbol Tables");
InitTest("h5p", test_h5p, "Dataspaces");
- Verbosity = 4; /* Default Verbosity is Low */
+ Verbosity = 4; /* Default Verbosity is Low */
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,
- (unsigned) minor, (unsigned) release, 'a'+patch);
- for (CLLoop = 1; CLLoop < argc; CLLoop++)
- {
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
- (HDstrcmp(argv[CLLoop], "-v") == 0)))
- {
- if (argv[CLLoop + 1][0] == 'l')
- Verbosity = 4;
- else if (argv[CLLoop + 1][0] == 'm')
- Verbosity = 6;
- else if (argv[CLLoop + 1][0] == 'h')
- Verbosity = 10;
- else
- Verbosity = atoi(argv[CLLoop + 1]);
- } /* end if */
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
- (HDstrcmp(argv[CLLoop], "-s") == 0)))
- Summary = 1;
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
- (HDstrcmp(argv[CLLoop], "-h") == 0)))
- {
- usage();
- exit(0);
- }
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
- (HDstrcmp(argv[CLLoop], "-c") == 0)))
- CleanUp = 0;
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) ||
- (HDstrcmp(argv[CLLoop], "-n") == 0)))
- Cache = 0;
-
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
- (HDstrcmp(argv[CLLoop], "-x") == 0)))
- {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Test[Loop1].SkipFlag = 1;
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
- (HDstrcmp(argv[CLLoop], "-b") == 0)))
- {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- {
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0)
- Test[Loop1].SkipFlag = 1;
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Loop1 = Index;
- } /* end for */
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
- (HDstrcmp(argv[CLLoop], "-o") == 0)))
- {
- for (Loop = 0; Loop < Index; Loop++)
- Test[Loop].SkipFlag = 1;
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Test[Loop1].SkipFlag = 0;
- Loop++;
- } /* end while */
- } /* end if */
- } /* end for */
+ (unsigned) minor, (unsigned) release, 'a' + patch);
+ for (CLLoop = 1; CLLoop < argc; CLLoop++) {
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-v") == 0))) {
+ if (argv[CLLoop + 1][0] == 'l')
+ Verbosity = 4;
+ else if (argv[CLLoop + 1][0] == 'm')
+ Verbosity = 6;
+ else if (argv[CLLoop + 1][0] == 'h')
+ Verbosity = 10;
+ else
+ Verbosity = atoi(argv[CLLoop + 1]);
+ } /* end if */
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-s") == 0)))
+ Summary = 1;
+
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-h") == 0))) {
+ usage();
+ exit(0);
+ }
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-c") == 0)))
+ CleanUp = 0;
+
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-n") == 0)))
+ Cache = 0;
+
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-x") == 0))) {
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++)
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Test[Loop1].SkipFlag = 1;
+ Loop++;
+ } /* end while */
+ } /* end if */
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-b") == 0))) {
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++) {
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0)
+ Test[Loop1].SkipFlag = 1;
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Loop1 = Index;
+ } /* end for */
+ Loop++;
+ } /* end while */
+ } /* end if */
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-o") == 0))) {
+ for (Loop = 0; Loop < Index; Loop++)
+ Test[Loop].SkipFlag = 1;
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++)
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Test[Loop1].SkipFlag = 0;
+ Loop++;
+ } /* end while */
+ } /* end if */
+ } /* end for */
#ifdef NOT_YET
- if(Cache) /* turn on caching, unless we were instucted not to */
- Hcache(CACHE_ALL_FILES,TRUE);
+ if (Cache) /* turn on caching, unless we were instucted not to */
+ Hcache(CACHE_ALL_FILES, TRUE);
#endif /* NOT_YET */
- for (Loop = 0; Loop < Index; Loop++)
- {
- if (Test[Loop].SkipFlag)
- {
- MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
- }
- else
- {
- MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description,
- Test[Loop].Name));
- MESSAGE(5, ("===============================================\n"));
- Test[Loop].NumErrors = num_errs;
- (*Test[Loop].Call) ();
- Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
- MESSAGE(5, ("===============================================\n"));
- MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors));
- } /* end else */
- } /* end for */
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (Test[Loop].SkipFlag) {
+ MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
+ } else {
+ MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description,
+ Test[Loop].Name));
+ MESSAGE(5, ("===============================================\n"));
+ Test[Loop].NumErrors = num_errs;
+ (*Test[Loop].Call) ();
+ Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
+ MESSAGE(5, ("===============================================\n"));
+ MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors));
+ } /* end else */
+ } /* end for */
MESSAGE(2, ("\n\n"))
if (num_errs)
@@ -272,33 +258,29 @@ int main(int argc, char *argv[])
else
print_func("All tests were successful. \n\n");
- if (Summary)
- {
- print_func("Summary of Test Results:\n");
- print_func("Name of Test Errors Description of Test\n");
- print_func("---------------- ------ --------------------------------------\n");
-
- for (Loop = 0; Loop < Index; Loop++)
- {
- if (Test[Loop].NumErrors == -1)
- print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
- else
- print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors,
- Test[Loop].Description);
- } /* end for */
- print_func("\n\n");
- } /* end if */
+ if (Summary) {
+ print_func("Summary of Test Results:\n");
+ print_func("Name of Test Errors Description of Test\n");
+ print_func("---------------- ------ --------------------------------------\n");
- if (CleanUp)
- {
- MESSAGE(2, ("\nCleaning Up...\n\n"));
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (Test[Loop].NumErrors == -1)
+ print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
+ else
+ print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors,
+ Test[Loop].Description);
+ } /* end for */
+ print_func("\n\n");
+ } /* end if */
+ if (CleanUp) {
+ MESSAGE(2, ("\nCleaning Up...\n\n"));
#if !(defined DOS386 | defined WIN386)
- system("rm -f *.h5 *.tmp");
-#else /* OLD_WAY */
- remove("*.h5");
- remove("*.tmp");
-#endif /* OLD_WAY */
- } /* end if */
+ system("rm -f *.h5 *.tmp");
+#else /* OLD_WAY */
+ remove("*.h5");
+ remove("*.tmp");
+#endif /* OLD_WAY */
+ } /* end if */
exit(0);
return (0);
-} /* end main() */
+} /* end main() */
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 27b9e19..d13f08a 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -26,8 +26,8 @@
#include <H5private.h>
#include <H5Eprivate.h>
-extern int num_errs;
-extern int Verbosity;
+extern int num_errs;
+extern int Verbosity;
/* Use %ld to print the value because long should cover most cases. */
/* Used to make certain a return value _is_not_ a value */
@@ -36,30 +36,30 @@ do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s retu
if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", where, (long)ret, (int)__LINE__,__FILE__); num_errs++;H5Eprint (H5E_thrdid_g, stdout);} \
} while(0)
-#define CHECK_I(ret,where) { \
- if (Verbosity>9) { \
+#define CHECK_I(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \
- (where), (int)__LINE__, __FILE__, (long)(ret)); \
- } \
- if ((ret)<0) { \
+ (where), (int)__LINE__, __FILE__, (long)(ret)); \
+ } \
+ if ((ret)<0) { \
print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \
- (where), (long)(ret), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
+ (where), (long)(ret), (int)__LINE__, __FILE__); \
+ H5Eprint (H5E_thrdid_g, stdout); \
+ num_errs++; \
+ } \
}
-
-#define CHECK_PTR(ret,where) { \
- if (Verbosity>9) { \
+
+#define CHECK_PTR(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \
- (where), (int)__LINE__, __FILE__, (ret)); \
- } \
- if (!(ret)) { \
+ (where), (int)__LINE__, __FILE__, (ret)); \
+ } \
+ if (!(ret)) { \
print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \
- (where), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
+ (where), (int)__LINE__, __FILE__); \
+ H5Eprint (H5E_thrdid_g, stdout); \
+ num_errs++; \
+ } \
}
/* Used to make certain a return value _is_ a value */
@@ -80,35 +80,34 @@ if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in
#define MESSAGE(V,A) {if (Verbosity>(V)) print_func A;}
/* definitions for command strings */
-#define VERBOSITY_STR "Verbosity"
-#define SKIP_STR "Skip"
-#define TEST_STR "Test"
-#define CLEAN_STR "Cleanup"
+#define VERBOSITY_STR "Verbosity"
+#define SKIP_STR "Skip"
+#define TEST_STR "Test"
+#define CLEAN_STR "Cleanup"
/* System command to use for Cleanup */
#ifdef VMS
-#define CLEAN_CMD "delete *.hdf;*"
+#define CLEAN_CMD "delete *.hdf;*"
#else
# ifdef WIN32
-# define CLEAN_CMD "del *.hdf"
+# define CLEAN_CMD "del *.hdf"
# else
/* default is Unix */
-# define CLEAN_CMD "rm -f *.hdf"
-# endif /* WIN32 */
+# define CLEAN_CMD "rm -f *.hdf"
+# endif /* WIN32 */
#endif /*VMS */
/* Prototypes for the support routines */
-int print_func(const char *, ...);
+int print_func(const char *,...);
/* Prototypes for the test routines */
-void test_metadata(void);
-void test_file(void);
-void test_heap (void);
-void test_ohdr (void);
-void test_stab (void);
-void test_h5t (void);
-void test_h5p (void);
-void test_h5d (void);
+void test_metadata(void);
+void test_file(void);
+void test_heap(void);
+void test_ohdr(void);
+void test_stab(void);
+void test_h5t(void);
+void test_h5p(void);
+void test_h5d(void);
#endif /* HDF5TEST_H */
-
diff --git a/test/tfile.c b/test/tfile.c
index b72e037..ffbe172 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "$Revision$";
+static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
@@ -34,22 +34,22 @@ static char RcsId[] = "$Revision$";
#define F1_USERBLOCK_SIZE 0
#define F1_OFFSET_SIZE 4
#define F1_LENGTH_SIZE 4
-#define F1_SYM_LEAF_K 4
-#define F1_SYM_INTERN_K 16
+#define F1_SYM_LEAF_K 4
+#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"
#define F2_USERBLOCK_SIZE 512
#define F2_OFFSET_SIZE 8
#define F2_LENGTH_SIZE 8
-#define F2_SYM_LEAF_K 8
-#define F2_SYM_INTERN_K 32
+#define F2_SYM_LEAF_K 8
+#define F2_SYM_INTERN_K 32
#define FILE2 "tfile2.h5"
#define F3_USERBLOCK_SIZE 0
#define F3_OFFSET_SIZE F2_OFFSET_SIZE
#define F3_LENGTH_SIZE F2_LENGTH_SIZE
-#define F3_SYM_LEAF_K F2_SYM_LEAF_K
-#define F3_SYM_INTERN_K F2_SYM_INTERN_K
+#define F3_SYM_LEAF_K F2_SYM_LEAF_K
+#define F3_SYM_INTERN_K F2_SYM_INTERN_K
#define FILE3 "tfile3.h5"
/****************************************************************
@@ -57,218 +57,218 @@ static char RcsId[] = "$Revision$";
** test_file_create(): Low-level file creation I/O test routine.
**
****************************************************************/
-static void test_file_create(void)
+static void
+test_file_create(void)
{
- hid_t fid1,fid2,fid3; /* HDF5 File IDs */
- hid_t tmpl1,tmpl2; /* File creation templates */
- size_t parm; /* File-creation parameters */
- size_t parm2; /* File-creation parameters */
- int iparm, iparm2;
- herr_t ret; /* Generic return value */
+ hid_t fid1, fid2, fid3; /* HDF5 File IDs */
+ hid_t tmpl1, tmpl2; /* File creation templates */
+ size_t parm; /* File-creation parameters */
+ size_t parm2; /* File-creation parameters */
+ int iparm, iparm2;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File Creation I/O\n"));
/* Create first file */
- fid1=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
- CHECK(fid1,FAIL,"H5Fcreate");
+ fid1 = H5Fcreate(FILE1, H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid1, FAIL, "H5Fcreate");
/* Try to create first file again (should fail) */
- fid2=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
- VERIFY(fid2,FAIL,"H5Fcreate");
+ fid2 = H5Fcreate(FILE1, H5ACC_OVERWRITE, 0, 0);
+ VERIFY(fid2, FAIL, "H5Fcreate");
/* Get the file-creation template */
- tmpl1 = H5Fget_create_template (fid1);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid1);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F1_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F1_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F1_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F1_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F1_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F1_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F1_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F1_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F1_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
/* Double-check that the atom has been vaporized */
- ret=H5Mclose(tmpl1);
- VERIFY(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ VERIFY(ret, FAIL, "H5Mrelease");
/* Create a new file with a non-standard file-creation template */
- tmpl1 = H5Ccreate (H5C_FILE_CREATE);
- CHECK(tmpl1,FAIL,"H5Cnew");
+ tmpl1 = H5Ccreate(H5C_FILE_CREATE);
+ CHECK(tmpl1, FAIL, "H5Cnew");
/* Set the new file-creation parameters */
- ret = H5Cset_userblock (tmpl1, F2_USERBLOCK_SIZE);
- CHECK(ret,FAIL,"H5Cset_userblock");
+ ret = H5Cset_userblock(tmpl1, F2_USERBLOCK_SIZE);
+ CHECK(ret, FAIL, "H5Cset_userblock");
- ret = H5Cset_sizes (tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
- CHECK(ret,FAIL,"H5Cset_sizes");
+ ret = H5Cset_sizes(tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
+ CHECK(ret, FAIL, "H5Cset_sizes");
- ret = H5Cset_sym_k (tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
- CHECK(ret,FAIL,"H5Cset_sym_k");
+ ret = H5Cset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
+ CHECK(ret, FAIL, "H5Cset_sym_k");
/*
* Try to create second file, with non-standard file-creation template
* params.
*/
- fid2=H5Fcreate(FILE2,H5ACC_OVERWRITE,tmpl1,0);
- CHECK(fid2,FAIL,"H5Fcreate");
+ fid2 = H5Fcreate(FILE2, H5ACC_OVERWRITE, tmpl1, 0);
+ CHECK(fid2, FAIL, "H5Fcreate");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid2);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid2);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F2_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k");
/* Clone the file-creation template */
- tmpl2=H5Mcopy(tmpl1);
- CHECK(tmpl2,FAIL,"H5Mcopy");
+ tmpl2 = H5Mcopy(tmpl1);
+ CHECK(tmpl2, FAIL, "H5Mcopy");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Set the new file-creation parameter */
- ret = H5Cset_userblock (tmpl2, F3_USERBLOCK_SIZE);
- CHECK(ret,FAIL,"H5Cset_userblock");
+ ret = H5Cset_userblock(tmpl2, F3_USERBLOCK_SIZE);
+ CHECK(ret, FAIL, "H5Cset_userblock");
/*
* Try to create second file, with non-standard file-creation template
* params
*/
- fid3=H5Fcreate(FILE3,H5ACC_OVERWRITE,tmpl2,0);
- CHECK(fid3,FAIL,"H5Fcreate");
+ fid3 = H5Fcreate(FILE3, H5ACC_OVERWRITE, tmpl2, 0);
+ CHECK(fid3, FAIL, "H5Fcreate");
/* Release file-creation template */
- ret=H5Mclose(tmpl2);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl2);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid3);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid3);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F3_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F3_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F3_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F3_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F3_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F3_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F3_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F3_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F3_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
/* Close second file */
- ret=H5Fclose(fid2);
- CHECK(ret,FAIL,"H5Fclose");
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
/* Close third file */
- ret=H5Fclose(fid3);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_file_create() */
-
+ ret = H5Fclose(fid3);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_file_create() */
/****************************************************************
**
** test_file_open(): Low-level file open I/O test routine.
**
****************************************************************/
-static void test_file_open(void)
+static void
+test_file_open(void)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t tmpl1; /* File creation templates */
- size_t parm; /* File-creation parameters */
- size_t parm2; /* File-creation parameters */
- int iparm, iparm2;
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t tmpl1; /* File creation templates */
+ size_t parm; /* File-creation parameters */
+ size_t parm2; /* File-creation parameters */
+ int iparm, iparm2;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File Opening I/O\n"));
/* Open first file */
- fid1=H5Fopen(FILE2,H5ACC_WRITE,0);
- CHECK(fid1,FAIL,"H5Fopen");
+ fid1 = H5Fopen(FILE2, H5ACC_WRITE, 0);
+ CHECK(fid1, FAIL, "H5Fopen");
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid1);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid1);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY(parm,F2_OFFSET_SIZE,"H5Cget_sizes");
- VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
- /* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_file_open() */
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+ /* Close first file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_file_open() */
/****************************************************************
**
** test_file(): Main low-level file I/O test routine.
**
****************************************************************/
-void test_file(void)
+void
+test_file(void)
{
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File I/O\n"));
- test_file_create(); /* Test file creation (also creation templates) */
- test_file_open(); /* Test file opening */
-} /* test_file() */
-
+ test_file_create(); /* Test file creation (also creation templates) */
+ test_file_open(); /* Test file opening */
+} /* test_file() */
diff --git a/test/th5p.c b/test/th5p.c
index eb8528b..78ec4a9 100644
--- a/test/th5p.c
+++ b/test/th5p.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "$Revision$";
+static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
@@ -53,82 +53,83 @@ static char RcsId[] = "$Revision$";
** test_h5p_basic(): Test basic H5P (dataspace) code.
**
****************************************************************/
-static void test_h5p_basic(void)
+static void
+test_h5p_basic(void)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t sid1,sid2; /* Dataspace ID */
- uint32 rank; /* Logical rank of dataspace */
- size_t dims1[]={SPACE1_DIM1,SPACE1_DIM2,SPACE1_DIM3}, /* dataspace dim sizes */
- dims2[]={SPACE2_DIM1,SPACE2_DIM2,SPACE2_DIM3,SPACE2_DIM4},
- tdims[4]; /* Dimension array to test with */
- uintn n; /* number of dataspace elements */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t sid1, sid2; /* Dataspace ID */
+ uint32 rank; /* Logical rank of dataspace */
+ size_t dims1[] =
+ {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}, /* dataspace dim sizes */
+ dims2[] =
+ {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */
+ uintn n; /* number of dataspace elements */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Datatype Manipulation\n"));
/* Create file */
- fid1=H5Fcreate(FILE,H5ACC_OVERWRITE,0,0);
- CHECK(fid1,FAIL,"H5Fcreate");
-
- sid1=H5Pcreate (H5P_SIMPLE);
- CHECK(sid1,FAIL,"H5Mcreate");
-
- ret=H5Pset_space(sid1,SPACE1_RANK,dims1);
- CHECK(ret,FAIL,"H5Pset_space");
-
- n=H5Pget_npoints(sid1);
- CHECK(n,UFAIL,"H5Pnelem");
- VERIFY(n,SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3,"H5Pnelem");
-
- rank=H5Pget_ndims(sid1);
- CHECK(rank,UFAIL,"H5Pget_lrank");
- VERIFY(rank,SPACE1_RANK,"H5Pget_lrank");
-
- ret=H5Pget_dims(sid1,tdims);
- CHECK(ret,FAIL,"H5Pget_ldims");
- VERIFY(HDmemcmp(tdims,dims1,SPACE1_RANK*sizeof(uint32)),0,"H5Pget_ldims");
-
- sid2=H5Pcreate(H5P_SIMPLE);
- CHECK(sid2,FAIL,"H5Mcreate");
-
- ret=H5Pset_space(sid2,SPACE2_RANK,dims2);
- CHECK(ret,FAIL,"H5Pset_space");
-
- n=H5Pget_npoints(sid2);
- CHECK(n,UFAIL,"H5Pnelem");
- VERIFY(n,SPACE2_DIM1*SPACE2_DIM2*SPACE2_DIM3*SPACE2_DIM4,"H5Pnelem");
-
- rank=H5Pget_ndims(sid2);
- CHECK(rank,UFAIL,"H5Pget_lrank");
- VERIFY(rank,SPACE2_RANK,"H5Pget_lrank");
-
- ret=H5Pget_dims(sid2,tdims);
- CHECK(ret,FAIL,"H5Pget_ldims");
- VERIFY(HDmemcmp(tdims,dims2,SPACE2_RANK*sizeof(uint32)),0,"H5Pget_ldims");
-
- ret=H5Mclose(sid1);
- CHECK(ret,FAIL,"H5Mrelease");
-
- ret=H5Mclose(sid2);
- CHECK(ret,FAIL,"H5Mrelease");
-
- /* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_h5p_basic() */
+ fid1 = H5Fcreate(FILE, H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ sid1 = H5Pcreate(H5P_SIMPLE);
+ CHECK(sid1, FAIL, "H5Mcreate");
+
+ ret = H5Pset_space(sid1, SPACE1_RANK, dims1);
+ CHECK(ret, FAIL, "H5Pset_space");
+
+ n = H5Pget_npoints(sid1);
+ CHECK(n, UFAIL, "H5Pnelem");
+ VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Pnelem");
+
+ rank = H5Pget_ndims(sid1);
+ CHECK(rank, UFAIL, "H5Pget_lrank");
+ VERIFY(rank, SPACE1_RANK, "H5Pget_lrank");
+
+ ret = H5Pget_dims(sid1, tdims);
+ CHECK(ret, FAIL, "H5Pget_ldims");
+ VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(uint32)), 0, "H5Pget_ldims");
+
+ sid2 = H5Pcreate(H5P_SIMPLE);
+ CHECK(sid2, FAIL, "H5Mcreate");
+
+ ret = H5Pset_space(sid2, SPACE2_RANK, dims2);
+ CHECK(ret, FAIL, "H5Pset_space");
+ n = H5Pget_npoints(sid2);
+ CHECK(n, UFAIL, "H5Pnelem");
+ VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "H5Pnelem");
+
+ rank = H5Pget_ndims(sid2);
+ CHECK(rank, UFAIL, "H5Pget_lrank");
+ VERIFY(rank, SPACE2_RANK, "H5Pget_lrank");
+
+ ret = H5Pget_dims(sid2, tdims);
+ CHECK(ret, FAIL, "H5Pget_ldims");
+ VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(uint32)), 0, "H5Pget_ldims");
+
+ ret = H5Mclose(sid1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
+ ret = H5Mclose(sid2);
+ CHECK(ret, FAIL, "H5Mrelease");
+
+ /* Close first file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_h5p_basic() */
/****************************************************************
**
** test_h5p(): Main H5P (dataspace) testing routine.
**
****************************************************************/
-void test_h5p(void)
+void
+test_h5p(void)
{
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataspaces\n"));
- test_h5p_basic(); /* Test basic H5P code */
-} /* test_h5p() */
-
+ test_h5p_basic(); /* Test basic H5P code */
+} /* test_h5p() */
diff --git a/test/theap.c b/test/theap.c
index 5a5bb72..fc9e391 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: theap.c
- * Jul 17 1997
- * Robb Matzke <robb@maya.nuance.com>
+ * Created: theap.c
+ * Jul 17 1997
+ * Robb Matzke <robb@maya.nuance.com>
*
- * Purpose:
+ * Purpose:
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,68 +21,68 @@
#include <H5Fprivate.h>
#include <H5Hprivate.h>
-#define NOBJS 40
-
+#define NOBJS 40
/*-------------------------------------------------------------------------
- * Function: test_heap
+ * Function: test_heap
*
- * Purpose: Test name and object heaps.
+ * Purpose: Test name and object heaps.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * robb@maya.nuance.com
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
-test_heap (void)
+test_heap(void)
{
- int i, j;
- hid_t fid;
- H5F_t *f;
- haddr_t heap_addr;
- char buf[NOBJS+8];
- const char *s;
- size_t obj[NOBJS];
- herr_t status;
-
- MESSAGE (5, ("Testing Heaps\n"));
+ int i, j;
+ hid_t fid;
+ H5F_t *f;
+ haddr_t heap_addr;
+ char buf[NOBJS + 8];
+ const char *s;
+ size_t obj[NOBJS];
+ herr_t status;
- /* Create the file */
- fid = H5Fcreate ("theap.h5", H5ACC_OVERWRITE, 0, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
+ MESSAGE(5, ("Testing Heaps\n"));
- /* Create a new heap */
- status = H5H_create (f, H5H_LOCAL, 0, &heap_addr/*out*/);
- CHECK_I (status, "H5H_new");
+ /* Create the file */
+ fid = H5Fcreate("theap.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
- /* Add stuff to the heap */
- for (i=0; i<NOBJS; i++) {
- sprintf (buf, "%03d-", i);
- for (j=4; j<i; j++) buf[j] = '0' + j%10;
- if (j>4) buf[j] = '\0';
+ /* Create a new heap */
+ status = H5H_create(f, H5H_LOCAL, 0, &heap_addr /*out */ );
+ CHECK_I(status, "H5H_new");
- obj[i] = H5H_insert (f, &heap_addr, strlen(buf)+1, buf);
- CHECK_I (obj[i], "H5H_insert");
- }
+ /* Add stuff to the heap */
+ for (i = 0; i < NOBJS; i++) {
+ sprintf(buf, "%03d-", i);
+ for (j = 4; j < i; j++)
+ buf[j] = '0' + j % 10;
+ if (j > 4)
+ buf[j] = '\0';
- /* Flush the cache and invalidate everything */
- H5AC_flush (f, NULL, 0, TRUE);
+ obj[i] = H5H_insert(f, &heap_addr, strlen(buf) + 1, buf);
+ CHECK_I(obj[i], "H5H_insert");
+ }
- /* Read the objects back out */
- for (i=0; i<NOBJS; i++) {
- s = H5H_peek (f, &heap_addr, obj[i]);
- MESSAGE (8, ("object is `%s'\n", s));
- }
+ /* Flush the cache and invalidate everything */
+ H5AC_flush(f, NULL, 0, TRUE);
- /* Close the file */
- H5Fclose (fid);
-}
+ /* Read the objects back out */
+ for (i = 0; i < NOBJS; i++) {
+ s = H5H_peek(f, &heap_addr, obj[i]);
+ MESSAGE(8, ("object is `%s'\n", s));
+ }
+ /* Close the file */
+ H5Fclose(fid);
+}
diff --git a/test/tmeta.c b/test/tmeta.c
index 014a09a..ec9269b 100644
--- a/test/tmeta.c
+++ b/test/tmeta.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "$Revision$";
+static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
@@ -34,98 +34,91 @@ static char RcsId[] = "$Revision$";
#define TEST_INT32_VALUE -981236
#define TEST_UINT32_VALUE 3476589
-uint8 compar_buffer[]={
+uint8 compar_buffer[] =
+{
/* Little-endian encoded version of the 16-bit signed integer */
- (uint8)((TEST_INT16_VALUE)&0xff), (uint8)((TEST_INT16_VALUE>>8)&0xff),
+ (uint8) ((TEST_INT16_VALUE) & 0xff), (uint8) ((TEST_INT16_VALUE >> 8) & 0xff),
/* Little-endian encoded version of the 16-bit unsigned integer */
- (uint8)((TEST_UINT16_VALUE)&0xff), (uint8)((TEST_UINT16_VALUE>>8)&0xff),
+ (uint8) ((TEST_UINT16_VALUE) & 0xff), (uint8) ((TEST_UINT16_VALUE >> 8) & 0xff),
/* Little-endian encoded version of the 32-bit signed integer */
- (uint8)((TEST_INT32_VALUE)&0xff), (uint8)((TEST_INT32_VALUE>>8)&0xff),
- (uint8)((TEST_INT32_VALUE>>16)&0xff), (uint8)((TEST_INT32_VALUE>>24)&0xff),
+ (uint8) ((TEST_INT32_VALUE) & 0xff), (uint8) ((TEST_INT32_VALUE >> 8) & 0xff),
+ (uint8) ((TEST_INT32_VALUE >> 16) & 0xff), (uint8) ((TEST_INT32_VALUE >> 24) & 0xff),
/* Little-endian encoded version of the 32-bit unsigned integer */
- (uint8)((TEST_UINT32_VALUE)&0xff), (uint8)((TEST_UINT32_VALUE>>8)&0xff),
- (uint8)((TEST_UINT32_VALUE>>16)&0xff), (uint8)((TEST_UINT32_VALUE>>24)&0xff),
- };
+ (uint8) ((TEST_UINT32_VALUE) & 0xff), (uint8) ((TEST_UINT32_VALUE >> 8) & 0xff),
+ (uint8) ((TEST_UINT32_VALUE >> 16) & 0xff), (uint8) ((TEST_UINT32_VALUE >> 24) & 0xff),
+};
-uint8 encode_buffer[sizeof(compar_buffer)];
+uint8 encode_buffer[sizeof(compar_buffer)];
/****************************************************************
**
** test_metadata(): Main meta-data encode/decode testing routine.
**
****************************************************************/
-void test_metadata(void)
+void
+test_metadata(void)
{
- int16 ei16=TEST_INT16_VALUE; /* variables to hold the values to encode */
- uint16 eu16=TEST_UINT16_VALUE;
- int32 ei32=TEST_INT32_VALUE;
- uint32 eu32=TEST_UINT32_VALUE;
- int16 di16; /* variables to hold the decoded values */
- uint16 du16;
- int32 di32;
- uint32 du32;
- uint8 *p; /* pointer into the buffer being en/de-coded */
+ int16 ei16 = TEST_INT16_VALUE; /* variables to hold the values to encode */
+ uint16 eu16 = TEST_UINT16_VALUE;
+ int32 ei32 = TEST_INT32_VALUE;
+ uint32 eu32 = TEST_UINT32_VALUE;
+ int16 di16; /* variables to hold the decoded values */
+ uint16 du16;
+ int32 di32;
+ uint32 du32;
+ uint8 *p; /* pointer into the buffer being en/de-coded */
/* Output message about test being performed */
MESSAGE(5, ("Testing Metadata encode/decode code\n"));
/* Start by encoding the values above */
- p=encode_buffer;
- INT16ENCODE(p,ei16); /* Encode the int16 value */
- UINT16ENCODE(p,eu16); /* Encode the uint16 value */
- INT32ENCODE(p,ei32); /* Encode the int32 value */
- UINT32ENCODE(p,eu32); /* Encode the uint32 value */
+ p = encode_buffer;
+ INT16ENCODE(p, ei16); /* Encode the int16 value */
+ UINT16ENCODE(p, eu16); /* Encode the uint16 value */
+ INT32ENCODE(p, ei32); /* Encode the int32 value */
+ UINT32ENCODE(p, eu32); /* Encode the uint32 value */
/* Check if we got what we asked for */
- if(HDmemcmp(encode_buffer,compar_buffer,sizeof(compar_buffer))!=0)
- {
- uintn u; /* local counting variable */
+ if (HDmemcmp(encode_buffer, compar_buffer, sizeof(compar_buffer)) != 0) {
+ uintn u; /* local counting variable */
- for(u=0; u<sizeof(compar_buffer); u++)
- {
- if(compar_buffer[u]!=encode_buffer[u])
- {
- print_func("Error encoding meta-data at offset %u, wanted: %u, got: %u\n",(unsigned)u,(unsigned)compar_buffer[u],(unsigned)encode_buffer[u]);
+ for (u = 0; u < sizeof(compar_buffer); u++) {
+ if (compar_buffer[u] != encode_buffer[u]) {
+ print_func("Error encoding meta-data at offset %u, wanted: %u, got: %u\n", (unsigned) u, (unsigned) compar_buffer[u], (unsigned) encode_buffer[u]);
num_errs++;
- } /* end if */
- } /* end for */
- } /* end if */
-
+ } /* end if */
+ } /* end for */
+ } /* end if */
/* Test decoding macros */
- p=encode_buffer;
- INT16DECODE(p,di16); /* Decode the int16 value */
- UINT16DECODE(p,du16); /* Decode the uint16 value */
- INT32DECODE(p,di32); /* Decode the int32 value */
- UINT32DECODE(p,du32); /* Decode the uint32 value */
+ p = encode_buffer;
+ INT16DECODE(p, di16); /* Decode the int16 value */
+ UINT16DECODE(p, du16); /* Decode the uint16 value */
+ INT32DECODE(p, di32); /* Decode the int32 value */
+ UINT32DECODE(p, du32); /* Decode the uint32 value */
/* Check the values decoded */
- if(di16!=TEST_INT16_VALUE)
- {
- print_func ("Error decoding int16 meta-data wanted: %d, got: %d "
- "at %s:%d\n", __FILE__, __LINE__, (int)TEST_INT16_VALUE,
- (int)di16);
+ if (di16 != TEST_INT16_VALUE) {
+ print_func("Error decoding int16 meta-data wanted: %d, got: %d "
+ "at %s:%d\n", __FILE__, __LINE__, (int) TEST_INT16_VALUE,
+ (int) di16);
num_errs++;
- } /* end if */
- if(du16!=TEST_UINT16_VALUE)
- {
- print_func ("Error decoding uint16 meta-data wanted: %u, got: %u "
- "at %s:%d\n", __FILE__, __LINE__,
- (unsigned)TEST_UINT16_VALUE, (unsigned)du16);
+ } /* end if */
+ if (du16 != TEST_UINT16_VALUE) {
+ print_func("Error decoding uint16 meta-data wanted: %u, got: %u "
+ "at %s:%d\n", __FILE__, __LINE__,
+ (unsigned) TEST_UINT16_VALUE, (unsigned) du16);
num_errs++;
- } /* end if */
- if(di32!=TEST_INT32_VALUE)
- {
- print_func ("Error decoding int32 meta-data wanted: %ld, got: %ld "
- "at %s:%d\n", __FILE__, __LINE__, (long)TEST_INT32_VALUE,
- (long)di32);
+ } /* end if */
+ if (di32 != TEST_INT32_VALUE) {
+ print_func("Error decoding int32 meta-data wanted: %ld, got: %ld "
+ "at %s:%d\n", __FILE__, __LINE__, (long) TEST_INT32_VALUE,
+ (long) di32);
num_errs++;
- } /* end if */
- if(du32!=TEST_UINT32_VALUE)
- {
- print_func ("Error decoding uint32 meta-data wanted: %lu, got: %lu "
- "at %s:%d\n", __FILE__, __LINE__,
- (unsigned long)TEST_UINT32_VALUE, (unsigned long)du32);
+ } /* end if */
+ if (du32 != TEST_UINT32_VALUE) {
+ print_func("Error decoding uint32 meta-data wanted: %lu, got: %lu "
+ "at %s:%d\n", __FILE__, __LINE__,
+ (unsigned long) TEST_UINT32_VALUE, (unsigned long) du32);
num_errs++;
- } /* end if */
-} /* test_metadata() */
-
+ } /* end if */
+} /* test_metadata() */
diff --git a/test/tohdr.c b/test/tohdr.c
index dd65eff..161ebaa 100644
--- a/test/tohdr.c
+++ b/test/tohdr.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: tohdr.c
- * Aug 6 1997
- * Robb Matzke <robb@maya.nuance.com>
+ * Created: tohdr.c
+ * Aug 6 1997
+ * Robb Matzke <robb@maya.nuance.com>
*
- * Purpose:
+ * Purpose:
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -27,145 +27,144 @@
*/
#define H5G_PACKAGE
#include <H5Gpkg.h>
-
/*-------------------------------------------------------------------------
- * Function: test_ohdr
+ * Function: test_ohdr
*
- * Purpose: Test object headers.
+ * Purpose: Test object headers.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * robb@maya.nuance.com
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
-test_ohdr (void)
+test_ohdr(void)
{
- hid_t fid;
- H5F_t *f;
- H5G_entry_t oh_ent;
- H5O_stab_t stab, ro;
- herr_t status;
- void *ptr;
- int i;
-
- MESSAGE (5, ("Testing Object Headers\n"));
-
- /* create the file */
- fid = H5Fcreate ("tohdr.h5", H5ACC_OVERWRITE, 0, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
-
- /* the new object header */
- MESSAGE (8, ("Creating new object header...\n"));
- status = H5O_create (f, 64, &oh_ent/*out*/);
- CHECK_I (status, "H5O_new");
-
- /*
- * Test creation of a new message.
- */
- MESSAGE (8, ("Creating new message...\n"));
- stab.btree_addr.offset = 11111111;
- stab.heap_addr.offset = 22222222;
- status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
- VERIFY (status, 0, "H5O_modify");
-
- H5AC_flush (f, NULL, 0, TRUE);
- ptr = H5O_read (&oh_ent, H5O_STAB, 0, &ro);
- CHECK_PTR (ptr, "H5O_read");
- VERIFY (ptr, &ro, "H5O_read");
- VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
- VERIFY (ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
-
- /*
- * Test modification of an existing message.
- */
- MESSAGE (8, ("Modifying message...\n"));
- stab.btree_addr.offset = 33333333;
- stab.heap_addr.offset = 44444444;
- status = H5O_modify (&oh_ent, H5O_STAB, 0, 0, &stab);
- VERIFY (status, 0, "H5O_modify");
-
- H5AC_flush (f, NULL, 0, TRUE);
- ptr = H5O_read (&oh_ent, H5O_STAB, 0, &ro);
- CHECK_PTR (ptr, "H5O_read");
- VERIFY (ptr, &ro, "H5O_read");
- VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
- VERIFY (ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
-
- /*
- * Test creation of a second message of the same type with a symbol
- * table.
- */
- MESSAGE (8, ("Creating a duplicate message...\n"));
- stab.btree_addr.offset = 55555555;
- stab.heap_addr.offset = 66666666;
- status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
- VERIFY (status, 1, "H5O_modify");
-
- H5AC_flush (f, NULL, 0, TRUE);
- ptr = H5O_read (&oh_ent, H5O_STAB, 1, &ro);
- CHECK_PTR (ptr, "H5O_read");
- VERIFY (ptr, &ro, "H5O_read");
- VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
- VERIFY (ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
-
- /*
- * Test modification of the second message with a symbol table.
- */
- MESSAGE (8, ("Modifying the duplicate message...\n"));
- stab.btree_addr.offset = 77777777;
- stab.heap_addr.offset = 88888888;
- status = H5O_modify (&oh_ent, H5O_STAB, 1, 0, &stab);
- VERIFY (status, 1, "H5O_modify");
-
- H5AC_flush (f, NULL, 0, TRUE);
- ptr = H5O_read (&oh_ent, H5O_STAB, 1, &ro);
- CHECK_PTR (ptr, "H5O_read");
- VERIFY (ptr, &ro, "H5O_read");
- VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
- VERIFY (ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
-
- /*
- * Test creation of a bunch of messages one after another to see
- * what happens when the object header overflows in core.
- */
- MESSAGE (8, ("Overflowing header in core...\n"));
- for (i=0; i<40; i++) {
- stab.btree_addr.offset = (i+1)*1000 + 1;
- stab.heap_addr.offset = (i+1)*1000 + 2;
- status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
- VERIFY (status, 2+i, "H5O_modify");
- }
- H5AC_flush (f, NULL, 0, TRUE);
-
- /*
- * Test creation of a bunch of messages one after another to see
- * what happens when the object header overflows on disk.
- */
- MESSAGE (8, ("Overflowing header on disk...\n"));
- for (i=0; i<10; i++) {
- stab.btree_addr.offset = (i+1)*1000 + 10;
- stab.heap_addr.offset = (i+1)*1000 + 20;
- status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
- VERIFY (status, 42+i, "H5O_modify");
- H5AC_flush (f, NULL, 0, TRUE);
- }
-
- /*
- * Delete all symbol table messages.
- */
- status = H5O_remove (&oh_ent, H5O_STAB, H5O_ALL);
- CHECK_I (status, "H5O_remove");
-
- /* release resources */
- H5O_close (&oh_ent);
- H5Fclose (fid);
+ hid_t fid;
+ H5F_t *f;
+ H5G_entry_t oh_ent;
+ H5O_stab_t stab, ro;
+ herr_t status;
+ void *ptr;
+ int i;
+
+ MESSAGE(5, ("Testing Object Headers\n"));
+
+ /* create the file */
+ fid = H5Fcreate("tohdr.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
+
+ /* the new object header */
+ MESSAGE(8, ("Creating new object header...\n"));
+ status = H5O_create(f, 64, &oh_ent /*out */ );
+ CHECK_I(status, "H5O_new");
+
+ /*
+ * Test creation of a new message.
+ */
+ MESSAGE(8, ("Creating new message...\n"));
+ stab.btree_addr.offset = 11111111;
+ stab.heap_addr.offset = 22222222;
+ status = H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
+ VERIFY(status, 0, "H5O_modify");
+
+ H5AC_flush(f, NULL, 0, TRUE);
+ ptr = H5O_read(&oh_ent, H5O_STAB, 0, &ro);
+ CHECK_PTR(ptr, "H5O_read");
+ VERIFY(ptr, &ro, "H5O_read");
+ VERIFY(ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
+ VERIFY(ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
+
+ /*
+ * Test modification of an existing message.
+ */
+ MESSAGE(8, ("Modifying message...\n"));
+ stab.btree_addr.offset = 33333333;
+ stab.heap_addr.offset = 44444444;
+ status = H5O_modify(&oh_ent, H5O_STAB, 0, 0, &stab);
+ VERIFY(status, 0, "H5O_modify");
+
+ H5AC_flush(f, NULL, 0, TRUE);
+ ptr = H5O_read(&oh_ent, H5O_STAB, 0, &ro);
+ CHECK_PTR(ptr, "H5O_read");
+ VERIFY(ptr, &ro, "H5O_read");
+ VERIFY(ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
+ VERIFY(ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
+
+ /*
+ * Test creation of a second message of the same type with a symbol
+ * table.
+ */
+ MESSAGE(8, ("Creating a duplicate message...\n"));
+ stab.btree_addr.offset = 55555555;
+ stab.heap_addr.offset = 66666666;
+ status = H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
+ VERIFY(status, 1, "H5O_modify");
+
+ H5AC_flush(f, NULL, 0, TRUE);
+ ptr = H5O_read(&oh_ent, H5O_STAB, 1, &ro);
+ CHECK_PTR(ptr, "H5O_read");
+ VERIFY(ptr, &ro, "H5O_read");
+ VERIFY(ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
+ VERIFY(ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
+
+ /*
+ * Test modification of the second message with a symbol table.
+ */
+ MESSAGE(8, ("Modifying the duplicate message...\n"));
+ stab.btree_addr.offset = 77777777;
+ stab.heap_addr.offset = 88888888;
+ status = H5O_modify(&oh_ent, H5O_STAB, 1, 0, &stab);
+ VERIFY(status, 1, "H5O_modify");
+
+ H5AC_flush(f, NULL, 0, TRUE);
+ ptr = H5O_read(&oh_ent, H5O_STAB, 1, &ro);
+ CHECK_PTR(ptr, "H5O_read");
+ VERIFY(ptr, &ro, "H5O_read");
+ VERIFY(ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
+ VERIFY(ro.heap_addr.offset, stab.heap_addr.offset, "H5O_read");
+
+ /*
+ * Test creation of a bunch of messages one after another to see
+ * what happens when the object header overflows in core.
+ */
+ MESSAGE(8, ("Overflowing header in core...\n"));
+ for (i = 0; i < 40; i++) {
+ stab.btree_addr.offset = (i + 1) * 1000 + 1;
+ stab.heap_addr.offset = (i + 1) * 1000 + 2;
+ status = H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
+ VERIFY(status, 2 + i, "H5O_modify");
+ }
+ H5AC_flush(f, NULL, 0, TRUE);
+
+ /*
+ * Test creation of a bunch of messages one after another to see
+ * what happens when the object header overflows on disk.
+ */
+ MESSAGE(8, ("Overflowing header on disk...\n"));
+ for (i = 0; i < 10; i++) {
+ stab.btree_addr.offset = (i + 1) * 1000 + 10;
+ stab.heap_addr.offset = (i + 1) * 1000 + 20;
+ status = H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
+ VERIFY(status, 42 + i, "H5O_modify");
+ H5AC_flush(f, NULL, 0, TRUE);
+ }
+
+ /*
+ * Delete all symbol table messages.
+ */
+ status = H5O_remove(&oh_ent, H5O_STAB, H5O_ALL);
+ CHECK_I(status, "H5O_remove");
+
+ /* release resources */
+ H5O_close(&oh_ent);
+ H5Fclose(fid);
}
diff --git a/test/tstab.c b/test/tstab.c
index f16d8f5..8ad20cc 100644
--- a/test/tstab.c
+++ b/test/tstab.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: tstab.c
- * Aug 7 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: tstab.c
+ * Aug 7 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose:
+ * Purpose:
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +19,7 @@
#include <H5private.h>
#include <H5ACprivate.h>
#include <H5Cprivate.h>
-#include <H5Fprivate.h>
+#include <H5Fprivate.h>
#include <H5Gprivate.h>
#include <H5Oprivate.h>
@@ -28,274 +28,265 @@
*/
#define H5G_PACKAGE
#include <H5Gpkg.h>
-
/*-------------------------------------------------------------------------
- * Function: test_1
+ * Function: test_1
*
- * Purpose: Tests the non-directory features of the HDF5 file. If the
- * file has just one non-directory object, then that object
- * should be the root object and there is no directory.
+ * Purpose: Tests the non-directory features of the HDF5 file. If the
+ * file has just one non-directory object, then that object
+ * should be the root object and there is no directory.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * robb@maya.nuance.com
- * Aug 29 1997
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Aug 29 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-test_1 (void)
+test_1(void)
{
- hid_t fid;
- H5F_t *f;
- H5G_entry_t ent1, ent2, obj_ent, dir_ent;
- herr_t status;
- H5O_name_t name_mesg;
- void *status_ptr;
- hbool_t b;
-
- MESSAGE (2, ("........non-directory files\n"));
+ hid_t fid;
+ H5F_t *f;
+ H5G_entry_t ent1, ent2, obj_ent, dir_ent;
+ herr_t status;
+ H5O_name_t name_mesg;
+ void *status_ptr;
+ hbool_t b;
- /*
- * Test 1A: Create an empty file and add a non-directory object
- * to the file with the name `/'. The object should become the
- * root object and should not have a name message.
- */
+ MESSAGE(2, ("........non-directory files\n"));
- /* create the file */
- fid = H5Fcreate ("tstab1.h5", H5ACC_OVERWRITE, 0, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
+ /*
+ * Test 1A: Create an empty file and add a non-directory object
+ * to the file with the name `/'. The object should become the
+ * root object and should not have a name message.
+ */
- /* create the object */
- status = H5O_create (f, 0, &ent1);
- CHECK_I (status, "H5O_create");
- status = H5G_insert ("/", &ent1);
- CHECK_I (status, "H5G_insert");
- status = H5O_close (&ent1);
- CHECK_I (status, "H5O_close");
+ /* create the file */
+ fid = H5Fcreate("tstab1.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
- /* look for a name message -- it shouldn't be present */
- status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
- VERIFY (status_ptr, NULL, "H5O_read [didn't fail but should have]");
-
- /*
- * Test 1B: Attempt to read the root object using the name `/'.
- */
- memset (&dir_ent, 0xff, sizeof(H5G_entry_t));
- memset (&obj_ent, 0xff, sizeof(H5G_entry_t));
- status = H5G_find (f, "/", &dir_ent, &obj_ent);
- CHECK_I (status, "H5G_find");
+ /* create the object */
+ status = H5O_create(f, 0, &ent1);
+ CHECK_I(status, "H5O_create");
+ status = H5G_insert("/", &ent1);
+ CHECK_I(status, "H5G_insert");
+ status = H5O_close(&ent1);
+ CHECK_I(status, "H5O_close");
- /* Is it really the root object? */
- b = H5F_addr_defined (&(dir_ent.header));
- VERIFY (b, FALSE, "H5G_insert");
- b = H5F_addr_eq (&(obj_ent.header), &(ent1.header));
- VERIFY (b, TRUE, "H5G_insert");
+ /* look for a name message -- it shouldn't be present */
+ status_ptr = H5O_read(&ent1, H5O_NAME, 0, &name_mesg);
+ VERIFY(status_ptr, NULL, "H5O_read [didn't fail but should have]");
-
- /*
- * Test 1C: Add a second object to the file to see if the first object
- * gets moved into the new root directory along with the second object.
- */
+ /*
+ * Test 1B: Attempt to read the root object using the name `/'.
+ */
+ memset(&dir_ent, 0xff, sizeof(H5G_entry_t));
+ memset(&obj_ent, 0xff, sizeof(H5G_entry_t));
+ status = H5G_find(f, "/", &dir_ent, &obj_ent);
+ CHECK_I(status, "H5G_find");
- /* create the object */
- status = H5O_create (f, 0, &ent2);
- CHECK_I (status, "H5O_create");
- status = H5G_insert ("/second", &ent2);
- CHECK_I (status, "H5G_insert");
- status = H5O_close (&ent2);
- CHECK_I (status, "H5O_close");
+ /* Is it really the root object? */
+ b = H5F_addr_defined(&(dir_ent.header));
+ VERIFY(b, FALSE, "H5G_insert");
+ b = H5F_addr_eq(&(obj_ent.header), &(ent1.header));
+ VERIFY(b, TRUE, "H5G_insert");
- /* try to read the first object */
- HDmemset (&obj_ent, 0xff, sizeof(H5G_entry_t));
- status = H5G_find (f, "/Root Object", NULL, &obj_ent);
- CHECK_I (status, "H5G_find");
- b = H5F_addr_defined (&(obj_ent.header));
- VERIFY (b, TRUE, "H5G_insert");
- b = H5F_addr_eq (&(obj_ent.header), &(ent1.header));
- VERIFY (b, TRUE, "H5G_create");
+ /*
+ * Test 1C: Add a second object to the file to see if the first object
+ * gets moved into the new root directory along with the second object.
+ */
- /* close the file */
- H5Fclose (fid);
+ /* create the object */
+ status = H5O_create(f, 0, &ent2);
+ CHECK_I(status, "H5O_create");
+ status = H5G_insert("/second", &ent2);
+ CHECK_I(status, "H5G_insert");
+ status = H5O_close(&ent2);
+ CHECK_I(status, "H5O_close");
-
-
- /*
- * Test 1D: Create an empty file and add a non-directory object
- * to the file with the name `/foo'. The object should become the
- * root object and should have a name message with the value `foo'.
- */
+ /* try to read the first object */
+ HDmemset(&obj_ent, 0xff, sizeof(H5G_entry_t));
+ status = H5G_find(f, "/Root Object", NULL, &obj_ent);
+ CHECK_I(status, "H5G_find");
+ b = H5F_addr_defined(&(obj_ent.header));
+ VERIFY(b, TRUE, "H5G_insert");
+ b = H5F_addr_eq(&(obj_ent.header), &(ent1.header));
+ VERIFY(b, TRUE, "H5G_create");
- /* create the file */
- fid = H5Fcreate ("tstab1.h5", H5ACC_OVERWRITE, 0, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
+ /* close the file */
+ H5Fclose(fid);
- /* create the object */
- status = H5O_create (f, 0, &ent1);
- CHECK_I (status, "H5O_create");
- status = H5G_insert ("/foo", &ent1);
- CHECK_I (status, "H5G_insert");
- status = H5O_close (&ent1);
- CHECK_I (status, "H5O_close");
+ /*
+ * Test 1D: Create an empty file and add a non-directory object
+ * to the file with the name `/foo'. The object should become the
+ * root object and should have a name message with the value `foo'.
+ */
- /* does it have the correct name message? */
- status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
- CHECK_PTR (status_ptr, "H5O_read");
- CHECK_PTR (name_mesg.s, "H5O_read");
- VERIFY (strcmp(name_mesg.s, "foo"), 0, "H5G_insert");
- if (status_ptr) H5O_reset (H5O_NAME, &name_mesg); /*free message data*/
+ /* create the file */
+ fid = H5Fcreate("tstab1.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
+ /* create the object */
+ status = H5O_create(f, 0, &ent1);
+ CHECK_I(status, "H5O_create");
+ status = H5G_insert("/foo", &ent1);
+ CHECK_I(status, "H5G_insert");
+ status = H5O_close(&ent1);
+ CHECK_I(status, "H5O_close");
- /*
- * Test 1E: Try to read the root object with the name `/' and `/foo'
- */
- HDmemset (&dir_ent, 0, sizeof(H5G_entry_t));
- HDmemset (&obj_ent, 0, sizeof(H5G_entry_t));
- status = H5G_find (f, "/", &dir_ent, &obj_ent);
- CHECK_I (status, "H5G_find");
- b = H5F_addr_defined (&(dir_ent.header));
- VERIFY (b, FALSE, "H5G_insert");
- b = H5F_addr_eq (&(obj_ent.header), &(ent1.header));
- VERIFY (b, TRUE, "H5G_insert");
+ /* does it have the correct name message? */
+ status_ptr = H5O_read(&ent1, H5O_NAME, 0, &name_mesg);
+ CHECK_PTR(status_ptr, "H5O_read");
+ CHECK_PTR(name_mesg.s, "H5O_read");
+ VERIFY(strcmp(name_mesg.s, "foo"), 0, "H5G_insert");
+ if (status_ptr)
+ H5O_reset(H5O_NAME, &name_mesg); /*free message data */
- /* now as `/foo' */
- HDmemset (&dir_ent, 0, sizeof(H5G_entry_t));
- HDmemset (&obj_ent, 0, sizeof(H5G_entry_t));
- status = H5G_find (f, "/foo", &dir_ent, &obj_ent);
- CHECK_I (status, "H5G_find");
- b = H5F_addr_defined (&(dir_ent.header));
- VERIFY (b, FALSE, "H5G_insert");
- b = H5F_addr_eq (&(obj_ent.header), &(ent1.header));
- VERIFY (b, TRUE, "H5G_insert");
+ /*
+ * Test 1E: Try to read the root object with the name `/' and `/foo'
+ */
+ HDmemset(&dir_ent, 0, sizeof(H5G_entry_t));
+ HDmemset(&obj_ent, 0, sizeof(H5G_entry_t));
+ status = H5G_find(f, "/", &dir_ent, &obj_ent);
+ CHECK_I(status, "H5G_find");
+ b = H5F_addr_defined(&(dir_ent.header));
+ VERIFY(b, FALSE, "H5G_insert");
+ b = H5F_addr_eq(&(obj_ent.header), &(ent1.header));
+ VERIFY(b, TRUE, "H5G_insert");
-
- /*
- * Test 1F: Create another object. This should create a root directory
- * and move the previous root object into that directory.
- */
+ /* now as `/foo' */
+ HDmemset(&dir_ent, 0, sizeof(H5G_entry_t));
+ HDmemset(&obj_ent, 0, sizeof(H5G_entry_t));
+ status = H5G_find(f, "/foo", &dir_ent, &obj_ent);
+ CHECK_I(status, "H5G_find");
+ b = H5F_addr_defined(&(dir_ent.header));
+ VERIFY(b, FALSE, "H5G_insert");
+ b = H5F_addr_eq(&(obj_ent.header), &(ent1.header));
+ VERIFY(b, TRUE, "H5G_insert");
- /* create the object */
- status = H5O_create (f, 0, &ent2);
- CHECK_I (status, "H5O_create");
- status = H5G_insert ("/second", &ent2);
- CHECK_I (status, "H5G_insert");
- status = H5O_close (&ent2);
- CHECK_I (status, "H5O_close");
+ /*
+ * Test 1F: Create another object. This should create a root directory
+ * and move the previous root object into that directory.
+ */
- /* try to read the first object */
- HDmemset (&obj_ent, 0, sizeof(H5G_entry_t));
- status = H5G_find (f, "/foo", NULL, &obj_ent);
- CHECK_I (status, "H5G_find");
- b = H5F_addr_eq (&(obj_ent.header), &(ent1.header));
- VERIFY (b, TRUE, "H5G_insert");
+ /* create the object */
+ status = H5O_create(f, 0, &ent2);
+ CHECK_I(status, "H5O_create");
+ status = H5G_insert("/second", &ent2);
+ CHECK_I(status, "H5G_insert");
+ status = H5O_close(&ent2);
+ CHECK_I(status, "H5O_close");
- /* the first object should not have a name message */
- status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
- VERIFY (status_ptr, NULL, "H5O_read [didn't fail but should have]");
+ /* try to read the first object */
+ HDmemset(&obj_ent, 0, sizeof(H5G_entry_t));
+ status = H5G_find(f, "/foo", NULL, &obj_ent);
+ CHECK_I(status, "H5G_find");
+ b = H5F_addr_eq(&(obj_ent.header), &(ent1.header));
+ VERIFY(b, TRUE, "H5G_insert");
- /* close the file */
- status = H5Fclose (fid);
- CHECK_I (status, "H5Fclose");
-}
+ /* the first object should not have a name message */
+ status_ptr = H5O_read(&ent1, H5O_NAME, 0, &name_mesg);
+ VERIFY(status_ptr, NULL, "H5O_read [didn't fail but should have]");
+ /* close the file */
+ status = H5Fclose(fid);
+ CHECK_I(status, "H5Fclose");
+}
/*-------------------------------------------------------------------------
- * Function: test_2
+ * Function: test_2
*
- * Purpose: Creates a really large directory.
+ * Purpose: Creates a really large directory.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * robb@maya.nuance.com
- * Aug 29 1997
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Aug 29 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-test_2 (void)
+test_2(void)
{
- hid_t fid, props, dir;
- H5F_t *f;
- int i;
- char name[256];
- herr_t status;
- int nsyms = 5000;
-
- MESSAGE (2, ("........large directories\n"));
+ hid_t fid, props, dir;
+ H5F_t *f;
+ int i;
+ char name[256];
+ herr_t status;
+ int nsyms = 5000;
- /*
- * Use larger symbol table data structures to be more efficient, use
- * defaults to bang harder on the library for testing.
- */
- props = H5Ccreate (H5C_FILE_CREATE);
+ MESSAGE(2, ("........large directories\n"));
+
+ /*
+ * Use larger symbol table data structures to be more efficient, use
+ * defaults to bang harder on the library for testing.
+ */
+ props = H5Ccreate(H5C_FILE_CREATE);
#if 1
- H5Cset_sym_k (props, 16, 16);
+ H5Cset_sym_k(props, 16, 16);
#endif
- /* create the file */
- fid = H5Fcreate ("tstab2.h5", H5ACC_OVERWRITE, props, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
- f->intent |= H5F_ACC_DEBUG;
+ /* create the file */
+ fid = H5Fcreate("tstab2.h5", H5ACC_OVERWRITE, props, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
+ f->intent |= H5F_ACC_DEBUG;
- /*
- * Create a directory that has so many entries that the root
- * of the B-tree ends up splitting.
- */
- dir = H5Gcreate (fid, "/big", nsyms*16+2);
- CHECK_I (dir, "H5Gcreate");
- status = H5Gclose (dir);
- CHECK_I (status, "H5Gclose");
- status = H5Gset (fid, "/big");
- CHECK_I (status, "H5Gset");
-
-
- for (i=0; i<nsyms; i++) {
- sprintf (name, "%05d%05d", rand()%100000, i);
- MESSAGE (8, ("%s\n", name));
- dir = H5Gcreate (fid, name, 0);
- CHECK_I (dir, "H5Gcreate");
- status = H5Gclose (dir);
- CHECK_I (status, "H5Gclose");
- }
-
- /* close the file */
- status = H5Fclose (fid);
- CHECK_I (status, "H5Fclose");
-}
+ /*
+ * Create a directory that has so many entries that the root
+ * of the B-tree ends up splitting.
+ */
+ dir = H5Gcreate(fid, "/big", nsyms * 16 + 2);
+ CHECK_I(dir, "H5Gcreate");
+ status = H5Gclose(dir);
+ CHECK_I(status, "H5Gclose");
+ status = H5Gset(fid, "/big");
+ CHECK_I(status, "H5Gset");
+ for (i = 0; i < nsyms; i++) {
+ sprintf(name, "%05d%05d", rand() % 100000, i);
+ MESSAGE(8, ("%s\n", name));
+ dir = H5Gcreate(fid, name, 0);
+ CHECK_I(dir, "H5Gcreate");
+ status = H5Gclose(dir);
+ CHECK_I(status, "H5Gclose");
+ }
+ /* close the file */
+ status = H5Fclose(fid);
+ CHECK_I(status, "H5Fclose");
+}
/*-------------------------------------------------------------------------
- * Function: test_stab
+ * Function: test_stab
*
- * Purpose: Test symbol tables
+ * Purpose: Test symbol tables
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@viper.llnl.gov
- * Aug 7 1997
+ * Programmer: Robb Matzke
+ * matzke@viper.llnl.gov
+ * Aug 7 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
-test_stab (void)
+test_stab(void)
{
- test_1();
- test_2();
+ test_1();
+ test_2();
}