-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor adjustments to usage of alarm(2) timer in tests #5292
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alarm timer set for tests has always (?) been per-subtest rather than per-test program, presumably to catch a particular hanging sub-test while allowing the rest of the tests to run. While this may be helpful for Autotools, where there's no real built-in mechanism for restricting the runtime of tests in general, it effectively goes against CMake's built-in timeout value in This changes the logic so that the alarm timer is per-test program and is turned on almost immediately on test program start (in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looking at the cmake configuration, it seems like the cmake timeouts are derived from the alarm timer value. Is this in reference to CMake starting a count to the same timeout value slightly earlier than the alarm (in the current per-test implementation) and always pre-empting it?
The ctest timeout documentation says that moving on to the next test after a timeout is already how it behaves. Are you talking about problems with continuing beyond hangs in entire test programs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There may be some historical precedent for this, but the ctest timer and alarm timer are separate from each other. It's generally likely that, since the ctest timer will be active before the program runs, the ctest timer will expire before the alarm timer since they currently have the same timeout value in seconds.
Yes this is referring to continuing to run other subtests in a test program. |
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's generally handy to be able to perform manual runs of long-running tests like multi-threaded ones, while still allowing them to be restricted by the |
||
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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a documentation cleanup. The intention for a "full" run may have been 30 minutes at some point, but the current timeout value for both
ctest
and for the alarm timer is 20 minutes by default, so a "full" run will always be kneecapped at 20 minutes anyway, unless the values are overridden.