src/test/SDL_test_harness.c
changeset 10609 d702ecbd8ba7
parent 10185 8eeab279c545
child 10611 52ba31230c02
     1.1 --- a/src/test/SDL_test_harness.c	Sun Nov 13 00:09:02 2016 -0800
     1.2 +++ b/src/test/SDL_test_harness.c	Sun Nov 13 22:57:41 2016 -0800
     1.3 @@ -50,7 +50,7 @@
     1.4  *
     1.5  * \returns The generated seed string
     1.6  */
     1.7 -char *
     1.8 +static char *
     1.9  SDLTest_GenerateRunSeed(const int length)
    1.10  {
    1.11      char *seed = NULL;
    1.12 @@ -97,8 +97,8 @@
    1.13  * \returns The generated execution key to initialize the fuzzer with.
    1.14  *
    1.15  */
    1.16 -Uint64
    1.17 -SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration)
    1.18 +static Uint64
    1.19 +SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, int iteration)
    1.20  {
    1.21      SDLTest_Md5Context md5Context;
    1.22      Uint64 *keys;
    1.23 @@ -168,7 +168,7 @@
    1.24  *
    1.25  * \return Timer id or -1 on failure.
    1.26  */
    1.27 -SDL_TimerID
    1.28 +static SDL_TimerID
    1.29  SDLTest_SetTestTimeout(int timeout, void (*callback)())
    1.30  {
    1.31      Uint32 timeoutInMilliseconds;
    1.32 @@ -206,8 +206,8 @@
    1.33  /**
    1.34  * \brief Timeout handler. Aborts test run and exits harness process.
    1.35  */
    1.36 -void
    1.37 -    SDLTest_BailOut()
    1.38 +static void
    1.39 +SDLTest_BailOut()
    1.40  {
    1.41      SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
    1.42      exit(TEST_ABORTED); /* bail out from the test */
    1.43 @@ -223,8 +223,8 @@
    1.44  *
    1.45  * \returns Test case result.
    1.46  */
    1.47 -int
    1.48 -SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun)
    1.49 +static int
    1.50 +SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseReference *testCase, Uint64 execKey, SDL_bool forceTestRun)
    1.51  {
    1.52      SDL_TimerID timer = 0;
    1.53      int testCaseResult = 0;
    1.54 @@ -313,7 +313,8 @@
    1.55  }
    1.56  
    1.57  /* Prints summary of all suites/tests contained in the given reference */
    1.58 -void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
    1.59 +#if 0 
    1.60 +static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
    1.61  {
    1.62      int suiteCounter;
    1.63      int testCounter;
    1.64 @@ -340,12 +341,13 @@
    1.65          }
    1.66      }
    1.67  }
    1.68 +#endif
    1.69  
    1.70  /* Gets a timer value in seconds */
    1.71 -float GetClock()
    1.72 +static float GetClock()
    1.73  {
    1.74 -    float currentClock = (float)clock();
    1.75 -    return currentClock / (float)CLOCKS_PER_SEC;
    1.76 +    float currentClock = clock() / (float) CLOCKS_PER_SEC;
    1.77 +    return currentClock;
    1.78  }
    1.79  
    1.80  /**
    1.81 @@ -370,7 +372,7 @@
    1.82      int testCounter;
    1.83      int iterationCounter;
    1.84      SDLTest_TestSuiteReference *testSuite;
    1.85 -    SDLTest_TestCaseReference *testCase;
    1.86 +    const SDLTest_TestCaseReference *testCase;
    1.87      const char *runSeed = NULL;
    1.88      char *currentSuiteName;
    1.89      char *currentTestName;
    1.90 @@ -396,7 +398,7 @@
    1.91      Uint32 testPassedCount = 0;
    1.92      Uint32 testSkippedCount = 0;
    1.93      Uint32 countSum = 0;
    1.94 -    SDLTest_TestCaseReference **failedTests;
    1.95 +    const SDLTest_TestCaseReference **failedTests;
    1.96  
    1.97      /* Sanitize test iterations */
    1.98      if (testIterations < 1) {
    1.99 @@ -440,7 +442,7 @@
   1.100  	}
   1.101  
   1.102  	/* Pre-allocate an array for tracking failed tests (potentially all test cases) */
   1.103 -	failedTests = (SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
   1.104 +	failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
   1.105  	if (failedTests == NULL) {	
   1.106  	   SDLTest_LogError("Unable to allocate cache for failed tests");
   1.107             SDL_Error(SDL_ENOMEM);	   
   1.108 @@ -466,7 +468,7 @@
   1.109              testCounter = 0;
   1.110              while (testSuite->testCases[testCounter] && testFilter == 0)
   1.111              {
   1.112 -                testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
   1.113 +                testCase = testSuite->testCases[testCounter];
   1.114                  testCounter++;
   1.115                  if (testCase->name != NULL && SDL_strcmp(filter, testCase->name) == 0) {
   1.116                      /* Matched a test name */
   1.117 @@ -521,7 +523,7 @@
   1.118              testCounter = 0;
   1.119              while(testSuite->testCases[testCounter])
   1.120              {
   1.121 -                testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
   1.122 +                testCase = testSuite->testCases[testCounter];
   1.123                  currentTestName = (char *)((testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT);
   1.124                  testCounter++;
   1.125  
   1.126 @@ -562,7 +564,7 @@
   1.127                          if (userExecKey != 0) {
   1.128                              execKey = userExecKey;
   1.129                          } else {
   1.130 -                            execKey = SDLTest_GenerateExecKey((char *)runSeed, testSuite->name, testCase->name, iterationCounter);
   1.131 +                            execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
   1.132                          }
   1.133  
   1.134                          SDLTest_Log("Test Iteration %i: execKey %" SDL_PRIu64, iterationCounter, execKey);