diff options
Diffstat (limited to 'test/dsets.c')
-rw-r--r-- | test/dsets.c | 442 |
1 files changed, 155 insertions, 287 deletions
diff --git a/test/dsets.c b/test/dsets.c index d7e518b..be2b911 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -8,40 +8,13 @@ * Purpose: Tests the dataset interface (H5D) */ -/* See H5private.h for how to include files */ -#undef NDEBUG -#include <hdf5.h> - -#ifdef STDC_HEADERS -# include <assert.h> -# include <math.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -#endif - -#ifdef HAVE_UNISTD_H -# include <sys/types.h> -# include <unistd.h> -#endif - -#ifndef HAVE_ATTRIBUTE -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define __unused__ /*void*/ -#else -# define __unused__ __attribute__((unused)) -#endif - -#ifndef HAVE_FUNCTION -# undef __FUNCTION__ -# define __FUNCTION__ "" -#endif +#include <h5test.h> -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, __FUNCTION__); +const char *FILENAME[] = { + "dataset", + NULL +}; -#define TEST_FILE_NAME "dataset.h5" #define DSET_DEFAULT_NAME "default" #define DSET_CHUNKED_NAME "chunked" #define DSET_SIMPLE_IO_NAME "simple_io" @@ -53,31 +26,6 @@ /*------------------------------------------------------------------------- - * Function: display_error_cb - * - * Purpose: Displays the error stack after printing "*FAILED*". - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Wednesday, March 4, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -display_error_cb (void __unused__ *client_data) -{ - puts ("*FAILED*"); - H5Eprint (stdout); - return 0; -} - - -/*------------------------------------------------------------------------- * Function: test_create * * Purpose: Attempts to create a dataset. @@ -100,11 +48,8 @@ test_create(hid_t file) hsize_t dims[2]; herr_t status; hsize_t csize[2]; - herr_t (*func)(void*) = NULL; - void *client_data = NULL; - printf("%-70s", "Testing create/open/close"); - fflush (stdout); + TESTING("create, open, close"); /* Create the data space */ dims[0] = 256; @@ -132,14 +77,13 @@ test_create(hid_t file) * dataset can only be created once. Temporarily turn off error * reporting. */ - H5Eget_auto (&func, &client_data); - H5Eset_auto (NULL, NULL); - dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT); - H5Eset_auto (func, client_data); + H5E_BEGIN_TRY { + dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, + H5P_DEFAULT); + } H5E_END_TRY; if (dataset >= 0) { - puts("*FAILED*"); - printf(" Library allowed overwrite of existing dataset.\n"); + FAILED(); + puts(" Library allowed overwrite of existing dataset."); goto error; } @@ -155,13 +99,12 @@ test_create(hid_t file) * cannot be created with this function. Temporarily turn off error * reporting. */ - H5Eget_auto (&func, &client_data); - H5Eset_auto (NULL, NULL); - dataset = H5Dopen(file, "does_not_exist"); - H5Eset_auto (func, client_data); + H5E_BEGIN_TRY { + dataset = H5Dopen(file, "does_not_exist"); + } H5E_END_TRY; if (dataset >= 0) { - puts("*FAILED*"); - printf(" Opened a non-existent dataset.\n"); + FAILED(); + puts(" Opened a non-existent dataset."); goto error; } @@ -186,7 +129,7 @@ test_create(hid_t file) */ if (H5Dclose(dataset) < 0) goto error; - puts(" PASSED"); + PASSED(); return 0; error: @@ -222,8 +165,7 @@ test_simple_io(hid_t file) hsize_t dims[2]; void *tconv_buf = NULL; - printf("%-70s", "Testing simple I/O"); - fflush (stdout); + TESTING("simple I/O"); /* Initialize the dataset */ for (i = n = 0; i < 100; i++) { @@ -235,38 +177,33 @@ test_simple_io(hid_t file) /* Create the data space */ dims[0] = 100; dims[1] = 200; - space = H5Screate_simple(2, dims, NULL); - assert(space>=0); + if ((space = H5Screate_simple(2, dims, NULL))<0) goto error; /* Create a small conversion buffer to test strip mining */ tconv_buf = malloc (1000); xfer = H5Pcreate (H5P_DATASET_XFER); assert (xfer>=0); - status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL); - assert (status>=0); + if ((status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL))<0) goto error; /* Create the dataset */ - dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, - H5P_DEFAULT); - assert(dataset >= 0); + if ((dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, + H5P_DEFAULT))<0) goto error; /* Write the data to the dataset */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, points); - if (status<0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0) + goto error; /* Read the dataset back */ - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + 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*"); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %d,%d\n", i, j); goto error; } } @@ -275,7 +212,7 @@ test_simple_io(hid_t file) H5Pclose (xfer); H5Dclose(dataset); free (tconv_buf); - puts(" PASSED"); + PASSED(); return 0; error: @@ -305,15 +242,13 @@ test_tconv(hid_t file) int i; hsize_t dims[1]; hid_t space, dataset; - herr_t status; out = malloc (4*1000000); assert (out); in = malloc (4*1000000); assert (in); - printf("%-70s", "Testing data type conversion"); - fflush (stdout); + TESTING("data type conversion"); /* Initialize the dataset */ for (i = 0; i < 1000000; i++) { @@ -325,38 +260,40 @@ test_tconv(hid_t file) /* Create the data space */ dims[0] = 1000000; - space = H5Screate_simple (1, dims, NULL); - assert(space >= 0); + if ((space = H5Screate_simple (1, dims, NULL))<0) goto error; /* Create the data set */ - dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space, - H5P_DEFAULT); - assert(dataset >= 0); + if ((dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space, + H5P_DEFAULT))<0) goto error; /* Write the data to the dataset */ - status = H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, out); - assert(status >= 0); + if (H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + out)<0) goto error; /* Read data with byte order conversion */ - status = H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, - H5P_DEFAULT, in); - assert(status >= 0); + if (H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in)<0) + goto error; /* 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]); + if (in[4*i+0]!=out[4*i+3] || + in[4*i+1]!=out[4*i+2] || + in[4*i+2]!=out[4*i+1] || + in[4*i+3]!=out[4*i+0]) { + FAILED(); + puts(" Read with byte order conversion failed."); + goto error; + } } - H5Dclose(dataset); + if (H5Dclose(dataset)<0) goto error; free (out); free (in); - puts(" PASSED"); return 0; + + error: + return -1; } @@ -381,9 +318,6 @@ bogus(unsigned int __unused__ flags, size_t __unused__ cd_nelmts, const unsigned int __unused__ cd_values[], size_t nbytes, size_t __unused__ *buf_size, void __unused__ **buf) { -#if 0 - abort(); -#endif return nbytes; } @@ -408,7 +342,6 @@ static herr_t test_compression(hid_t file) { hid_t dataset, space, xfer, dc; - herr_t status; int points[100][200], check[100][200]; const hsize_t size[2] = {100, 200}; const hsize_t chunk_size[2] = {2, 25}; @@ -418,64 +351,57 @@ test_compression(hid_t file) hsize_t i, j, n; void *tconv_buf = NULL; - printf ("%-70s", "Testing compression (setup)"); - fflush (stderr); + TESTING("compression (setup)"); /* Create the data space */ - space = H5Screate_simple(2, size, NULL); - assert(space>=0); + if ((space = H5Screate_simple(2, size, NULL))<0) goto error; /* * Create a small conversion buffer to test strip mining. We * might as well test all we can! */ - xfer = H5Pcreate (H5P_DATASET_XFER); - assert (xfer>=0); + if ((xfer = H5Pcreate (H5P_DATASET_XFER))<0) goto error; tconv_buf = malloc (1000); - status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL); - assert (status>=0); + if (H5Pset_buffer (xfer, 1000, tconv_buf, NULL)<0) goto error; /* Use chunked storage with compression */ - dc = H5Pcreate (H5P_DATASET_CREATE); - H5Pset_chunk (dc, 2, chunk_size); - H5Pset_deflate (dc, 6); + if ((dc = H5Pcreate (H5P_DATASET_CREATE))<0) goto error; + if (H5Pset_chunk (dc, 2, chunk_size)<0) goto error; + if (H5Pset_deflate (dc, 6)<0) goto error; /* Create the dataset */ - dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space, dc); - assert(dataset >= 0); - puts (" PASSED"); + if ((dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space, + dc))<0) goto error; + PASSED(); /*---------------------------------------------------------------------- * STEP 1: Read uninitialized data. It should be zero. *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (uninitialized read)"); - fflush (stdout); + TESTING("compression (uninitialized read)"); - status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + goto error; for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (0!=check[i][j]) { - puts("*FAILED*"); - printf(" Read a non-zero value.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read a non-zero value.\n"); + printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } - puts (" PASSED"); + PASSED(); /*---------------------------------------------------------------------- * STEP 2: Test compression by setting up a chunked dataset and writing * to it. *---------------------------------------------------------------------- */ - printf("%-70s", "Testing compression (write)"); - fflush (stdout); + TESTING("compression (write)"); for (i=n=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { @@ -483,36 +409,33 @@ test_compression(hid_t file) } } - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, points); - if (status<0) goto error; - puts (" PASSED"); + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0) + goto error; + PASSED(); /*---------------------------------------------------------------------- * STEP 3: Try to read the data we just wrote. *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (read)"); - fflush (stdout); + TESTING("compression (read)"); /* Read the dataset back */ - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + goto error; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (points[i][j] != check[i][j]) { - puts("*FAILED*"); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } - puts (" PASSED"); + PASSED(); /*---------------------------------------------------------------------- * STEP 4: Write new data over the top of the old data. The new data is @@ -521,37 +444,33 @@ test_compression(hid_t file) * dataset although we rewrite the whole thing. *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (modify)"); - fflush (stdout); + TESTING("compression (modify)"); for (i=0; i<size[0]; i++) { for (j=0; j<size[1]/2; j++) { points[i][j] = rand (); } } - status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, points); - if (status<0) goto error; - + if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0) + goto error; /* Read the dataset back and check it */ - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + goto error; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (points[i][j] != check[i][j]) { - puts("*FAILED*"); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } - puts (" PASSED"); + PASSED(); /*---------------------------------------------------------------------- * STEP 5: Close the dataset and then open it and read it again. This @@ -559,29 +478,26 @@ test_compression(hid_t file) * object header. *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (re-open)"); - fflush (stdout); + TESTING("compression (re-open)"); - H5Dclose (dataset); - dataset = H5Dopen (file, DSET_COMPRESS_NAME); - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dclose (dataset)<0) goto error; + if ((dataset = H5Dopen (file, DSET_COMPRESS_NAME))<0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + goto error; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (points[i][j] != check[i][j]) { - puts("*FAILED*"); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } - puts (" PASSED"); - + PASSED(); /*---------------------------------------------------------------------- * STEP 6: Test partial I/O by writing to and then reading from a @@ -589,76 +505,72 @@ test_compression(hid_t file) * boundaries (we know that case already works from above tests). *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (partial I/O)"); - fflush (stderr); + TESTING("compression (partial I/O)"); for (i=0; i<hs_size[0]; i++) { for (j=0; j<hs_size[1]; j++) { points[hs_offset[0]+i][hs_offset[1]+j] = rand (); } } - H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); - - status = H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points); - if (status<0) goto error; - status = H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check); - if (status<0) goto error; + if (H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size, + NULL)<0) goto error; + if (H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points)<0) + goto error; + if (H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check)<0) + goto error; /* Check that the values read are the same as the values written */ for (i=0; i<hs_size[0]; i++) { for (j=0; j<hs_size[1]; j++) { if (points[hs_offset[0]+i][hs_offset[1]+j] != check[hs_offset[0]+i][hs_offset[1]+j]) { - puts("*FAILED*"); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", (unsigned long)(hs_offset[0]+i), (unsigned long)(hs_offset[1]+j)); - printf(" At original: %d\n", + printf(" At original: %d\n", (int)points[hs_offset[0]+i][hs_offset[1]+j]); - printf(" At returned: %d\n", + printf(" At returned: %d\n", (int)check[hs_offset[0]+i][hs_offset[1]+j]); goto error; } } } - puts (" PASSED"); + PASSED(); /*---------------------------------------------------------------------- * STEP 7: Register an application-defined compression method and use it * to write and then read the dataset. *---------------------------------------------------------------------- */ - printf ("%-70s", "Testing compression (app-defined method)"); - fflush (stdout); + TESTING("compression (app-defined method)"); if (H5Zregister (H5Z_BOGUS, "bogus", bogus)<0) goto error; if (H5Pset_filter (dc, H5Z_BOGUS, 0, 0, NULL)<0) goto error; if (H5Dclose (dataset)<0) goto error; if (H5Sclose (space)<0) goto error; if ((space = H5Screate_simple (2, size, NULL))<0) goto error; - dataset = H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space, dc); - assert (dataset>=0); + if ((dataset=H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space, + dc))<0) goto error; - status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, points); - if (status<0) goto error; - status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - xfer, check); - if (status<0) goto error; + if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0) + goto error; + if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0) + goto error; for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (points[i][j] != check[i][j]) { - puts("*FAILED*"); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", + FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } } - puts (" PASSED"); + PASSED(); @@ -666,9 +578,9 @@ test_compression(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - H5Pclose (xfer); - H5Pclose (dc); - H5Dclose(dataset); + if (H5Pclose (xfer)<0) goto error; + if (H5Pclose (dc)<0) goto error; + if (H5Dclose(dataset)<0) goto error; free (tconv_buf); return 0; @@ -704,7 +616,7 @@ test_multiopen (hid_t file) static hsize_t max_size[1] = {H5S_UNLIMITED}; hsize_t tmp_size[1]; - printf ("%-70s", "Testing multi-open with extending"); + TESTING("multi-open with extending"); /* Create the dataset and open it twice */ if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error; @@ -723,8 +635,8 @@ test_multiopen (hid_t file) if ((space = H5Dget_space (dset2))<0) goto error; if (H5Sget_simple_extent_dims (space, tmp_size, NULL)<0) goto error; if (cur_size[0]!=tmp_size[0]) { - puts ("*FAILED*"); - printf (" Got %d instead of %d!\n", + FAILED(); + printf (" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); goto error; } @@ -733,7 +645,7 @@ test_multiopen (hid_t file) if (H5Dclose (dset2)<0) goto error; if (H5Sclose (space)<0) goto error; if (H5Pclose (dcpl)<0) goto error; - puts (" PASSED"); + PASSED(); return 0; error: @@ -748,29 +660,6 @@ test_multiopen (hid_t file) /*------------------------------------------------------------------------- - * Function: cleanup - * - * Purpose: Cleanup temporary test files - * - * Return: none - * - * Programmer: Albert Cheng - * May 28, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -cleanup(void) -{ - if (!getenv ("HDF5_NOCLEANUP")) { - remove(TEST_FILE_NAME); - } -} - - -/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the dataset interface (H5D) @@ -790,64 +679,43 @@ int main(void) { hid_t file, grp, fapl; - herr_t status; int nerrors=0, mdc_nelmts; + char filename[1024]; - status = H5open (); - assert (status>=0); - - /* Automatic error reporting to standard output */ - H5Eset_auto (display_error_cb, NULL); - - /* Create the file */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - assert(fapl>=0); - + h5_reset(); + fapl = h5_fileaccess(); + #if 1 /* Turn off raw data cache */ - status = H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL); - assert(status>=0); - status = H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0); - assert(status>=0); + if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error; + if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0)<0) goto error; #endif - file = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, - H5P_DEFAULT, fapl); - assert(file >= 0); - H5Pclose(fapl); + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG, + H5P_DEFAULT, fapl))<0) goto error; /* Cause the library to emit initial messages */ - grp = H5Gcreate (file, "emit diagnostics", 0); - H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted"); - H5Gclose (grp); - - 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 = test_compression(file); - nerrors += status < 0 ? 1 : 0; - - status = test_multiopen (file); - nerrors += status < 0 ? 1 : 0; + if ((grp = H5Gcreate (file, "emit diagnostics", 0))<0) goto error; + if (H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted")<0) + goto error; + if (H5Gclose (grp)<0) goto error; - status = H5Fclose(file); + nerrors += test_create(file)<0 ?1:0; + nerrors += test_simple_io(file)<0 ?1:0; + nerrors += test_tconv(file)<0 ?1:0; + nerrors += test_compression(file)<0 ?1:0; + nerrors += test_multiopen (file)<0 ?1:0; - if (nerrors) { - printf("***** %d DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); - exit(1); - } + if (H5Fclose(file)<0) goto error; + if (nerrors) goto error; printf("All dataset tests passed.\n"); - - status = H5close (); - assert (status>=0); - - cleanup(); + h5_cleanup(fapl); return 0; + + error: + nerrors = MAX(1, nerrors); + printf("***** %d DATASET TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return 1; } |