Fixes in harness and fuzzer test lib components; improve harness driver; add rect test suite
This commit is contained in:
parent
a6185d6ad9
commit
adefd543ce
5 changed files with 1743 additions and 38 deletions
|
@ -38,7 +38,7 @@
|
|||
/**
|
||||
*Counter for fuzzer invocations
|
||||
*/
|
||||
static int fuzzerInvocationCounter;
|
||||
static int fuzzerInvocationCounter = 0;
|
||||
|
||||
/**
|
||||
* Context for shared random number generator
|
||||
|
@ -54,7 +54,9 @@ SDLTest_FuzzerInit(Uint64 execKey)
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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,11 +412,14 @@ 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",
|
||||
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;
|
||||
|
@ -424,7 +433,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
|
|||
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);
|
||||
|
||||
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) {
|
||||
|
@ -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;
|
||||
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,9 +98,12 @@ 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);
|
||||
|
|
1677
test/tests/testrect.c
Normal file
1677
test/tests/testrect.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@
|
|||
//extern SDLTest_TestSuiteReference eventsTestSuite;
|
||||
//extern SDLTest_TestSuiteReference keyboardTestSuite;
|
||||
extern SDLTest_TestSuiteReference platformTestSuite;
|
||||
//extern SDLTest_TestSuiteReference rectTestSuite;
|
||||
extern SDLTest_TestSuiteReference rectTestSuite;
|
||||
//extern SDLTest_TestSuiteReference renderTestSuite;
|
||||
//extern SDLTest_TestSuiteReference rwopsTestSuite;
|
||||
//extern SDLTest_TestSuiteReference surfaceTestSuite;
|
||||
|
@ -28,7 +28,7 @@ SDLTest_TestSuiteReference *testSuites[] = {
|
|||
// &eventsTestSuite,
|
||||
// &keyboardTestSuite,
|
||||
&platformTestSuite,
|
||||
// &rectTestSuite,
|
||||
&rectTestSuite,
|
||||
// &renderTestSuite,
|
||||
// &rwopsTestSuite,
|
||||
// &surfaceTestSuite,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue