diff options
-rw-r--r-- | test/cmpd_dset.c | 25 | ||||
-rw-r--r-- | test/dsets.c | 25 | ||||
-rw-r--r-- | test/extend.c | 24 | ||||
-rw-r--r-- | test/external.c | 44 | ||||
-rw-r--r-- | test/gheap.c | 41 | ||||
-rw-r--r-- | test/istore.c | 21 | ||||
-rw-r--r-- | test/links.c | 25 | ||||
-rw-r--r-- | test/shtype.c | 43 |
8 files changed, 229 insertions, 19 deletions
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 31492b9..13d9ca3 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -12,6 +12,8 @@ #include <stdlib.h> #include <string.h> +#define TEST_FILE_NAME "cmpd_dset.h5" + /* The first dataset */ typedef struct s1_t { unsigned int a; @@ -63,6 +65,26 @@ typedef struct s5_t { /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Creates a simple dataset of a compound type and then reads @@ -131,7 +153,7 @@ main (void) hsize_t h_sample[2]; /*hyperslab sampling */ /* Create the file */ - file = H5Fcreate ("cmpd_dset.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); @@ -591,5 +613,6 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ H5Dclose (dataset); H5Fclose (file); + cleanup(); return 0; } diff --git a/test/dsets.c b/test/dsets.c index c532954..a6d86fa 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -32,6 +32,7 @@ #define AT() printf (" at %s:%d in %s()...\n", \ __FILE__, __LINE__, __FUNCTION__); +#define TEST_FILE_NAME "dataset.h5" #define DSET_DEFAULT_NAME "default" #define DSET_CHUNKED_NAME "chunked" #define DSET_SIMPLE_IO_NAME "simple_io" @@ -671,6 +672,26 @@ test_compression(hid_t file) } /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the dataset interface (H5D) @@ -699,8 +720,7 @@ main(void) /* Automatic error reporting to standard output */ H5Eset_auto (display_error_cb, NULL); - unlink("dataset.h5"); - file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert(file >= 0); @@ -733,5 +753,6 @@ main(void) status = H5close (); assert (status>=0); + cleanup(); return 0; } diff --git a/test/extend.c b/test/extend.c index 7ead138..b582cc4 100644 --- a/test/extend.c +++ b/test/extend.c @@ -10,11 +10,32 @@ #include <assert.h> #include <hdf5.h> +#define TEST_FILE_NAME "extend.h5" #define NX 100 /* USE AN EVEN NUMBER!*/ #define NY 100 /* USE AN EVEN NUMBER!*/ /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests extendible datasets @@ -54,7 +75,7 @@ main (void) assert (mem_space>=0); /* Create the file */ - file = H5Fcreate ("extend.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); @@ -126,6 +147,7 @@ main (void) H5Dclose (dataset); H5Fclose (file); + cleanup(); return 0; } diff --git a/test/external.c b/test/external.c index 49e6d94..6857129 100644 --- a/test/external.c +++ b/test/external.c @@ -24,6 +24,10 @@ # define __unused__ __attribute__((unused)) #endif +#define TEST_FILE_NAME1 "extern_1.h5" +#define TEST_FILE_NAME2 "extern_2.h5" +#define TEST_FILE_NAME3 "extern_3.h5" + static int nerrors_g = 0; @@ -131,7 +135,7 @@ test_1 (void) * debugging to be emitted before we start playing games with what the * output looks like. */ - file = H5Fcreate ("extern_1.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate (TEST_FILE_NAME1, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); grp = H5Gcreate (file, "emit-diagnostics", 8); @@ -521,7 +525,7 @@ test_2 (void) * debugging to be emitted before we start playing games with what the * output looks like. */ - file = H5Fcreate ("extern_2.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate (TEST_FILE_NAME2, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); grp = H5Gcreate (file, "emit-diagnostics", 8); @@ -660,7 +664,7 @@ test_3 (void) /* * Create another file */ - file = H5Fcreate ("extern_3.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, + file = H5Fcreate (TEST_FILE_NAME3, H5F_ACC_TRUNC|H5F_ACC_DEBUG, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); @@ -767,6 +771,39 @@ test_3 (void) /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME1); + remove(TEST_FILE_NAME2); + remove(TEST_FILE_NAME3); + /* not sure if the following file names can be #defined */ + /* because some of them are created during runtime. */ + /* List them out this way for now. */ + remove("extern_1.raw"); + remove("extern_1b.raw"); + remove("extern_2.raw"); + remove("extern_2b.raw"); + remove("extern_3.raw"); + remove("extern_3b.raw"); + remove("extern_4.raw"); + remove("extern_4b.raw"); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Runs external dataset tests. @@ -793,6 +830,7 @@ main (void) if (0==nerrors_g) { printf ("All external storage tests passed.\n"); + cleanup(); } else { printf ("%d TEST%s FAILED.\n", nerrors_g, 1==nerrors_g?"":"s"); } diff --git a/test/gheap.c b/test/gheap.c index c4a4420..208f5e4 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -21,6 +21,12 @@ # define __FUNCTION__ "" #endif +#define TEST_FILE_NAME0 "gheap0.h5" +#define TEST_FILE_NAME1 "gheap1.h5" +#define TEST_FILE_NAME2 "gheap2.h5" +#define TEST_FILE_NAME3 "gheap3.h5" +#define TEST_FILE_NAME4 "gheap4.h5" + #define FAILED(S) { \ puts ("*FAILED*"); \ printf (" Failed at %s:%d in %s()%s%s\n", \ @@ -49,7 +55,7 @@ static void emit_diagnostics (void) { - H5F_t *f = H5F_open ("gheap0.h5", H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC, + H5F_t *f = H5F_open (TEST_FILE_NAME0, H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC, NULL, NULL); H5G_t *g = H5G_create (f->shared->root_grp, "emit", 0); H5G_close (g); @@ -91,7 +97,7 @@ test_1 (void) /* Open a clean file */ H5Eclear (); - f = H5F_open ("gheap1.h5", + f = H5F_open (TEST_FILE_NAME1, H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC|H5F_ACC_DEBUG, NULL, NULL); if (!f) { @@ -174,7 +180,7 @@ test_2 (void) /* Open a clean file */ H5Eclear (); - f = H5F_open ("gheap2.h5", + f = H5F_open (TEST_FILE_NAME2, H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC|H5F_ACC_DEBUG, NULL, NULL); if (!f) { @@ -251,7 +257,7 @@ test_3 (void) /* Open a clean file */ H5Eclear (); - f = H5F_open ("gheap3.h5", + f = H5F_open (TEST_FILE_NAME3, H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC|H5F_ACC_DEBUG, NULL, NULL); if (!f) { @@ -320,7 +326,7 @@ test_4 (void) /* Open a clean file */ H5Eclear (); - f = H5F_open ("gheap4.h5", + f = H5F_open (TEST_FILE_NAME4, H5F_ACC_CREAT|H5F_ACC_RDWR|H5F_ACC_TRUNC|H5F_ACC_DEBUG, NULL, NULL); if (!f) { @@ -364,6 +370,30 @@ test_4 (void) /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME0); + remove(TEST_FILE_NAME1); + remove(TEST_FILE_NAME2); + remove(TEST_FILE_NAME3); + remove(TEST_FILE_NAME4); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests global heap. @@ -397,6 +427,7 @@ main (void) nfailed, 1==nfailed?"":"s"); } else { printf ("All global heap tests passed.\n"); + cleanup(); } return nfailed?-1:0; } diff --git a/test/istore.c b/test/istore.c index 2aedee2..fb02e20 100644 --- a/test/istore.c +++ b/test/istore.c @@ -527,6 +527,26 @@ test_sparse(H5F_t *f, const char *prefix, size_t nblocks, } /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(FILENAME); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests indexed storage stuff. @@ -675,5 +695,6 @@ main(int argc, char *argv[]) } H5Pclose (template_id); printf("All i-store tests passed.\n"); + cleanup(); return 0; } diff --git a/test/links.c b/test/links.c index ac4a3e1..81c185d 100644 --- a/test/links.c +++ b/test/links.c @@ -9,6 +9,28 @@ */ #include <hdf5.h> +#define TEST_FILE_NAME "links.h5" + + +/*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME); +} /*------------------------------------------------------------------------- * Function: main @@ -33,7 +55,7 @@ main (void) hsize_t size[1] = {1}; /* Create a file */ - file = H5Fcreate ("links.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); scalar = H5Screate_simple (1, size, size); /* Create a group */ @@ -59,5 +81,6 @@ main (void) /* Close */ H5Sclose (scalar); H5Fclose (file); + cleanup(); return 0; } diff --git a/test/shtype.c b/test/shtype.c index 243ab5c..e9fb935 100644 --- a/test/shtype.c +++ b/test/shtype.c @@ -19,6 +19,12 @@ # define __unused__ __attribute__((unused)) #endif +#define TEST_FILE_NAME0 "shtype0.h5" +#define TEST_FILE_NAME1 "shtype1.h5" +#define TEST_FILE_NAME2A "shtype2a.h5" +#define TEST_FILE_NAME2B "shtype2b.h5" +#define TEST_FILE_NAME3 "shtype3.h5" + /*------------------------------------------------------------------------- * Function: display_error_cb @@ -72,7 +78,7 @@ test_1 (void) printf ("%-70s", "...creating/quering datasets with shared type"); fflush (stdout); - f = H5Fcreate ("shtype1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + f = H5Fcreate (TEST_FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (f<0) goto error; if ((s1 = H5Screate_simple (1, size, size))<0) goto error; if ((t1 = H5Tcopy (H5T_NATIVE_INT))<0) goto error; @@ -131,9 +137,9 @@ test_2 (void) printf ("%-70s", "...compare shared and unshared types"); fflush (stdout); - f1 = H5Fcreate ("shtype2a.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + f1 = H5Fcreate (TEST_FILE_NAME2A, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (f1<0) goto error; - f2 = H5Fcreate ("shtype2b.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + f2 = H5Fcreate (TEST_FILE_NAME2B, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (f2<0) goto error; s1 = H5Screate_simple (1, size, size); if (s1<0) goto error; @@ -207,7 +213,7 @@ test_3 (void) * access. Add a dataset with a shared type. Then close it and open it * for read-only. The shared type causes a global heap to be allocated. */ - f1 = H5Fcreate ("shtype3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + f1 = H5Fcreate (TEST_FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (f1<0) goto error; if ((s1 = H5Screate_simple (1, size, size))<0) goto error; if ((t1 = H5Tcopy (H5T_NATIVE_INT))<0) goto error; @@ -216,7 +222,7 @@ test_3 (void) if (H5Sclose (s1)<0) goto error; if (H5Dclose (d1)<0) goto error; if (H5Fclose (f1)<0) goto error; - f1 = H5Fopen ("shtype3.h5", H5F_ACC_RDONLY, H5P_DEFAULT); + f1 = H5Fopen (TEST_FILE_NAME3, H5F_ACC_RDONLY, H5P_DEFAULT); if (f1<0) goto error; assert (0==H5Tis_shared (f1, t1)); @@ -252,6 +258,30 @@ test_3 (void) /*------------------------------------------------------------------------- + * Function: cleanup + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * May 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +cleanup(void) +{ + remove(TEST_FILE_NAME0); + remove(TEST_FILE_NAME1); + remove(TEST_FILE_NAME2A); + remove(TEST_FILE_NAME2B); + remove(TEST_FILE_NAME3); +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: @@ -274,7 +304,7 @@ main (void) hid_t f1, g1; /* Make sure diagnostics get emitted before we start doing real stuff */ - f1 = H5Fcreate ("shtype0.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + f1 = H5Fcreate (TEST_FILE_NAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); g1 = H5Gcreate (f1, "howdy", 0); H5Gclose (g1); H5Fclose (f1); @@ -292,6 +322,7 @@ main (void) puts ("*** Shared data type test(s) failed ***"); } else { puts ("All shared data type tests passed."); + cleanup(); } return nerrors ? 1 : 0; } |