SDL
2.0
|
#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.
Macros | |
#define | SDLTEST_INVALID_NAME_FORMAT "(Invalid)" |
#define | SDLTEST_LOG_SUMMARY_FORMAT "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d" |
#define | SDLTEST_FINAL_RESULT_FORMAT ">>> %s '%s': %s\n" |
Functions | |
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). More... | |
static Uint64 | SDLTest_GenerateExecKey (const char *runSeed, char *suiteName, char *testName, int iteration) |
static SDL_TimerID | SDLTest_SetTestTimeout (int timeout, void(*callback)()) |
Set timeout handler for test. More... | |
static SDL_NORETURN void | SDLTest_BailOut () |
Timeout handler. Aborts test run and exits harness process. More... | |
static int | SDLTest_RunTest (SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun) |
Execute a test using the given execution key. More... | |
static float | GetClock () |
int | SDLTest_RunSuites (SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations) |
Execute a test suite using the given run seed and execution key. More... | |
Variables | |
static Uint32 | SDLTest_TestCaseTimeout = 3600 |
Definition at line 38 of file SDL_test_harness.c.
Referenced by SDLTest_RunSuites(), and SDLTest_RunTest().
#define SDLTEST_INVALID_NAME_FORMAT "(Invalid)" |
Definition at line 32 of file SDL_test_harness.c.
Referenced by SDLTest_RunSuites(), and SDLTest_RunTest().
Definition at line 35 of file SDL_test_harness.c.
Referenced by SDLTest_RunSuites().
|
static |
Definition at line 347 of file SDL_test_harness.c.
Referenced by SDLTest_RunSuites().
|
static |
Timeout handler. Aborts test run and exits harness process.
Definition at line 210 of file SDL_test_harness.c.
References SDLTest_LogError(), and TEST_ABORTED.
Referenced by SDLTest_RunTest().
|
static |
Generates an execution key for the fuzzer.
runSeed | The run seed to use |
suiteName | The name of the test suite |
testName | The name of the test |
iteration | The iteration count |
Definition at line 101 of file SDL_test_harness.c.
References SDLTest_Md5Context::digest, NULL, SDL_ENOMEM, SDL_Error, 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).
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.
length | The length of the seed string to generate |
Definition at line 54 of file SDL_test_harness.c.
References NULL, SDL_ENOMEM, SDL_Error, SDL_malloc, SDLTest_LogError(), SDLTest_Random(), and SDLTest_RandomInitTime().
Referenced by sdltest_generateRunSeed(), and 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 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.
testSuites | Suites containing the test case. |
userRunSeed | Custom run seed provided by user, or NULL to autogenerate one. |
userExecKey | Custom execution key provided by user, or 0 to autogenerate one. |
filter | Filter specification. NULL disables. Case sensitive. |
testIterations | Number of iterations to run each test case. |
Definition at line 367 of file SDL_test_harness.c.
References SDLTest_TestCaseReference::description, SDLTest_TestCaseReference::enabled, GetClock(), SDLTest_TestCaseReference::name, SDLTest_TestSuiteReference::name, NULL, SDL_ENOMEM, SDL_Error, SDL_FALSE, SDL_free, SDL_malloc, SDL_PRIu64, SDL_strcmp, SDL_TRUE, SDLTEST_FINAL_RESULT_FORMAT, SDLTest_GenerateExecKey(), SDLTest_GenerateRunSeed(), SDLTEST_INVALID_NAME_FORMAT, SDLTest_Log(), SDLTEST_LOG_SUMMARY_FORMAT, SDLTest_LogError(), SDLTest_RunTest(), TEST_RESULT_FAILED, TEST_RESULT_NO_ASSERT, TEST_RESULT_PASSED, TEST_RESULT_SKIPPED, and SDLTest_TestSuiteReference::testCases.
Referenced by main().
|
static |
Execute a test using the given execution key.
testSuite | Suite containing the test case. |
testCase | Case to execute. |
execKey | Execution key for the fuzzer. |
forceTestRun | Force test to run even if test was disabled in suite. |
Definition at line 227 of file SDL_test_harness.c.
References SDLTest_TestCaseReference::description, SDLTest_TestCaseReference::enabled, SDLTest_TestCaseReference::name, SDLTest_TestSuiteReference::name, NULL, SDL_FALSE, SDL_RemoveTimer, SDLTest_AssertSummaryToTestResult(), SDLTest_BailOut(), SDLTEST_FINAL_RESULT_FORMAT, SDLTest_FuzzerInit(), SDLTest_GetFuzzerInvocationCount(), SDLTEST_INVALID_NAME_FORMAT, SDLTest_Log(), SDLTest_LogAssertSummary(), SDLTest_LogError(), SDLTest_ResetAssertSummary(), SDLTest_SetTestTimeout(), SDLTest_TestCaseTimeout, TEST_ABORTED, TEST_RESULT_FAILED, TEST_RESULT_SETUP_FAILURE, TEST_RESULT_SKIPPED, TEST_SKIPPED, TEST_STARTED, SDLTest_TestCaseReference::testCase, SDLTest_TestSuiteReference::testCases, SDLTest_TestSuiteReference::testSetUp, testSuites, and SDLTest_TestSuiteReference::testTearDown.
Referenced by SDLTest_RunSuites().
|
static |
Set timeout handler for test.
Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.
timeout | Timeout interval in seconds. |
callback | Function that will be called after timeout has elapsed. |
Definition at line 172 of file SDL_test_harness.c.
References callback(), NULL, SDL_AddTimer, SDL_GetError, SDL_INIT_TIMER, SDL_InitSubSystem, SDL_NORETURN, SDL_WasInit, and SDLTest_LogError().
Referenced by SDLTest_RunTest().
|
static |
Definition at line 41 of file SDL_test_harness.c.
Referenced by SDLTest_RunTest().