Refined test skipping.
This commit is contained in:
parent
e16810661d
commit
82d0a86964
2 changed files with 51 additions and 17 deletions
|
@ -439,12 +439,6 @@ FilterTestCase(TestCaseReference *testReference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(testReference->requirements & TEST_REQUIRES_AUDIO) {
|
|
||||||
//printf("Debug: checking for audio support.\n");
|
|
||||||
retVal = PlatformSupportsAudio();
|
|
||||||
//printf("Debug: Audio support: %d\n", retVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +632,29 @@ KillHungTestInChildProcess(int signum)
|
||||||
exit(TEST_RESULT_KILLED);
|
exit(TEST_RESULT_KILLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks if given test case can be executed on the current platform.
|
||||||
|
*
|
||||||
|
* \param testCase Test to be checked
|
||||||
|
* \returns 1 if test is runnable, otherwise 0. On error returns -1
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
CheckTestRequirements(TestCase *testCase)
|
||||||
|
{
|
||||||
|
int retVal = 1;
|
||||||
|
|
||||||
|
if(testCase == NULL) {
|
||||||
|
fprintf(stderr, "TestCase parameter can't be NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(testCase->requirements & TEST_REQUIRES_AUDIO) {
|
||||||
|
retVal = PlatformSupportsAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute a test. Loads the test, executes it and
|
* Execute a test. Loads the test, executes it and
|
||||||
|
@ -647,35 +664,40 @@ KillHungTestInChildProcess(int signum)
|
||||||
* \param test result
|
* \param test result
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
RunTest(TestCase *testItem)
|
RunTest(TestCase *testCase)
|
||||||
{
|
{
|
||||||
if(testItem->timeout > 0 || universal_timeout > 0) {
|
int runnable = CheckTestRequirements(testCase);
|
||||||
|
if(runnable != 1) {
|
||||||
|
return TEST_RESULT_SKIPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(testCase->timeout > 0 || universal_timeout > 0) {
|
||||||
if(execute_inproc) {
|
if(execute_inproc) {
|
||||||
Log(time(0), "Test asked for timeout which is not supported.");
|
Log(time(0), "Test asked for timeout which is not supported.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetTestTimeout(testItem->timeout, KillHungTestInChildProcess);
|
SetTestTimeout(testCase->timeout, KillHungTestInChildProcess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testItem->initTestEnvironment();
|
testCase->initTestEnvironment();
|
||||||
|
|
||||||
if(testItem->testSetUp) {
|
if(testCase->testSetUp) {
|
||||||
testItem->testSetUp(0x0);
|
testCase->testSetUp(0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cntFailedAsserts = testItem->countFailedAsserts();
|
int cntFailedAsserts = testCase->countFailedAsserts();
|
||||||
if(cntFailedAsserts != 0) {
|
if(cntFailedAsserts != 0) {
|
||||||
return TEST_RESULT_SETUP_FAILURE;
|
return TEST_RESULT_SETUP_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
testItem->testCase(0x0);
|
testCase->testCase(0x0);
|
||||||
|
|
||||||
if(testItem->testTearDown) {
|
if(testCase->testTearDown) {
|
||||||
testItem->testTearDown(0x0);
|
testCase->testTearDown(0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return testItem->quitTestEnvironment();
|
return testCase->quitTestEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,19 @@ PlatformSupportsAudio()
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
Example of implementing new PlatformSupportXXX functions. The function
|
||||||
|
should return 1 if the feature is supported. Otherwise return 0.
|
||||||
|
|
||||||
|
Add call to the implemented function to runner.c in function
|
||||||
|
CheckTestRequirements. Use the current implementation as a guide.
|
||||||
|
|
||||||
|
Also add TEST_REQUIRES_XXX to SDL_test.h and use it in your tests
|
||||||
|
TestCaseReference. In this case, you'd add TEST_REQUIRES_OPENGL to
|
||||||
|
SDL_test.h
|
||||||
|
|
||||||
int
|
int
|
||||||
PlatformSupportsOpenGL() {
|
PlatformSupportsOpenGL() {
|
||||||
int retValue = 0;
|
int retValue = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue