Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Refining the output of XML logger.

  • Loading branch information
mkauppila committed Jun 27, 2011
1 parent add4c01 commit 23f8d07b2384985362c09420ecb4ffd20d5afc88
@@ -23,14 +23,11 @@

#include <time.h>

// Function pointer to function which handles to output
typedef int (*LogOutputFp)(const char *, ...);

/*!
* Generic logger interface
*
*/
typedef void (*RunStartedFp)(LogOutputFp outputFn, const char *runnerParameters, time_t eventTime);
typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], time_t eventTime);
typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, time_t totalRuntime);

@@ -54,7 +51,6 @@ typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed, int numAss

typedef void (*LogFp)(const char *logMessage, time_t eventTime);

int Output(const char *message, ...);

extern RunStartedFp RunStarted;
extern RunEndedFp RunEnded;
@@ -27,7 +27,7 @@ Output(const char *message, ...)
}

void
PlainRunStarted(const char *runnerParameters, time_t eventTime)
PlainRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime)
{
Output("Test run started");
Output("Given command line options: %s", "add options");
@@ -3,7 +3,7 @@

#include "logger.h"

void PlainRunStarted(const char *runnerParameters, time_t eventTime);
void PlainRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime);

void PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, time_t totalRuntime);
@@ -220,19 +220,19 @@ LoadTestCases(TestSuiteReference *suites)
item->testCaseQuit = testCaseQuit;

// copy suite name
int length = strlen(suiteReference->name) + 1;
int length = SDL_strlen(suiteReference->name) + 1;
item->suiteName = SDL_malloc(length);
strcpy(item->suiteName, suiteReference->name);
strncpy(item->suiteName, suiteReference->name, length);

// copy test name
length = strlen(testReference->name) + 1;
length = SDL_strlen(testReference->name) + 1;
item->testName = SDL_malloc(length);
strcpy(item->testName, testReference->name);
strncpy(item->testName, testReference->name, length);

// copy test description
length = strlen(testReference->description) + 1;
length = SDL_strlen(testReference->description) + 1;
item->description = SDL_malloc(length);
strcpy(item->testName, testReference->name);
strncpy(item->description, testReference->description, length);

item->requirements = testReference->requirements;
item->timeout = testReference->timeout;
@@ -637,7 +637,8 @@ main(int argc, char *argv[])

// print: Testing against SDL version fuu (rev: bar) if verbose == true

int failureCount = 0, passCount = 0;
int totalTestfailureCount = 0, totalTestPassCount = 0;
int testFailureCount = 0, testPassCount = 0, testSkipCount = 0;
char *testSuiteName = NULL;
int suiteCounter = 0;

@@ -670,7 +671,7 @@ main(int argc, char *argv[])
return 0;
}

RunStarted(Output, NULL, 0);
RunStarted(argc, argv, 0);

char *currentSuiteName = NULL;

@@ -679,50 +680,50 @@ main(int argc, char *argv[])
if(currentSuiteName == NULL) {
currentSuiteName = testItem->suiteName;
SuiteStarted(currentSuiteName, 0);

testFailureCount = testPassCount = 0;

suiteCounter++;
}
else if(strncmp(currentSuiteName, testItem->suiteName, NAME_BUFFER_SIZE) != 0) {
SuiteEnded(testPassCount, testFailureCount, testSkipCount, 0.0f, 0);

currentSuiteName = testItem->suiteName;
SuiteStarted(currentSuiteName, 0);

testFailureCount = testPassCount = 0;

suiteCounter++;
}

TestStarted(testItem->testName, testItem->suiteName,
testItem->description, 0);

int retVal = ExecuteTest(testItem);

if(retVal) {
failureCount++;
if(retVal == 2) {
//printf("%s (in %s): FAILED -> No asserts\n", testItem->testName, testItem->suiteName);
} else {
//printf("%s (in %s): FAILED\n", testItem->testName, testItem->suiteName);
}
totalTestfailureCount++;
testFailureCount++;
} else {
passCount++;
//printf("%s (in %s): ok\n", testItem->testName, testItem->suiteName);
totalTestPassCount++;
testPassCount++;
}

TestEnded(testItem->testName, testItem->suiteName, retVal, 0, 0);

if(strncmp(currentSuiteName, testItem->suiteName, 100) != 0) {
SuiteEnded(0, 0, 0, 0.0f, 0);

currentSuiteName = testItem->suiteName;
SuiteStarted(currentSuiteName, 0);
}
}

SuiteEnded(0, 0, 0, 0.0f, 0);
if(currentSuiteName) {
// \todo if no test are run, this will case incorrect nesting with
// xml output
SuiteEnded(testPassCount, testFailureCount, testSkipCount, 0.0f, 0);
}

UnloadTestCases(testCases);
UnloadTestSuites(suites);

const Uint32 endTicks = SDL_GetTicks();

RunEnded(passCount + failureCount, 1 /*add suiteCount */,
passCount, failureCount, 0, 0);
/*
printf("Ran %d tests in %0.5f seconds.\n", (passCount + failureCount), (endTicks-startTicks)/1000.0f);
printf("%d tests passed\n", passCount);
printf("%d tests failed\n", failureCount);
*/
RunEnded(totalTestPassCount + totalTestfailureCount, suiteCounter,
totalTestPassCount, totalTestfailureCount, 0, 0);

return 0;
}
@@ -26,9 +26,6 @@

#include "xml.h"

/*! Points the function which handles the output */
static LogOutputFp logger = 0;

/*!
* Defines structure used for "counting" open XML-tags
*/
@@ -88,13 +85,6 @@ RemoveOpenTag(const char *tag)
TagList *openTag = openTags;
SDL_free((char *)openTag->tag);

/*
int counter = 0;
for(; counter < strlen(buffer); ++counter) {
buffer[counter] = tolower(buffer[counter]);
}
*/

openTags = openTags->next;
SDL_free(openTag);
} else {
@@ -188,7 +178,6 @@ ToLowerCase(const char *string)
strncpy(ret, string, size);
ret[size] = '\0';

// turn the tag to lower case for case-insensitive comparation
int counter = 0;
for(; counter < size; ++counter) {
ret[counter] = tolower(ret[counter]);
@@ -283,6 +272,9 @@ XMLCloseElement(const char *tag)
char *ret = SDL_malloc(bufferSize);
memset(ret, 0, bufferSize);

// \todo check that element we're trying is actually open,
// otherwise it'll case nesting problems

// Close the open tags with proper nesting. Closes tags until it finds
// the given tag which is the last tag that will be closed
TagList *openTag = openTags;

0 comments on commit 23f8d07

Please sign in to comment.