src/test/SDL_test_harness.c
changeset 10185 8eeab279c545
parent 9998 f67cf37e9cd4
child 10609 d702ecbd8ba7
     1.1 --- a/src/test/SDL_test_harness.c	Sat Jun 25 19:40:02 2016 +0200
     1.2 +++ b/src/test/SDL_test_harness.c	Sat Jun 25 19:40:44 2016 +0200
     1.3 @@ -29,13 +29,13 @@
     1.4  #include <time.h>
     1.5  
     1.6  /* Invalid test name/description message format */
     1.7 -const char *SDLTest_InvalidNameFormat = "(Invalid)";
     1.8 +#define SDLTEST_INVALID_NAME_FORMAT "(Invalid)"
     1.9  
    1.10  /* Log summary message format */
    1.11 -const char *SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d";
    1.12 +#define SDLTEST_LOG_SUMMARY_FORMAT "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d"
    1.13  
    1.14  /* Final result message format */
    1.15 -const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n";
    1.16 +#define SDLTEST_FINAL_RESULT_FORMAT ">>> %s '%s': %s\n"
    1.17  
    1.18  /* ! \brief Timeout for single test case execution */
    1.19  static Uint32 SDLTest_TestCaseTimeout = 3600;
    1.20 @@ -239,7 +239,7 @@
    1.21  
    1.22  	if (!testCase->enabled && forceTestRun == SDL_FALSE)
    1.23      {
    1.24 -        SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Disabled)");
    1.25 +        SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Disabled)");
    1.26          return TEST_RESULT_SKIPPED;
    1.27      }
    1.28  
    1.29 @@ -256,7 +256,7 @@
    1.30      if (testSuite->testSetUp) {
    1.31          testSuite->testSetUp(0x0);
    1.32          if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) {
    1.33 -            SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite Setup", testSuite->name, "Failed");
    1.34 +            SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite Setup", testSuite->name, "Failed");
    1.35              return TEST_RESULT_SETUP_FAILURE;
    1.36          }
    1.37      }
    1.38 @@ -298,13 +298,13 @@
    1.39      /* Final log based on test execution result */
    1.40      if (testCaseResult == TEST_SKIPPED) {
    1.41          /* Test was programatically skipped */
    1.42 -        SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Programmatically)");
    1.43 +        SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Programmatically)");
    1.44      } else if (testCaseResult == TEST_STARTED) {
    1.45          /* Test did not return a TEST_COMPLETED value; assume it failed */
    1.46 -        SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)");
    1.47 +        SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)");
    1.48      } else if (testCaseResult == TEST_ABORTED) {
    1.49          /* Test was aborted early; assume it failed */
    1.50 -        SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (Aborted)");
    1.51 +        SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Failed (Aborted)");
    1.52      } else {
    1.53          SDLTest_LogAssertSummary();
    1.54      }
    1.55 @@ -326,7 +326,7 @@
    1.56          testSuite=&testSuites[suiteCounter];
    1.57          suiteCounter++;
    1.58          SDLTest_Log("Test Suite %i - %s\n", suiteCounter,
    1.59 -            (testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
    1.60 +            (testSuite->name) ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
    1.61  
    1.62          /* Loop over all test cases */
    1.63          testCounter = 0;
    1.64 @@ -335,8 +335,8 @@
    1.65              testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
    1.66              testCounter++;
    1.67              SDLTest_Log("  Test Case %i - %s: %s", testCounter,
    1.68 -                (testCase->name) ? testCase->name : SDLTest_InvalidNameFormat,
    1.69 -                (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
    1.70 +                (testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT,
    1.71 +                (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
    1.72          }
    1.73      }
    1.74  }
    1.75 @@ -396,7 +396,6 @@
    1.76      Uint32 testPassedCount = 0;
    1.77      Uint32 testSkippedCount = 0;
    1.78      Uint32 countSum = 0;
    1.79 -    char *logFormat = (char *)SDLTest_LogSummaryFormat;
    1.80      SDLTest_TestCaseReference **failedTests;
    1.81  
    1.82      /* Sanitize test iterations */
    1.83 @@ -493,7 +492,7 @@
    1.84      suiteCounter = 0;
    1.85      while(testSuites[suiteCounter]) {
    1.86          testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
    1.87 -        currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
    1.88 +        currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
    1.89          suiteCounter++;
    1.90  
    1.91          /* Filter suite if flag set and we have a name */
    1.92 @@ -523,7 +522,7 @@
    1.93              while(testSuite->testCases[testCounter])
    1.94              {
    1.95                  testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
    1.96 -                currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
    1.97 +                currentTestName = (char *)((testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT);
    1.98                  testCounter++;
    1.99  
   1.100                  /* Filter tests if flag set and we have a name */
   1.101 @@ -551,7 +550,7 @@
   1.102                          currentTestName);
   1.103                      if (testCase->description != NULL && testCase->description[0] != '\0') {
   1.104                          SDLTest_Log("Test Description: '%s'",
   1.105 -                            (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
   1.106 +                            (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
   1.107                      }
   1.108  
   1.109                      /* Loop over all iterations */
   1.110 @@ -598,13 +597,13 @@
   1.111                      /* Log final test result */
   1.112                      switch (testResult) {
   1.113                      case TEST_RESULT_PASSED:
   1.114 -                        SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed");
   1.115 +                        SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Passed");
   1.116                          break;
   1.117                      case TEST_RESULT_FAILED:
   1.118 -                        SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed");
   1.119 +                        SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed");
   1.120                          break;
   1.121                      case TEST_RESULT_NO_ASSERT:
   1.122 -                        SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts");
   1.123 +                        SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT,"Test", currentTestName, "No Asserts");
   1.124                          break;
   1.125                      }
   1.126  
   1.127 @@ -628,13 +627,13 @@
   1.128              countSum = testPassedCount + testFailedCount + testSkippedCount;
   1.129              if (testFailedCount == 0)
   1.130              {
   1.131 -                SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
   1.132 -                SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed");
   1.133 +                SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
   1.134 +                SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
   1.135              }
   1.136              else
   1.137              {
   1.138 -                SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
   1.139 -                SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
   1.140 +                SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
   1.141 +                SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
   1.142              }
   1.143  
   1.144          }
   1.145 @@ -653,14 +652,14 @@
   1.146      if (totalTestFailedCount == 0)
   1.147      {
   1.148          runResult = 0;
   1.149 -        SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.150 -        SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed");
   1.151 +        SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.152 +        SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
   1.153      }
   1.154      else
   1.155      {
   1.156          runResult = 1;
   1.157 -        SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.158 -        SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
   1.159 +        SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
   1.160 +        SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
   1.161      }
   1.162  
   1.163      /* Print repro steps for failed tests */