2004-01-07 01:53:13 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2004-01-07 01:53:13 +08:00
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:04 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2004-01-07 01:53:13 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
2019-02-14 05:53:25 +08:00
|
|
|
* Purpose: Provides support functions for the testing framework.
|
2005-08-14 04:53:35 +08:00
|
|
|
*
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "testhdf5.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for the testing structure.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
#define MAXTESTNAME 16
|
|
|
|
#define MAXTESTDESC 64
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
typedef struct TestStruct {
|
2020-09-30 22:27:10 +08:00
|
|
|
int NumErrors;
|
|
|
|
char Description[MAXTESTDESC];
|
|
|
|
int SkipFlag;
|
|
|
|
char Name[MAXTESTNAME];
|
2019-02-14 05:53:25 +08:00
|
|
|
void (*Call)(void);
|
|
|
|
void (*Cleanup)(void);
|
|
|
|
const void *Parameters;
|
2004-01-07 01:53:13 +08:00
|
|
|
} TestStruct;
|
|
|
|
|
|
|
|
/*
|
2004-01-10 09:41:13 +08:00
|
|
|
* Variables used by testing framework.
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */
|
|
|
|
static int num_errs = 0; /* Total number of errors during testing */
|
|
|
|
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 = 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;
|
2004-08-19 14:32:47 +08:00
|
|
|
static int (*TestPrivateParser)(int ac, char *av[]) = NULL;
|
2023-09-01 12:34:57 +08:00
|
|
|
int mpi_rank_framework_g = 0;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup a test function and add it to the list of tests.
|
|
|
|
* It must have no parameters and returns void.
|
2004-08-08 10:26:44 +08:00
|
|
|
* TheName--short test name.
|
|
|
|
* If the name starts with '-', do not run it by default.
|
|
|
|
* TheCall--the test routine.
|
|
|
|
* Cleanup--the cleanup routine for the test.
|
|
|
|
* TheDescr--Long description of the test.
|
2004-03-31 07:35:16 +08:00
|
|
|
* Parameters--pointer to extra parameters. Use NULL if none used.
|
|
|
|
* Since only the pointer is copied, the contents should not change.
|
2014-07-23 03:06:18 +08:00
|
|
|
* Return: Void
|
|
|
|
* exit EXIT_FAILURE if error is encountered.
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
void
|
2020-09-30 22:27:10 +08:00
|
|
|
AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void), const char *TheDescr,
|
|
|
|
const void *Parameters)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
|
|
|
/* Sanity checking */
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(TheDescr) >= MAXTESTDESC) {
|
2023-06-28 23:31:32 +08:00
|
|
|
printf("Test description ('%s') too long, increase MAXTESTDESC(%d).\n", TheDescr, MAXTESTDESC);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2023-06-29 06:48:12 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strlen(TheName) >= MAXTESTNAME) {
|
2023-06-28 23:31:32 +08:00
|
|
|
printf("Test name too long, increase MAXTESTNAME(%d).\n", MAXTESTNAME);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2023-06-29 06:48:12 +08:00
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2016-07-19 06:36:44 +08:00
|
|
|
/* Check for increasing the Test array size */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (Index >= TestAlloc) {
|
|
|
|
TestStruct *newTest = Test; /* New array of tests */
|
|
|
|
unsigned newAlloc = MAX(1, TestAlloc * 2); /* New array size */
|
2016-07-19 06:36:44 +08:00
|
|
|
|
|
|
|
/* Reallocate array */
|
2023-06-29 06:48:12 +08:00
|
|
|
if (NULL == (newTest = (TestStruct *)realloc(Test, newAlloc * sizeof(TestStruct)))) {
|
2023-06-28 23:31:32 +08:00
|
|
|
printf("Out of memory for tests, Index = %u, TestAlloc = %u, newAlloc = %u\n", Index, TestAlloc,
|
|
|
|
newAlloc);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2023-06-29 06:48:12 +08:00
|
|
|
}
|
2016-07-19 06:36:44 +08:00
|
|
|
|
|
|
|
/* Update info */
|
2020-09-30 22:27:10 +08:00
|
|
|
Test = newTest;
|
2016-07-19 06:36:44 +08:00
|
|
|
TestAlloc = newAlloc;
|
2023-06-29 06:48:12 +08:00
|
|
|
}
|
2016-07-19 06:36:44 +08:00
|
|
|
|
2004-01-07 01:53:13 +08:00
|
|
|
/* Set up test function */
|
2023-09-16 06:13:18 +08:00
|
|
|
strcpy(Test[Index].Description, TheDescr);
|
2020-09-30 22:27:10 +08:00
|
|
|
if (*TheName != '-') {
|
2023-09-16 06:13:18 +08:00
|
|
|
strcpy(Test[Index].Name, TheName);
|
2019-02-14 05:53:25 +08:00
|
|
|
Test[Index].SkipFlag = 0;
|
2004-08-08 10:26:44 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else { /* skip test by default */
|
2023-09-16 06:13:18 +08:00
|
|
|
strcpy(Test[Index].Name, TheName + 1);
|
2019-02-14 05:53:25 +08:00
|
|
|
Test[Index].SkipFlag = 1;
|
2004-08-08 10:26:44 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
Test[Index].Call = TheCall;
|
|
|
|
Test[Index].Cleanup = Cleanup;
|
|
|
|
Test[Index].NumErrors = -1;
|
2004-03-31 07:35:16 +08:00
|
|
|
Test[Index].Parameters = Parameters;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
/* Increment test count */
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize testing framework
|
2004-08-19 14:32:47 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]))
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Turn off automatic error reporting since we do it ourselves. Besides,
|
|
|
|
* half the functions this test calls are private, so automatic error
|
|
|
|
* reporting wouldn't do much good since it's triggered at the API layer.
|
|
|
|
*/
|
2019-02-14 05:53:25 +08:00
|
|
|
if (enable_error_stack == 0)
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2004-08-19 14:32:47 +08:00
|
|
|
/*
|
|
|
|
* Record the program name and private routines if provided.
|
|
|
|
*/
|
|
|
|
TestProgName = ProgName;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL != private_usage)
|
2018-09-21 01:40:51 +08:00
|
|
|
TestPrivateUsage = private_usage;
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL != private_parser)
|
2018-09-21 01:40:51 +08:00
|
|
|
TestPrivateParser = private_parser;
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print test usage.
|
2019-02-14 05:53:25 +08:00
|
|
|
* First print the common test options, then the extra options if provided.
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestUsage(void)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2019-02-14 05:53:25 +08:00
|
|
|
unsigned i;
|
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0) {
|
|
|
|
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");
|
|
|
|
print_func(" [-s[ummary]] \n");
|
|
|
|
print_func(" [-c[leanoff]] \n");
|
|
|
|
print_func(" [-h[elp]] \n");
|
|
|
|
print_func("\n\n");
|
|
|
|
print_func("verbose controls the amount of information displayed\n");
|
|
|
|
print_func("exclude to exclude tests by name\n");
|
|
|
|
print_func("only to name tests which should be run\n");
|
|
|
|
print_func("begin start at the name of the test given\n");
|
|
|
|
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");
|
|
|
|
print_func("%16s %s\n", "----", "-----------");
|
2019-02-14 05:53:25 +08:00
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
for (i = 0; i < Index; i++)
|
|
|
|
print_func("%16s %s\n", Test[i].Name, Test[i].Description);
|
2019-02-14 05:53:25 +08:00
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
print_func("\n\n");
|
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print test info.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestInfo(const char *ProgName)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0) {
|
|
|
|
unsigned major, minor, release;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
H5get_libversion(&major, &minor, &release);
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
print_func("\nFor help use: %s -help\n", ProgName);
|
|
|
|
print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
|
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-08-14 05:53:26 +08:00
|
|
|
* Parse command line information.
|
|
|
|
* argc, argv: the usual command line argument count and strings
|
|
|
|
*
|
2014-07-23 03:06:18 +08:00
|
|
|
* Return: Void
|
|
|
|
* exit EXIT_FAILURE if error is encountered.
|
2004-01-07 01:53:13 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestParseCmdLine(int argc, char *argv[])
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2023-09-06 04:11:52 +08:00
|
|
|
bool skipped_all = false;
|
|
|
|
int ret_code;
|
2004-08-24 07:35:17 +08:00
|
|
|
|
2023-06-19 13:13:38 +08:00
|
|
|
while ((void)argv++, --argc > 0) {
|
2023-09-16 06:13:18 +08:00
|
|
|
if ((strcmp(*argv, "-verbose") == 0) || (strcmp(*argv, "-v") == 0)) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (argc > 0) {
|
|
|
|
--argc;
|
|
|
|
++argv;
|
2019-08-25 03:07:19 +08:00
|
|
|
ParseTestVerbosity(*argv);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else {
|
2019-08-25 03:07:19 +08:00
|
|
|
TestUsage();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2019-02-14 05:53:25 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (((strcmp(*argv, "-exclude") == 0) || (strcmp(*argv, "-x") == 0))) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (argc > 0) {
|
|
|
|
--argc;
|
|
|
|
++argv;
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTest(*argv, SKIPTEST);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else {
|
2019-08-25 03:07:19 +08:00
|
|
|
TestUsage();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2019-02-14 05:53:25 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (((strcmp(*argv, "-begin") == 0) || (strcmp(*argv, "-b") == 0))) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (argc > 0) {
|
|
|
|
--argc;
|
|
|
|
++argv;
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTest(*argv, BEGINTEST);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else {
|
2019-08-25 03:07:19 +08:00
|
|
|
TestUsage();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2019-02-14 05:53:25 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (((strcmp(*argv, "-only") == 0) || (strcmp(*argv, "-o") == 0))) {
|
2020-09-30 22:27:10 +08:00
|
|
|
if (argc > 0) {
|
2019-08-25 03:07:19 +08:00
|
|
|
unsigned Loop;
|
2019-02-14 05:53:25 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
--argc;
|
|
|
|
++argv;
|
2019-02-14 05:53:25 +08:00
|
|
|
|
2019-08-25 03:07:19 +08:00
|
|
|
/* Skip all tests, then activate only one. */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!skipped_all) {
|
|
|
|
for (Loop = 0; Loop < Index; Loop++)
|
2015-09-17 06:27:49 +08:00
|
|
|
Test[Loop].SkipFlag = 1;
|
2023-09-06 04:11:52 +08:00
|
|
|
skipped_all = true;
|
2015-09-17 06:27:49 +08:00
|
|
|
} /* end if */
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTest(*argv, ONLYTEST);
|
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else {
|
2019-08-25 03:07:19 +08:00
|
|
|
TestUsage();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if ((strcmp(*argv, "-summary") == 0) || (strcmp(*argv, "-s") == 0))
|
2019-08-25 03:07:19 +08:00
|
|
|
Summary = 1;
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (strcmp(*argv, "-enable-error-stack") == 0)
|
2019-08-25 03:07:19 +08:00
|
|
|
enable_error_stack = 1;
|
2023-09-16 06:13:18 +08:00
|
|
|
else if ((strcmp(*argv, "-help") == 0) || (strcmp(*argv, "-h") == 0)) {
|
2019-08-25 03:07:19 +08:00
|
|
|
TestUsage();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_SUCCESS);
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2023-09-16 06:13:18 +08:00
|
|
|
else if ((strcmp(*argv, "-cleanoff") == 0) || (strcmp(*argv, "-c") == 0))
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTestNoCleanup();
|
|
|
|
else {
|
|
|
|
/* non-standard option. Break out. */
|
|
|
|
break;
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
2004-08-14 05:53:26 +08:00
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2004-08-14 05:53:26 +08:00
|
|
|
/* Call extra parsing function if provided. */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (NULL != TestPrivateParser) {
|
|
|
|
ret_code = TestPrivateParser(argc + 1, argv - 1);
|
2019-08-25 03:07:19 +08:00
|
|
|
if (ret_code != 0)
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2004-08-14 05:53:26 +08:00
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform Tests.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
PerformTests(void)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned Loop;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
for (Loop = 0; Loop < Index; Loop++)
|
|
|
|
if (Test[Loop].SkipFlag) {
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0)
|
|
|
|
MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
else {
|
2023-09-01 12:34:57 +08:00
|
|
|
if (mpi_rank_framework_g == 0)
|
|
|
|
MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0)
|
|
|
|
MESSAGE(5, ("===============================================\n"));
|
2004-01-07 01:53:13 +08:00
|
|
|
Test[Loop].NumErrors = num_errs;
|
2020-09-30 22:27:10 +08:00
|
|
|
Test_parameters = Test[Loop].Parameters;
|
2021-06-29 12:59:25 +08:00
|
|
|
TestAlarmOn();
|
2004-01-07 01:53:13 +08:00
|
|
|
Test[Loop].Call();
|
2021-06-29 12:59:25 +08:00
|
|
|
TestAlarmOff();
|
2004-01-07 01:53:13 +08:00
|
|
|
Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0) {
|
|
|
|
MESSAGE(5, ("===============================================\n"));
|
|
|
|
MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
|
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
Test_parameters = NULL; /* clear it. */
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2023-09-01 12:34:57 +08:00
|
|
|
if (mpi_rank_framework_g == 0) {
|
|
|
|
MESSAGE(2, ("\n\n"));
|
|
|
|
if (num_errs)
|
|
|
|
print_func("!!! %d Error(s) were detected !!!\n\n", (int)num_errs);
|
|
|
|
else
|
|
|
|
print_func("All tests were successful. \n\n");
|
|
|
|
}
|
2004-01-07 01:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display test summary.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestSummary(void)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned Loop;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
print_func("Summary of Test Results:\n");
|
|
|
|
print_func("Name of Test Errors Description of Test\n");
|
|
|
|
print_func("---------------- ------ --------------------------------------\n");
|
|
|
|
|
|
|
|
for (Loop = 0; Loop < Index; Loop++) {
|
|
|
|
if (Test[Loop].NumErrors == -1)
|
|
|
|
print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
|
|
|
|
else
|
|
|
|
print_func("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description);
|
|
|
|
}
|
|
|
|
|
|
|
|
print_func("\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup files from testing
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestCleanup(void)
|
2004-01-07 01:53:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
unsigned Loop;
|
2004-01-07 01:53:13 +08:00
|
|
|
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0)
|
|
|
|
MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
|
2004-01-07 01:53:13 +08:00
|
|
|
|
|
|
|
/* call individual cleanup routines in each source module */
|
|
|
|
for (Loop = 0; Loop < Index; Loop++)
|
2020-09-30 22:27:10 +08:00
|
|
|
if (!Test[Loop].SkipFlag && Test[Loop].Cleanup != NULL)
|
2004-01-07 01:53:13 +08:00
|
|
|
Test[Loop].Cleanup();
|
|
|
|
}
|
|
|
|
|
2016-07-19 06:36:44 +08:00
|
|
|
/*
|
|
|
|
* Shutdown the test infrastructure
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestShutdown(void)
|
2016-07-19 06:36:44 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
if (Test)
|
2023-06-29 06:48:12 +08:00
|
|
|
free(Test);
|
2016-07-19 06:36:44 +08:00
|
|
|
}
|
|
|
|
|
2004-01-10 09:41:13 +08:00
|
|
|
/*
|
|
|
|
* Retrieve the verbosity level for the testing framework
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_ATTR_PURE int
|
|
|
|
GetTestVerbosity(void)
|
2004-01-10 09:41:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (TestVerbosity);
|
2004-01-10 09:41:13 +08:00
|
|
|
}
|
|
|
|
|
2004-01-23 07:05:55 +08:00
|
|
|
/*
|
|
|
|
* Set the verbosity level for the testing framework.
|
|
|
|
* Return previous verbosity level.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
int
|
|
|
|
SetTestVerbosity(int newval)
|
2004-01-23 07:05:55 +08:00
|
|
|
{
|
2004-01-23 11:33:51 +08:00
|
|
|
int oldval;
|
2004-01-23 07:05:55 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
oldval = TestVerbosity;
|
2010-01-23 05:17:48 +08:00
|
|
|
TestVerbosity = newval;
|
2020-09-30 22:27:10 +08:00
|
|
|
return (oldval);
|
2004-01-23 07:05:55 +08:00
|
|
|
}
|
|
|
|
|
2006-04-07 23:34:40 +08:00
|
|
|
/*
|
|
|
|
* Retrieve the TestExpress mode for the testing framework
|
2006-06-27 22:45:06 +08:00
|
|
|
Values:
|
2006-06-22 06:44:45 +08:00
|
|
|
0: Exhaustive run
|
|
|
|
Tests should take as long as necessary
|
2022-05-18 00:54:05 +08:00
|
|
|
1: Full run. Default if H5_TEST_EXPRESS_LEVEL_DEFAULT
|
|
|
|
and HDF5TestExpress are not defined
|
2006-06-22 06:44:45 +08:00
|
|
|
Tests should take no more than 30 minutes
|
|
|
|
2: Quick run
|
|
|
|
Tests should take no more than 10 minutes
|
2022-05-18 00:54:05 +08:00
|
|
|
3: Smoke test.
|
|
|
|
Default if HDF5TestExpress is set to a value other than 0-3
|
2006-06-22 06:44:45 +08:00
|
|
|
Tests should take less than 1 minute
|
|
|
|
|
|
|
|
Design:
|
2006-04-07 23:34:40 +08:00
|
|
|
If the environment variable $HDF5TestExpress is defined,
|
2022-05-18 00:54:05 +08:00
|
|
|
or if a default testing level > 1 has been set via
|
|
|
|
H5_TEST_EXPRESS_LEVEL_DEFAULT, then test programs should
|
|
|
|
skip some tests so that they
|
2006-06-22 06:44:45 +08:00
|
|
|
complete sooner.
|
2006-04-07 23:34:40 +08:00
|
|
|
|
|
|
|
Terms:
|
2006-06-22 06:44:45 +08:00
|
|
|
A "test" is a single executable, even if it contains multiple
|
|
|
|
sub-tests.
|
|
|
|
The standard system for test times is a Linux machine running in
|
|
|
|
NFS space (to catch tests that involve a great deal of disk I/O).
|
2006-06-27 22:45:06 +08:00
|
|
|
|
2006-04-07 23:34:40 +08:00
|
|
|
Implementation:
|
|
|
|
I think this can be easily implemented in the test library (libh5test.a)
|
|
|
|
so that all tests can just call it to check the status of $HDF5TestExpress.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
int
|
|
|
|
GetTestExpress(void)
|
2006-04-07 23:34:40 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
char *env_val;
|
2006-06-22 06:44:45 +08:00
|
|
|
|
2006-04-07 23:34:40 +08:00
|
|
|
/* set it here for now. Should be done in something like h5test_init(). */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (TestExpress == -1) {
|
2022-05-18 00:54:05 +08:00
|
|
|
int express_val = 1;
|
|
|
|
|
|
|
|
/* Check if a default test express level is defined (e.g., by build system) */
|
|
|
|
#ifdef H5_TEST_EXPRESS_LEVEL_DEFAULT
|
|
|
|
express_val = H5_TEST_EXPRESS_LEVEL_DEFAULT;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check if HDF5TestExpress is set to override the default level */
|
2023-09-27 04:11:22 +08:00
|
|
|
env_val = getenv("HDF5TestExpress");
|
2022-05-18 00:54:05 +08:00
|
|
|
if (env_val) {
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strcmp(env_val, "0") == 0)
|
2022-05-18 00:54:05 +08:00
|
|
|
express_val = 0;
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (strcmp(env_val, "1") == 0)
|
2022-05-18 00:54:05 +08:00
|
|
|
express_val = 1;
|
2023-09-16 06:13:18 +08:00
|
|
|
else if (strcmp(env_val, "2") == 0)
|
2022-05-18 00:54:05 +08:00
|
|
|
express_val = 2;
|
|
|
|
else
|
|
|
|
express_val = 3;
|
|
|
|
}
|
2019-08-25 03:07:19 +08:00
|
|
|
|
2022-05-18 00:54:05 +08:00
|
|
|
SetTestExpress(express_val);
|
2006-06-22 06:44:45 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
return (TestExpress);
|
2006-04-07 23:34:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the TestExpress mode for the testing framework.
|
|
|
|
* Return previous TestExpress mode.
|
|
|
|
* Values: non-zero means TestExpress mode is on, 0 means off.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
int
|
|
|
|
SetTestExpress(int newval)
|
2006-04-07 23:34:40 +08:00
|
|
|
{
|
|
|
|
int oldval;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
oldval = TestExpress;
|
2006-04-07 23:34:40 +08:00
|
|
|
TestExpress = newval;
|
2020-09-30 22:27:10 +08:00
|
|
|
return (oldval);
|
2006-04-07 23:34:40 +08:00
|
|
|
}
|
|
|
|
|
2004-08-19 14:32:47 +08:00
|
|
|
/*
|
|
|
|
* Retrieve Summary request value.
|
|
|
|
* 0 means no summary, 1 means yes.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_ATTR_PURE int
|
|
|
|
GetTestSummary(void)
|
2004-08-19 14:32:47 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (Summary);
|
2004-08-19 14:32:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieve Cleanup request value.
|
|
|
|
* 0 means no Cleanup, 1 means yes.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_ATTR_PURE int
|
|
|
|
GetTestCleanup(void)
|
2004-08-19 14:32:47 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (CleanUp);
|
2004-08-19 14:32:47 +08:00
|
|
|
}
|
|
|
|
|
2006-01-09 13:14:54 +08:00
|
|
|
/*
|
|
|
|
* Set cleanup to no.
|
|
|
|
* Return previous cleanup value.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
int
|
|
|
|
SetTestNoCleanup(void)
|
2006-01-09 13:14:54 +08:00
|
|
|
{
|
|
|
|
int oldval;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
oldval = CleanUp;
|
2006-01-09 13:14:54 +08:00
|
|
|
CleanUp = 0;
|
2020-09-30 22:27:10 +08:00
|
|
|
return (oldval);
|
2006-01-09 13:14:54 +08:00
|
|
|
}
|
|
|
|
|
2004-01-23 14:29:57 +08:00
|
|
|
/*
|
|
|
|
* Parse an argument string for verbosity level and set it.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
ParseTestVerbosity(char *argv)
|
2004-01-23 14:29:57 +08:00
|
|
|
{
|
|
|
|
if (*argv == 'l')
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTestVerbosity(VERBO_LO);
|
2004-01-23 14:29:57 +08:00
|
|
|
else if (*argv == 'm')
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTestVerbosity(VERBO_MED);
|
2004-01-23 14:29:57 +08:00
|
|
|
else if (*argv == 'h')
|
2019-08-25 03:07:19 +08:00
|
|
|
SetTestVerbosity(VERBO_HI);
|
2004-01-23 14:29:57 +08:00
|
|
|
else
|
2023-06-29 21:33:09 +08:00
|
|
|
SetTestVerbosity(atoi(argv));
|
2004-01-23 14:29:57 +08:00
|
|
|
}
|
|
|
|
|
2004-01-10 09:41:13 +08:00
|
|
|
/*
|
|
|
|
* Retrieve the number of testing errors for the testing framework
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_ATTR_PURE int
|
|
|
|
GetTestNumErrs(void)
|
2004-01-10 09:41:13 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (num_errs);
|
2004-01-10 09:41:13 +08:00
|
|
|
}
|
|
|
|
|
2005-03-19 22:11:40 +08:00
|
|
|
/*
|
|
|
|
* Increment the number of testing errors
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
IncTestNumErrs(void)
|
2005-03-19 22:11:40 +08:00
|
|
|
{
|
|
|
|
num_errs++;
|
|
|
|
}
|
|
|
|
|
2004-04-02 06:51:47 +08:00
|
|
|
/*
|
|
|
|
* Retrieve the current Test Parameters pointer.
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
H5_ATTR_PURE const void *
|
|
|
|
GetTestParameters(void)
|
2004-04-02 06:51:47 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
return (Test_parameters);
|
2004-04-02 06:51:47 +08:00
|
|
|
}
|
|
|
|
|
2004-01-10 09:41:13 +08:00
|
|
|
/*
|
|
|
|
* This routine is designed to provide equivalent functionality to 'printf'
|
|
|
|
* and also increment the error count for the testing framework.
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
int
|
2004-01-10 09:41:13 +08:00
|
|
|
TestErrPrintf(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list arglist;
|
2020-09-30 22:27:10 +08:00
|
|
|
int ret_value;
|
2004-01-10 09:41:13 +08:00
|
|
|
|
|
|
|
/* Increment the error count */
|
|
|
|
num_errs++;
|
|
|
|
|
|
|
|
/* Print the requested information */
|
2023-06-28 08:43:23 +08:00
|
|
|
va_start(arglist, format);
|
2023-09-16 06:13:18 +08:00
|
|
|
ret_value = vprintf(format, arglist);
|
2023-06-28 08:43:23 +08:00
|
|
|
va_end(arglist);
|
2004-01-10 09:41:13 +08:00
|
|
|
|
|
|
|
/* Return the length of the string produced (like printf() does) */
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
2004-04-04 05:35:01 +08:00
|
|
|
* Set (control) which test will be tested.
|
|
|
|
* SKIPTEST: skip this test
|
|
|
|
* ONLYTEST: do only this test
|
|
|
|
* BEGINETEST: skip all tests before this test
|
|
|
|
*
|
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
SetTest(const char *testname, int action)
|
2004-04-04 05:35:01 +08:00
|
|
|
{
|
2016-07-19 06:36:44 +08:00
|
|
|
unsigned Loop;
|
2015-09-17 06:27:49 +08:00
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
switch (action) {
|
|
|
|
case SKIPTEST:
|
|
|
|
for (Loop = 0; Loop < Index; Loop++)
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strcmp(testname, Test[Loop].Name) == 0) {
|
2020-09-30 22:27:10 +08:00
|
|
|
Test[Loop].SkipFlag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BEGINTEST:
|
|
|
|
for (Loop = 0; Loop < Index; Loop++) {
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strcmp(testname, Test[Loop].Name) != 0)
|
2020-09-30 22:27:10 +08:00
|
|
|
Test[Loop].SkipFlag = 1;
|
|
|
|
else {
|
|
|
|
/* Found it. Set it to run. Done. */
|
|
|
|
Test[Loop].SkipFlag = 0;
|
|
|
|
break;
|
|
|
|
}
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
|
|
|
case ONLYTEST:
|
|
|
|
for (Loop = 0; Loop < Index; Loop++) {
|
2023-09-16 06:13:18 +08:00
|
|
|
if (strcmp(testname, Test[Loop].Name) == 0) {
|
2020-09-30 22:27:10 +08:00
|
|
|
/* Found it. Set it to run. Break to skip the rest. */
|
|
|
|
Test[Loop].SkipFlag = 0;
|
|
|
|
break;
|
|
|
|
}
|
2019-08-25 03:07:19 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* error */
|
2023-10-28 12:18:24 +08:00
|
|
|
if (mpi_rank_framework_g == 0)
|
|
|
|
printf("*** ERROR: Unknown action (%d) for SetTest\n", action);
|
2020-09-30 22:27:10 +08:00
|
|
|
break;
|
2004-04-04 05:35:01 +08:00
|
|
|
}
|
|
|
|
}
|
2010-08-17 05:04:53 +08:00
|
|
|
|
2021-06-29 12:59:25 +08:00
|
|
|
/* Enable a test timer that will kill long-running tests, the time is configurable
|
|
|
|
* via an environment variable.
|
|
|
|
*
|
|
|
|
* Only useful on POSIX systems where alarm(2) is present.
|
2010-08-17 05:04:53 +08:00
|
|
|
*/
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
TestAlarmOn(void)
|
2010-08-17 05:04:53 +08:00
|
|
|
{
|
2021-06-29 12:59:25 +08:00
|
|
|
#ifdef H5_HAVE_ALARM
|
2023-09-27 04:11:22 +08:00
|
|
|
char *env_val = getenv("HDF5_ALARM_SECONDS"); /* Alarm environment */
|
|
|
|
unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */
|
2010-08-17 05:04:53 +08:00
|
|
|
|
|
|
|
/* Get the alarm value from the environment variable, if set */
|
2020-09-30 22:27:10 +08:00
|
|
|
if (env_val != NULL)
|
2023-06-29 23:18:49 +08:00
|
|
|
alarm_sec = (unsigned)strtoul(env_val, (char **)NULL, 10);
|
2010-08-17 05:04:53 +08:00
|
|
|
|
|
|
|
/* Set the number of seconds before alarm goes off */
|
2023-06-29 21:32:40 +08:00
|
|
|
alarm((unsigned)alarm_sec);
|
2021-06-29 12:59:25 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable the test timer */
|
|
|
|
void
|
|
|
|
TestAlarmOff(void)
|
|
|
|
{
|
|
|
|
#ifdef H5_HAVE_ALARM
|
|
|
|
/* Set the number of seconds to zero */
|
2023-06-29 21:32:40 +08:00
|
|
|
alarm(0);
|
2021-06-29 12:59:25 +08:00
|
|
|
#endif
|
2010-08-17 05:04:53 +08:00
|
|
|
}
|