src/test/SDL_test_harness.c
changeset 6757 9935f71c8c81
parent 6756 398073b195bb
child 6760 04dcce3081e6
     1.1 --- a/src/test/SDL_test_harness.c	Fri Dec 14 23:05:34 2012 -0800
     1.2 +++ b/src/test/SDL_test_harness.c	Sat Dec 15 21:50:17 2012 -0800
     1.3 @@ -222,6 +222,7 @@
     1.4  {
     1.5  	SDL_TimerID timer = 0;
     1.6  	int testResult = 0;
     1.7 +	int fuzzerCount;
     1.8  
     1.9  	if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL)
    1.10  	{
    1.11 @@ -235,7 +236,7 @@
    1.12  		return TEST_RESULT_SKIPPED;
    1.13  	}
    1.14  
    1.15 -    // Initialize fuzzer
    1.16 +        // Initialize fuzzer
    1.17  	SDLTest_FuzzerInit(execKey);
    1.18  
    1.19  	// Reset assert tracker
    1.20 @@ -268,7 +269,10 @@
    1.21  	}
    1.22  
    1.23  	// Report on asserts and fuzzer usage
    1.24 -	SDLTest_Log("Fuzzer invocations: %d", SDLTest_GetFuzzerInvocationCount());
    1.25 +	fuzzerCount = SDLTest_GetFuzzerInvocationCount();
    1.26 +	if (fuzzerCount > 0) {
    1.27 +		SDLTest_Log("Fuzzer invocations: %d", fuzzerCount);
    1.28 +	}
    1.29  	SDLTest_LogAssertSummary();
    1.30  
    1.31  	return testResult;
    1.32 @@ -361,6 +365,8 @@
    1.33  			SDLTest_LogError("Generating a random seed failed");
    1.34  			return 2;
    1.35  		}
    1.36 +	} else {
    1.37 +		runSeed = userRunSeed;
    1.38  	}
    1.39  
    1.40  	// Reset per-run counters
    1.41 @@ -372,7 +378,7 @@
    1.42  	runStartSeconds = GetClock();
    1.43  
    1.44  	// Log run with fuzzer parameters
    1.45 -	SDLTest_Log("::::: Test Run '%s' started\n", runSeed);
    1.46 +	SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
    1.47  
    1.48  	// Loop over all suites
    1.49  	suiteCounter = 0;
    1.50 @@ -390,7 +396,7 @@
    1.51  
    1.52  		// Log suite started
    1.53  		currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
    1.54 -		SDLTest_Log("===== Test Suite %i: %s started\n", 
    1.55 +		SDLTest_Log("===== Test Suite %i: '%s' started\n", 
    1.56  			suiteCounter, 
    1.57  			currentSuiteName);
    1.58  
    1.59 @@ -406,25 +412,28 @@
    1.60  
    1.61  			// Log test started
    1.62  			currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
    1.63 -			SDLTest_Log("----- Test Case %i: %s started", 
    1.64 +			SDLTest_Log("----- Test Case %i.%i: '%s' started",
    1.65 +			        suiteCounter,
    1.66  				testCounter, 
    1.67  				currentTestName);
    1.68 -			SDLTest_Log("Test Description: %s", 
    1.69 -				(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
    1.70 -
    1.71 +			if (testCase->description != NULL && strlen(testCase->description)>0) {
    1.72 +				SDLTest_Log("Test Description: '%s'", 
    1.73 +					(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
    1.74 +			}
    1.75 +			
    1.76  			// Loop over all iterations
    1.77  			iterationCounter = 0;
    1.78  			while(iterationCounter < testIterations)
    1.79  			{
    1.80  				iterationCounter++;
    1.81  
    1.82 -				if(userExecKey != 0) {
    1.83 +				if (userExecKey != 0) {
    1.84  					execKey = userExecKey;
    1.85  				} else {
    1.86  					execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
    1.87  				}
    1.88  
    1.89 -				SDLTest_Log("Test Iteration %i: execKey %d", iterationCounter, execKey);
    1.90 +				SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey);
    1.91  				testResult = SDLTest_RunTest(testSuite, testCase, execKey);
    1.92  
    1.93  				if (testResult == TEST_RESULT_PASSED) {
    1.94 @@ -442,10 +451,14 @@
    1.95  			// Take time - test end
    1.96  			testEndSeconds = GetClock();
    1.97  
    1.98 -			SDLTest_Log("Test Case %s ended", currentTestName);
    1.99 -
   1.100 -			// Log test runtime
   1.101 -			SDLTest_Log("Test runtime: %.1f sec", testEndSeconds - testStartSeconds);
   1.102 +			if (testIterations > 1) {
   1.103 +        			// Log test runtime
   1.104 +	        		SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, testEndSeconds - testStartSeconds);
   1.105 +	        		SDLTest_Log("Test runtime: %.5f sec", (testEndSeconds - testStartSeconds) / (float)testIterations);
   1.106 +                        } else {
   1.107 +        			// Log test runtime
   1.108 +	        		SDLTest_Log("Test runtime: %.1f sec", testEndSeconds - testStartSeconds);
   1.109 +                        }
   1.110  
   1.111  			// Log final test result
   1.112  			switch (testResult) {
   1.113 @@ -468,7 +481,7 @@
   1.114  		SDLTest_Log("Suite runtime: %.1f sec", suiteEndSeconds - suiteStartSeconds);
   1.115  
   1.116  		// Log summary and final Suite result
   1.117 -	    countSum = testPassedCount + testFailedCount + testSkippedCount;
   1.118 +		countSum = testPassedCount + testFailedCount + testSkippedCount;
   1.119  		if (testFailedCount == 0)
   1.120  		{
   1.121  			SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
   1.122 @@ -493,14 +506,15 @@
   1.123  	{
   1.124  		runResult = 0;
   1.125  		SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.126 -		SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run", runSeed, "Passed");
   1.127 +		SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed");
   1.128  	} 
   1.129  	else 
   1.130  	{
   1.131  		runResult = 1;
   1.132  		SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.133 -		SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run", runSeed, "Failed");
   1.134 +		SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
   1.135  	}
   1.136  
   1.137 +	SDLTest_Log("Exit code: %d", runResult);	
   1.138  	return runResult;
   1.139  }