This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various fixes and additions to logger system.
- Loading branch information
Showing
9 changed files
with
266 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdarg.h> | ||
|
||
#include "logger.h" | ||
#include "xml_logger.h" | ||
#include "plain_logger.h" | ||
|
||
// Pointers to selected logger implementation | ||
RunStartedFp RunStarted = 0; | ||
RunEndedFp RunEnded = 0; | ||
SuiteStartedFp SuiteStarted = 0; | ||
SuiteEndedFp SuiteEnded = 0; | ||
TestStartedFp TestStarted = 0; | ||
TestEndedFp TestEnded = 0; | ||
AssertFp Assert = 0; | ||
LogFp Log = 0; | ||
|
||
/*! | ||
* Prints the given message to stderr. Function adds nesting | ||
* to the output. | ||
* | ||
* \return Possible error value (\todo) | ||
*/ | ||
int | ||
LogGenericOutput(const char *message) | ||
{ | ||
/* | ||
int depth = indentDepth; | ||
while(depth--) { | ||
fprintf(stderr, " "); | ||
} | ||
*/ | ||
|
||
fprintf(stderr, "%s\n", message); | ||
fflush(stderr); | ||
} | ||
|
||
|
||
/*! | ||
* Test app for logging functionality | ||
*/ | ||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
int xml_enabled = 1; | ||
|
||
if(xml_enabled) { | ||
RunStarted = XMLRunStarted; | ||
RunEnded = XMLRunEnded; | ||
|
||
SuiteStarted = XMLSuiteStarted; | ||
SuiteEnded = XMLSuiteEnded; | ||
|
||
TestStarted = XMLTestStarted; | ||
TestEnded = XMLTestEnded; | ||
|
||
Assert = XMLAssert; | ||
Log = XMLLog; | ||
} else { | ||
RunStarted = PlainRunStarted; | ||
RunEnded = PlainRunEnded; | ||
|
||
SuiteStarted = PlainSuiteStarted; | ||
SuiteEnded = PlainSuiteEnded; | ||
|
||
TestStarted = PlainTestStarted; | ||
TestEnded = PlainTestEnded; | ||
|
||
Assert = PlainAssert; | ||
Log = PlainLog; | ||
} | ||
|
||
RunStarted(LogGenericOutput, "All the data from harness", 0); | ||
SuiteStarted("Suite data here", 0); | ||
|
||
TestStarted("test1", "desc", 0); | ||
TestEnded("test1", "desc", 0, 0, 0, 0); | ||
|
||
//XMLTestStarted("test2", "desc", 0); | ||
//XMLTestEnded("test2", "desc", 0, 0, 0, 0); | ||
|
||
SuiteEnded(0, 0, 0, 0.0f, 0); | ||
RunEnded(0, 0); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
#ifndef _PLAIN_LOGGER | ||
#define _PLAIN_LOGGER | ||
|
||
#include <stdio.h> | ||
|
||
#include "plain_logger.h" | ||
|
||
|
||
LogOutputFp logger = 0; | ||
|
||
void | ||
PlainRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t eventTime) | ||
{ | ||
logger = outputFn; | ||
} | ||
|
||
void | ||
PlainRunEnded(time_t endTime, time_t totalRuntime) | ||
{ | ||
// \todo add total number of tests, suites, pass/failure test count | ||
} | ||
|
||
void | ||
PlainSuiteStarted(const char *suiteName, time_t eventTime) | ||
{ | ||
printf("Executing tests in %s\n", suiteName); | ||
} | ||
|
||
void | ||
PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped, | ||
double endTime, time_t totalRuntime) | ||
{ | ||
printf("Suite executed. %d passed, %d failed and %d skipped\n", testsPassed, testsFailed, testsSkipped); | ||
} | ||
|
||
void | ||
PlainTestStarted(const char *testName, const char *testDescription, time_t startTime) | ||
{ | ||
} | ||
|
||
void | ||
PlainTestEnded(const char *testName, const char *testDescription, | ||
int testResult, int numAsserts, time_t endTime, time_t totalRuntime) | ||
{ | ||
printf("Asserts:%d\n", numAsserts); | ||
printf("%s: ok\n", testName); | ||
} | ||
|
||
void | ||
PlainAssert(const char *assertName, int assertResult, const char *assertMessage, | ||
time_t eventTime) | ||
{ | ||
const char *result = (assertResult) ? "passed" : "failed"; | ||
printf("%s %s: %s\n", assertName, assertResult, assertMessage); | ||
} | ||
|
||
void | ||
PlainLog(const char *logMessage, time_t eventTime) | ||
{ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef _PLAIN_LOGGER_H | ||
#define _PLAIN_LOGGER_H | ||
|
||
#include "logger.h" | ||
|
||
void PlainRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t eventTime); | ||
|
||
void PlainRunEnded(time_t endTime, time_t totalRuntime); | ||
|
||
void PlainSuiteStarted(const char *suiteName, time_t eventTime); | ||
|
||
void PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped, | ||
double endTime, time_t totalRuntime); | ||
|
||
void PlainTestStarted(const char *testName, const char *testDescription, time_t startTime); | ||
|
||
void PlainTestEnded(const char *testName, const char *testDescription, | ||
int testResult, int numAsserts, time_t endTime, time_t totalRuntime); | ||
|
||
void PlainAssert(const char *assertName, int assertResult, const char *assertMessage, | ||
time_t eventTime); | ||
|
||
void PlainLog(const char *logMessage, time_t eventTime); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.