summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--c++/test/testhdf5.cpp11
-rw-r--r--test/h5test.h6
-rw-r--r--test/testframe.c71
-rw-r--r--test/testhdf5.c12
-rw-r--r--test/ttsafe.c10
-rw-r--r--testpar/t_mpi.c19
-rw-r--r--testpar/testphdf5.c12
7 files changed, 91 insertions, 50 deletions
diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp
index df97485..b93689b 100644
--- a/c++/test/testhdf5.cpp
+++ b/c++/test/testhdf5.cpp
@@ -47,11 +47,8 @@ using namespace H5;
int
main(int argc, char *argv[])
{
- int Summary = 0;
- int CleanUp = 1;
-
/* Initialize testing framework */
- TestInit();
+ TestInit(argv[0], NULL, NULL);
// testing file creation and opening in tfile.cpp
AddTest("file", test_file, cleanup_file, "File I/O Operations", NULL);
@@ -74,17 +71,17 @@ Comment out tests that are not done yet */
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/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();
diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c
index 43eafea..2d5da66 100644
--- a/testpar/t_mpi.c
+++ b/testpar/t_mpi.c
@@ -54,7 +54,7 @@ test_mpio_overlap_writes(char *filename)
MPI_File fh;
int i;
int vrfyerrs;
- char buf[4093]; /* use some prime number for size */
+ unsigned char buf[4093]; /* use some prime number for size */
int bufsize = sizeof(buf);
MPI_Offset stride;
MPI_Offset mpi_off;
@@ -97,7 +97,7 @@ test_mpio_overlap_writes(char *filename)
/* set data to some trivial pattern for easy verification */
for (i=0; i<stride; i++)
- buf[i] = (char)(mpi_off+i);
+ buf[i] = (unsigned char)(mpi_off+i);
mrc = MPI_File_write_at(fh, mpi_off, buf, (int)stride, MPI_BYTE,
&mpi_stat);
VRFY((mrc==MPI_SUCCESS), "");
@@ -143,12 +143,13 @@ test_mpio_overlap_writes(char *filename)
VRFY((mrc==MPI_SUCCESS), "");
vrfyerrs=0;
for (i=0; i<stride; i++){
- char expected;
- expected = (char)(mpi_off+i);
- if ((buf[i] != expected) &&
- (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED))
- printf("proc %d: found data error at [%ld], expect %d, got %d\n",
+ unsigned char expected;
+ expected = (unsigned char)(mpi_off+i);
+ if ((expected != buf[i]) &&
+ (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) {
+ printf("proc %d: found data error at [%ld], expect %u, got %u\n",
mpi_rank, (long)(mpi_off+i), expected, buf[i]);
+ }
}
if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED)
printf("proc %d: [more errors ...]\n", mpi_rank);
@@ -341,9 +342,10 @@ test_mpio_gb_file(char *filename)
vrfyerrs=0;
for (j=0; j<MB; j++){
if ((*(buf+j) != expected) &&
- (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED))
+ (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)){
printf("proc %d: found data error at [%ld+%d], expect %d, got %d\n",
mpi_rank, (long)mpi_off, j, expected, *(buf+j));
+ }
}
if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED)
printf("proc %d: [more errors ...]\n", mpi_rank);
@@ -669,6 +671,7 @@ main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
H5open();
+ TestInit(argv[0], NULL, parse_options);
if (parse_options(argc, argv) != 0){
if (MAINPROCESS)
usage();
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index 106e4ba..3578843 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -121,7 +121,7 @@ int MPI_Init(int *argc, char ***argv)
static void
usage(void)
{
- printf("Usage: testphdf5 [-r] [-w] [-v<verbosity>] [-m<n_datasets>] [-n<n_groups>] "
+ printf(" [-r] [-w] [-v<verbosity>] [-m<n_datasets>] [-n<n_groups>] "
"[-o] [-f <prefix>] [-d <dim0> <dim1>]\n");
printf("\t-r\t\tno read test\n");
printf("\t-w\t\tno write test\n");
@@ -368,8 +368,6 @@ int main(int argc, char **argv)
int mpi_size, mpi_rank; /* mpi variables */
H5Ptest_param_t ndsets_params, ngroups_params;
H5Ptest_param_t collngroups_params;
- int Summary = 0;
- int CleanUp = 1;
/* Un-buffer the stdout and stderr */
setbuf(stderr, NULL);
@@ -388,7 +386,7 @@ int main(int argc, char **argv)
h5_show_hostname();
/* Initialize testing framework */
- TestInit();
+ TestInit(argv[0], usage, parse_options);
/* Tests are generally arranged from least to most complexity... */
AddTest("mpio_dup", test_fapl_mpio_dup, NULL,
@@ -476,7 +474,7 @@ int main(int argc, char **argv)
H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL);
/* Parse command line arguments */
- TestParseCmdLine(argc, argv, &Summary, &CleanUp, parse_options);
+ TestParseCmdLine(argc, argv);
/*
if (parse_options(argc, argv) != 0){
@@ -501,11 +499,11 @@ int main(int argc, char **argv)
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();
nerrors += GetTestNumErrs();