mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Minor adjustments to usage of alarm(2) timer in tests (#5292)
Make alarm(2) timer per-test program rather than per-subtest Avoid enabling alarm(2) timer when TestExpress is set to 0
This commit is contained in:
+1
-1
@@ -204,7 +204,7 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
|
||||
|
||||
/* Macros for the different TestExpress levels for expediting tests */
|
||||
#define H5_TEST_EXPRESS_EXHAUSTIVE 0 /** Exhaustive run; tests should take as long as necessary */
|
||||
#define H5_TEST_EXPRESS_FULL 1 /** Full run; tests should take no more than 30 minutes */
|
||||
#define H5_TEST_EXPRESS_FULL 1 /** Full run; tests should take no more than 20 minutes */
|
||||
#define H5_TEST_EXPRESS_QUICK 2 /** Quick run; tests should take no more than 10 minutes */
|
||||
#define H5_TEST_EXPRESS_SMOKE_TEST 3 /** Smoke test; tests should take no more than 1 minute */
|
||||
|
||||
|
||||
+36
-26
@@ -158,6 +158,12 @@ TestInit(const char *ProgName, void (*TestPrivateUsage)(FILE *stream),
|
||||
/* Initialize value for TestExpress functionality */
|
||||
h5_get_testexpress();
|
||||
|
||||
/* Enable alarm timer for test program once TestExpress setting
|
||||
* has been determined
|
||||
*/
|
||||
if (TestAlarmOn() < 0)
|
||||
MESSAGE(5, ("Couldn't enable test alarm timer\n"));
|
||||
|
||||
/* Record the program name and private routines if provided. */
|
||||
TestProgName = ProgName;
|
||||
if (NULL != TestPrivateUsage)
|
||||
@@ -461,10 +467,6 @@ PerformTests(void)
|
||||
MESSAGE(2, ("Testing -- %s (%s) \n", TestArray[Loop].Description, TestArray[Loop].Name));
|
||||
MESSAGE(5, ("===============================================\n"));
|
||||
|
||||
if (TestAlarmOn() < 0)
|
||||
MESSAGE(5, ("Couldn't enable test alarm timer for test -- %s (%s) \n",
|
||||
TestArray[Loop].Description, TestArray[Loop].Name));
|
||||
|
||||
if (TestArray[Loop].TestSetupFunc)
|
||||
TestArray[Loop].TestSetupFunc(TestArray[Loop].TestParameters);
|
||||
|
||||
@@ -473,8 +475,6 @@ PerformTests(void)
|
||||
if (TestArray[Loop].TestCleanupFunc)
|
||||
TestArray[Loop].TestCleanupFunc(TestArray[Loop].TestParameters);
|
||||
|
||||
TestAlarmOff();
|
||||
|
||||
TestArray[Loop].TestNumErrors = TestNumErrs_g - old_num_errs;
|
||||
|
||||
MESSAGE(5, ("===============================================\n"));
|
||||
@@ -573,6 +573,8 @@ TestShutdown(void)
|
||||
|
||||
free(TestArray);
|
||||
|
||||
TestAlarmOff();
|
||||
|
||||
return SUCCEED;
|
||||
}
|
||||
|
||||
@@ -829,30 +831,38 @@ SetTestMaxNumThreads(int max_num_threads)
|
||||
herr_t
|
||||
TestAlarmOn(void)
|
||||
{
|
||||
/* A TestExpress setting of H5_TEST_EXPRESS_EXHAUSTIVE should allow
|
||||
* tests to run for as long as necessary, so avoid enabling an
|
||||
* alarm-style timer here that would, by default, kill the test.
|
||||
*/
|
||||
if (GetTestExpress() == H5_TEST_EXPRESS_EXHAUSTIVE)
|
||||
return SUCCEED;
|
||||
#ifdef H5_HAVE_ALARM
|
||||
char *env_val = getenv("HDF5_ALARM_SECONDS"); /* Alarm environment */
|
||||
unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */
|
||||
else {
|
||||
char *env_val = getenv("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) {
|
||||
errno = 0;
|
||||
alarm_sec = strtoul(env_val, NULL, 10);
|
||||
if (errno != 0) {
|
||||
if (TestFrameworkProcessID_g == 0)
|
||||
fprintf(stderr, "%s: error while parsing value (%s) specified for alarm timeout\n", __func__,
|
||||
env_val);
|
||||
return FAIL;
|
||||
}
|
||||
else if (alarm_sec > (unsigned long)UINT_MAX) {
|
||||
if (TestFrameworkProcessID_g == 0)
|
||||
fprintf(stderr, "%s: value (%lu) specified for alarm timeout too large\n", __func__,
|
||||
alarm_sec);
|
||||
return FAIL;
|
||||
/* Get the alarm value from the environment variable, if set */
|
||||
if (env_val != NULL) {
|
||||
errno = 0;
|
||||
alarm_sec = strtoul(env_val, NULL, 10);
|
||||
if (errno != 0) {
|
||||
if (TestFrameworkProcessID_g == 0)
|
||||
fprintf(stderr, "%s: error while parsing value (%s) specified for alarm timeout\n",
|
||||
__func__, env_val);
|
||||
return FAIL;
|
||||
}
|
||||
else if (alarm_sec > (unsigned long)UINT_MAX) {
|
||||
if (TestFrameworkProcessID_g == 0)
|
||||
fprintf(stderr, "%s: value (%lu) specified for alarm timeout too large\n", __func__,
|
||||
alarm_sec);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the number of seconds before alarm goes off */
|
||||
alarm((unsigned)alarm_sec);
|
||||
}
|
||||
|
||||
/* Set the number of seconds before alarm goes off */
|
||||
alarm((unsigned)alarm_sec);
|
||||
#endif
|
||||
|
||||
return SUCCEED;
|
||||
|
||||
Reference in New Issue
Block a user