summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c++/test/testhdf5.cpp3
-rw-r--r--test/h5test.h1
-rw-r--r--test/testframe.c57
-rw-r--r--test/testhdf5.c3
-rw-r--r--test/ttsafe.c3
-rw-r--r--testpar/t_shapesame.c6
-rw-r--r--testpar/testphdf5.c4
7 files changed, 59 insertions, 18 deletions
diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp
index b3415f1..b17d942 100644
--- a/c++/test/testhdf5.cpp
+++ b/c++/test/testhdf5.cpp
@@ -132,6 +132,9 @@ Comment out tests that are not done yet */
if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
TestCleanup();
+ /* Release test infrastructure */
+ TestShutdown();
+
return (GetTestNumErrs());
}
diff --git a/test/h5test.h b/test/h5test.h
index 575497b..6806e8f 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -166,6 +166,7 @@ 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 TestShutdown(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);
diff --git a/test/testframe.c b/test/testframe.c
index df5abe0..c2db235 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -26,9 +26,8 @@
/*
* Definitions for the testing structure.
*/
-#define MAXNUMOFTESTS 24
#define MAXTESTNAME 16
-#define MAXTESTDESC 32
+#define MAXTESTDESC 64
typedef struct TestStruct {
int NumErrors;
@@ -49,8 +48,9 @@ int TestVerbosity = 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 int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */
-static TestStruct Test[MAXNUMOFTESTS];
-static int Index = 0;
+static TestStruct *Test = NULL; /* Array of tests */
+static unsigned TestAlloc = 0; /* Size of the Test array */
+static unsigned Index = 0;
static const void *Test_parameters = NULL;
static const char *TestProgName = NULL;
static void (*TestPrivateUsage)(void) = NULL;
@@ -74,14 +74,9 @@ void
AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr, const void *Parameters)
{
/* Sanity checking */
- if (Index >= MAXNUMOFTESTS) {
- printf("Too many tests added, increase MAXNUMOFTESTS(%d).\n",
- MAXNUMOFTESTS);
- exit(EXIT_FAILURE);
- } /* end if */
if (HDstrlen(TheDescr) >= MAXTESTDESC) {
- printf("Test description too long, increase MAXTESTDESC(%d).\n",
- MAXTESTDESC);
+ printf("Test description ('%s') too long, increase MAXTESTDESC(%d).\n",
+ TheDescr, MAXTESTDESC);
exit(EXIT_FAILURE);
} /* end if */
if (HDstrlen(TheName) >= MAXTESTNAME) {
@@ -90,9 +85,25 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con
exit(EXIT_FAILURE);
} /* end if */
+ /* Check for increasing the Test array size */
+ if(Index >= TestAlloc) {
+ TestStruct *newTest = Test; /* New array of tests */
+ unsigned newAlloc = MAX(1, TestAlloc * 2); /* New array size */
+
+ /* Reallocate array */
+ if(NULL == (newTest = (TestStruct *)HDrealloc(Test, newAlloc * sizeof(TestStruct)))) {
+ printf("Out of memory for tests, Index = %u, TestAlloc = %u, newAlloc = %u\n", Index, TestAlloc, newAlloc);
+ exit(EXIT_FAILURE);
+ } /* end if */
+
+ /* Update info */
+ Test = newTest;
+ TestAlloc = newAlloc;
+ } /* end if */
+
/* Set up test function */
HDstrcpy(Test[Index].Description, TheDescr);
- if (*TheName != '-'){
+ if(*TheName != '-') {
HDstrcpy(Test[Index].Name, TheName);
Test[Index].SkipFlag = 0;
}
@@ -153,7 +164,7 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p
*/
void TestUsage(void)
{
- int i;
+ unsigned i;
print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
TestProgName, (TestPrivateUsage ? "<extra options>" : ""));
@@ -250,7 +261,7 @@ void TestParseCmdLine(int argc, char *argv[])
else if (((HDstrcmp(*argv, "-only") == 0) ||
(HDstrcmp(*argv, "-o") == 0))) {
if(argc > 0) {
- int Loop;
+ unsigned Loop;
--argc; ++argv;
@@ -296,7 +307,7 @@ void TestParseCmdLine(int argc, char *argv[])
*/
void PerformTests(void)
{
- int Loop;
+ unsigned Loop;
for (Loop = 0; Loop < Index; Loop++)
if (Test[Loop].SkipFlag) {
@@ -329,7 +340,7 @@ void PerformTests(void)
*/
void TestSummary(void)
{
- int Loop;
+ unsigned Loop;
print_func("Summary of Test Results:\n");
print_func("Name of Test Errors Description of Test\n");
@@ -351,7 +362,7 @@ void TestSummary(void)
*/
void TestCleanup(void)
{
- int Loop;
+ unsigned Loop;
MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
@@ -363,6 +374,16 @@ void TestCleanup(void)
/*
+ * Shutdown the test infrastructure
+ */
+void TestShutdown(void)
+{
+ if(Test)
+ HDfree(Test);
+}
+
+
+/*
* Retrieve the verbosity level for the testing framework
*/
H5_ATTR_PURE int GetTestVerbosity(void)
@@ -554,7 +575,7 @@ TestErrPrintf(const char *format, ...)
*/
void SetTest(const char *testname, int action)
{
- int Loop;
+ unsigned Loop;
switch (action){
case SKIPTEST:
diff --git a/test/testhdf5.c b/test/testhdf5.c
index eade815..0e7303e 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -86,6 +86,9 @@ main(int argc, char *argv[])
if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
TestCleanup();
+ /* Release test infrastructure */
+ TestShutdown();
+
/* Exit failure if errors encountered; else exit success. */
/* No need to print anything since PerformTests() already does. */
if (GetTestNumErrs() > 0)
diff --git a/test/ttsafe.c b/test/ttsafe.c
index 1fb9446..bfd24ba 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -143,6 +143,9 @@ int main(int argc, char *argv[])
if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
TestCleanup();
+ /* Release test infrastructure */
+ TestShutdown();
+
return GetTestNumErrs();
} /* end main() */
diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c
index 12d0587..3675824 100644
--- a/testpar/t_shapesame.c
+++ b/testpar/t_shapesame.c
@@ -5147,6 +5147,12 @@ int main(int argc, char **argv)
printf("===================================\n");
}
+ /* close HDF5 library */
+ H5close();
+
+ /* Release test infrastructure */
+ TestShutdown();
+
MPI_Finalize();
/* cannot just return (nerrors) because exit code is limited to 1byte */
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index aaf18de..7818101 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -589,9 +589,13 @@ int main(int argc, char **argv)
printf("PHDF5 tests finished with no errors\n");
printf("===================================\n");
}
+
/* close HDF5 library */
H5close();
+ /* Release test infrastructure */
+ TestShutdown();
+
/* MPI_Finalize must be called AFTER H5close which may use MPI calls */
MPI_Finalize();