summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2004-08-13 21:53:26 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2004-08-13 21:53:26 (GMT)
commit60412f524d06178ebd1ad7ba7ac720a1cc061888 (patch)
tree927d45fa691eec79a929ff30469e3cbeb468864b
parent188a2cfdc741ecfd137307244e089dc5d215cbde (diff)
downloadhdf5-60412f524d06178ebd1ad7ba7ac720a1cc061888.zip
hdf5-60412f524d06178ebd1ad7ba7ac720a1cc061888.tar.gz
hdf5-60412f524d06178ebd1ad7ba7ac720a1cc061888.tar.bz2
[svn-r9079] Purpose:
Feature Description: Changed TestParseCmdLine to accept an optional extra_parse() function provided by indidivual test application. Extra_parse() can handle extra options special to that test application. Updated testhdf5.c to use the new syntax of TestParseCmdLine(). Platforms tested: On eirene both serial and parallel.
-rw-r--r--test/h5test.h2
-rw-r--r--test/testframe.c121
-rw-r--r--test/testhdf5.c2
3 files changed, 75 insertions, 50 deletions
diff --git a/test/h5test.h b/test/h5test.h
index 396be2b..6713b92 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -124,7 +124,7 @@ 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);
+H5TEST_DLL void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*extra_parse)(int ac, char *av[]));
H5TEST_DLL void PerformTests(void);
H5TEST_DLL void TestSummary(void);
H5TEST_DLL void TestCleanup(void);
diff --git a/test/testframe.c b/test/testframe.c
index a8b4d00..ff87ffd 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -175,60 +175,82 @@ void TestInfo(const char *ProgName)
/*
- * Parse command line information
+ * 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.
*/
-void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp)
+void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp, int (*extra_parse)(int ac, char *av[]))
{
- int CLLoop; /* Command Line Loop */
- int Loop;
-
- for (CLLoop = 1; CLLoop < argc; CLLoop++) {
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
- (HDstrcmp(argv[CLLoop], "-v") == 0))) {
- ParseTestVerbosity(argv[CLLoop + 1]);
- } /* end if */
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
- (HDstrcmp(argv[CLLoop], "-s") == 0)))
+ while (argv++, --argc > 0){
+ if ((HDstrcmp(*argv, "-verbose") == 0) ||
+ (HDstrcmp(*argv, "-v") == 0)) {
+ if (argc > 0){
+ --argc; ++argv;
+ ParseTestVerbosity(*argv);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((HDstrcmp(*argv, "-exclude") == 0) ||
+ (HDstrcmp(*argv, "-x") == 0))) {
+ if (argc > 0){
+ --argc; ++argv;
+ SetTest(*argv, SKIPTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((HDstrcmp(*argv, "-begin") == 0) ||
+ (HDstrcmp(*argv, "-b") == 0))) {
+ if (argc > 0){
+ --argc; ++argv;
+ SetTest(*argv, BEGINTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if (((HDstrcmp(*argv, "-only") == 0) ||
+ (HDstrcmp(*argv, "-o") == 0))) {
+ if (argc > 0){
+ int Loop;
+ --argc; ++argv;
+ /* Skip all tests, then activate only one. */
+ for (Loop = 0; Loop < Index; Loop++)
+ Test[Loop].SkipFlag = 1;
+ SetTest(*argv, ONLYTEST);
+ }else{
+ TestUsage();
+ exit(1);
+ }
+ }
+ else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0))
*Summary = 1;
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
- (HDstrcmp(argv[CLLoop], "-h") == 0))) {
+ else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) {
TestUsage();
exit(0);
}
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
- (HDstrcmp(argv[CLLoop], "-c") == 0)))
+ else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0))
*CleanUp = 0;
+ else {
+ /* non-standard option. Break out. */
+ break;
+ }
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
- (HDstrcmp(argv[CLLoop], "-x") == 0))) {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-')) {
- SetTest(argv[Loop], SKIPTEST);
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
- (HDstrcmp(argv[CLLoop], "-b") == 0))) {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-')) {
- SetTest(argv[Loop], BEGINTEST);
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
- (HDstrcmp(argv[CLLoop], "-o") == 0))) {
- for (Loop = 0; Loop < Index; Loop++)
- Test[Loop].SkipFlag = 1;
-
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-')) {
- SetTest(argv[Loop], ONLYTEST);
- Loop++;
- } /* end while */
- } /* end if */
- } /* end for */
+ }
+ /* Call extra parsing function if provided. */
+ if (NULL != extra_parse){
+ extra_parse(argc+1, argv-1);
+ }
}
@@ -241,7 +263,7 @@ void PerformTests(void)
for (Loop = 0; Loop < Index; Loop++)
if (Test[Loop].SkipFlag) {
- MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
+ MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
} else {
MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
MESSAGE(5, ("===============================================\n"));
@@ -389,7 +411,6 @@ TestErrPrintf(const char *format, ...)
void SetTest(const char *testname, int action)
{
int Loop;
-
switch (action){
case SKIPTEST:
for (Loop = 0; Loop < Index; Loop++)
@@ -402,8 +423,11 @@ void SetTest(const char *testname, int action)
for (Loop = 0; Loop < Index; Loop++) {
if (HDstrcmp(testname, Test[Loop].Name) != 0)
Test[Loop].SkipFlag = 1;
- else
+ else{
+ /* Found it. Set it to run. Done. */
+ Test[Loop].SkipFlag = 0;
break;
+ }
}
break;
case ONLYTEST:
@@ -411,6 +435,7 @@ void SetTest(const char *testname, int action)
if (HDstrcmp(testname, Test[Loop].Name) != 0)
Test[Loop].SkipFlag = 1;
else {
+ /* Found it. Set it to run. Break to skip the rest. */
Test[Loop].SkipFlag = 0;
break;
}
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 38193fc..b0408af 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -70,7 +70,7 @@ main(int argc, char *argv[])
TestInfo(argv[0]);
/* Parse command line arguments */
- TestParseCmdLine(argc,argv,&Summary,&CleanUp);
+ TestParseCmdLine(argc,argv,&Summary,&CleanUp,NULL);
/* Perform requested testing */
PerformTests();