Made run seed more file name friendly.
--- a/test/test-automation/build-scripts/install-tests.sh Thu Jul 28 18:32:27 2011 +0300
+++ b/test/test-automation/build-scripts/install-tests.sh Thu Jul 28 21:35:47 2011 +0300
@@ -21,4 +21,6 @@
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."
--- a/test/test-automation/plain_logger.c Thu Jul 28 18:32:27 2011 +0300
+++ b/test/test-automation/plain_logger.c Thu Jul 28 21:35:47 2011 +0300
@@ -27,12 +27,17 @@
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 @@
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 @@
}
}
+
level = data->level;
//printf("Debug: %d == %d\n", level, data->level);
@@ -87,6 +98,8 @@
Output(indentLevel, "%d tests passed", testPassCount);
Output(indentLevel, "%d tests failed", testFailCount);
Output(indentLevel, "%d tests skipped", testSkippedCount);
+
+ fclose(logFile);
}
void
--- a/test/test-automation/runner.c Thu Jul 28 18:32:27 2011 +0300
+++ b/test/test-automation/runner.c Thu Jul 28 21:35:47 2011 +0300
@@ -77,7 +77,8 @@
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 @@
//! 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
currentIteration--;
+ /*
if(userExecKey != NULL) {
SDL_free(globalExecKey);
}
globalExecKey = NULL;
+ */
}
}
@@ -1325,7 +1341,7 @@
}
UnloadTestCases(testCases);
- UnloadTestSuites(suites);
+ UnloadTestSuites(suites); // crashes here with -ts case1
const Uint32 endTicks = SDL_GetTicks();
const double totalRunTime = (endTicks - startTicks) / 1000.0f;
--- a/test/test-automation/xml_logger.c Thu Jul 28 18:32:27 2011 +0300
+++ b/test/test-automation/xml_logger.c Thu Jul 28 21:35:47 2011 +0300
@@ -257,6 +257,9 @@
output = XMLCloseDocument(documentRoot);
XMLOutputter(--indentLevel, YES, output);
+
+ // close the log file
+ fclose(logFile);
}
void