Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixes to logging system.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkauppila committed Jul 18, 2011
1 parent f923882 commit 99c4845
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/test-automation/logger.h
Expand Up @@ -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 */
Expand Down
11 changes: 10 additions & 1 deletion test/test-automation/plain_logger.c
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion test/test-automation/plain_logger.h
Expand Up @@ -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
10 changes: 5 additions & 5 deletions test/test-automation/runner.c
Expand Up @@ -557,6 +557,7 @@ LoadQuitTestInvironmentFunction(void *suite) {
return testEnvQuit;
}


/*!
* Loads function that returns failed assert count in the current
* test environment
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/test-automation/testdummy/testdummy.c
Expand Up @@ -95,7 +95,7 @@ void
dummycase2(void *arg)
{
char *msg = "eello";
//msg[0] = 'H';
msg[0] = 'H';
AssertTrue(1, "Assert message");
}

Expand Down
14 changes: 12 additions & 2 deletions test/test-automation/xml_logger.c
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/test-automation/xml_logger.h
Expand Up @@ -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

0 comments on commit 99c4845

Please sign in to comment.