Fixed compile warnings in test library about formats strings not being literals.
Partially fixes Bugzilla #3375.
1.1 --- a/src/test/SDL_test_assert.c Sat Jun 25 19:40:02 2016 +0200
1.2 +++ b/src/test/SDL_test_assert.c Sat Jun 25 19:40:44 2016 +0200
1.3 @@ -30,10 +30,10 @@
1.4 #include "SDL_test.h"
1.5
1.6 /* Assert check message format */
1.7 -const char *SDLTest_AssertCheckFormat = "Assert '%s': %s";
1.8 +#define SDLTEST_ASSERT_CHECK_FORMAT "Assert '%s': %s"
1.9
1.10 /* Assert summary message format */
1.11 -const char *SDLTest_AssertSummaryFormat = "Assert Summary: Total=%d Passed=%d Failed=%d";
1.12 +#define SDLTEST_ASSERT_SUMMARY_FORMAT "Assert Summary: Total=%d Passed=%d Failed=%d"
1.13
1.14 /* ! \brief counts the failed asserts */
1.15 static Uint32 SDLTest_AssertsFailed = 0;
1.16 @@ -77,12 +77,12 @@
1.17 if (assertCondition == ASSERT_FAIL)
1.18 {
1.19 SDLTest_AssertsFailed++;
1.20 - SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed");
1.21 + SDLTest_LogError(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Failed");
1.22 }
1.23 else
1.24 {
1.25 SDLTest_AssertsPassed++;
1.26 - SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed");
1.27 + SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed");
1.28 }
1.29
1.30 return assertCondition;
1.31 @@ -104,7 +104,7 @@
1.32
1.33 /* Log pass message */
1.34 SDLTest_AssertsPassed++;
1.35 - SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass");
1.36 + SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Pass");
1.37 }
1.38
1.39 /*
1.40 @@ -125,11 +125,11 @@
1.41 Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
1.42 if (SDLTest_AssertsFailed == 0)
1.43 {
1.44 - SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
1.45 + SDLTest_Log(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
1.46 }
1.47 else
1.48 {
1.49 - SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
1.50 + SDLTest_LogError(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
1.51 }
1.52 }
1.53
2.1 --- a/src/test/SDL_test_harness.c Sat Jun 25 19:40:02 2016 +0200
2.2 +++ b/src/test/SDL_test_harness.c Sat Jun 25 19:40:44 2016 +0200
2.3 @@ -29,13 +29,13 @@
2.4 #include <time.h>
2.5
2.6 /* Invalid test name/description message format */
2.7 -const char *SDLTest_InvalidNameFormat = "(Invalid)";
2.8 +#define SDLTEST_INVALID_NAME_FORMAT "(Invalid)"
2.9
2.10 /* Log summary message format */
2.11 -const char *SDLTest_LogSummaryFormat = "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d";
2.12 +#define SDLTEST_LOG_SUMMARY_FORMAT "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d"
2.13
2.14 /* Final result message format */
2.15 -const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n";
2.16 +#define SDLTEST_FINAL_RESULT_FORMAT ">>> %s '%s': %s\n"
2.17
2.18 /* ! \brief Timeout for single test case execution */
2.19 static Uint32 SDLTest_TestCaseTimeout = 3600;
2.20 @@ -239,7 +239,7 @@
2.21
2.22 if (!testCase->enabled && forceTestRun == SDL_FALSE)
2.23 {
2.24 - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Disabled)");
2.25 + SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Disabled)");
2.26 return TEST_RESULT_SKIPPED;
2.27 }
2.28
2.29 @@ -256,7 +256,7 @@
2.30 if (testSuite->testSetUp) {
2.31 testSuite->testSetUp(0x0);
2.32 if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) {
2.33 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite Setup", testSuite->name, "Failed");
2.34 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite Setup", testSuite->name, "Failed");
2.35 return TEST_RESULT_SETUP_FAILURE;
2.36 }
2.37 }
2.38 @@ -298,13 +298,13 @@
2.39 /* Final log based on test execution result */
2.40 if (testCaseResult == TEST_SKIPPED) {
2.41 /* Test was programatically skipped */
2.42 - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Programmatically)");
2.43 + SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Programmatically)");
2.44 } else if (testCaseResult == TEST_STARTED) {
2.45 /* Test did not return a TEST_COMPLETED value; assume it failed */
2.46 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)");
2.47 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)");
2.48 } else if (testCaseResult == TEST_ABORTED) {
2.49 /* Test was aborted early; assume it failed */
2.50 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (Aborted)");
2.51 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Failed (Aborted)");
2.52 } else {
2.53 SDLTest_LogAssertSummary();
2.54 }
2.55 @@ -326,7 +326,7 @@
2.56 testSuite=&testSuites[suiteCounter];
2.57 suiteCounter++;
2.58 SDLTest_Log("Test Suite %i - %s\n", suiteCounter,
2.59 - (testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
2.60 + (testSuite->name) ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
2.61
2.62 /* Loop over all test cases */
2.63 testCounter = 0;
2.64 @@ -335,8 +335,8 @@
2.65 testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
2.66 testCounter++;
2.67 SDLTest_Log(" Test Case %i - %s: %s", testCounter,
2.68 - (testCase->name) ? testCase->name : SDLTest_InvalidNameFormat,
2.69 - (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
2.70 + (testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT,
2.71 + (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
2.72 }
2.73 }
2.74 }
2.75 @@ -396,7 +396,6 @@
2.76 Uint32 testPassedCount = 0;
2.77 Uint32 testSkippedCount = 0;
2.78 Uint32 countSum = 0;
2.79 - char *logFormat = (char *)SDLTest_LogSummaryFormat;
2.80 SDLTest_TestCaseReference **failedTests;
2.81
2.82 /* Sanitize test iterations */
2.83 @@ -493,7 +492,7 @@
2.84 suiteCounter = 0;
2.85 while(testSuites[suiteCounter]) {
2.86 testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
2.87 - currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
2.88 + currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTEST_INVALID_NAME_FORMAT);
2.89 suiteCounter++;
2.90
2.91 /* Filter suite if flag set and we have a name */
2.92 @@ -523,7 +522,7 @@
2.93 while(testSuite->testCases[testCounter])
2.94 {
2.95 testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
2.96 - currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
2.97 + currentTestName = (char *)((testCase->name) ? testCase->name : SDLTEST_INVALID_NAME_FORMAT);
2.98 testCounter++;
2.99
2.100 /* Filter tests if flag set and we have a name */
2.101 @@ -551,7 +550,7 @@
2.102 currentTestName);
2.103 if (testCase->description != NULL && testCase->description[0] != '\0') {
2.104 SDLTest_Log("Test Description: '%s'",
2.105 - (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
2.106 + (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT);
2.107 }
2.108
2.109 /* Loop over all iterations */
2.110 @@ -598,13 +597,13 @@
2.111 /* Log final test result */
2.112 switch (testResult) {
2.113 case TEST_RESULT_PASSED:
2.114 - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed");
2.115 + SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Passed");
2.116 break;
2.117 case TEST_RESULT_FAILED:
2.118 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed");
2.119 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed");
2.120 break;
2.121 case TEST_RESULT_NO_ASSERT:
2.122 - SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts");
2.123 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT,"Test", currentTestName, "No Asserts");
2.124 break;
2.125 }
2.126
2.127 @@ -628,13 +627,13 @@
2.128 countSum = testPassedCount + testFailedCount + testSkippedCount;
2.129 if (testFailedCount == 0)
2.130 {
2.131 - SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
2.132 - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed");
2.133 + SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
2.134 + SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
2.135 }
2.136 else
2.137 {
2.138 - SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
2.139 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
2.140 + SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
2.141 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
2.142 }
2.143
2.144 }
2.145 @@ -653,14 +652,14 @@
2.146 if (totalTestFailedCount == 0)
2.147 {
2.148 runResult = 0;
2.149 - SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
2.150 - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed");
2.151 + SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
2.152 + SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
2.153 }
2.154 else
2.155 {
2.156 runResult = 1;
2.157 - SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
2.158 - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
2.159 + SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
2.160 + SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
2.161 }
2.162
2.163 /* Print repro steps for failed tests */