Harness kills hung tests (won't work with --in-proc option).
Added result description to test logs (tells why test failed, such as exceeding its timeout).
This commit is contained in:
parent
4790fd63e3
commit
7de8abe0c4
7 changed files with 110 additions and 30 deletions
|
@ -600,7 +600,7 @@ RunTest(TestCase *testItem) {
|
|||
|
||||
int cntFailedAsserts = testItem->countFailedAsserts();
|
||||
if(cntFailedAsserts != 0) {
|
||||
return 3;
|
||||
return TEST_RESULT_SETUP_FAILURE;
|
||||
}
|
||||
|
||||
testItem->testCase(0x0);
|
||||
|
@ -612,6 +612,22 @@ RunTest(TestCase *testItem) {
|
|||
return testItem->quitTestEnvironment();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Kills test that hungs. Test hungs when its execution
|
||||
* takes longer than timeout specified for it.
|
||||
*
|
||||
* When test will be killed SIG_ALRM will be triggered and
|
||||
* it'll call this function which kills the test process.
|
||||
*
|
||||
* Note: if runner is executed with --in-proc then hung tests
|
||||
* can't be killed
|
||||
*
|
||||
* \param signum
|
||||
*/
|
||||
void KillHungTest(int signum) {
|
||||
exit(TEST_RESULT_KILLED);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Executes a test case. Loads the test, executes it and
|
||||
* returns the tests return value to the caller.
|
||||
|
@ -621,13 +637,18 @@ RunTest(TestCase *testItem) {
|
|||
*/
|
||||
int
|
||||
ExecuteTest(TestCase *testItem) {
|
||||
int retVal = 1;
|
||||
int retVal = -1;
|
||||
|
||||
if(execute_inproc) {
|
||||
retVal = RunTest(testItem);
|
||||
} else {
|
||||
int childpid = fork();
|
||||
if(childpid == 0) {
|
||||
if(testItem->timeout > 0) {
|
||||
signal(SIGALRM, KillHungTest);
|
||||
alarm((unsigned int) testItem->timeout);
|
||||
}
|
||||
|
||||
exit(RunTest(testItem));
|
||||
} else {
|
||||
int stat_lock = -1;
|
||||
|
@ -641,6 +662,7 @@ ExecuteTest(TestCase *testItem) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* If using out-of-proc execution of tests. This function
|
||||
* will handle the return value of the child process
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue