SDL  2.0
SDL_test_harness.h File Reference
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_test_harness.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDLTest_TestCaseReference
 
struct  SDLTest_TestSuiteReference
 

Macros

#define TEST_ENABLED   1
 
#define TEST_DISABLED   0
 
#define TEST_ABORTED   -1
 
#define TEST_STARTED   0
 
#define TEST_COMPLETED   1
 
#define TEST_SKIPPED   2
 
#define TEST_RESULT_PASSED   0
 
#define TEST_RESULT_FAILED   1
 
#define TEST_RESULT_NO_ASSERT   2
 
#define TEST_RESULT_SKIPPED   3
 
#define TEST_RESULT_SETUP_FAILURE   4
 

Typedefs

typedef void(* SDLTest_TestCaseSetUpFp) (void *arg)
 
typedef int(* SDLTest_TestCaseFp) (void *arg)
 
typedef void(* SDLTest_TestCaseTearDownFp) (void *arg)
 

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...
 
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...
 

Detailed Description

Include file for SDL test framework.

This code is a part of the SDL2_test library, not the main SDL library.

Definition in file SDL_test_harness.h.

Macro Definition Documentation

◆ TEST_ABORTED

◆ TEST_COMPLETED

#define TEST_COMPLETED   1

Definition at line 53 of file SDL_test_harness.h.

Referenced by audio_buildAudioCVT(), audio_buildAudioCVTNegative(), audio_convertAudio(), audio_enumerateAndNameAudioDevices(), audio_enumerateAndNameAudioDevicesNegativeTests(), audio_getAudioStatus(), audio_initOpenCloseQuitAudio(), audio_initQuitAudio(), audio_lockUnlockOpenAudioDevice(), audio_openCloseAndGetAudioStatus(), audio_openCloseAudioDeviceConnected(), audio_pauseUnpauseAudio(), audio_printAudioDrivers(), audio_printCurrentAudioDriver(), audio_quitInitAudioSubSystem(), clipboard_testClipboardTextFunctions(), clipboard_testGetClipboardText(), clipboard_testHasClipboardText(), clipboard_testSetClipboardText(), events_addDelEventWatch(), events_addDelEventWatchWithUserdata(), events_pushPumpAndPollUserevent(), hints_getHint(), hints_setHint(), keyboard_getKeyboardFocus(), keyboard_getKeyboardState(), keyboard_getKeyFromName(), keyboard_getKeyFromScancode(), keyboard_getKeyName(), keyboard_getKeyNameNegative(), keyboard_getScancodeFromKey(), keyboard_getScancodeFromName(), keyboard_getScancodeFromNameNegative(), keyboard_getScancodeNameNegative(), keyboard_getSetModState(), keyboard_setTextInputRect(), keyboard_setTextInputRectNegative(), keyboard_startStopTextInput(), main_testImpliedJoystickInit(), main_testImpliedJoystickQuit(), main_testInitQuitJoystickHaptic(), main_testInitQuitSubSystem(), mouse_createFreeColorCursor(), mouse_createFreeCursor(), mouse_getCursor(), mouse_getMouseFocus(), mouse_getMouseState(), mouse_getRelativeMouseState(), mouse_getSetRelativeMouseMode(), mouse_setCursor(), mouse_showCursor(), mouse_warpMouseInWindow(), pixels_allocFreeFormat(), pixels_allocFreePalette(), pixels_calcGammaRamp(), pixels_getPixelFormatName(), platform_testDefaultInit(), platform_testEndianessAndSwap(), platform_testGetFunctions(), platform_testGetPowerInfo(), platform_testGetSetClearError(), platform_testGetVersion(), platform_testHasFunctions(), platform_testSDLVersion(), platform_testSetErrorEmptyInput(), platform_testSetErrorInvalidInput(), platform_testTypes(), rect_testEnclosePoints(), rect_testEnclosePointsParam(), rect_testEnclosePointsRepeatedInput(), rect_testEnclosePointsWithClipping(), rect_testHasIntersectionEmpty(), rect_testHasIntersectionInside(), rect_testHasIntersectionOutside(), rect_testHasIntersectionParam(), rect_testHasIntersectionPartial(), rect_testHasIntersectionPoint(), rect_testIntersectRectAndLine(), rect_testIntersectRectAndLineEmpty(), rect_testIntersectRectAndLineInside(), rect_testIntersectRectAndLineOutside(), rect_testIntersectRectAndLineParam(), rect_testIntersectRectEmpty(), rect_testIntersectRectInside(), rect_testIntersectRectOutside(), rect_testIntersectRectParam(), rect_testIntersectRectPartial(), rect_testIntersectRectPoint(), rect_testRectEmpty(), rect_testRectEmptyParam(), rect_testRectEquals(), rect_testRectEqualsParam(), rect_testUnionRectEmpty(), rect_testUnionRectInside(), rect_testUnionRectOutside(), rect_testUnionRectParam(), render_testBlit(), render_testBlitAlpha(), render_testBlitBlend(), render_testBlitColor(), render_testGetNumRenderDrivers(), render_testPrimitives(), render_testPrimitivesBlend(), rwops_testAllocFree(), rwops_testCompareRWFromMemWithRWFromFile(), rwops_testConstMem(), rwops_testFileRead(), rwops_testFileWrite(), rwops_testFileWriteReadEndian(), rwops_testFPRead(), rwops_testFPWrite(), rwops_testMem(), rwops_testParamNegative(), sdltest_generateRunSeed(), sdltest_getFuzzerInvocationCount(), sdltest_randomAsciiString(), sdltest_randomAsciiStringOfSize(), sdltest_randomAsciiStringWithMaximumLength(), sdltest_randomBoundaryNumberSint16(), sdltest_randomBoundaryNumberSint32(), sdltest_randomBoundaryNumberSint64(), sdltest_randomBoundaryNumberSint8(), sdltest_randomBoundaryNumberUint16(), sdltest_randomBoundaryNumberUint32(), sdltest_randomBoundaryNumberUint64(), sdltest_randomBoundaryNumberUint8(), sdltest_randomIntegerInRange(), sdltest_randomNumber(), stdlib_getsetenv(), stdlib_snprintf(), stdlib_sscanf(), stdlib_strlcpy(), surface_testBlit(), surface_testBlitAlphaMod(), surface_testBlitBlendAdd(), surface_testBlitBlendBlend(), surface_testBlitBlendLoop(), surface_testBlitBlendMod(), surface_testBlitBlendNone(), surface_testBlitColorMod(), surface_testCompleteSurfaceConversion(), surface_testLoadFailure(), surface_testSaveLoadBitmap(), surface_testSurfaceConversion(), syswm_getWindowWMInfo(), timer_addRemoveTimer(), timer_delayAndGetTicks(), timer_getPerformanceCounter(), timer_getPerformanceFrequency(), video_createWindowVariousFlags(), video_createWindowVariousPositions(), video_createWindowVariousSizes(), video_enableDisableScreensaver(), video_getClosestDisplayModeCurrentResolution(), video_getClosestDisplayModeRandomResolution(), video_getNumDisplayModes(), video_getNumDisplayModesNegative(), video_getSetWindowData(), video_getSetWindowGrab(), video_getSetWindowMaximumSize(), video_getSetWindowMinimumSize(), video_getSetWindowPosition(), video_getSetWindowSize(), video_getWindowBrightness(), video_getWindowBrightnessNegative(), video_getWindowDisplayMode(), video_getWindowDisplayModeNegative(), video_getWindowFlags(), video_getWindowGammaRamp(), video_getWindowGammaRampNegative(), video_getWindowId(), and video_getWindowPixelFormat().

◆ TEST_DISABLED

#define TEST_DISABLED   0

Definition at line 48 of file SDL_test_harness.h.

◆ TEST_ENABLED

#define TEST_ENABLED   1

Definition at line 47 of file SDL_test_harness.h.

◆ TEST_RESULT_FAILED

#define TEST_RESULT_FAILED   1

◆ TEST_RESULT_NO_ASSERT

#define TEST_RESULT_NO_ASSERT   2

Definition at line 59 of file SDL_test_harness.h.

Referenced by SDLTest_AssertSummaryToTestResult(), and SDLTest_RunSuites().

◆ TEST_RESULT_PASSED

#define TEST_RESULT_PASSED   0

Definition at line 57 of file SDL_test_harness.h.

Referenced by SDLTest_AssertSummaryToTestResult(), and SDLTest_RunSuites().

◆ TEST_RESULT_SETUP_FAILURE

#define TEST_RESULT_SETUP_FAILURE   4

Definition at line 61 of file SDL_test_harness.h.

Referenced by SDLTest_RunTest().

◆ TEST_RESULT_SKIPPED

#define TEST_RESULT_SKIPPED   3

Definition at line 60 of file SDL_test_harness.h.

Referenced by SDLTest_RunSuites(), and SDLTest_RunTest().

◆ TEST_SKIPPED

◆ TEST_STARTED

#define TEST_STARTED   0

Definition at line 52 of file SDL_test_harness.h.

Referenced by SDLTest_RunTest().

Typedef Documentation

◆ SDLTest_TestCaseFp

typedef int(* SDLTest_TestCaseFp) (void *arg)

Definition at line 67 of file SDL_test_harness.h.

◆ SDLTest_TestCaseSetUpFp

typedef void(* SDLTest_TestCaseSetUpFp) (void *arg)

Definition at line 64 of file SDL_test_harness.h.

◆ SDLTest_TestCaseTearDownFp

typedef void(* SDLTest_TestCaseTearDownFp) (void *arg)

Definition at line 70 of file SDL_test_harness.h.

Function Documentation

◆ SDLTest_GenerateRunSeed()

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

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.

55 {
56  char *seed = NULL;
57  SDLTest_RandomContext randomContext;
58  int counter;
59 
60  /* Sanity check input */
61  if (length <= 0) {
62  SDLTest_LogError("The length of the harness seed must be >0.");
63  return NULL;
64  }
65 
66  /* Allocate output buffer */
67  seed = (char *)SDL_malloc((length + 1) * sizeof(char));
68  if (seed == NULL) {
69  SDLTest_LogError("SDL_malloc for run seed output buffer failed.");
71  return NULL;
72  }
73 
74  /* Generate a random string of alphanumeric characters */
75  SDLTest_RandomInitTime(&randomContext);
76  for (counter = 0; counter < length; counter++) {
77  unsigned int number = SDLTest_Random(&randomContext);
78  char ch = (char) (number % (91 - 48)) + 48;
79  if (ch >= 58 && ch <= 64) {
80  ch = 65;
81  }
82  seed[counter] = ch;
83  }
84  seed[length] = '\0';
85 
86  return seed;
87 }
#define SDL_Error
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:103
void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext)
Initialize random number generator based on current system time.
unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext)
Initialize random number generator based on current system time.
#define NULL
Definition: begin_code.h:164
GLuint counter
#define SDL_malloc
GLuint GLsizei GLsizei * length

◆ 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.

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.

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 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().

368 {
369  int totalNumberOfTests = 0;
370  int failedNumberOfTests = 0;
371  int suiteCounter;
372  int testCounter;
373  int iterationCounter;
374  SDLTest_TestSuiteReference *testSuite;
375  const SDLTest_TestCaseReference *testCase;
376  const char *runSeed = NULL;
377  char *currentSuiteName;
378  char *currentTestName;
379  Uint64 execKey;
380  float runStartSeconds;
381  float suiteStartSeconds;
382  float testStartSeconds;
383  float runEndSeconds;
384  float suiteEndSeconds;
385  float testEndSeconds;
386  float runtime;
387  int suiteFilter = 0;
388  char *suiteFilterName = NULL;
389  int testFilter = 0;
390  char *testFilterName = NULL;
391  SDL_bool forceTestRun = SDL_FALSE;
392  int testResult = 0;
393  int runResult = 0;
394  Uint32 totalTestFailedCount = 0;
395  Uint32 totalTestPassedCount = 0;
396  Uint32 totalTestSkippedCount = 0;
397  Uint32 testFailedCount = 0;
398  Uint32 testPassedCount = 0;
399  Uint32 testSkippedCount = 0;
400  Uint32 countSum = 0;
401  const SDLTest_TestCaseReference **failedTests;
402 
403  /* Sanitize test iterations */
404  if (testIterations < 1) {
405  testIterations = 1;
406  }
407 
408  /* Generate run see if we don't have one already */
409  if (userRunSeed == NULL || userRunSeed[0] == '\0') {
410  runSeed = SDLTest_GenerateRunSeed(16);
411  if (runSeed == NULL) {
412  SDLTest_LogError("Generating a random seed failed");
413  return 2;
414  }
415  } else {
416  runSeed = userRunSeed;
417  }
418 
419 
420  /* Reset per-run counters */
421  totalTestFailedCount = 0;
422  totalTestPassedCount = 0;
423  totalTestSkippedCount = 0;
424 
425  /* Take time - run start */
426  runStartSeconds = GetClock();
427 
428  /* Log run with fuzzer parameters */
429  SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
430 
431  /* Count the total number of tests */
432  suiteCounter = 0;
433  while (testSuites[suiteCounter]) {
434  testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
435  suiteCounter++;
436  testCounter = 0;
437  while (testSuite->testCases[testCounter])
438  {
439  testCounter++;
440  totalNumberOfTests++;
441  }
442  }
443 
444  /* Pre-allocate an array for tracking failed tests (potentially all test cases) */
445  failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
446  if (failedTests == NULL) {
447  SDLTest_LogError("Unable to allocate cache for failed tests");
449  return -1;
450  }
451 
452  /* Initialize filtering */
453  if (filter != NULL && filter[0] != '\0') {
454  /* Loop over all suites to check if we have a filter match */
455  suiteCounter = 0;
456  while (testSuites[suiteCounter] && suiteFilter == 0) {
457  testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
458  suiteCounter++;
459  if (testSuite->name != NULL && SDL_strcmp(filter, testSuite->name) == 0) {
460  /* Matched a suite name */
461  suiteFilter = 1;
462  suiteFilterName = testSuite->name;
463  SDLTest_Log("Filtering: running only suite '%s'", suiteFilterName);
464  break;
465  }
466 
467  /* Within each suite, loop over all test cases to check if we have a filter match */
468  testCounter = 0;
469  while (testSuite->testCases[testCounter] && testFilter == 0)
470  {
471  testCase = testSuite->testCases[testCounter];
472  testCounter++;
473  if (testCase->name != NULL && SDL_strcmp(filter, testCase->name) == 0) {
474  /* Matched a test name */
475  suiteFilter = 1;
476  suiteFilterName = testSuite->name;
477  testFilter = 1;
478  testFilterName = testCase->name;
479  SDLTest_Log("Filtering: running only test '%s' in suite '%s'", testFilterName, suiteFilterName);
480  break;
481  }
482  }
483  }
484 
485  if (suiteFilter == 0 && testFilter == 0) {
486  SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
487  SDLTest_Log("Exit code: 2");
488  SDL_free((void *) failedTests);
489  return 2;
490  }
491  }
492 
493  /* Loop over all suites */
494  suiteCounter = 0;
495  while(testSuites[suiteCounter]) {
496  testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
497  currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
498  suiteCounter++;
499 
500  /* Filter suite if flag set and we have a name */
501  if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL &&
502  SDL_strcmp(suiteFilterName, testSuite->name) != 0) {
503  /* Skip suite */
504  SDLTest_Log("===== Test Suite %i: '%s' skipped\n",
505  suiteCounter,
506  currentSuiteName);
507  } else {
508 
509  /* Reset per-suite counters */
510  testFailedCount = 0;
511  testPassedCount = 0;
512  testSkippedCount = 0;
513 
514  /* Take time - suite start */
515  suiteStartSeconds = GetClock();
516 
517  /* Log suite started */
518  SDLTest_Log("===== Test Suite %i: '%s' started\n",
519  suiteCounter,
520  currentSuiteName);
521 
522  /* Loop over all test cases */
523  testCounter = 0;
524  while(testSuite->testCases[testCounter])
525  {
526  testCase = testSuite->testCases[testCounter];
527  currentTestName = (char *)((testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT);
528  testCounter++;
529 
530  /* Filter tests if flag set and we have a name */
531  if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL &&
532  SDL_strcmp(testFilterName, testCase->name) != 0) {
533  /* Skip test */
534  SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n",
535  suiteCounter,
536  testCounter,
537  currentTestName);
538  } else {
539  /* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */
540  if (testFilter == 1 && !testCase->enabled) {
541  SDLTest_Log("Force run of disabled test since test filter was set");
542  forceTestRun = SDL_TRUE;
543  }
544 
545  /* Take time - test start */
546  testStartSeconds = GetClock();
547 
548  /* Log test started */
549  SDLTest_Log("----- Test Case %i.%i: '%s' started",
550  suiteCounter,
551  testCounter,
552  currentTestName);
553  if (testCase->description != NULL && testCase->description[0] != '\0') {
554  SDLTest_Log("Test Description: '%s'",
555  (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
556  }
557 
558  /* Loop over all iterations */
559  iterationCounter = 0;
560  while(iterationCounter < testIterations)
561  {
562  iterationCounter++;
563 
564  if (userExecKey != 0) {
565  execKey = userExecKey;
566  } else {
567  execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
568  }
569 
570  SDLTest_Log("Test Iteration %i: execKey %" SDL_PRIu64, iterationCounter, execKey);
571  testResult = SDLTest_RunTest(testSuite, testCase, execKey, forceTestRun);
572 
573  if (testResult == TEST_RESULT_PASSED) {
574  testPassedCount++;
575  totalTestPassedCount++;
576  } else if (testResult == TEST_RESULT_SKIPPED) {
577  testSkippedCount++;
578  totalTestSkippedCount++;
579  } else {
580  testFailedCount++;
581  totalTestFailedCount++;
582  }
583  }
584 
585  /* Take time - test end */
586  testEndSeconds = GetClock();
587  runtime = testEndSeconds - testStartSeconds;
588  if (runtime < 0.0f) runtime = 0.0f;
589 
590  if (testIterations > 1) {
591  /* Log test runtime */
592  SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime);
593  SDLTest_Log("Average Test runtime: %.5f sec", runtime / (float)testIterations);
594  } else {
595  /* Log test runtime */
596  SDLTest_Log("Total Test runtime: %.1f sec", runtime);
597  }
598 
599  /* Log final test result */
600  switch (testResult) {
601  case TEST_RESULT_PASSED:
602  SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Passed");
603  break;
604  case TEST_RESULT_FAILED:
605  SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed");
606  break;
608  SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT,"Test", currentTestName, "No Asserts");
609  break;
610  }
611 
612  /* Collect failed test case references for repro-step display */
613  if (testResult == TEST_RESULT_FAILED) {
614  failedTests[failedNumberOfTests] = testCase;
615  failedNumberOfTests++;
616  }
617  }
618  }
619 
620  /* Take time - suite end */
621  suiteEndSeconds = GetClock();
622  runtime = suiteEndSeconds - suiteStartSeconds;
623  if (runtime < 0.0f) runtime = 0.0f;
624 
625  /* Log suite runtime */
626  SDLTest_Log("Total Suite runtime: %.1f sec", runtime);
627 
628  /* Log summary and final Suite result */
629  countSum = testPassedCount + testFailedCount + testSkippedCount;
630  if (testFailedCount == 0)
631  {
632  SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
633  SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
634  }
635  else
636  {
637  SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
638  SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
639  }
640 
641  }
642  }
643 
644  /* Take time - run end */
645  runEndSeconds = GetClock();
646  runtime = runEndSeconds - runStartSeconds;
647  if (runtime < 0.0f) runtime = 0.0f;
648 
649  /* Log total runtime */
650  SDLTest_Log("Total Run runtime: %.1f sec", runtime);
651 
652  /* Log summary and final run result */
653  countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
654  if (totalTestFailedCount == 0)
655  {
656  runResult = 0;
657  SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
658  SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
659  }
660  else
661  {
662  runResult = 1;
663  SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
664  SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
665  }
666 
667  /* Print repro steps for failed tests */
668  if (failedNumberOfTests > 0) {
669  SDLTest_Log("Harness input to repro failures:");
670  for (testCounter = 0; testCounter < failedNumberOfTests; testCounter++) {
671  SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
672  }
673  }
674  SDL_free((void *) failedTests);
675 
676  SDLTest_Log("Exit code: %d", runResult);
677  return runResult;
678 }
#define SDLTEST_INVALID_NAME_FORMAT
char * SDLTest_GenerateRunSeed(const int length)
Generates a random run seed string for the harness. The generated seed will contain alphanumeric char...
#define SDLTEST_FINAL_RESULT_FORMAT
GLfloat f
uint32_t Uint32
Definition: SDL_stdinc.h:181
#define SDL_Error
uint64_t Uint64
Definition: SDL_stdinc.h:194
const SDLTest_TestCaseReference ** testCases
GLuint const GLchar * name
#define TEST_RESULT_FAILED
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:103
#define SDL_free
static float GetClock()
#define TEST_RESULT_NO_ASSERT
#define NULL
Definition: begin_code.h:164
SDL_bool
Definition: SDL_stdinc.h:139
#define TEST_RESULT_PASSED
#define SDLTEST_LOG_SUMMARY_FORMAT
#define SDL_PRIu64
Definition: SDL_stdinc.h:216
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
static Uint64 SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, int iteration)
#define SDL_malloc
#define SDL_strcmp
#define TEST_RESULT_SKIPPED
static int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun)
Execute a test using the given execution key.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter