summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-01-06 02:49:01 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-01-06 02:49:01 (GMT)
commit83c7a8dfaa7a83b462a92f8b449ed73a92d26610 (patch)
tree124bceadf0b6d04fc56c13d587dc6335139d121c /test
parent31dc73ffcc4d8d5f5f91c0087b13eaed85afd732 (diff)
downloadhdf5-83c7a8dfaa7a83b462a92f8b449ed73a92d26610.zip
hdf5-83c7a8dfaa7a83b462a92f8b449ed73a92d26610.tar.gz
hdf5-83c7a8dfaa7a83b462a92f8b449ed73a92d26610.tar.bz2
[svn-r8019] Purpose:
Feature Description: Moved the InitTest from individual tests (testhdf5.c, ttsafe.c) to libh5test (h5test.*) so that it can be used by other tests too. Platforms tested: "h5committested"
Diffstat (limited to 'test')
-rw-r--r--test/h5test.c30
-rw-r--r--test/h5test.h17
-rw-r--r--test/testhdf5.c30
-rw-r--r--test/ttsafe.c34
4 files changed, 50 insertions, 61 deletions
diff --git a/test/h5test.c b/test/h5test.c
index ccee874..640f4b2 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -89,6 +89,14 @@ 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;
+
/*-------------------------------------------------------------------------
* Function: h5_errors
@@ -778,3 +786,25 @@ 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("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++;
+}
+
+
diff --git a/test/h5test.h b/test/h5test.h
index 2cdf217..df73952 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 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" {
@@ -75,6 +90,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 c866cf6..ffbdd9f 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -38,12 +38,10 @@
*/
#include <stdarg.h>
+#include "h5test.h"
-#define MAXNUMOFTESTS 30
#define HDF5_TEST_MASTER
-/* Internal Variables */
-static int Index = 0;
/* Global variables */
int num_errs = 0;
@@ -52,35 +50,9 @@ 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];
-
-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 94e1209..9c1b708 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -42,6 +42,7 @@
#include <stdarg.h>
+#include "h5test.h"
#include "ttsafe.h"
#ifndef H5_HAVE_THREADSAFE
@@ -52,49 +53,18 @@ int main(void)
}
#else
-#define MAXNUMOFTESTS 50
#define HDF5_TEST_MASTER
#define MAX_NUM_NAME 1000
#define NAME_OFFSET 6 /* offset for "name<num>" */
-/* 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);
-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)
{