From 6ab0dd4945db95ad91b18dc736fcc9a7dd43189e Mon Sep 17 00:00:00 2001 From: Markus Kauppila Date: Mon, 18 Jul 2011 16:37:02 +0300 Subject: [PATCH] Fixes to logging system. --- test/test-automation/logger.h | 2 +- test/test-automation/plain_logger.c | 11 ++++++++++- test/test-automation/plain_logger.h | 2 +- test/test-automation/runner.c | 10 +++++----- test/test-automation/testdummy/testdummy.c | 2 +- test/test-automation/xml_logger.c | 14 ++++++++++++-- test/test-automation/xml_logger.h | 2 +- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/test/test-automation/logger.h b/test/test-automation/logger.h index 4f1053680..67e91e207 100644 --- a/test/test-automation/logger.h +++ b/test/test-automation/logger.h @@ -51,7 +51,7 @@ typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult, typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime); -typedef void (*LogFp)(const char *logMessage, time_t eventTime); +typedef void (*LogFp)(time_t eventTime, char *fmt, ...); /*! Function pointers to actual logging function implementations */ diff --git a/test/test-automation/plain_logger.c b/test/test-automation/plain_logger.c index e4f492e1e..8c1f14858 100644 --- a/test/test-automation/plain_logger.c +++ b/test/test-automation/plain_logger.c @@ -136,8 +136,17 @@ PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, tim } void -PlainLog(const char *logMessage, time_t eventTime) +PlainLog(time_t eventTime, char *fmt, ...) { + // create the log message + va_list args; + char logMessage[1024]; + memset(logMessage, 0, sizeof(logMessage)); + + va_start( args, fmt ); + SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); + va_end( args ); + Output(indentLevel, "%s", logMessage); } diff --git a/test/test-automation/plain_logger.h b/test/test-automation/plain_logger.h index 76b6bb590..8c915a183 100644 --- a/test/test-automation/plain_logger.h +++ b/test/test-automation/plain_logger.h @@ -113,6 +113,6 @@ void PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass * \param logMessage Message to be logged * \param eventTime Timestamp for log message */ -void PlainLog(const char *logMessage, time_t eventTime); +void PlainLog(time_t eventTime, char *fmt, ...); #endif diff --git a/test/test-automation/runner.c b/test/test-automation/runner.c index 7aeb0b677..612d95895 100644 --- a/test/test-automation/runner.c +++ b/test/test-automation/runner.c @@ -557,6 +557,7 @@ LoadQuitTestInvironmentFunction(void *suite) { return testEnvQuit; } + /*! * Loads function that returns failed assert count in the current * test environment @@ -643,7 +644,7 @@ RunTest(TestCase *testItem) { if(testItem->timeout > 0 || universal_timeout > 0) { if(execute_inproc) { - Log("Test asked for timeout which is not supported.", time(0)); + Log(time(0), "Test asked for timeout which is not supported."); } else { SetTestTimeout(testItem->timeout, KillHungTestInChildProcess); @@ -700,7 +701,6 @@ ExecuteTest(TestCase *testItem) { } - /*! * If using out-of-proc execution of tests. This function * will handle the return value of the child process @@ -721,7 +721,7 @@ HandleChildProcessReturnValue(int stat_lock) } else if(WIFSIGNALED(stat_lock)) { int signal = WTERMSIG(stat_lock); // \todo add this to logger (add signal number) - Log("FAILURE: test was aborted due to signal\n", time(0)); + Log(time(0), "FAILURE: test was aborted due to %d\n", signal); returnValue = 1; } @@ -972,8 +972,8 @@ main(int argc, char *argv[]) RunStarted(argc, argv, time(0), loggerData); if(execute_inproc && universal_timeout_enabled) { - Log("Test timeout is not supported with in-proc execution.", time(0)); - Log("Timeout will be disabled...", time(0)); + Log(time(0), "Test timeout is not supported with in-proc execution."); + Log(time(0), "Timeout will be disabled..."); universal_timeout_enabled = 0; universal_timeout = -1; diff --git a/test/test-automation/testdummy/testdummy.c b/test/test-automation/testdummy/testdummy.c index ec2dcbfdf..a4f740bc6 100644 --- a/test/test-automation/testdummy/testdummy.c +++ b/test/test-automation/testdummy/testdummy.c @@ -95,7 +95,7 @@ void dummycase2(void *arg) { char *msg = "eello"; - //msg[0] = 'H'; + msg[0] = 'H'; AssertTrue(1, "Assert message"); } diff --git a/test/test-automation/xml_logger.c b/test/test-automation/xml_logger.c index 296b12694..07bf46a88 100644 --- a/test/test-automation/xml_logger.c +++ b/test/test-automation/xml_logger.c @@ -571,15 +571,25 @@ XMLAssertSummary(int numAsserts, int numAssertsFailed, } void -XMLLog(const char *logMessage, time_t eventTime) +XMLLog(time_t eventTime, char *fmt, ...) { + // create the log message + va_list args; + char logMessage[1024]; + memset(logMessage, 0, sizeof(logMessage)); + + va_start( args, fmt ); + SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); + va_end( args ); + char *output = XMLOpenElement(logElementName); - XMLOutputter(indentLevel++, NO, output); + XMLOutputter(indentLevel++, YES, output); // log message output = XMLOpenElement(messageElementName); XMLOutputter(indentLevel++, NO, output); + // fix this here! output = XMLAddContent(logMessage); XMLOutputter(indentLevel, NO, output); diff --git a/test/test-automation/xml_logger.h b/test/test-automation/xml_logger.h index c812a503f..159e9b4e1 100644 --- a/test/test-automation/xml_logger.h +++ b/test/test-automation/xml_logger.h @@ -109,6 +109,6 @@ void XMLAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, * \param logMessage Message to be logged * \param eventTime Timestamp for log message */ -void XMLLog(const char *logMessage, time_t eventTime); +void XMLLog(time_t eventTime, char *fmt, ...); #endif