diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/h5test.h | 8 | ||||
-rw-r--r-- | test/testframe.c | 18 |
2 files changed, 22 insertions, 4 deletions
diff --git a/test/h5test.h b/test/h5test.h index ff065bc..3d3f72e 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -127,11 +127,9 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ /* * Alarm definitions to wait up (terminate) a test that runs too long. */ -#define alarm_seconds 1200 /* default is 20 minutes */ -#define ALARM_ON HDalarm(alarm_seconds) +#define H5_ALARM_SEC 1200 /* default is 20 minutes */ +#define ALARM_ON TestAlarmOn() #define ALARM_OFF HDalarm(0) -/* set alarms to N seconds if N > 0, else use default alarm_seconds. */ -#define ALARM_SET(N) HDalarm((N)>0 ? N : alarm_seconds) /* * The methods to compare the equality of floating-point values: @@ -192,6 +190,8 @@ H5TEST_DLL void IncTestNumErrs(void); H5TEST_DLL const void *GetTestParameters(void); H5TEST_DLL int TestErrPrintf(const char *format, ...); H5TEST_DLL void SetTest(const char *testname, int action); +H5TEST_DLL void TestAlarmOn(void); +H5TEST_DLL void TestAlarmOff(void); #ifdef H5_HAVE_FILTER_SZIP H5TEST_DLL int h5_szip_can_encode(void); diff --git a/test/testframe.c b/test/testframe.c index 97d1e1a..1d7c958 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -588,3 +588,21 @@ void SetTest(const char *testname, int action) break; } } + + +/* + * Enable alarm on test execution, configurable by environment variable + */ +void TestAlarmOn(void) +{ + char * env_val = HDgetenv("HDF5_ALARM_SECONDS"); /* Alarm environment */ + unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */ + + /* Get the alarm value from the environment variable, if set */ + if(env_val != NULL) + alarm_sec = (unsigned)HDstrtoul(env_val, (char **)NULL, 10); + + /* Set the number of seconds before alarm goes off */ + HDalarm((unsigned)alarm_sec); +} + |