diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-01-06 17:53:13 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-01-06 17:53:13 (GMT) |
commit | ce2b03097bbf2fb80db60673610e707a028645d0 (patch) | |
tree | 20178d40250fff3696bfff8b6864c011e8018562 /test | |
parent | 68607efcd10222ed1b1d19308d3586eb65fe3644 (diff) | |
download | hdf5-ce2b03097bbf2fb80db60673610e707a028645d0.zip hdf5-ce2b03097bbf2fb80db60673610e707a028645d0.tar.gz hdf5-ce2b03097bbf2fb80db60673610e707a028645d0.tar.bz2 |
[svn-r8022] Purpose:
Code cleanup
Description:
Refactor library testing framework (used for the testhdf5 & ttsafe tests)
to remove almost all of the duplicated code, moving the common code into a
new 'testframe.c' source file.
Platforms tested:
FreeBSD 4.9 (sleipnir) w & w/o thread-safety
h5committest
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.in | 25 | ||||
-rw-r--r-- | test/cmpd_dset.c | 4 | ||||
-rw-r--r-- | test/h5test.c | 36 | ||||
-rw-r--r-- | test/h5test.h | 32 | ||||
-rw-r--r-- | test/testframe.c | 298 | ||||
-rw-r--r-- | test/testhdf5.c | 263 | ||||
-rw-r--r-- | test/testhdf5.h | 41 | ||||
-rw-r--r-- | test/ttsafe.c | 265 | ||||
-rw-r--r-- | test/ttsafe.h | 98 |
9 files changed, 435 insertions, 627 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index 7a96a15..09701ad 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -76,13 +76,14 @@ CLEAN=$(TIMINGS) TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \ external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \ istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c tarray.c \ - tattr.c tconfig.c testhdf5.c testmeta.c tfile.c tgenprop.c th5s.c \ - theap.c titerate.c tmeta.c trefer.c trefstr.c tselect.c ttime.c \ - ttbbt.c ttst.c tvltypes.c tvlstr.c tmisc.c unlink.c enum.c ttsafe.c \ - ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c ttsafe_acreate.c \ - gass_write.c gass_read.c gass_append.c srb_read.c srb_write.c \ - srb_append.c stream_test.c set_extent.c getname.c file_handle.c \ - ntypes.c dangle.c error_test.c err_compat.c + tattr.c tconfig.c testframe.c testhdf5.c testmeta.c tfile.c \ + tgenprop.c th5s.c theap.c titerate.c tmeta.c trefer.c trefstr.c \ + tselect.c ttime.c ttbbt.c ttst.c tvltypes.c tvlstr.c tmisc.c \ + unlink.c enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c \ + ttsafe_cancel.c ttsafe_acreate.c gass_write.c gass_read.c \ + gass_append.c srb_read.c srb_write.c srb_append.c stream_test.c \ + set_extent.c getname.c file_handle.c ntypes.c dangle.c error_test.c \ + err_compat.c TEST_OBJ=$(TEST_SRC:.c=.lo) @@ -108,12 +109,12 @@ check test _test: $(PROGS) ## How to build the tests... They all depend on the test and hdf5 libraries. $(PROGS): $(LIB) $(LIBHDF5) -TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo tgenprop.lo \ - th5s.lo theap.lo titerate.lo tmeta.lo ttime.lo trefer.lo trefstr.lo \ - tselect.lo ttbbt.lo ttst.lo tvltypes.lo tvlstr.lo tmisc.lo +TESTHDF5_OBJ=testhdf5.lo testframe.lo tarray.lo tattr.lo tconfig.lo tfile.lo \ + tgenprop.lo th5s.lo theap.lo titerate.lo tmeta.lo ttime.lo trefer.lo \ + trefstr.lo tselect.lo ttbbt.lo ttst.lo tvltypes.lo tvlstr.lo tmisc.lo -TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo ttsafe_cancel.lo \ - ttsafe_acreate.lo +TTS_OBJ=ttsafe.lo testframe.lo ttsafe_dcreate.lo ttsafe_error.lo \ + ttsafe_cancel.lo ttsafe_acreate.lo testhdf5: $(TESTHDF5_OBJ) @$(LT_LINK_EXE) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 8bee741..ddc8a83 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -19,6 +19,10 @@ /* See H5private.h for how to include headers */ #undef NDEBUG + +#define H5T_PACKAGE +#include "H5Tpkg.h" /*to turn off hardware conversions*/ + #include "h5test.h" const char *FILENAME[] = { diff --git a/test/h5test.c b/test/h5test.c index 79c9da8..3a8e72c 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -89,14 +89,6 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ */ static const char *multi_letters = "msbrglo"; -/* - * Global variables used by InitTest(). - * The code should be revised so that these do not need to be - * global. - */ -struct TestStruct Test[MAXNUMOFTESTS]; -int Index = 0; - #ifdef H5_WANT_H5_V1_6_COMPAT static herr_t h5_errors(void *client_data); #else /* H5_WANT_H5_V1_6_COMPAT */ @@ -804,24 +796,20 @@ h5_get_file_size(const char *filename) return(0); } /* end get_file_size() */ - /* - * Setup a test function. It must have no parameters and returns void. + * 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) */ -void -InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr) +int +print_func(const char *format, ...) { - if (Index >= MAXNUMOFTESTS) { - printf("Too many tests added, increase MAXNUMOFTEST(%d).\n", - MAXNUMOFTESTS); - exit(-1); - } /* end if */ - HDstrcpy(Test[Index].Description, TheDescr); - HDstrcpy(Test[Index].Name, TheName); - Test[Index].Call = TheCall; - Test[Index].Cleanup = Cleanup; - Test[Index].NumErrors = -1; - Test[Index].SkipFlag = 0; - Index++; + va_list arglist; + int ret_value; + + va_start(arglist, format); + ret_value = vprintf(format, arglist); + va_end(arglist); + return ret_value; } diff --git a/test/h5test.h b/test/h5test.h index af709b4..fac6c26 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -21,6 +21,8 @@ #ifndef _H5TEST_H #define _H5TEST_H +#include <stdarg.h> + #undef NDEBUG #include "hdf5.h" #include "H5private.h" @@ -29,9 +31,6 @@ # include <signal.h> #endif -#define H5T_PACKAGE -#include "H5Tpkg.h" /*to turn off hardware conversions*/ - /* * This contains the filename prefix specificied as command line option for * the parallel test files. @@ -62,26 +61,11 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define SKIPPED() {puts(" -SKIP-");fflush(stdout);} #define TEST_ERROR {H5_FAILED(); AT(); goto error;} -/* - * Definitions for the InitTest(). - */ -#define MAXNUMOFTESTS 30 -extern int Index; -typedef struct TestStruct { - int NumErrors; - char Description[64]; - int SkipFlag; - char Name[16]; - void (*Call)(void); - void (*Cleanup)(void); -} TestStruct; -extern TestStruct Test[]; - - #ifdef __cplusplus extern "C" { #endif +/* Generally useful testing routines */ H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); @@ -89,13 +73,13 @@ H5TEST_DLL hid_t h5_fileaccess(void); H5TEST_DLL void h5_no_hwconv(void); H5TEST_DLL void h5_reset(void); H5TEST_DLL void h5_show_hostname(void); -H5TEST_DLL void InitTest(const char *TheName, void (*TheCall) (void), - void (*Cleanup) (void), const char *TheDescr); +H5TEST_DLL off_t h5_get_file_size(const char *filename); +H5TEST_DLL int print_func(const char *format, ...); + #ifdef H5_HAVE_PARALLEL -int h5_set_info_object(void); -void h5_dump_info_object(MPI_Info info); +H5TEST_DLL int h5_set_info_object(void); +H5TEST_DLL void h5_dump_info_object(MPI_Info info); #endif -H5TEST_DLL off_t h5_get_file_size(const char *filename); #ifdef __cplusplus } diff --git a/test/testframe.c b/test/testframe.c new file mode 100644 index 0000000..550ea81 --- /dev/null +++ b/test/testframe.c @@ -0,0 +1,298 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Tuesday, January 6, 2004 + * + * Purpose: Provides support functions for the testing framework. + * + */ + +#include "testhdf5.h" + +/* + * Definitions for the testing structure. + */ +#define MAXNUMOFTESTS 30 +#define MAXTESTNAME 16 +#define MAXTESTDESC 64 + +typedef struct TestStruct { + int NumErrors; + char Description[MAXTESTDESC]; + int SkipFlag; + char Name[MAXTESTNAME]; + void (*Call)(void); + void (*Cleanup)(void); +} TestStruct; + + +/* + * Global variables used by InitTest(). + */ +static TestStruct Test[MAXNUMOFTESTS]; +static int Index = 0; + + +/* + * Setup a test function and add it to the list of tests. + * It must have no parameters and returns void. + */ +void +AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr) +{ + /* Sanity checking */ + if (Index >= MAXNUMOFTESTS) { + printf("Too many tests added, increase MAXNUMOFTEST(%d).\n", + MAXNUMOFTESTS); + exit(-1); + } /* end if */ + if (HDstrlen(TheDescr) >= MAXTESTDESC) { + printf("Test description too long, increase MAXTESTDESC(%d).\n", + MAXTESTDESC); + exit(-1); + } /* end if */ + if (HDstrlen(TheName) >= MAXTESTNAME) { + printf("Test name too long, increase MAXTESTNAME(%d).\n", + MAXTESTNAME); + exit(-1); + } /* end if */ + + /* Set up test function */ + HDstrcpy(Test[Index].Description, TheDescr); + HDstrcpy(Test[Index].Name, TheName); + Test[Index].Call = TheCall; + Test[Index].Cleanup = Cleanup; + Test[Index].NumErrors = -1; + Test[Index].SkipFlag = 0; + + /* Increment test count */ + Index++; +} + + +/* + * Initialize testing framework + */ +void TestInit(void) +{ +#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) + /* Un-buffer the stdout and stderr */ + setbuf(stderr, NULL); + setbuf(stdout, NULL); +#endif + + /* + * Turn off automatic error reporting since we do it ourselves. Besides, + * half the functions this test calls are private, so automatic error + * reporting wouldn't do much good since it's triggered at the API layer. + */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto (NULL, NULL); +#else + H5Eset_auto (H5E_DEFAULT, NULL, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + +} + + +/* + * Print test usage. + */ +void TestUsage(void) +{ + int i; + + print_func("Usage: ttsafe [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n"); + print_func(" [-[e]x[clude] name+] \n"); + print_func(" [-o[nly] name+] \n"); + print_func(" [-b[egin] name] \n"); + print_func(" [-s[ummary]] \n"); + print_func(" [-c[leanoff]] \n"); + print_func(" [-h[elp]] \n"); + print_func("\n\n"); + print_func("verbose controls the amount of information displayed\n"); + print_func("exclude to exclude tests by name\n"); + print_func("only to name tests which should be run\n"); + print_func("begin start at the name of the test givin\n"); + print_func("summary prints a summary of test results at the end\n"); + print_func("cleanoff does not delete *.hdf files after execution of tests\n"); + print_func("help print out this information\n"); + print_func("\n\n"); + print_func("This program currently tests the following: \n\n"); + print_func("%16s %s\n", "Name", "Description"); + print_func("%16s %s\n", "----", "-----------"); + + for (i = 0; i < Index; i++) + print_func("%16s %s\n", Test[i].Name, Test[i].Description); + + print_func("\n\n"); +} + + +/* + * Print test info. + */ +void TestInfo(const char *ProgName) +{ + unsigned major, minor, release; + + H5get_libversion(&major, &minor, &release); + + print_func("\nFor help use: %s -help\n",ProgName); + print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release); +} + + +/* + * Parse command line information + */ +void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp) +{ + int CLLoop; /* Command Line Loop */ + int Loop, Loop1; + + 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))) { + TestUsage(); + exit(0); + } + if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) || + (HDstrcmp(argv[CLLoop], "-c") == 0))) + *CleanUp = 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 */ + +} + + +/* + * Perform Tests. + */ +void PerformTests(void) +{ + int Loop; + + 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)); + } + + MESSAGE(2, ("\n\n")) + + if (num_errs) + print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs); + else + print_func("All tests were successful. \n\n"); +} + + +/* + * Display test summary. + */ +void TestSummary(void) +{ + int Loop; + + 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); + } + + print_func("\n\n"); +} + + +/* + * Cleanup files from testing + */ +void TestCleanup(void) +{ + int Loop; + + MESSAGE(2, ("\nCleaning Up temp files...\n\n")); + + /* call individual cleanup routines in each source module */ + for (Loop = 0; Loop < Index; Loop++) + if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) + Test[Loop].Cleanup(); +} + diff --git a/test/testhdf5.c b/test/testhdf5.c index f246e08..e213b19 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /* FILE testhdf5.c - HDF5 testing framework main file. @@ -24,250 +22,69 @@ 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 + into the list of AddTest() calls in main() below. Functions which depend + on other functionality should be placed below the AddTest() 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. */ -#include <stdarg.h> #include "h5test.h" #define HDF5_TEST_MASTER - -/* Global variables */ -int num_errs = 0; -int Verbosity; - -/* ANY new test needs to have a prototype in tproto.h */ +/* ANY new test needs to have a prototype in testhdf5.h */ #include "testhdf5.h" -static void usage(void); - -static void -usage(void) -{ - int i; - - print_func("Usage: testhdf5 [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n"); - print_func(" [-[e]x[clude] name+] \n"); - print_func(" [-o[nly] name+] \n"); - print_func(" [-b[egin] name] \n"); - print_func(" [-s[ummary]] \n"); - print_func(" [-c[leanoff]] \n"); - print_func(" [-n[ocaching]] \n"); - print_func(" [-h[elp]] \n"); - print_func("\n\n"); - print_func("verbose controls the amount of information displayed\n"); - print_func("exclude to exclude tests by name\n"); - print_func("only to name tests which should be run\n"); - print_func("begin start at the name of the test givin\n"); - print_func("summary prints a summary of test results at the end\n"); - print_func("cleanoff does not delete *.hdf files after execution of tests\n"); - print_func("nocaching do not turn on low-level DD caching\n"); - print_func("help print out this information\n"); - print_func("\n\n"); - print_func("This program currently tests the following: \n\n"); - print_func("%16s %s\n", "Name", "Description"); - print_func("%16s %s\n", "----", "-----------"); - for (i = 0; i < Index; i++) - print_func("%16s %s\n", Test[i].Name, Test[i].Description); - print_func("\n\n"); -} /* 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,...) -{ - va_list arglist; - int ret_value; - - va_start(arglist, format); - ret_value = vprintf(format, arglist); - va_end(arglist); - return (ret_value); -} - int main(int argc, char *argv[]) { - int CLLoop; /* Command Line Loop */ - int Loop, Loop1; int Summary = 0; int CleanUp = 1; - int Cache = 1; - unsigned major, minor, release; - -#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) - /* Un-buffer the stdout and stderr */ - setbuf(stderr, NULL); - setbuf(stdout, NULL); -#endif - /* - * Turn off automatic error reporting since we do it ourselves. Besides, - * half the functions this test calls are private, so automatic error - * reporting wouldn't do much good since it's triggered at the API layer. - */ -#ifdef H5_WANT_H5_V1_6_COMPAT - H5Eset_auto (NULL, NULL); -#else - H5Eset_auto (H5E_DEFAULT, NULL, NULL); -#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Initialize testing framework */ + TestInit(); /* Tests are generally arranged from least to most complexity... */ - InitTest("configure", test_configure, cleanup_configure, "Configure definitions"); - InitTest("metadata", test_metadata, cleanup_metadata, "Encode/decode metadata code"); - InitTest("tbbt", test_tbbt, NULL, "Threaded, Balanced, Binary Trees"); - InitTest("tst", test_tst, NULL, "Ternary Search Trees"); - InitTest("heap", test_heap, NULL, "Memory Heaps"); - InitTest("refstr", test_refstr, NULL, "Reference Counted Strings"); - InitTest("file", test_file, cleanup_file, "Low-Level File I/O"); - InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces"); - InitTest("attr", test_attr, cleanup_attr, "Attributes"); - InitTest("select", test_select, cleanup_select, "Selections"); - InitTest("time", test_time, cleanup_time, "Time Datatypes"); - InitTest("reference", test_reference, cleanup_reference, "References"); - InitTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes"); - InitTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings"); - InitTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration"); - InitTest("array", test_array, cleanup_array, "Array Datatypes"); - InitTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); - InitTest("misc", test_misc, cleanup_misc, "Miscellaneous"); - - Verbosity = 4; /* Default Verbosity is Low */ - H5get_libversion(&major, &minor, &release); - - print_func("\nFor help use: testhdf5 -help\n"); - print_func("Linked with hdf5 version %u.%u release %u\n", - (unsigned)major, (unsigned)minor, (unsigned)release); - 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; - printf ("Cache = %d\n", Cache); - } - - 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); -#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 */ - - MESSAGE(2, ("\n\n")) - if (num_errs) - print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs); - 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 (CleanUp && !getenv("HDF5_NOCLEANUP")) { - MESSAGE(2, ("\nCleaning Up temp files...\n\n")); + AddTest("configure", test_configure, cleanup_configure, "Configure definitions"); + AddTest("metadata", test_metadata, cleanup_metadata, "Encode/decode metadata code"); + AddTest("tbbt", test_tbbt, NULL, "Threaded, Balanced, Binary Trees"); + AddTest("tst", test_tst, NULL, "Ternary Search Trees"); + AddTest("heap", test_heap, NULL, "Memory Heaps"); + AddTest("refstr", test_refstr, NULL, "Reference Counted Strings"); + AddTest("file", test_file, cleanup_file, "Low-Level File I/O"); + AddTest("h5s", test_h5s, cleanup_h5s, "Dataspaces"); + AddTest("attr", test_attr, cleanup_attr, "Attributes"); + AddTest("select", test_select, cleanup_select, "Selections"); + AddTest("time", test_time, cleanup_time, "Time Datatypes"); + AddTest("reference", test_reference, cleanup_reference, "References"); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes"); + AddTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings"); + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration"); + AddTest("array", test_array, cleanup_array, "Array Datatypes"); + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); + AddTest("misc", test_misc, cleanup_misc, "Miscellaneous"); + + /* Display testing information */ + TestInfo(argv[0]); + + /* Parse command line arguments */ + TestParseCmdLine(argc,argv,&Summary,&CleanUp); + + /* Perform requested testing */ + PerformTests(); + + /* Display test summary, if requested */ + if (Summary) + TestSummary(); + + /* Clean up test files, if allowed */ + if (CleanUp && !getenv("HDF5_NOCLEANUP")) + TestCleanup(); - /* call individual cleanup routines in each source module */ - for (Loop = 0; Loop < Index; Loop++) - if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) - (*Test[Loop].Cleanup) (); - } return (num_errs); } /* end main() */ diff --git a/test/testhdf5.h b/test/testhdf5.h index f5e51e3..156aa78 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -16,8 +16,8 @@ * This header file contains information required for testing the HDF5 library. */ -#ifndef HDF5TEST_H -#define HDF5TEST_H +#ifndef TESTHDF5_H +#define TESTHDF5_H /* * Include required headers. This file tests internal library functions, @@ -26,7 +26,14 @@ #include "H5private.h" #include "H5Eprivate.h" -#ifndef HDF5_TEST_MASTER +/* Include generic testing header also */ +#include "h5test.h" + +#ifdef HDF5_TEST_MASTER +/* Global variables */ +int num_errs = 0; +int Verbosity = 4; /* Default Verbosity is Low */ +#else /* HDF5_TEST_MASTER */ extern int num_errs; extern int Verbosity; #endif /* HDF5_TEST_MASTER */ @@ -45,7 +52,6 @@ extern int Verbosity; num_errs++; \ H5Eprint (stdout); \ } \ - H5Eclear(); \ } while(0) #define CHECK_I(ret,where) { \ @@ -59,7 +65,6 @@ extern int Verbosity; H5Eprint (stdout); \ num_errs++; \ } \ - H5Eclear (); \ } #define CHECK_PTR(ret,where) { \ @@ -73,7 +78,6 @@ extern int Verbosity; H5Eprint (stdout); \ num_errs++; \ } \ - H5Eclear (); \ } /* Used to make certain a return value _is_ a value */ @@ -88,7 +92,6 @@ extern int Verbosity; H5Eprint (stdout); \ num_errs++; \ } \ - H5Eclear(); \ } while(0) /* Used to document process through a test and to check for errors */ @@ -97,14 +100,13 @@ extern int Verbosity; print_func(" Call to routine: %15s at line %4d in %s returned " \ "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ } \ - if (Verbosity>9) HEprint(stdout, 0); \ + if (Verbosity>9) HEEprint(stdout); \ if ((ret) == FAIL) { \ print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ num_errs++; \ } \ - H5Eclear(); \ } while(0) #else @@ -119,7 +121,6 @@ extern int Verbosity; num_errs++; \ H5Eprint (H5E_DEFAULT, stdout); \ } \ - H5Eclear(H5E_DEFAULT); \ } while(0) #define CHECK_I(ret,where) { \ @@ -133,7 +134,6 @@ extern int Verbosity; H5Eprint (H5E_DEFAULT, stdout); \ num_errs++; \ } \ - H5Eclear (H5E_DEFAULT); \ } #define CHECK_PTR(ret,where) { \ @@ -147,7 +147,6 @@ extern int Verbosity; H5Eprint (H5E_DEFAULT, stdout); \ num_errs++; \ } \ - H5Eclear (H5E_DEFAULT); \ } /* Used to make certain a return value _is_ a value */ @@ -162,7 +161,6 @@ extern int Verbosity; H5Eprint (H5E_DEFAULT, stdout); \ num_errs++; \ } \ - H5Eclear(H5E_DEFAULT); \ } while(0) /* Used to document process through a test and to check for errors */ @@ -171,14 +169,13 @@ extern int Verbosity; print_func(" Call to routine: %15s at line %4d in %s returned " \ "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ } \ - if (Verbosity>9) HEprint(stdout, 0); \ + if (Verbosity>9) H5Eprint(H5E_DEFAULT, stdout); \ if ((ret) == FAIL) { \ print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ H5Eprint (H5E_DEFAULT, stdout); \ num_errs++; \ } \ - H5Eclear(H5E_DEFAULT); \ } while(0) #endif /* H5_WANT_H5_V1_6_COMPAT */ @@ -192,8 +189,16 @@ extern int Verbosity; #define TEST_STR "Test" #define CLEAN_STR "Cleanup" -/* Prototypes for the support routines */ -int print_func(const char *,...); +/* Routines for operating on the list of tests (for the "all in one" tests) */ +H5TEST_DLL void TestUsage(void); +H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void), + void (*Cleanup) (void), const char *TheDescr); +H5TEST_DLL void TestInfo(const char *ProgName); +H5TEST_DLL void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp); +H5TEST_DLL void PerformTests(void); +H5TEST_DLL void TestSummary(void); +H5TEST_DLL void TestCleanup(void); +H5TEST_DLL void TestInit(void); /* Prototypes for the test routines */ void test_metadata(void); @@ -233,4 +238,4 @@ void cleanup_genprop(void); void cleanup_configure(void); void cleanup_misc(void); -#endif /* HDF5cleanup_H */ +#endif /* TESTHDF5_H */ diff --git a/test/ttsafe.c b/test/ttsafe.c index d7c941a..afc84e6 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /* * FILE * ttsafe.c - HDF5 threadsafe testing framework main file. @@ -40,9 +38,11 @@ #include <console.h> #endif -#include <stdarg.h> - #include "h5test.h" + +#define HDF5_TEST_MASTER + +/* ANY new test needs to have a prototype in ttsafe.h */ #include "ttsafe.h" #ifndef H5_HAVE_THREADSAFE @@ -53,76 +53,32 @@ int main(void) } #else -#define HDF5_TEST_MASTER - #define MAX_NUM_NAME 1000 #define NAME_OFFSET 6 /* offset for "name<num>" */ -/* Global variables */ -int num_errs = 0; -int Verbosity; - -/* ANY new test needs to have a prototype in tproto.h */ - -static void usage(void); - -static void usage(void) +/* pre-condition: num must be a non-negative number */ +static int num_digits(int num) { int i; - print_func("Usage: ttsafe [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n"); - print_func(" [-[e]x[clude] name+] \n"); - print_func(" [-o[nly] name+] \n"); - print_func(" [-b[egin] name] \n"); - print_func(" [-s[ummary]] \n"); - print_func(" [-c[leanoff]] \n"); - print_func(" [-n[ocaching]] \n"); - print_func(" [-h[elp]] \n"); - print_func("\n\n"); - print_func("verbose controls the amount of information displayed\n"); - print_func("exclude to exclude tests by name\n"); - print_func("only to name tests which should be run\n"); - print_func("begin start at the name of the test givin\n"); - print_func("summary prints a summary of test results at the end\n"); - print_func("cleanoff does not delete *.hdf files after execution of tests\n"); - print_func("nocaching do not turn on low-level DD caching\n"); - print_func("help print out this information\n"); - print_func("\n\n"); - print_func("This program currently tests the following: \n\n"); - print_func("%16s %s\n", "Name", "Description"); - print_func("%16s %s\n", "----", "-----------"); - - for (i = 0; i < Index; i++) - print_func("%16s %s\n", Test[i].Name, Test[i].Description); - - print_func("\n\n"); -} + if (num == 0) + return 1; -/* - * 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, ...) -{ - va_list arglist; - int ret_value; + for (i = 0; num > 0; i++) + num = num / 10; - va_start(arglist, format); - ret_value = vprintf(format, arglist); - va_end(arglist); - return ret_value; + return i; } +/* Routine to generate attribute names for numeric values */ char *gen_name(int value) { char *temp; int i, length; length = num_digits(MAX_NUM_NAME - 1); - temp = (char *)malloc((NAME_OFFSET + length + 1) * sizeof(char)); - temp = strcpy(temp, "attrib"); + temp = (char *)HDmalloc((NAME_OFFSET + length + 1) * sizeof(char)); + temp = HDstrcpy(temp, "attrib"); temp[NAME_OFFSET + length] = '\0'; for (i = length - 1; i >= 0; i--) { @@ -133,190 +89,35 @@ char *gen_name(int value) return temp; } -/* pre-condition: num must be a non-negative number */ -int num_digits(int num) -{ - int i; - - if (num == 0) - return 1; - - for (i = 0; num > 0; i++) - num = num / 10; - - return i; -} - int main(int argc, char *argv[]) { - int CLLoop; /* Command Line Loop */ - int Loop, Loop1, Summary = 0, CleanUp = 1, Cache = 1; - unsigned major, minor, release; + int Summary = 0, CleanUp = 1; -#if defined __MWERKS__ - argc = ccommand(&argv); -#endif - -#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) - /* Un-buffer the stdout and stderr */ - setbuf(stderr, NULL); - setbuf(stdout, NULL); -#endif - - /* - * Turn off automatic error reporting since we do it ourselves. - * Besides, half the functions this test calls are private, so - * automatic error reporting wouldn't do much good since it's - * triggered at the API layer. - */ -#ifdef H5_WANT_H5_V1_6_COMPAT - H5Eset_auto (NULL, NULL); -#else /*H5_WANT_H5_V1_6_COMPAT*/ - H5Eset_auto (H5E_DEFAULT, NULL, NULL); -#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Initialize testing framework */ + TestInit(); /* Tests are generally arranged from least to most complexity... */ - InitTest("dcreate", tts_dcreate, cleanup_dcreate, - "multi-dataset creation"); - InitTest("error", tts_error, cleanup_error, - "per-thread error stacks"); - InitTest("cancel", tts_cancel, cleanup_cancel, - "thread cancellation safety test"); - InitTest("acreate", tts_acreate, cleanup_acreate, - "multi-attribute creation"); - - Verbosity = 4; /* Default Verbosity is Low */ - H5get_libversion(&major, &minor, &release); - - print_func("\nFor help use: ttsafe -help\n"); - print_func("Linked with hdf5 version %u.%u release %u\n", - (unsigned)major, (unsigned)minor, (unsigned)release); - - 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; + AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation"); + AddTest("error", tts_error, cleanup_error, "per-thread error stacks"); + AddTest("cancel", tts_cancel, cleanup_cancel, "thread cancellation safety test"); + AddTest("acreate", tts_acreate, cleanup_acreate, "multi-attribute creation"); - if (argc > CLLoop && - (HDstrcmp(argv[CLLoop], "-help") == 0 || - HDstrcmp(argv[CLLoop], "-h") == 0)) { - usage(); - exit(0); - } + /* Display testing information */ + TestInfo(argv[0]); - if (argc > CLLoop && - (HDstrcmp(argv[CLLoop], "-cleanoff") == 0 || - HDstrcmp(argv[CLLoop], "-c") == 0)) - CleanUp = 0; + /* Parse command line arguments */ + TestParseCmdLine(argc,argv,&Summary,&CleanUp); - if (argc > CLLoop && - (HDstrcmp(argv[CLLoop], "-nocache") == 0 || - HDstrcmp(argv[CLLoop], "-n") == 0)) { - Cache = 0; - print_func("Cache = %d\n", Cache); - } + /* Perform requested testing */ + PerformTests(); - if (argc > CLLoop + 1 && - (HDstrcmp(argv[CLLoop], "-exclude") == 0 || - HDstrcmp(argv[CLLoop], "-x") == 0)) - for (Loop = CLLoop + 1; Loop < argc && argv[Loop][0] != '-'; Loop++) - for (Loop1 = 0; Loop1 < Index; Loop1++) - if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) - Test[Loop1].SkipFlag = 1; + /* Display test summary, if requested */ + if (Summary) + TestSummary(); - if (argc > CLLoop + 1 && - (HDstrcmp(argv[CLLoop], "-begin") == 0 || - HDstrcmp(argv[CLLoop], "-b") == 0)) - for (Loop = CLLoop + 1; Loop < argc && argv[Loop][0] != '-'; Loop++) - 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; - } - - if (argc > CLLoop + 1 && - (HDstrcmp(argv[CLLoop], "-only") == 0 || - HDstrcmp(argv[CLLoop], "-o") == 0)) { - for (Loop = 0; Loop < Index; Loop++) - Test[Loop].SkipFlag = 1; - - for (Loop = CLLoop + 1; Loop < argc && argv[Loop][0] != '-'; Loop++) - for (Loop1 = 0; Loop1 < Index; Loop1++) - if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) - Test[Loop1].SkipFlag = 0; - } - } /* end for */ - -#ifdef NOT_YET - 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)); - } - - MESSAGE(2, ("\n\n")) - - if (num_errs) - print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs); - else - print_func("All threadsafe 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); - } - - print_func("\n\n"); - } - - if (CleanUp && !getenv("HDF5_NOCLEANUP")) { - MESSAGE(2, ("\nCleaning Up temp files...\n\n")); - - /* call individual cleanup routines in each source module */ - for (Loop = 0; Loop < Index; Loop++) - if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) - Test[Loop].Cleanup(); - } + /* Clean up test files, if allowed */ + if (CleanUp && !getenv("HDF5_NOCLEANUP")) + TestCleanup(); return num_errs; } /* end main() */ diff --git a/test/ttsafe.h b/test/ttsafe.h index ce763db..ace54b7 100644 --- a/test/ttsafe.h +++ b/test/ttsafe.h @@ -12,14 +12,12 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /* * This header file contains information required for testing the HDF5 library. */ -#ifndef HDF5TEST_H -#define HDF5TEST_H +#ifndef TTSAFE_H +#define TTSAFE_H #include <string.h> @@ -30,102 +28,14 @@ #include "hdf5.h" #include "H5private.h" #include "H5Eprivate.h" +#include "testhdf5.h" #ifdef H5_HAVE_THREADSAFE /* Include pthread library for threadsafe tests */ #include <pthread.h> -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 */ -#define CHECK(ret, val, where) do { \ - 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 == val) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", where, (long)ret, (int)__LINE__, __FILE__); \ - num_errs++; \ - H5Eprint (stdout); \ - } \ - H5Eclear(H5E_DEFAULT); \ -} while(0) - -#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) { \ - print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ - (where), (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint (stdout); \ - num_errs++; \ - } \ - H5Eclear(H5E_DEFAULT); \ -} - -#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)) { \ - print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ - (where), (int)__LINE__, __FILE__); \ - H5Eprint (stdout); \ - num_errs++; \ - } \ - H5Eclear(H5E_DEFAULT); \ -} - -/* Used to make certain a return value _is_ a value */ -#define VERIFY(x, val, where) do { \ - if (Verbosity>9) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", where, (int)__LINE__, __FILE__, (long)x); \ - } \ - if (x != val) { \ - print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d " \ - "in %s\n", where, (long)x, (int)__LINE__, __FILE__); \ - H5Eprint (stdout); \ - num_errs++; \ - } \ - H5Eclear(H5E_DEFAULT); \ -} while(0) - -/* Used to document process through a test and to check for errors */ -#define RESULT(ret,func) do { \ - if (Verbosity>8) { \ - print_func(" Call to routine: %15s at line %4d in %s returned " \ - "%ld\n", func, (int)__LINE__, __FILE__, (long)ret); \ - } \ - if (Verbosity>9) HEprint(stdout, 0); \ - if (ret == FAIL) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", func, (long)ret, (int)__LINE__, __FILE__); \ - H5Eprint (stdout); \ - num_errs++; \ - } \ - H5Eclear(H5E_DEFAULT); \ -} while(0) - -/* Used to document process through a test */ -#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" - /* Prototypes for the support routines */ -int print_func(const char *,...); extern char* gen_name(int); -extern int num_digits(int); /* Prototypes for the test routines */ void tts_dcreate(void); @@ -140,4 +50,4 @@ void cleanup_cancel(void); void cleanup_acreate(void); #endif /* H5_HAVE_THREADSAFE */ -#endif /* HDF5_TESTH */ +#endif /* TTSAFE_H */ |