diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-11-21 03:36:51 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-11-21 03:36:51 (GMT) |
commit | 7488c6366e878651f6bb8dc94f05eb69cd0df83b (patch) | |
tree | c2ba0295a0bec1b350fa3d4fa291b46ac75e271f /test/cmpd_dset.c | |
parent | 6345a417a3930b32ec9e5fc087e0aeb20a94aed7 (diff) | |
download | hdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.zip hdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.tar.gz hdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.tar.bz2 |
[svn-r936] Changes since 19981119
----------------------
./src/H5.c
./src/H5A.c
./src/H5AC.c
./src/H5B.c
./src/H5D.c
./src/H5E.c
./src/H5F.c
./src/H5Farray.c
./src/H5Fcore.c
./src/H5Ffamily.c
./src/H5Fistore.c
./src/H5Flow.c
./src/H5Fmpio.c
./src/H5Fsec2.c
./src/H5Fsplit.c
./src/H5Fstdio.c
./src/H5G.c
./src/H5Gent.c
./src/H5Gnode.c
./src/H5Gstab.c
./src/H5HG.c
./src/H5HL.c
./src/H5I.c
./src/H5Iprivate.h
./src/H5MF.c
./src/H5MM.c
./src/H5O.c
./src/H5Oattr.c
./src/H5Ocomp.c
./src/H5Ocont.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Ofill.c
./src/H5Olayout.c
./src/H5Omtime.c
./src/H5Oname.c
./src/H5Osdspace.c
./src/H5Oshared.c
./src/H5Ostab.c
./src/H5P.c
./src/H5R.c
./src/H5RA.c
./src/H5S.c
./src/H5Sall.c
./src/H5Shyper.c
./src/H5Smpio.c
./src/H5Snone.c
./src/H5Spoint.c
./src/H5Sselect.c
./src/H5T.c
./src/H5TB.c
./src/H5Tbit.c
./src/H5Tconv.c
./src/H5V.c
./src/H5Z.c
./src/H5detect.c
./src/H5private.h
Most of these changes are because the `interface_initialize_g'
variable change from hbool_t to int. It's a one line change.
Changed the way the library is closed so we have more control
over the order the interfaces are shut down. Instead of
registering an atexit() function for every interface in some
haphazard order we just register one: H5_term_library() which
then calls the H5*_term_interface() functions in a
well-defined order.
If the library is closed and then reopened repeatedly by
calling H5close() and H5open() in a loop we only add one copy
of the library termination functions with atexit().
Termination is a two-step process in order to help detect
programming errors that would cause an infinite loop caused by
the termination of one interface waking up some other
previously terminated interface. The first step terminates
the interface and *marks it as unusable*. After all
interfaces are terminated then we mark them all as usable
again. The FUNC_ENTER() macro has been modified to return
failure or to dump core (depending on whether NDEBUG is
defined) if we try to call an interface while it's shutting
down.
./src/H5.c
The H5dont_atexit() function returns failure if it's called
more than once or if it's called too late. However, the error
stack is not automatically printed on failure because the
library might not be initialized yet
./test/chunk.c
./test/flush1.c
./test/flush2.c
./test/iopipe.c
./test/overhead.c
./test/ragged.c
Changed the extra cast for Win32 so we do floating point
division again -- it was just confusion about precedence and
associativity of casting and the C coercion rules. Removed
extra carriage returns inserted by broken operating system.
./src/H5Ffamily.c
Fixed an bug where H5F_fam_write() lowered the EOF marker for
one of the family members causing H5F_fam_read() to read
zeros.
./test/h5test.h [NEW]
./test/h5test.c [NEW]
./test/Makefile.in
./test/bittests.c
./test/cmpd_dset.c
./test/dsets.c
./test/dtypes.c
./test/extend.c
./test/external.c
Support library for test files. This isn't done yet but
Katie's contractions are ~10 minutes apart so I figured I
better back this stuff up just in case I'm not here next
week...
Eventually all test files will understand HDF5_DRIVER to name
the low level file driver and parameters so we can easily test
various drivers. They will also understand HDF5_PREFIX to
prepend to the beginning of file names which is necessary for
testing ROMIO with various drivers. Also, the cleanup function
will know how to use the file name prefix and will understand
different file driver naming schemes like file families. I'm
not sure they'll understand the `gsf:' type prefixes yet.
Note, the external test is completely commented out because
I'm in the middle of modifying it. It will still compile and
run but it doesn't test anything at the moment.
Diffstat (limited to 'test/cmpd_dset.c')
-rw-r--r-- | test/cmpd_dset.c | 205 |
1 files changed, 70 insertions, 135 deletions
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index f50966a..f3ccf39 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -8,24 +8,12 @@ /* See H5private.h for how to include headers */ #undef NDEBUG -#include <hdf5.h> +#include <h5test.h> -#ifdef STDC_HEADERS -# include <assert.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -#endif - -#ifndef HAVE_ATTRIBUTE -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define __unused__ /*void*/ -#else -# define __unused__ __attribute__((unused)) -#endif - -#define TEST_FILE_NAME "cmpd_dset.h5" +const char *FILENAME[] = { + "cmpd_dset", + NULL +}; /* The first dataset */ typedef struct s1_t { @@ -76,54 +64,6 @@ typedef struct s5_t { # define NY 9u #endif - -/*------------------------------------------------------------------------- - * Function: cleanup - * - * Purpose: Cleanup temporary test files - * - * Return: none - * - * Programmer: Albert Cheng - * May 28, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -cleanup(void) -{ - if (!getenv ("HDF5_NOCLEANUP")) { - remove(TEST_FILE_NAME); - } -} - - -/*------------------------------------------------------------------------- - * Function: display_error_cb - * - * Purpose: Displays the error stack after printing "*FAILED*". - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Wednesday, March 4, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -display_error_cb (void __unused__ *client_data) -{ - puts ("*FAILED*"); - H5Eprint (stdout); - return 0; -} - /*------------------------------------------------------------------------- * Function: main @@ -186,18 +126,20 @@ main (void) /* Other variables */ unsigned int i, j; - hid_t file, dataset, space, PRESERVE; + hid_t file, dataset, space, PRESERVE, fapl; static hsize_t dim[] = {NX, NY}; hssize_t f_offset[2]; /*offset of hyperslab in file */ hsize_t h_size[2]; /*size of hyperslab */ size_t memb_size[1] = {4}; + char filename[256]; - /* Set up error handling */ - H5Eset_auto(display_error_cb, NULL); + h5_reset(); /* Create the file */ - if ((file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, - H5P_DEFAULT, H5P_DEFAULT))<0) goto error; + fapl = h5_fileaccess(); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG, + H5P_DEFAULT, fapl))<0) goto error; /* Create the data space */ if ((space = H5Screate_simple (2, dim, NULL))<0) goto error; @@ -210,8 +152,7 @@ main (void) *###################################################################### * STEP 1: Save the original dataset natively. */ - printf("%-70s", "Testing basic compound write"); - fflush(stdout); + TESTING("basic compound write"); /* Initialize the dataset */ for (i=0; i<NX*NY; i++) { @@ -245,7 +186,7 @@ main (void) if (H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1)<0) { goto error; } - puts(" PASSED"); + PASSED(); /* *###################################################################### @@ -253,8 +194,7 @@ main (void) * it's the same as the first just to test things better, but * in fact, we could have used s1_tid. */ - printf("%-70s", "Testing basic compound read"); - fflush(stdout); + TESTING("basic compound read"); /* Create a data type for s2 */ if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0) goto error; @@ -282,12 +222,12 @@ main (void) s1[i].c[3]!=s2[i].c[3] || s1[i].d!=s2[i].d || s1[i].e!=s2[i].e) { - puts("*FAILED*"); - puts(" Incorrect values read from the file"); + FAILED(); + puts(" Incorrect values read from the file"); goto error; } } - puts(" PASSED"); + PASSED(); /* *###################################################################### @@ -295,8 +235,7 @@ main (void) * has the same data space but the data type is different: the * data type is a struct whose members are in the opposite order. */ - printf("%-70s", "Testing reversal of struct members"); - fflush (stdout); + TESTING("reversal of struct members"); /* Create a data type for s3 */ if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0) goto error; @@ -324,20 +263,19 @@ main (void) s1[i].c[3]!=s3[i].c[3] || s1[i].d!=s3[i].d || s1[i].e!=s3[i].e) { - puts("*FAILED*"); - puts(" Incorrect values read from the file"); + FAILED(); + puts(" Incorrect values read from the file"); goto error; } } - puts(" PASSED"); + PASSED(); /* *###################################################################### * STEP 4: Read a subset of the members. Of the <a,b,c,d,e> members * stored on disk we'll read <b,d>. */ - printf("%-70s", "Testing subset struct read"); - fflush (stdout); + TESTING("subset struct read"); /* Create a datatype for s4 */ if ((s4_tid = H5Tcreate (H5T_COMPOUND, sizeof(s4_t)))<0) goto error; @@ -353,20 +291,19 @@ main (void) for (i=0; i<NX*NY; i++) { if (s1[i].b!=s4[i].b || s1[i].d!=s4[i].d) { - puts("*FAILED*"); - puts(" Incorrect values read from the file"); + FAILED(); + puts(" Incorrect values read from the file"); goto error; } } - puts(" PASSED"); + PASSED(); /* *###################################################################### * STEP 5: Read all the members into a struct which has other members * which have already been initialized. */ - printf("%-70s", "Testing partially initialized superset read"); - fflush(stdout); + TESTING("partially initialized superset read"); /* Initialize some members */ for (i=0; i<NX*NY; i++) { @@ -402,8 +339,8 @@ main (void) s1[i].c[3]!=s5[i].c[3] || s1[i].d!=s5[i].d || s1[i].e!=s5[i].e) { - puts("*FAILED*"); - puts(" Incorrect values read from the file"); + FAILED(); + puts(" Incorrect values read from the file"); goto error; } } @@ -414,12 +351,12 @@ main (void) s5[i].mid1 != 1001+4*i || s5[i].mid2 != 1002+4*i || s5[i].post != 1003+4*i) { - puts("*FAILED*"); - puts(" Memory values were clobbered"); + FAILED(); + puts(" Memory values were clobbered"); goto error; } } - puts(" PASSED"); + PASSED(); /* *###################################################################### @@ -427,8 +364,7 @@ main (void) * fields unchanged. This tests member alignment and background * buffers. */ - printf("%-70s", "Testing partially initialized superset write"); - fflush (stdout); + TESTING("partially initialized superset write"); /* Initialize `s4' with new values */ for (i=0; i<NX*NY; i++) { @@ -456,12 +392,17 @@ main (void) s1[i].c[3] != 8*i+5 || s1[i].d != 8*i+6 || s1[i].e != 8*i+7) { - puts("*FAILED*"); - puts(" File values were clobbered"); + FAILED(); + printf(" i==%u, row=%u, col=%u\n", i, i/NY, i%NY); + printf(" got: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n", + s1[i].a, s1[i].b, s1[i].c[0], s1[i].c[1], s1[i].c[2], + s1[i].c[3], s1[i].d, s1[i].e); + printf(" ans: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n", + 8*i+0, 8*i+1, 8*i+2, 8*i+3, 8*i+4, 8*i+5, 8*i+6, 8*i+7); goto error; } } - puts(" PASSED"); + PASSED(); /* *###################################################################### @@ -469,8 +410,7 @@ main (void) * though these data spaces are equal it tests a different part of the * library. */ - printf("%-70s", "Testing explicit data space"); - fflush (stdout); + TESTING("explicit data space"); /* Create the data space */ if ((s7_sid = H5Screate_simple (2, dim, NULL))<0) goto error; @@ -490,12 +430,12 @@ main (void) s2[i].c[3] != s1[i].c[3] || s2[i].d != s1[i].d || s2[i].e != s1[i].e) { - puts("*FAILED*"); - puts(" Incorrect values read from file"); + FAILED(); + puts(" Incorrect values read from file"); goto error; } } - puts(" PASSED"); + PASSED(); /* @@ -503,8 +443,7 @@ main (void) * STEP 8. Read a hyperslab of the file into a complete array in memory. * The hyperslab is the middle third of the array. */ - printf("%-70s", "Testing hyperslab partial read to array"); - fflush (stdout); + TESTING("hyperslab partial read to array"); /* Create the file data space */ if ((s8_f_sid = H5Dget_space (dataset))<0) goto error; @@ -539,8 +478,8 @@ main (void) ps8->c[3] != ps1->c[3] || ps8->d != ps1->d || ps8->e != ps1->e) { - puts("*FAILED*"); - puts(" Incorrect values read from file"); + FAILED(); + puts(" Incorrect values read from file"); goto error; } } @@ -548,7 +487,7 @@ main (void) free (s8); s8 = NULL; - puts(" PASSED"); + PASSED(); /* @@ -556,8 +495,7 @@ main (void) * STEP 9. Read a hyperslab of the file into a hyperslab of memory. The * part of memory not read is already initialized and must not change. */ - printf("%-70s", "Testing hyperslab partial read to another hyperslab"); - fflush (stdout); + TESTING("hyperslab partial read to another hyperslab"); /* Initialize */ for (i=0; i<NX*NY; i++) { @@ -587,8 +525,8 @@ main (void) ps2->c[3] != ps1->c[3] || ps2->d != ps1->d || ps2->e != ps1->e) { - puts("*FAILED*"); - puts(" Memory values clobbered"); + FAILED(); + puts(" Memory values clobbered"); goto error; } } else { @@ -600,22 +538,21 @@ main (void) ps2->c[3] != (unsigned)(-1) || ps2->d != (unsigned)(-1) || ps2->e != (unsigned)(-1)) { - puts("*FAILED*"); - puts(" Incorrect values read from file"); + FAILED(); + puts(" Incorrect values read from file"); goto error; } } } } - puts(" PASSED"); + PASSED(); /* *###################################################################### * STEP 10. Same as step 9 except the memory array contains some members * which are already initialized, like step 5. */ - printf("%-70s", "Testing hyperslab to hyperslab part initialized read"); - fflush (stdout); + TESTING("hyperslab to hyperslab part initialized read"); /* Initialize */ for (i=0; i<NX*NY; i++) { @@ -650,8 +587,8 @@ main (void) ps5->d != ps1->d || ps5->e != ps1->e || ps5->post != (unsigned)(-1)) { - puts("*FAILED*"); - puts(" Memory values clobbered"); + FAILED(); + puts(" Memory values clobbered"); goto error; } } else { @@ -667,22 +604,21 @@ main (void) ps5->d != (unsigned)(-1) || ps5->e != (unsigned)(-1) || ps5->post != (unsigned)(-1)) { - puts("*FAILED*"); - puts(" Incorrect values read from file"); + FAILED(); + puts(" Incorrect values read from file"); goto error; } } } } - puts(" PASSED"); + PASSED(); /* *###################################################################### * Step 11: Write an array into the middle third of the dataset * initializeing only members `b' and `d' to -1. */ - printf("%-70s", "Testing hyperslab part initialized write"); - fflush (stdout); + TESTING("hyperslab part initialized write"); /* Create the memory array and initialize all fields to zero */ ndims = 2; @@ -721,8 +657,8 @@ main (void) ps1->c[2] != 8*(i*NY+j)+4 || ps1->c[3] != 8*(i*NY+j)+5 || ps1->e != 8*(i*NY+j)+7) { - puts("*FAILED*"); - puts(" Write clobbered values"); + FAILED(); + puts(" Write clobbered values"); goto error; } @@ -732,21 +668,21 @@ main (void) (hsize_t)j<f_offset[1]+h_size[1]) { if (ps1->b != (unsigned)(-1) || ps1->d != (unsigned)(-1)) { - puts("*FAILED*"); - puts(" Wrong values written or read"); + FAILED(); + puts(" Wrong values written or read"); goto error; } } else { if (ps1->b != 8*(i*NY+j)+1 || ps1->d != 8*(i*NY+j)+6) { - puts("*FAILED*"); - puts(" Write clobbered values"); + FAILED(); + puts(" Write clobbered values"); goto error; } } } } - puts(" PASSED"); + PASSED(); /* @@ -756,12 +692,11 @@ main (void) H5Dclose (dataset); H5Fclose (file); - cleanup(); + h5_cleanup(fapl); puts("All compound dataset tests passed."); return 0; error: - cleanup(); puts("Remaining tests have been skipped."); puts("*** DATASET TESTS FAILED ***"); return 1; |