#include "SDL_config.h"
#include "SDL_test.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SDLTEST_INVALID_NAME_FORMAT "(Invalid)"
/* Log summary message format */
-#define SDLTEST_LOG_SUMMARY_FORMAT "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d"
+#define SDLTEST_LOG_SUMMARY_FORMAT "%s Summary: Total=%d Passed=%d Failed=%d Skipped=%d Unsupported=%d"
/* Final result message format */
#define SDLTEST_FINAL_RESULT_FORMAT ">>> %s '%s': %s\n"
SDLTest_ResetAssertSummary();
/* Set timeout timer */
- timer = SDLTest_SetTestTimeout(SDLTest_TestCaseTimeout, SDLTest_BailOut);
+ //timer = SDLTest_SetTestTimeout(SDLTest_TestCaseTimeout, SDLTest_BailOut);
/* Maybe run suite initalizer function */
if (testSuite->testSetUp) {
} else if (testCaseResult == TEST_ABORTED) {
/* Test was aborted early; assume it failed */
testResult = TEST_RESULT_FAILED;
+ } else if (testCaseResult == TEST_UNSUPPORTED) {
+ /* Test was unsupported */
+ testResult = TEST_RESULT_UNSUPPORTED;
} else {
/* Perform failure analysis based on asserts */
testResult = SDLTest_AssertSummaryToTestResult();
} else if (testCaseResult == TEST_ABORTED) {
/* Test was aborted early; assume it failed */
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Failed (Aborted)");
+ } else if (testCaseResult == TEST_UNSUPPORTED) {
+ /* Test was unsupported */
+ SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Unsupported");
} else {
SDLTest_LogAssertSummary();
}
}
/* Prints summary of all suites/tests contained in the given reference */
-#if 0
+#if 0
static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
{
int suiteCounter;
return currentClock;
}
+void SDLTest_writeLogFile(SDL_RWops *rwops, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
+{
+ va_list list;
+ char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
+
+ /* Print log message into a buffer */
+ SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+ va_start(list, fmt);
+ SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
+ va_end(list);
+
+ char *message = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+ if (!message)
+ return;
+
+ size_t len = SDL_strlen(logMessage);
+ SDL_strlcpy(message, logMessage,len+1);
+
+ char *text = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+ if(text)
+ {
+ SDL_snprintf(text, SDLTEST_MAX_LOGMESSAGE_LENGTH, " INFO: %s\n", message);
+ SDL_RWwrite(rwops, text, 1, SDL_strlen(text));
+ SDL_stack_free(text);
+ }
+ SDL_stack_free(message);
+
+}
/**
* \brief Execute a test suite using the given run seed and execution key.
*
char *suiteFilterName = NULL;
int testFilter = 0;
char *testFilterName = NULL;
- SDL_bool forceTestRun = SDL_FALSE;
+ SDL_bool forceTestRun = SDL_FALSE;
int testResult = 0;
int runResult = 0;
Uint32 totalTestFailedCount = 0;
Uint32 totalTestPassedCount = 0;
Uint32 totalTestSkippedCount = 0;
+ Uint32 totalTestUnsupportedCount = 0;
Uint32 testFailedCount = 0;
Uint32 testPassedCount = 0;
Uint32 testSkippedCount = 0;
+ Uint32 testUnsupportedCount = 0;
Uint32 countSum = 0;
const SDLTest_TestCaseReference **failedTests;
totalTestFailedCount = 0;
totalTestPassedCount = 0;
totalTestSkippedCount = 0;
+ totalTestUnsupportedCount = 0;
/* Take time - run start */
runStartSeconds = GetClock();
/* Log run with fuzzer parameters */
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
- /* Count the total number of tests */
+ /* Count the total number of tests */
suiteCounter = 0;
while (testSuites[suiteCounter]) {
testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
while (testSuite->testCases[testCounter])
{
testCounter++;
- totalNumberOfTests++;
- }
- }
-
- /* Pre-allocate an array for tracking failed tests (potentially all test cases) */
- failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
- if (failedTests == NULL) {
- SDLTest_LogError("Unable to allocate cache for failed tests");
- SDL_Error(SDL_ENOMEM);
+ totalNumberOfTests++;
+ }
+ }
+
+ /* Pre-allocate an array for tracking failed tests (potentially all test cases) */
+ failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
+ if (failedTests == NULL) {
+ SDLTest_LogError("Unable to allocate cache for failed tests");
+ SDL_Error(SDL_ENOMEM);
return -1;
- }
+ }
/* Initialize filtering */
if (filter != NULL && filter[0] != '\0') {
}
}
+
+
+
+ SDL_RWops *rwops = SDL_RWFromFile("SDL_Log_Summary.txt", "a+");
+
/* Loop over all suites */
suiteCounter = 0;
while(testSuites[suiteCounter]) {
if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL &&
SDL_strcmp(suiteFilterName, testSuite->name) != 0) {
/* Skip suite */
- SDLTest_Log("===== Test Suite %i: '%s' skipped\n",
- suiteCounter,
- currentSuiteName);
+ SDLTest_Log("===== Test Suite %i: '%s' skipped\n", suiteCounter, currentSuiteName);
+ SDLTest_writeLogFile(rwops, "===== Test Suite %i: '%s' skipped\n", suiteCounter, currentSuiteName);
} else {
/* Reset per-suite counters */
testFailedCount = 0;
testPassedCount = 0;
testSkippedCount = 0;
+ testUnsupportedCount = 0;
/* Take time - suite start */
suiteStartSeconds = GetClock();
/* Log suite started */
- SDLTest_Log("===== Test Suite %i: '%s' started\n",
- suiteCounter,
- currentSuiteName);
+ SDLTest_Log("===== Test Suite %i: '%s' started\n", suiteCounter, currentSuiteName);
+ SDLTest_writeLogFile(rwops, "===== Test Suite %i: '%s' started\n", suiteCounter, currentSuiteName);
/* Loop over all test cases */
testCounter = 0;
/* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */
if (testFilter == 1 && !testCase->enabled) {
SDLTest_Log("Force run of disabled test since test filter was set");
- forceTestRun = SDL_TRUE;
+ forceTestRun = SDL_TRUE;
}
/* Take time - test start */
}
SDLTest_Log("Test Iteration %i: execKey %" SDL_PRIu64, iterationCounter, execKey);
- testResult = SDLTest_RunTest(testSuite, testCase, execKey, forceTestRun);
+ testResult = SDLTest_RunTest(testSuite, testCase, execKey, forceTestRun);
if (testResult == TEST_RESULT_PASSED) {
testPassedCount++;
} else if (testResult == TEST_RESULT_SKIPPED) {
testSkippedCount++;
totalTestSkippedCount++;
+ } else if (testResult == TEST_RESULT_UNSUPPORTED) {
+ testUnsupportedCount++;
+ totalTestUnsupportedCount++;
} else {
testFailedCount++;
totalTestFailedCount++;
switch (testResult) {
case TEST_RESULT_PASSED:
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Passed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Passed");
break;
case TEST_RESULT_FAILED:
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "Failed");
break;
case TEST_RESULT_NO_ASSERT:
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT,"Test", currentTestName, "No Asserts");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Test", currentTestName, "No Asserts");
break;
}
/* Log suite runtime */
SDLTest_Log("Total Suite runtime: %.1f sec", runtime);
+ SDLTest_writeLogFile(rwops, "Total Suite runtime: %.1f sec", runtime);
/* Log summary and final Suite result */
- countSum = testPassedCount + testFailedCount + testSkippedCount;
+ countSum = testPassedCount + testFailedCount + testSkippedCount + testUnsupportedCount;
if (testFailedCount == 0)
{
- SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
+ SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount, testUnsupportedCount);
+ SDLTest_writeLogFile(rwops, SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount, testUnsupportedCount);
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Passed");
}
else
{
- SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
+ SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount, testUnsupportedCount);
+ SDLTest_writeLogFile(rwops, SDLTEST_LOG_SUMMARY_FORMAT, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount, testUnsupportedCount);
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Suite", currentSuiteName, "Failed");
}
}
SDLTest_Log("Total Run runtime: %.1f sec", runtime);
/* Log summary and final run result */
- countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
+ countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount + totalTestUnsupportedCount;
if (totalTestFailedCount == 0)
{
runResult = 0;
- SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
+ SDLTest_Log(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount, totalTestUnsupportedCount);
+ SDLTest_writeLogFile(rwops, SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount, totalTestUnsupportedCount);
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Passed");
+
}
else
{
runResult = 1;
- SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);
+ SDLTest_LogError(SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount, totalTestUnsupportedCount);
+ SDLTest_writeLogFile(rwops, SDLTEST_LOG_SUMMARY_FORMAT, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount, totalTestUnsupportedCount);
SDLTest_LogError(SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
+ SDLTest_writeLogFile(rwops, SDLTEST_FINAL_RESULT_FORMAT, "Run /w seed", runSeed, "Failed");
}
/* Print repro steps for failed tests */
SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
}
}
+ SDL_RWclose(rwops);
SDL_free((void *) failedTests);
SDLTest_Log("Exit code: %d", runResult);