summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-08-19 06:32:47 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-08-19 06:32:47 (GMT)
commit3c596787759d86e8f672f51e8675e93dc3f6d6dc (patch)
tree82869255fc6b1a25161147e0194cde2c71746b06 /test
parent3fe6ec11413f24d5dfcab5ac050c9e7312c3fd9d (diff)
downloadhdf5-3c596787759d86e8f672f51e8675e93dc3f6d6dc.zip
hdf5-3c596787759d86e8f672f51e8675e93dc3f6d6dc.tar.gz
hdf5-3c596787759d86e8f672f51e8675e93dc3f6d6dc.tar.bz2
[svn-r9115] Purpose:
feature Description: Another revamp of the test interface. TestInit: is used to register Test Program name, test program specific Usage and option parsing routines. TestUsage: will invoke extra usage routine if provided. TestParseCmdLine: will invoke extra option parsing routine if provided. GetTestSummary() and GetTestCleanup() replaces the previous Summary and CleanUp arguments of TestParseCmdLine. test/testhdf5, test/ttsafe.c, testpar/t_mpi.c, testpar/testphdf5.c: All have been updated to use the new Test Routines. testpar/t_mpi.c: Also a fix of a compiler optimization bug when pgcc in Linux is used to compile it. Changed buf[] and expected to unsigned char type to avoid a bug that failed to do sign-extension. Platforms tested: "h5committested" Also tested thread-safe option in eirene.
Diffstat (limited to 'test')
-rw-r--r--test/h5test.h6
-rw-r--r--test/testframe.c71
-rw-r--r--test/testhdf5.c12
-rw-r--r--test/ttsafe.c10
4 files changed, 71 insertions, 28 deletions
diff --git a/test/h5test.h b/test/h5test.h
index 6713b92..886a681 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -124,13 +124,15 @@ H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void),
void (*Cleanup) (void), const char *TheDescr,
const void *Parameters);
H5TEST_DLL void TestInfo(const char *ProgName);
-H5TEST_DLL void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*extra_parse)(int ac, char *av[]));
+H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]);
H5TEST_DLL void PerformTests(void);
H5TEST_DLL void TestSummary(void);
H5TEST_DLL void TestCleanup(void);
-H5TEST_DLL void TestInit(void);
+H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]));
H5TEST_DLL int GetTestVerbosity(void);
H5TEST_DLL int SetTestVerbosity(int newval);
+H5TEST_DLL int GetTestSummary(void);
+H5TEST_DLL int GetTestCleanup(void);
H5TEST_DLL void ParseTestVerbosity(char *argv);
H5TEST_DLL int GetTestNumErrs(void);
H5TEST_DLL const void *GetTestParameters(void);
diff --git a/test/testframe.c b/test/testframe.c
index ff87ffd..01829c3 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -45,9 +45,14 @@ typedef struct TestStruct {
*/
static int num_errs = 0; /* Total number of errors during testing */
static int Verbosity = VERBO_DEF; /* Default Verbosity is Low */
+static int Summary = 0; /* Show test summary. Default is no. */
+static int CleanUp = 1; /* Do cleanup or not. Default is yes. */
static TestStruct Test[MAXNUMOFTESTS];
static int Index = 0;
static const void *Test_parameters = NULL;
+static const char *TestProgName = NULL;
+static void (*TestPrivateUsage)(void) = NULL;
+static int (*TestPrivateParser)(int ac, char *av[]) = NULL;
/*
@@ -103,8 +108,19 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con
/*
* Initialize testing framework
+ *
+ * ProgName: Name of test program.
+ * private_usage: Optional routine provided by test program to print the
+ * private portion of usage page. Default to NULL which means none is
+ * provided.
+ * private_parser: Optional routine provided by test program to parse the
+ * private options. Default to NULL which means none is provided.
+ *
+ * Modifications:
+ * Albert Cheng 2004/08/17
+ * Added the ProgName, private_usage and private_parser arguments.
*/
-void TestInit(void)
+void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]))
{
#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C)
/* Un-buffer the stdout and stderr */
@@ -123,17 +139,30 @@ void TestInit(void)
H5Eset_auto (H5E_DEFAULT, NULL, NULL);
#endif /* H5_WANT_H5_V1_6_COMPAT */
+ /*
+ * Record the program name and private routines if provided.
+ */
+ TestProgName = ProgName;
+ if (NULL != private_usage)
+ TestPrivateUsage = private_usage;
+ if (NULL != private_parser)
+ TestPrivateParser = private_parser;
}
/*
* Print test usage.
+ * First print the common test options, then the extra options if provided.
+ *
+ * Modification:
+ * 2004/08/18 Albert Cheng. Add TestPrivateUsage feature.
*/
void TestUsage(void)
{
int i;
- print_func("Usage: ttsafe [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] \n");
+ print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
+ TestProgName, (TestPrivateUsage ? "<extra options>" : ""));
print_func(" [-[e]x[clude] name+] \n");
print_func(" [-o[nly] name+] \n");
print_func(" [-b[egin] name] \n");
@@ -148,6 +177,10 @@ void TestUsage(void)
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");
+ if (TestPrivateUsage){
+ print_func("\nExtra options\n");
+ TestPrivateUsage();
+ }
print_func("\n\n");
print_func("This program currently tests the following: \n\n");
print_func("%16s %s\n", "Name", "Description");
@@ -177,15 +210,11 @@ void TestInfo(const char *ProgName)
/*
* Parse command line information.
* argc, argv: the usual command line argument count and strings
- * Summary: Return if summary is desired. Default no.
- * CleanUp: Return if Cleanup is desired. Default yes.
- * extra_parse: Extra Parse function provided by individual application.
- * NULL means no extra parsing needed.
*
* Modification:
- * 2004/08/12 Albert Cheng. Add extra_parse feature.
+ * 2004/08/18 Albert Cheng. Add extra_parse feature.
*/
-void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*extra_parse)(int ac, char *av[]))
+void TestParseCmdLine(int argc, char *argv[])
{
while (argv++, --argc > 0){
if ((HDstrcmp(*argv, "-verbose") == 0) ||
@@ -233,13 +262,13 @@ void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*
}
}
else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0))
- *Summary = 1;
+ Summary = 1;
else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) {
TestUsage();
exit(0);
}
else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0))
- *CleanUp = 0;
+ CleanUp = 0;
else {
/* non-standard option. Break out. */
break;
@@ -248,8 +277,8 @@ void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*
}
/* Call extra parsing function if provided. */
- if (NULL != extra_parse){
- extra_parse(argc+1, argv-1);
+ if (NULL != TestPrivateParser){
+ TestPrivateParser(argc+1, argv-1);
}
}
@@ -345,6 +374,24 @@ int SetTestVerbosity(int newval)
}
/*
+ * Retrieve Summary request value.
+ * 0 means no summary, 1 means yes.
+ */
+int GetTestSummary(void)
+{
+ return(Summary);
+}
+
+/*
+ * Retrieve Cleanup request value.
+ * 0 means no Cleanup, 1 means yes.
+ */
+int GetTestCleanup(void)
+{
+ return(CleanUp);
+}
+
+/*
* Parse an argument string for verbosity level and set it.
*/
void ParseTestVerbosity(char *argv)
diff --git a/test/testhdf5.c b/test/testhdf5.c
index b0408af..813cc87 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -39,11 +39,8 @@
int
main(int argc, char *argv[])
{
- int Summary = 0;
- int CleanUp = 1;
-
/* Initialize testing framework */
- TestInit();
+ TestInit(argv[0], NULL, NULL);
/* Tests are generally arranged from least to most complexity... */
AddTest("configure", test_configure, cleanup_configure, "Configure definitions", NULL);
@@ -64,23 +61,22 @@ main(int argc, char *argv[])
AddTest("array", test_array, cleanup_array, "Array Datatypes", NULL);
AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL);
AddTest("misc", test_misc, cleanup_misc, "Miscellaneous", NULL);
- AddTest("id", test_ids, NULL, "Public ID Functions", NULL);
/* Display testing information */
TestInfo(argv[0]);
/* Parse command line arguments */
- TestParseCmdLine(argc,argv,&Summary,&CleanUp,NULL);
+ TestParseCmdLine(argc,argv);
/* Perform requested testing */
PerformTests();
/* Display test summary, if requested */
- if (Summary)
+ if (GetTestSummary())
TestSummary();
/* Clean up test files, if allowed */
- if (CleanUp && !getenv("HDF5_NOCLEANUP"))
+ if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
TestCleanup();
return (GetTestNumErrs());
diff --git a/test/ttsafe.c b/test/ttsafe.c
index 0a4bb34..0e24bf3 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -85,10 +85,8 @@ char *gen_name(int value)
int main(int argc, char *argv[])
{
- int Summary = 0, CleanUp = 1;
-
/* Initialize testing framework */
- TestInit();
+ TestInit(argv[0], NULL, NULL);
/* Tests are generally arranged from least to most complexity... */
AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation", NULL);
@@ -100,17 +98,17 @@ int main(int argc, char *argv[])
TestInfo(argv[0]);
/* Parse command line arguments */
- TestParseCmdLine(argc,argv,&Summary,&CleanUp,NULL);
+ TestParseCmdLine(argc,argv);
/* Perform requested testing */
PerformTests();
/* Display test summary, if requested */
- if (Summary)
+ if (GetTestSummary())
TestSummary();
/* Clean up test files, if allowed */
- if (CleanUp && !getenv("HDF5_NOCLEANUP"))
+ if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
TestCleanup();
return GetTestNumErrs();