Fixes based on CR.
This commit is contained in:
parent
6cb39be4a6
commit
c843c7e815
8 changed files with 317 additions and 330 deletions
|
@ -3,7 +3,7 @@ ACLOCAL_AMFLAGS = -I acinclude -I build-scripts
|
|||
SUBDIRS = testdummy testrect testplatform
|
||||
|
||||
bin_PROGRAMS = runner
|
||||
runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c
|
||||
runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c logger_helpers.c
|
||||
runner_CLAGS = -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
|
||||
runner_LDFLAGS = `sdl-config --libs`
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "xml_logger.h"
|
||||
#include "plain_logger.h"
|
||||
|
||||
// Pointers to selected logger implementation
|
||||
//! Pointers to selected logger implementation
|
||||
RunStartedFp RunStarted = 0;
|
||||
RunEndedFp RunEnded = 0;
|
||||
SuiteStartedFp SuiteStarted = 0;
|
||||
|
@ -22,6 +22,9 @@ AssertWithValuesFp AssertWithValues = 0;
|
|||
AssertSummaryFp AssertSummary = 0;
|
||||
LogFp Log = 0;
|
||||
|
||||
/*!
|
||||
* Sets up the XML logger
|
||||
*/
|
||||
int
|
||||
SetupXMLLogger()
|
||||
{
|
||||
|
@ -41,6 +44,9 @@ SetupXMLLogger()
|
|||
Log = XMLLog;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Sets up the plain logger
|
||||
*/
|
||||
int
|
||||
SetupPlainLogger()
|
||||
{
|
||||
|
@ -59,64 +65,3 @@ SetupPlainLogger()
|
|||
|
||||
Log = PlainLog;
|
||||
}
|
||||
|
||||
|
||||
char *IntToString(const int integer) {
|
||||
static char buffer[sizeof(int) * 8 + 1]; // malloc might work better
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
SDL_snprintf(buffer, sizeof(buffer), "%d", integer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
char *DoubleToString(const double decimal) {
|
||||
static char buffer[sizeof(double) * 8 + 1]; // malloc might work better
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *TimestampToString(const time_t timestamp) {
|
||||
static char buffer[1024];
|
||||
//char *buffer = SDL_malloc(1024);
|
||||
memset(buffer, 0, 1024);
|
||||
|
||||
time_t copy = timestamp;
|
||||
|
||||
struct tm *local = localtime(©);
|
||||
strftime(buffer, 1024, "%a %Y-%m-%d %H:%M:%S %Z", local);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*!
|
||||
* Test app for logging functionality
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int xml_enabled = 1;
|
||||
|
||||
if(xml_enabled) {
|
||||
SetupXMLLogger();
|
||||
} else {
|
||||
SetupPlainLogger();
|
||||
}
|
||||
|
||||
RunStarted(Output, "some_<data_>here&here", 0);
|
||||
SuiteStarted("Suite data here", 0);
|
||||
|
||||
TestStarted("test1", "suite", "desc", 0);
|
||||
TestEnded("test1", "suite", 0, 0, 0, 0);
|
||||
|
||||
SuiteEnded(0, 0, 0, 0.0f, 0);
|
||||
RunEnded(0, 0, 0, 0, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -65,30 +65,4 @@ extern AssertWithValuesFp AssertWithValues;
|
|||
extern AssertSummaryFp AssertSummary;
|
||||
extern LogFp Log;
|
||||
|
||||
/*!
|
||||
* Helper functions. Turns the given integer in to a string
|
||||
*
|
||||
* \param integer The converted integer
|
||||
* \returns Given integer as string
|
||||
*/
|
||||
char *IntToString(const int integer);
|
||||
|
||||
/*!
|
||||
* Helper functions. Turns the given double value in to a string
|
||||
*
|
||||
* \param decimal The converted double value
|
||||
* \returns Given double value as string
|
||||
*/
|
||||
char *DoubleToString(const double decimal);
|
||||
|
||||
|
||||
/*!
|
||||
* Converts unix timestamp to it's ascii presentation
|
||||
*
|
||||
* \param timestamp Timestamp
|
||||
* \return Ascii presentation
|
||||
*/
|
||||
char *TimestampToString(const time_t timestamp);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
119
test/test-automation/logger_helpers.c
Normal file
119
test/test-automation/logger_helpers.c
Normal file
|
@ -0,0 +1,119 @@
|
|||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include "logger_helpers.h"
|
||||
|
||||
/*!
|
||||
* Helper functions. Turns the given integer in to a string
|
||||
*
|
||||
* Note: uses static buffer internally, so the return value
|
||||
* isn't valid after the next call of this function. If you
|
||||
* want to retain the return value, make a copy of it
|
||||
*
|
||||
* \param integer The converted integer
|
||||
* \returns Given integer as string
|
||||
*/
|
||||
char *IntToString(const int integer) {
|
||||
static char buffer[256]; // malloc might work better
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
SDL_snprintf(buffer, sizeof(buffer), "%d", integer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Helper functions. Turns the given double value in to a string
|
||||
*
|
||||
* Note: uses static buffer internally, so the return value
|
||||
* isn't valid after the next call of this function. If you
|
||||
* want to retain the return value, make a copy of it
|
||||
*
|
||||
* \param decimal The converted double value
|
||||
* \returns Given double value as string
|
||||
*/
|
||||
char *DoubleToString(const double decimal) {
|
||||
static char buffer[256]; // malloc might work better
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Converts unix timestamp to its ascii presentation
|
||||
*
|
||||
* Note: uses static buffer internally, so the return value
|
||||
* isn't valid after the next call of this function. If you
|
||||
* want to retain the return value, make a copy of it
|
||||
*
|
||||
* \param timestamp Timestamp
|
||||
* \return Ascii presentation
|
||||
*/
|
||||
char *TimestampToString(const time_t timestamp) {
|
||||
static char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
time_t copy = timestamp;
|
||||
|
||||
struct tm *local = localtime(©);
|
||||
strftime(buffer, sizeof(buffer), "%a %Y-%m-%d %H:%M:%S %Z", local);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*! Turns all the characters of the given
|
||||
* string to lowercase and returns the resulting string.
|
||||
*
|
||||
* \param string String to be converted
|
||||
* \return Newly allocated lower-case version of the given string
|
||||
*/
|
||||
char *
|
||||
ToLowerCase(const char *string)
|
||||
{
|
||||
if(ValidateString(string) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int size = SDL_strlen(string);
|
||||
char *ret = SDL_malloc(size + 1);
|
||||
strncpy(ret, string, size);
|
||||
ret[size] = '\0';
|
||||
|
||||
int counter = 0;
|
||||
for(; counter < size; ++counter) {
|
||||
ret[counter] = tolower(ret[counter]);
|
||||
}
|
||||
|
||||
// printf("Debug: %s == %s\n", string, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Validates string by checking that given string is not
|
||||
* NULL, its length is non-zero etc.
|
||||
*
|
||||
* \param string Validated string
|
||||
* \returns 1 if string is valid, otherwise 0
|
||||
*/
|
||||
int
|
||||
ValidateString(const char *string)
|
||||
{
|
||||
int retVal = 1;
|
||||
|
||||
if(string != NULL) {
|
||||
if(SDL_strlen(string) > 0) {
|
||||
retVal = 1;
|
||||
}
|
||||
|
||||
retVal = 1;
|
||||
} else {
|
||||
retVal = 0;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
16
test/test-automation/logger_helpers.h
Normal file
16
test/test-automation/logger_helpers.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef _LOGGER_HELPERS_G
|
||||
#define _LOGGER_HELPERS_G
|
||||
|
||||
#include <time.h>
|
||||
|
||||
char *IntToString(const int integer);
|
||||
|
||||
char *DoubleToString(const double decimal);
|
||||
|
||||
char *TimestampToString(const time_t timestamp);
|
||||
|
||||
char *ToLowerCase(const char *string);
|
||||
|
||||
int ValidateString(const char *string);
|
||||
|
||||
#endif
|
|
@ -25,6 +25,15 @@
|
|||
#include <SDL/SDL.h>
|
||||
|
||||
#include "xml.h"
|
||||
#include "logger_helpers.h"
|
||||
|
||||
/*! Size for xml element buffer */
|
||||
#define bufferSize 1024
|
||||
/*! Buffer for storing the xml element under construction */
|
||||
static char buffer[bufferSize];
|
||||
|
||||
/*! Pointer to XML root element's tag */
|
||||
static const char *root;
|
||||
|
||||
/*!
|
||||
* Defines structure used for "counting" open XML-tags
|
||||
|
@ -52,6 +61,11 @@ AddOpenTag(const char *tag)
|
|||
|
||||
const int tagSize = SDL_strlen(tag) + 1;
|
||||
openTag->tag = SDL_malloc(tagSize);
|
||||
if(openTag->tag == NULL) {
|
||||
SDL_free(openTag);
|
||||
return 1;
|
||||
}
|
||||
|
||||
strncpy((char *)openTag->tag, (char *)tag, tagSize);
|
||||
|
||||
openTag->next = openTags;
|
||||
|
@ -69,7 +83,7 @@ AddOpenTag(const char *tag)
|
|||
static int
|
||||
RemoveOpenTag(const char *tag)
|
||||
{
|
||||
if(openTags == NULL) {
|
||||
if(openTags == NULL || ValidateString(tag) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +95,7 @@ RemoveOpenTag(const char *tag)
|
|||
|
||||
// Tag should always be the same as previously opened tag
|
||||
// It prevents opening and ending tag mismatch
|
||||
if(SDL_strcmp(tempTag, tag) == 0) {
|
||||
if(SDL_strncmp(tempTag, tag, size) == 0) {
|
||||
TagList *openTag = openTags;
|
||||
SDL_free((char *)openTag->tag);
|
||||
|
||||
|
@ -115,15 +129,20 @@ PrintOpenTags()
|
|||
* corresponding entities: ' " < > and &
|
||||
*
|
||||
* \param string String to be escaped
|
||||
* \return Escaped string
|
||||
* \return Newly allocated escaped string
|
||||
*/
|
||||
const char *EscapeString(const char *string) {
|
||||
const int bufferSize = 4096;
|
||||
const char *
|
||||
EscapeString(const char *string)
|
||||
{
|
||||
//const int bufferSize = 4096;
|
||||
char buffer[bufferSize];
|
||||
memset(buffer, 0, bufferSize);
|
||||
|
||||
// prevents the code doing a 'bus error'
|
||||
char *stringBuffer = SDL_malloc(bufferSize);
|
||||
if(stringBuffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(stringBuffer, string, bufferSize);
|
||||
|
||||
// Ampersand (&) must be first, otherwise it'll mess up the other entities
|
||||
|
@ -164,29 +183,6 @@ const char *EscapeString(const char *string) {
|
|||
return stringBuffer;
|
||||
}
|
||||
|
||||
/*! Turns all the characters of the given
|
||||
* string to lowercase and returns the resulting string.
|
||||
*
|
||||
* \param string String to be converted
|
||||
* \return Lower-case version of the given string
|
||||
*/
|
||||
char *
|
||||
ToLowerCase(const char *string)
|
||||
{
|
||||
const int size = SDL_strlen(string);
|
||||
char *ret = SDL_malloc(size + 1);
|
||||
strncpy(ret, string, size);
|
||||
ret[size] = '\0';
|
||||
|
||||
int counter = 0;
|
||||
for(; counter < size; ++counter) {
|
||||
ret[counter] = tolower(ret[counter]);
|
||||
}
|
||||
|
||||
// printf("Debug: %s == %s\n", string, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
|
@ -196,13 +192,6 @@ ToLowerCase(const char *string)
|
|||
===================
|
||||
*/
|
||||
|
||||
static const char *root;
|
||||
|
||||
/*! Size for xml element buffer */
|
||||
#define bufferSize 1024
|
||||
/*! Buffer for storing the xml element under construction */
|
||||
static char buffer[bufferSize];
|
||||
|
||||
char *
|
||||
XMLOpenDocument(const char *rootTag)
|
||||
{
|
||||
|
@ -252,8 +241,16 @@ XMLOpenElement(const char *tag)
|
|||
char *
|
||||
XMLAddContent(const char *content)
|
||||
{
|
||||
if(ValidateString(content) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *escapedContent = EscapeString(content);
|
||||
|
||||
if(SDL_strlen(escapedContent) >= bufferSize) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(buffer, 0, bufferSize);
|
||||
snprintf(buffer, bufferSize, "%s", escapedContent);
|
||||
SDL_free((char *)escapedContent);
|
||||
|
@ -269,11 +266,16 @@ XMLAddContent(const char *content)
|
|||
char *
|
||||
XMLCloseElement(const char *tag)
|
||||
{
|
||||
char *ret = SDL_malloc(bufferSize);
|
||||
memset(ret, 0, bufferSize);
|
||||
if(ValidateString(tag) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// \todo check that element we're trying is actually open,
|
||||
// otherwise it'll case nesting problems
|
||||
int retBufferSize = 150;
|
||||
char *ret = SDL_malloc(retBufferSize);
|
||||
memset(ret, 0, retBufferSize);
|
||||
|
||||
// \todo check that element we're trying to close is actually open,
|
||||
// otherwise it'll cause 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
|
||||
|
|
|
@ -34,6 +34,8 @@ typedef struct Attribute {
|
|||
* Opens XML document.
|
||||
* Creates header and start tag for root element.
|
||||
*
|
||||
* Note: XML creation is not thread-safe!
|
||||
*
|
||||
* \param rootTag Root tag for the XML document
|
||||
* \return The generated XML output
|
||||
*/
|
||||
|
|
|
@ -25,87 +25,119 @@
|
|||
#include <SDL/SDL.h>
|
||||
|
||||
#include "xml.h"
|
||||
#include "logger.h"
|
||||
#include "logger_helpers.h"
|
||||
|
||||
#include "xml_logger.h"
|
||||
|
||||
/*! Static strings for XML elements */
|
||||
const char *documentRoot = "testlog";
|
||||
const char *parametersElementName = "parameters";
|
||||
const char *parameterElementName = "parameter";
|
||||
const char *startTimeElementName = "startTime";
|
||||
const char *numSuitesElementName = "numSuites";
|
||||
const char *numTestElementName = "numTests";
|
||||
const char *numPassedTestsElementName = "numPassedTests";
|
||||
const char *numFailedTestsElementName = "numFailedTests";
|
||||
const char *endTimeElementName = "endTime";
|
||||
const char *totalRuntimeElementName = "totalRuntime";
|
||||
const char *suiteElementName = "suite";
|
||||
const char *testsPassedElementName = "testsPassed";
|
||||
const char *testsFailedElementName = "testsFailed";
|
||||
const char *testsSkippedElementName = "testsSkipped";
|
||||
const char *testElementName = "test";
|
||||
const char *nameElementName = "name";
|
||||
const char *descriptionElementName = "description";
|
||||
const char *resultElementName = "result";
|
||||
const char *assertElementName = "assert";
|
||||
const char *messageElementName = "message";
|
||||
const char *timeElementName = "time";
|
||||
const char *assertSummaryElementName = "assertSummary";
|
||||
const char *assertCountElementName = "assertName";
|
||||
const char *assertsPassedElementName = "assertsPassed";
|
||||
const char *assertsFailedElementName = "assertsFailed";
|
||||
const char *logElementName = "log";
|
||||
|
||||
|
||||
/*! Current indentationt level */
|
||||
static int indentLevel;
|
||||
|
||||
//! Constants for XMLOuputters EOL parameter
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
/*! Controls printing the identation in relation to line breaks */
|
||||
/*! Controls printing the indentation in relation to line breaks */
|
||||
static int prevEOL = YES;
|
||||
|
||||
/*
|
||||
* Prints out the given xml element etc.
|
||||
*
|
||||
* \todo Make the destination of the output changeable (defaults to stdout)
|
||||
*
|
||||
* \param identLevel the indent level of the message
|
||||
* \param EOL will it print end of line character or not
|
||||
* \param the XML element itself
|
||||
*
|
||||
*/
|
||||
void XMLOutputter(const int currentIdentLevel, int EOL, const char *message) {
|
||||
int ident = 0;
|
||||
for( ; ident < currentIdentLevel && prevEOL; ++ident) {
|
||||
printf("\t");
|
||||
}
|
||||
void
|
||||
XMLOutputter(const int currentIdentLevel,
|
||||
int EOL, const char *message)
|
||||
{
|
||||
if(ValidateString(message)) {
|
||||
int ident = 0;
|
||||
for( ; ident < currentIdentLevel && prevEOL; ++ident) {
|
||||
printf(" "); // \todo make configurable?
|
||||
}
|
||||
|
||||
prevEOL = EOL;
|
||||
prevEOL = EOL;
|
||||
|
||||
if(EOL) {
|
||||
printf("%s\n", message);
|
||||
if(EOL) {
|
||||
fprintf(stdout, "%s\n", message);
|
||||
} else {
|
||||
fprintf(stdout, "%s", message);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
} else {
|
||||
printf("%s", message);
|
||||
fprintf(stdout, "Error: Tried to output invalid string!");
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
SDL_free(message);
|
||||
}
|
||||
|
||||
void
|
||||
XMLRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenDocument("testlog");
|
||||
char *output = XMLOpenDocument(documentRoot);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("parameters");
|
||||
output = XMLOpenElement(parametersElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
int counter = 0;
|
||||
for(counter = 0; counter < parameterCount; counter++) {
|
||||
char *parameter = runnerParameters[counter];
|
||||
|
||||
output = XMLOpenElement("parameter");
|
||||
output = XMLOpenElement(parameterElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(parameter);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("parameter");
|
||||
output = XMLCloseElement(parameterElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
output = XMLCloseElement("parameters");
|
||||
output = XMLCloseElement(parametersElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("eventTime");
|
||||
output = XMLOpenElement(startTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(eventTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("eventTime");
|
||||
output = XMLCloseElement(startTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -113,107 +145,83 @@ XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
|
|||
time_t endTime, double totalRuntime)
|
||||
{
|
||||
// log suite count
|
||||
char *output = XMLOpenElement("numSuites");
|
||||
char *output = XMLOpenElement(numSuitesElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(suiteCount));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("numSuites");
|
||||
output = XMLCloseElement(numSuitesElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log test count
|
||||
output = XMLOpenElement("numTest");
|
||||
output = XMLOpenElement(numTestElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testCount));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("numTest");
|
||||
output = XMLCloseElement(numTestElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log passed test count
|
||||
output = XMLOpenElement("numPassedTests");
|
||||
output = XMLOpenElement(numPassedTestsElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testPassCount));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("numPassedTests");
|
||||
output = XMLCloseElement(numPassedTestsElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log failed test count
|
||||
output = XMLOpenElement("numFailedTests");
|
||||
output = XMLOpenElement(numFailedTestsElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testFailCount));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("numFailedTests");
|
||||
output = XMLCloseElement(numFailedTestsElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
|
||||
// log end timte
|
||||
output = XMLOpenElement("endTime");
|
||||
output = XMLOpenElement(endTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(endTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("endTime");
|
||||
output = XMLCloseElement(endTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log total runtime
|
||||
output = XMLOpenElement("totalRuntime");
|
||||
output = XMLOpenElement(totalRuntimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(DoubleToString(totalRuntime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("totalRuntime");
|
||||
output = XMLCloseElement(totalRuntimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseDocument("testlog");
|
||||
output = XMLCloseDocument(documentRoot);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLSuiteStarted(const char *suiteName, time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenElement("suite");
|
||||
char *output = XMLOpenElement(suiteElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("eventTime");
|
||||
output = XMLOpenElement(startTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(eventTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("eventTime");
|
||||
output = XMLCloseElement(startTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -221,130 +229,103 @@ XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
|
|||
time_t endTime, double totalRuntime)
|
||||
{
|
||||
// log tests passed
|
||||
char *output = XMLOpenElement("testsPassed");
|
||||
char *output = XMLOpenElement(testsPassedElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testsPassed));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("testsPassed");
|
||||
output = XMLCloseElement(testsPassedElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log tests failed
|
||||
output = XMLOpenElement("testsFailed");
|
||||
output = XMLOpenElement(testsFailedElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testsFailed));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("testsFailed");
|
||||
output = XMLCloseElement(testsFailedElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log tests skipped
|
||||
output = XMLOpenElement("testsSkipped");
|
||||
output = XMLOpenElement(testsSkippedElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(testsSkipped));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("testsSkipped");
|
||||
output = XMLCloseElement(testsSkippedElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log tests skipped
|
||||
output = XMLOpenElement("endTime");
|
||||
output = XMLOpenElement(endTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(endTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("endTime");
|
||||
output = XMLCloseElement(endTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log total runtime
|
||||
output = XMLOpenElement("totalRuntime");
|
||||
output = XMLOpenElement(totalRuntimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(DoubleToString(totalRuntime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("totalRuntime");
|
||||
output = XMLCloseElement(totalRuntimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
|
||||
output = XMLCloseElement("suite");
|
||||
output = XMLCloseElement(suiteElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLTestStarted(const char *testName, const char *suiteName,
|
||||
const char *testDescription, time_t startTime)
|
||||
{
|
||||
char * output = XMLOpenElement("test");
|
||||
char * output = XMLOpenElement(testElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
//Attribute attribute = {"test", "value"};
|
||||
//XMLOpenElementWithAttribute("name", &attribute);
|
||||
output = XMLOpenElement("name");
|
||||
output = XMLOpenElement(nameElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(testName);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("name");
|
||||
output = XMLCloseElement(nameElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("description");
|
||||
output = XMLOpenElement(descriptionElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(testDescription);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("description");
|
||||
output = XMLCloseElement(descriptionElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("startTime");
|
||||
output = XMLOpenElement(startTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(startTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("startTime");
|
||||
output = XMLCloseElement(startTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLTestEnded(const char *testName, const char *suiteName,
|
||||
int testResult, time_t endTime, double totalRuntime)
|
||||
{
|
||||
char *output = XMLOpenElement("result");
|
||||
char *output = XMLOpenElement(resultElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
if(testResult) {
|
||||
if(testResult == 2) {
|
||||
|
@ -353,236 +334,184 @@ XMLTestEnded(const char *testName, const char *suiteName,
|
|||
output = XMLAddContent("failed");
|
||||
}
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
} else {
|
||||
output = XMLAddContent("passed");
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
output = XMLCloseElement("result");
|
||||
output = XMLCloseElement(resultElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log total runtime
|
||||
output = XMLOpenElement("endTime");
|
||||
output = XMLOpenElement(endTimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(endTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("endTime");
|
||||
output = XMLCloseElement(endTimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log total runtime
|
||||
output = XMLOpenElement("totalRuntime");
|
||||
output = XMLOpenElement(totalRuntimeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(DoubleToString(totalRuntime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("totalRuntime");
|
||||
output = XMLCloseElement(totalRuntimeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("test");
|
||||
output = XMLCloseElement(testElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLAssert(const char *assertName, int assertResult, const char *assertMessage,
|
||||
time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenElement("assert");
|
||||
char *output = XMLOpenElement(assertElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log assert result
|
||||
output = XMLOpenElement("result");
|
||||
output = XMLOpenElement(resultElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent((assertResult) ? "pass" : "failure");
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("result");
|
||||
output = XMLCloseElement(resultElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log assert message
|
||||
output = XMLOpenElement("message");
|
||||
output = XMLOpenElement(messageElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(assertMessage);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("message");
|
||||
output = XMLCloseElement(messageElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log event time
|
||||
output = XMLOpenElement("eventTime");
|
||||
output = XMLOpenElement(timeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(eventTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("eventTime");
|
||||
output = XMLCloseElement(timeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assert");
|
||||
output = XMLCloseElement(assertElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
|
||||
int actualValue, int excpected, time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenElement("assert");
|
||||
char *output = XMLOpenElement(assertElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log assert result
|
||||
output = XMLOpenElement("result");
|
||||
output = XMLOpenElement(resultElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent((assertResult) ? "pass" : "failure");
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("result");
|
||||
output = XMLCloseElement(resultElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log assert message
|
||||
output = XMLOpenElement("message");
|
||||
output = XMLOpenElement(messageElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(assertMessage);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("message");
|
||||
output = XMLCloseElement(messageElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log event time
|
||||
output = XMLOpenElement("eventTime");
|
||||
output = XMLOpenElement(timeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(eventTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("eventTime");
|
||||
output = XMLCloseElement(timeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assert");
|
||||
output = XMLCloseElement(assertElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XMLAssertSummary(int numAsserts, int numAssertsFailed,
|
||||
int numAssertsPass, time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenElement("assertSummary");
|
||||
char *output = XMLOpenElement(assertSummaryElementName);
|
||||
XMLOutputter(indentLevel++, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("assertCount");
|
||||
output = XMLOpenElement(assertCountElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(numAsserts));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assertCount");
|
||||
output = XMLCloseElement(assertCountElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("assertsPassed");
|
||||
output = XMLOpenElement(assertsPassedElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(numAssertsPass));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assertsPassed");
|
||||
output = XMLCloseElement(assertsPassedElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLOpenElement("assertsFailed");
|
||||
output = XMLOpenElement(assertsFailedElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(IntToString(numAsserts));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assertsFailed");
|
||||
output = XMLCloseElement(assertsFailedElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("assertSummary");
|
||||
output = XMLCloseElement(assertSummaryElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
||||
void
|
||||
XMLLog(const char *logMessage, time_t eventTime)
|
||||
{
|
||||
char *output = XMLOpenElement("log");
|
||||
char *output = XMLOpenElement(logElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log message
|
||||
output = XMLOpenElement("message");
|
||||
output = XMLOpenElement(messageElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(logMessage);
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("message");
|
||||
output = XMLCloseElement(messageElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
// log eventTime
|
||||
output = XMLOpenElement("eventTime");
|
||||
output = XMLOpenElement(timeElementName);
|
||||
XMLOutputter(indentLevel++, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLAddContent(TimestampToString(eventTime));
|
||||
XMLOutputter(indentLevel, NO, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("eventTime");
|
||||
output = XMLCloseElement(timeElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
|
||||
output = XMLCloseElement("log");
|
||||
output = XMLCloseElement(logElementName);
|
||||
XMLOutputter(--indentLevel, YES, output);
|
||||
SDL_free(output);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue