zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_test_harness.c File Reference
#include "SDL_config.h"
#include "SDL_test.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

Go to the source code of this file.

Functions

float GetClock ()
 
void SDLTest_BailOut ()
 Timeout handler. Aborts test run and exits harness process. More...
 
Uint64 SDLTest_GenerateExecKey (char *runSeed, char *suiteName, char *testName, int iteration)
 
char * SDLTest_GenerateRunSeed (const int length)
 
void SDLTest_LogTestSuiteSummary (SDLTest_TestSuiteReference *testSuites)
 
int SDLTest_RunSuites (SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations)
 Execute a test suite using the given run seend and execution key. More...
 
int SDLTest_RunTest (SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey)
 Execute a test using the given execution key. More...
 
SDL_TimerID SDLTest_SetTestTimeout (int timeout, void(*callback)())
 Set timeout handler for test. More...
 

Variables

const char * SDLTest_FinalResultFormat = ">>> %s '%s': %s\n"
 
const char * SDLTest_InvalidNameFormat = "(Invalid)"
 
const char * SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d"
 
static Uint32 SDLTest_TestCaseTimeout = 3600
 

Function Documentation

float GetClock ( )

Definition at line 343 of file SDL_test_harness.c.

Referenced by SDLTest_RunSuites().

void SDLTest_BailOut ( )

Timeout handler. Aborts test run and exits harness process.

Definition at line 208 of file SDL_test_harness.c.

References SDLTest_LogError(), and TEST_ABORTED.

Referenced by SDLTest_RunTest().

Uint64 SDLTest_GenerateExecKey ( char *  runSeed,
char *  suiteName,
char *  testName,
int  iteration 
)

Generates an execution key for the fuzzer.

Parameters
runSeedThe run seed to use
suiteNameThe name of the test suite
testNameThe name of the test
iterationThe iteration count
Returns
The generated execution key to initialize the fuzzer with.

Definition at line 100 of file SDL_test_harness.c.

References SDLTest_Md5Context::digest, NULL, SDL_free(), SDL_malloc(), SDL_memset(), SDL_snprintf(), SDL_strlen(), SDLTest_LogError(), SDLTest_Md5Final(), SDLTest_Md5Init(), and SDLTest_Md5Update().

Referenced by SDLTest_RunSuites().

char* SDLTest_GenerateRunSeed ( const int  length)

Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z).

Note: The returned string needs to be deallocated by the caller.

Parameters
lengthThe length of the seed string to generate
Returns
The generated seed string

Definition at line 54 of file SDL_test_harness.c.

References NULL, SDL_malloc(), SDLTest_LogError(), SDLTest_Random(), and SDLTest_RandomInitTime().

Referenced by SDLTest_RunSuites().

int SDLTest_RunSuites ( SDLTest_TestSuiteReference testSuites[],
const char *  userRunSeed,
Uint64  userExecKey,
const char *  filter,
int  testIterations 
)

Execute a test suite using the given run seend and execution key.

Execute a test suite using the given run seed and execution key.

The filter string is matched to the suite name (full comparison) to select a single suite, or if no suite matches, it is matched to the test names (full comparison) to select a single test.

Parameters
testSuitesSuites containing the test case.
userRunSeedCustom run seed provided by user, or NULL to autogenerate one.
userExecKeyCustom execution key provided by user, or 0 to autogenerate one.
filterFilter specification. NULL disables. Case sensitive.
testIterationsNumber of iterations to run each test case.
Returns
Test run result; 0 when all tests passed, 1 if any tests failed.

Definition at line 363 of file SDL_test_harness.c.

References SDLTest_TestCaseReference::description, SDLTest_TestCaseReference::enabled, GetClock(), if(), SDLTest_TestCaseReference::name, SDLTest_TestSuiteReference::name, NULL, SDL_strcmp(), SDLTest_FinalResultFormat, SDLTest_GenerateExecKey(), SDLTest_GenerateRunSeed(), SDLTest_InvalidNameFormat, SDLTest_Log(), SDLTest_LogError(), SDLTest_LogSummaryFormat, SDLTest_RunTest(), TEST_RESULT_FAILED, TEST_RESULT_NO_ASSERT, TEST_RESULT_PASSED, TEST_RESULT_SKIPPED, and SDLTest_TestSuiteReference::testCases.

SDL_TimerID SDLTest_SetTestTimeout ( int  timeout,
void(*)()  callback 
)

Set timeout handler for test.

Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.

Parameters
timeoutTimeout interval in seconds.
callbackFunction that will be called after timeout has elapsed.
Returns
Timer id or -1 on failure.

Definition at line 170 of file SDL_test_harness.c.

References NULL, SDL_AddTimer(), SDL_GetError(), SDL_INIT_TIMER, SDL_InitSubSystem(), SDL_WasInit(), and SDLTest_LogError().

Referenced by SDLTest_RunTest().

Variable Documentation

const char* SDLTest_FinalResultFormat = ">>> %s '%s': %s\n"

Definition at line 38 of file SDL_test_harness.c.

Referenced by SDLTest_RunSuites(), and SDLTest_RunTest().

const char* SDLTest_InvalidNameFormat = "(Invalid)"

Definition at line 32 of file SDL_test_harness.c.

Referenced by SDLTest_LogTestSuiteSummary(), and SDLTest_RunSuites().

const char* SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d"

Definition at line 35 of file SDL_test_harness.c.

Referenced by SDLTest_RunSuites().

Uint32 SDLTest_TestCaseTimeout = 3600
static

Definition at line 41 of file SDL_test_harness.c.

Referenced by SDLTest_RunTest().