Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixes in harness and fuzzer test lib components; improve harness driv…

…er; add rect test suite
  • Loading branch information
ferzkopp committed Dec 16, 2012
1 parent 2ac7334 commit 5c0dd4756aba73ec377327722f2a7e51558bf3be
Showing with 1,743 additions and 38 deletions.
  1. +4 −2 src/test/SDL_test_fuzzer.c
  2. +31 −17 src/test/SDL_test_harness.c
  3. +29 −17 test/testautomation.c
  4. +1,677 −0 test/tests/testrect.c
  5. +2 −2 test/tests/testsuites.h
@@ -38,7 +38,7 @@
/**
*Counter for fuzzer invocations
*/
static int fuzzerInvocationCounter;
static int fuzzerInvocationCounter = 0;

/**
* Context for shared random number generator
@@ -52,9 +52,11 @@ static SDLTest_RandomContext rndContext;
void
SDLTest_FuzzerInit(Uint64 execKey)
{
Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF;
Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF;
Uint32 b = execKey & 0x00000000FFFFFFFF;
SDL_memset((void *)&rndContext, 0, sizeof(SDLTest_RandomContext));
SDLTest_RandomInit(&rndContext, a, b);
fuzzerInvocationCounter = 0;
}

int
@@ -222,6 +222,7 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference
{
SDL_TimerID timer = 0;
int testResult = 0;
int fuzzerCount;

if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL)
{
@@ -235,7 +236,7 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference
return TEST_RESULT_SKIPPED;
}

// Initialize fuzzer
// Initialize fuzzer
SDLTest_FuzzerInit(execKey);

// Reset assert tracker
@@ -268,7 +269,10 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference
}

// Report on asserts and fuzzer usage
SDLTest_Log("Fuzzer invocations: %d", SDLTest_GetFuzzerInvocationCount());
fuzzerCount = SDLTest_GetFuzzerInvocationCount();
if (fuzzerCount > 0) {
SDLTest_Log("Fuzzer invocations: %d", fuzzerCount);
}
SDLTest_LogAssertSummary();

return testResult;
@@ -361,6 +365,8 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
SDLTest_LogError("Generating a random seed failed");
return 2;
}
} else {
runSeed = userRunSeed;
}

// Reset per-run counters
@@ -372,7 +378,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
runStartSeconds = GetClock();

// Log run with fuzzer parameters
SDLTest_Log("::::: Test Run '%s' started\n", runSeed);
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);

// Loop over all suites
suiteCounter = 0;
@@ -390,7 +396,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U

// Log suite started
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
SDLTest_Log("===== Test Suite %i: %s started\n",
SDLTest_Log("===== Test Suite %i: '%s' started\n",
suiteCounter,
currentSuiteName);

@@ -406,25 +412,28 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U

// Log test started
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
SDLTest_Log("----- Test Case %i: %s started",
SDLTest_Log("----- Test Case %i.%i: '%s' started",
suiteCounter,
testCounter,
currentTestName);
SDLTest_Log("Test Description: %s",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);

if (testCase->description != NULL && strlen(testCase->description)>0) {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}

// Loop over all iterations
iterationCounter = 0;
while(iterationCounter < testIterations)
{
iterationCounter++;

if(userExecKey != 0) {
if (userExecKey != 0) {
execKey = userExecKey;
} else {
execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
}

SDLTest_Log("Test Iteration %i: execKey %d", iterationCounter, execKey);
SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey);
testResult = SDLTest_RunTest(testSuite, testCase, execKey);

if (testResult == TEST_RESULT_PASSED) {
@@ -442,10 +451,14 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
// Take time - test end
testEndSeconds = GetClock();

SDLTest_Log("Test Case %s ended", currentTestName);

// Log test runtime
SDLTest_Log("Test runtime: %.1f sec", testEndSeconds - testStartSeconds);
if (testIterations > 1) {
// Log test runtime
SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, testEndSeconds - testStartSeconds);
SDLTest_Log("Test runtime: %.5f sec", (testEndSeconds - testStartSeconds) / (float)testIterations);
} else {
// Log test runtime
SDLTest_Log("Test runtime: %.1f sec", testEndSeconds - testStartSeconds);
}

// Log final test result
switch (testResult) {
@@ -468,7 +481,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
SDLTest_Log("Suite runtime: %.1f sec", suiteEndSeconds - suiteStartSeconds);

// Log summary and final Suite result
countSum = testPassedCount + testFailedCount + testSkippedCount;
countSum = testPassedCount + testFailedCount + testSkippedCount;
if (testFailedCount == 0)
{
SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
@@ -493,14 +506,15 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
{
runResult = 0;
SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run", runSeed, "Passed");
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed");
}
else
{
runResult = 1;
SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run", runSeed, "Failed");
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
}

SDLTest_Log("Exit code: %d", runResult);
return runResult;
}
@@ -34,6 +34,9 @@ int
main(int argc, char *argv[])
{
int result;
int testIterations = 1;
Uint64 userExecKey = 0;
char *userRunSeed = NULL;
int i;

/* Initialize test framework */
@@ -52,27 +55,33 @@ main(int argc, char *argv[])
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
consumed = -1;
/* Parse additional parameters
if (SDL_strcasecmp(argv[i], "--BLAH") == 0) {
if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
if (argv[i + 1]) {
if (SDL_strcasecmp(argv[i + 1], "BLUB") == 0) {
blah = blub;
consumed = 2;
}
testIterations = SDL_atoi(argv[i + 1]);
if (testIterations < 1) testIterations = 1;
consumed = 2;
}
} else if (SDL_strcasecmp(argv[i], "--BINGO") == 0) {
bingo = SDL_TRUE;
consumed = 1;
}
*/
}
else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
if (argv[i + 1]) {
SDL_sscanf(argv[i + 1], "%llu", &userExecKey);
consumed = 2;
}
}
else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
if (argv[i + 1]) {
userRunSeed = SDL_strdup(argv[i + 1]);
consumed = 2;
}
}
}
if (consumed < 0) {
fprintf(stderr,
"Usage: %s %s [--BLAH BLUB --BINGO]\n",
"Usage: %s %s [--iterations #] [--execKey #] [--seed string]\n",
argv[0], SDLTest_CommonUsage(state));
quit(1);
}

i += consumed;
}

@@ -89,10 +98,13 @@ main(int argc, char *argv[])
}

/* Call Harness */
// TODO: pass custom parameters
result = SDLTest_RunSuites(testSuites, NULL, 0, 1);
//int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites, char *userRunSeed, Uint64 userExecKey, int testIterations);

result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, testIterations);

/* Clean up */
if (userRunSeed != NULL) {
SDL_free(userRunSeed);
}

/* Shutdown everything */
quit(result);
return(result);

0 comments on commit 5c0dd47

Please sign in to comment.