summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-08-19 06:34:59 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-08-19 06:34:59 (GMT)
commit19cb3b5ae784c804efbc9a730bebb710845e4602 (patch)
tree02951364f326db62aa92e07ffd7285febd6ecbad
parentd3e91f26898ea8de856bb82e8d9643dccae0d138 (diff)
downloadhdf5-19cb3b5ae784c804efbc9a730bebb710845e4602.zip
hdf5-19cb3b5ae784c804efbc9a730bebb710845e4602.tar.gz
hdf5-19cb3b5ae784c804efbc9a730bebb710845e4602.tar.bz2
[svn-r9116] 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.c72
-rw-r--r--test/testhdf5.c11
-rw-r--r--test/ttsafe.c10
-rw-r--r--testpar/t_mpi.c19
-rw-r--r--testpar/testphdf5.c26
7 files changed, 100 insertions, 55 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 2164d11..cebb558 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 */
@@ -118,17 +134,31 @@ void TestInit(void)
* reporting wouldn't do much good since it's triggered at the API layer.
*/
H5Eset_auto (NULL, NULL);
+
+ /*
+ * 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");
@@ -143,6 +173,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");
@@ -172,15 +206,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) ||
@@ -228,13 +258,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;
@@ -243,8 +273,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);
}
}
@@ -340,6 +370,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 e055f56..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);
@@ -69,17 +66,17 @@ 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/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 bc37cb9..0a99b02 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -119,7 +119,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");
@@ -367,8 +367,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);
@@ -387,7 +385,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,
@@ -447,13 +445,15 @@ int main(int argc, char **argv)
if(mpi_size > 64) {
- if(MAINPROCESS) {
- printf("The collective chunk IO test hasn't been tested for the number of process greater than 64\n");
- printf("Please try with the number of process no greater than 64\n");
- printf("All collective chunk tests will be skipped \n");
- }
+ if(MAINPROCESS) {
+ printf("Collective chunk IO tests haven't been tested \n");
+ printf(" for the number of process greater than 64.\n");
+ printf("Please try with the number of process \n");
+ printf(" no greater than 64 for collective chunk IO test.\n");
+ printf("Collective chunk tests will be skipped \n");
+ }
}
- else {
+ else {
AddTest("coll_chunked1", coll_chunk1,NULL,
"simple collective chunk io",filenames[9]);
AddTest("coll_chunked2", coll_chunk2,NULL,
@@ -472,7 +472,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){
@@ -497,11 +497,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();