From dc458e5f6f7f4ea69644653aa3f348d2f6eb9d53 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 5 Jan 2004 16:58:37 -0500 Subject: [svn-r8017] Purpose: Code reorg. Description: Move the InitTest() from individual tests (testhdf5 and ttsafe) to libh5test (h5test.c) so that it can be shared among all tests. Platforms tested: Only tested in Eirene via serial with thread-safe enabled. No other platforms test since this is pretty trivial. --- test/h5test.c | 20 ++++++++++++++++++++ test/h5test.h | 17 +++++++++++++++++ test/testhdf5.c | 30 +++--------------------------- test/ttsafe.c | 36 ++++-------------------------------- 4 files changed, 44 insertions(+), 59 deletions(-) diff --git a/test/h5test.c b/test/h5test.c index a361bcc..87a8a0b 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -796,3 +796,23 @@ 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. + */ +void +InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr) +{ + if (Index >= MAXNUMOFTESTS) { + printf("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n"); + 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++; +} + diff --git a/test/h5test.h b/test/h5test.h index 5084c6f..acaa197 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -62,6 +62,21 @@ 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 50 +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" { @@ -74,6 +89,8 @@ 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); #ifdef H5_HAVE_PARALLEL int h5_set_info_object(void); void h5_dump_info_object(MPI_Info info); diff --git a/test/testhdf5.c b/test/testhdf5.c index 1fd2f34..58eacbe 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -38,12 +38,11 @@ */ #include +#include "h5test.h" #define MAXNUMOFTESTS 30 #define HDF5_TEST_MASTER -/* Internal Variables */ -static int Index = 0; /* Global variables */ int num_errs = 0; @@ -52,35 +51,12 @@ int Verbosity; /* ANY new test needs to have a prototype in tproto.h */ #include "testhdf5.h" -struct TestStruct { - int NumErrors; - char Description[64]; - int SkipFlag; - char Name[16]; - void (*Call) (void); - void (*Cleanup) (void); -} Test[MAXNUMOFTESTS]; +struct TestStruct Test[MAXNUMOFTESTS]; +int Index = 0; -static void InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr); static void usage(void); static void -InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr) -{ - if (Index >= MAXNUMOFTESTS) { - print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n"); - 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++; -} - -static void usage(void) { int i; diff --git a/test/ttsafe.c b/test/ttsafe.c index 8d95d3e..276b757 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -42,6 +42,7 @@ #include +#include "h5test.h" #include "ttsafe.h" #ifndef H5_HAVE_THREADSAFE @@ -52,49 +53,20 @@ int main(void) } #else -#define MAXNUMOFTESTS 50 #define HDF5_TEST_MASTER #define MAX_NUM_NAME 1000 #define NAME_OFFSET 6 /* offset for "name" */ -/* Internal Variables */ -static int Index = 0; - /* Global variables */ int num_errs = 0; int Verbosity; /* ANY new test needs to have a prototype in tproto.h */ -struct TestStruct { - int NumErrors; - char Description[64]; - int SkipFlag; - char Name[16]; - void (*Call)(void); - void (*Cleanup)(void); -} Test[MAXNUMOFTESTS]; - -static void InitTest(const char *TheName, void (*TheCall) (void), - void (*Cleanup) (void), const char *TheDescr); -static void usage(void); +TestStruct Test[MAXNUMOFTESTS]; +int Index = 0; -static void InitTest(const char *TheName, void (*TheCall) (void), - void (*Cleanup) (void), const char *TheDescr) -{ - if (Index >= MAXNUMOFTESTS) { - print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n"); - exit(-1); - } - - 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++; -} +static void usage(void); static void usage(void) { -- cgit v0.12