src/test/SDL_test_harness.c
changeset 6727 1b5280cd5885
parent 6721 53b71f45a53a
child 6756 398073b195bb
     1.1 --- a/src/test/SDL_test_harness.c	Sat Dec 08 15:33:14 2012 -0500
     1.2 +++ b/src/test/SDL_test_harness.c	Sun Dec 09 17:56:19 2012 -0800
     1.3 @@ -218,6 +218,7 @@
     1.4  SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey)
     1.5  {
     1.6  	SDL_TimerID timer = 0;
     1.7 +	int testResult = 0;
     1.8  
     1.9  	if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL)
    1.10  	{
    1.11 @@ -243,7 +244,7 @@
    1.12  	// Maybe run suite initalizer function
    1.13  	if (testSuite->testSetUp) {
    1.14  		testSuite->testSetUp(0x0);
    1.15 -		if (SDLTest_AssertsFailed > 0) {
    1.16 +		if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) {
    1.17  			SDLTest_LogError((char *)SDLTest_TestCheckFmt, testSuite->name, "Failed");
    1.18  			return TEST_RESULT_SETUP_FAILURE;
    1.19  		}
    1.20 @@ -251,8 +252,9 @@
    1.21  
    1.22  	// Run test case function
    1.23  	testCase->testCase(0x0);
    1.24 +	testResult = SDLTest_AssertSummaryToTestResult();
    1.25  
    1.26 -	// Maybe run suite cleanup function
    1.27 +	// Maybe run suite cleanup function (ignore failed asserts)
    1.28  	if (testSuite->testTearDown) {
    1.29  		testSuite->testTearDown(0x0);
    1.30  	}
    1.31 @@ -266,19 +268,17 @@
    1.32  	SDLTest_Log("Fuzzer invocations: %d", SDLTest_GetFuzzerInvocationCount());
    1.33  	SDLTest_LogAssertSummary();
    1.34  
    1.35 -	// Analyze assert count to determine test case result
    1.36 -	if (SDLTest_AssertsFailed > 0) {
    1.37 -		SDLTest_LogError((char *)SDLTest_TestCheckFmt, testCase->name, "Failed");
    1.38 -		return TEST_RESULT_FAILED;
    1.39 -	} else {
    1.40 -		if (SDLTest_AssertsPassed > 0) {
    1.41 +	// Analyze assert count to determine final test case result
    1.42 +	switch (testResult) {
    1.43 +		case TEST_RESULT_PASSED:
    1.44 +			SDLTest_LogError((char *)SDLTest_TestCheckFmt, testCase->name, "Failed");
    1.45 +		case TEST_RESULT_FAILED:
    1.46  			SDLTest_Log((char *)SDLTest_TestCheckFmt, testCase->name, "Passed");
    1.47 -			return TEST_RESULT_PASSED;
    1.48 -		} else {
    1.49 +		case TEST_RESULT_NO_ASSERT:
    1.50  			SDLTest_LogError((char *)SDLTest_TestCheckFmt, testCase->name, "No Asserts");
    1.51 -			return TEST_RESULT_NO_ASSERT;
    1.52 -		}
    1.53  	}
    1.54 +
    1.55 +	return testResult;
    1.56  }
    1.57  
    1.58  /* Prints summary of all suites/tests contained in the given reference */
    1.59 @@ -329,7 +329,7 @@
    1.60  	int iterationCounter;
    1.61  	SDLTest_TestSuiteReference *testSuite;
    1.62  	SDLTest_TestCaseReference *testCase;
    1.63 -	char *runSeed;
    1.64 +	char *runSeed = NULL;
    1.65  	Uint64 execKey;
    1.66  	Uint32 runStartTicks;
    1.67  	time_t runStartTimestamp;