diff --git a/test/test-automation/build-scripts/install-tests.sh b/test/test-automation/build-scripts/install-tests.sh index cb7efebc1..a9517a271 100755 --- a/test/test-automation/build-scripts/install-tests.sh +++ b/test/test-automation/build-scripts/install-tests.sh @@ -21,4 +21,6 @@ do cp -f "$suite/.libs/lib$suite.$EXT" $DIRECTORY done +sudo cp .libs/libtest.0.dylib /usr/local/lib/libtest.0.dylib + echo "Test suites installed." diff --git a/test/test-automation/plain_logger.c b/test/test-automation/plain_logger.c index 4e605a64d..15dda5d14 100644 --- a/test/test-automation/plain_logger.c +++ b/test/test-automation/plain_logger.c @@ -27,12 +27,17 @@ static FILE *logFile; int Output(const int currentIndentLevel, const char *message, ...) { + if(logFile == NULL) { + fprintf(stderr, "logfile is NULL\n"); + exit(3); + } + int indent = 0; for( ; indent < currentIndentLevel; ++indent) { fprintf(logFile, " "); // \todo make configurable? } - char buffer[1024]; + char buffer[1024]; memset(buffer, 0, 1024); va_list list; @@ -41,17 +46,22 @@ Output(const int currentIndentLevel, const char *message, ...) SDL_vsnprintf(buffer, 1024, message, list); va_end(list); - fprintf(logFile, "%s\n", buffer); fflush(logFile); } + void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, time_t eventTime, LoggerData *data) { + if(data == NULL) { + fprintf(stderr, "Logger data is NULL\n"); + exit(3); + } + // Set up the logging destination - if(data->stdoutEnabled) { + if(data->stdoutEnabled == 1) { logFile = stdout; } else { logFile = fopen(data->filename, "w"); @@ -61,6 +71,7 @@ PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, } } + level = data->level; //printf("Debug: %d == %d\n", level, data->level); @@ -87,6 +98,8 @@ PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCoun Output(indentLevel, "%d tests passed", testPassCount); Output(indentLevel, "%d tests failed", testFailCount); Output(indentLevel, "%d tests skipped", testSkippedCount); + + fclose(logFile); } void diff --git a/test/test-automation/runner.c b/test/test-automation/runner.c index 3463b076e..3aee5d6a2 100644 --- a/test/test-automation/runner.c +++ b/test/test-automation/runner.c @@ -77,7 +77,8 @@ static int universal_timeout_enabled = 0; static int enable_verbose_logger = 0; //! Flag for using user supplied run seed static int userRunSeed = 0; - +//! Whether or not logger should log to stdout instead of file +static int log_stdout_enabled = 0; //!< Size of the test and suite name buffers #define NAME_BUFFER_SIZE 1024 @@ -119,10 +120,6 @@ char *userExecKey = NULL; //! How man time a test will be invocated int testInvocationCount = 1; -//! Whether or not logger should log to stdout instead of file -static int log_stdout_enabled = 0; - - //! Stores the basename for log files char log_basename[NAME_BUFFER_SIZE]; @@ -859,9 +856,23 @@ GenerateRunSeed(const int length) int counter = 0; for( ; counter < length; ++counter) { int number = abs(utl_random(&randomContext)); - seed[counter] = (char) (number % (127 - 34)) + 34; + char ch = (char) (number % (122 - 48)) + 48; + + // Remove all the special characters so the run seed + // can be used to form a valid filename. + // A lot more characters are skipped than necessary. + if(ch >= 58 && ch <= 64) { + ch = 65; + } + if(ch >= 91 && ch <= 96) { + ch = 97; + } + + seed[counter] = ch; } + seed[counter] = '\0'; + return seed; } @@ -878,11 +889,12 @@ SetUpLogger() fprintf(stderr, "Error: Logger data structure not allocated."); return NULL; } + memset(loggerData, 0, sizeof(LoggerData)); loggerData->level = (enable_verbose_logger ? VERBOSE : STANDARD); - if(log_stdout_enabled) { - loggerData->stdoutEnabled = SDL_TRUE; + if(log_stdout_enabled == 1) { + loggerData->stdoutEnabled = 1; loggerData->filename = NULL; } else { const char *extension = (xml_enabled ? "xml": "log"); @@ -1037,6 +1049,7 @@ ParseOptions(int argc, char *argv[]) exit(1); } + memset(log_directory, 0, NAME_BUFFER_SIZE); memcpy(log_directory, dirString, SDL_strlen(dirString)); } else if(SDL_strcmp(arg, "--logfile") == 0) { @@ -1050,6 +1063,7 @@ ParseOptions(int argc, char *argv[]) exit(1); } + memset(log_basename, 0, NAME_BUFFER_SIZE); memcpy(log_basename, fileString, SDL_strlen(fileString)); } else if(SDL_strcmp(arg, "--log-stdout") == 0) { @@ -1241,6 +1255,11 @@ main(int argc, char *argv[]) RunStarted(argc, argv, runSeed, time(0), loggerData); + // logger data is no longer used + SDL_free(loggerData->filename); + SDL_free(loggerData); + + /* // validate the parsed command options if(execute_inproc && universal_timeout_enabled) { Log(time(0), "Test timeout is not supported with in-proc execution."); @@ -1248,16 +1267,12 @@ main(int argc, char *argv[]) universal_timeout_enabled = 0; universal_timeout = -1; - }/* + }*/ /* if(userExecKey && testInvocationCount > 1 || userRunSeed) { printf("The given combination of command line options doesn't make sense\n"); printf("--exec-key should only be used to rerun failed fuzz tests\n"); }*/ - // logger data is no longer used - SDL_free(loggerData->filename); - SDL_free(loggerData); - char *currentSuiteName = NULL; int suiteStartTime = SDL_GetTicks(); @@ -1293,9 +1308,8 @@ main(int argc, char *argv[]) if(userExecKey != NULL) { globalExecKey = userExecKey; } else { - char *execKey = GenerateExecKey(runSeed, testItem->suiteName, + globalExecKey = GenerateExecKey(runSeed, testItem->suiteName, testItem->testName, currentIteration); - globalExecKey = execKey; } TestStarted(testItem->testName, testItem->suiteName, @@ -1311,10 +1325,12 @@ main(int argc, char *argv[]) currentIteration--; + /* if(userExecKey != NULL) { SDL_free(globalExecKey); } globalExecKey = NULL; + */ } } @@ -1325,7 +1341,7 @@ main(int argc, char *argv[]) } UnloadTestCases(testCases); - UnloadTestSuites(suites); + UnloadTestSuites(suites); // crashes here with -ts case1 const Uint32 endTicks = SDL_GetTicks(); const double totalRunTime = (endTicks - startTicks) / 1000.0f; diff --git a/test/test-automation/xml_logger.c b/test/test-automation/xml_logger.c index 8e0a2d23c..a576584a5 100644 --- a/test/test-automation/xml_logger.c +++ b/test/test-automation/xml_logger.c @@ -257,6 +257,9 @@ XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount, output = XMLCloseDocument(documentRoot); XMLOutputter(--indentLevel, YES, output); + + // close the log file + fclose(logFile); } void