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

Added command option --version

  • Loading branch information
mkauppila committed Jul 4, 2011
1 parent 97bff35 commit 42c79763be5bf253d3cb8f75ef37123743caf004
Showing with 36 additions and 21 deletions.
  1. +23 −14 test/test-automation/plain_logger.c
  2. +12 −6 test/test-automation/runner.c
  3. +1 −1 test/test-automation/xml_logger.c
@@ -9,17 +9,24 @@
#include "plain_logger.h"


static int indentLevel;

/*!
* Prints out the output of the logger
*
* \param message The message to be printed out
*/
int
Output(const char *message, ...)
Output(const int currentIdentLevel, const char *message, ...)
{
va_list list;
va_start(list, message);

int ident = 0;
for( ; ident < currentIdentLevel; ++ident) {
fprintf(stdout, " "); // \todo make configurable?
}

char buffer[1024];
SDL_vsnprintf(buffer, sizeof(buffer), message, list);

@@ -46,30 +53,32 @@ void
PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
time_t endTime, double totalRuntime)
{
Output("\nRan %d tests in %0.5f seconds from %d suites.",
Output(indentLevel, "\nRan %d tests in %0.5f seconds from %d suites.",
testCount, totalRuntime, suiteCount);

Output("%d tests passed", testPassCount);
Output("%d tests failed", testFailCount);
Output(indentLevel, "%d tests passed", testPassCount);
Output(indentLevel, "%d tests failed", testFailCount);
}

void
PlainSuiteStarted(const char *suiteName, time_t eventTime)
{
Output("Executing tests from %s", suiteName);
Output(indentLevel++, "Executing tests from %s", suiteName);
}

void
PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
time_t endTime, double totalRuntime)
{
Output("Suite executed. %d passed, %d failed and %d skipped", testsPassed, testsFailed, testsSkipped);
Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds",
testsPassed, testsFailed, testsSkipped, totalRuntime);
Output(indentLevel, "");
}

void
PlainTestStarted(const char *testName, const char *suiteName, const char *testDescription, time_t startTime)
{
Output("%s (in %s) started", testName, suiteName);
Output(indentLevel++, "%s (in %s) started", testName, suiteName);
}

void
@@ -78,12 +87,12 @@ PlainTestEnded(const char *testName, const char *suiteName,
{
if(testResult) {
if(testResult == 2) {
Output("%s: failed -> no assert", testName);
Output(--indentLevel, "%s: failed -> no assert", testName);
} else {
Output("%s: failed", testName);
Output(--indentLevel, "%s: failed", testName);
}
} else {
Output("%s: ok", testName);
Output(--indentLevel, "%s: ok", testName);
}
}

@@ -92,28 +101,28 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output("%s: %s", assertName, assertMessage);
Output(indentLevel, "%s: %s", assertName, assertMessage);
}

void
PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int excpected, time_t eventTime)
{
const char *result = (assertResult) ? "passed" : "failed";
Output("%s %d: %s", assertName, assertResult, assertMessage);
Output(indentLevel, "%s %d: %s", assertName, assertResult, assertMessage);
}

void
PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime)
{
Output("Assert summary: %d failed, %d passed (total: %d)",
Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)",
numAssertsFailed, numAssertsPass, numAsserts);
}

void
PlainLog(const char *logMessage, time_t eventTime)
{
Output("%s %d", logMessage, eventTime);
Output(indentLevel, "%s %d", logMessage, eventTime);
}

#endif
@@ -28,6 +28,8 @@

#include <sys/types.h>

#include "config.h"

#include "SDL_test.h"
#include "logger.h"

@@ -547,7 +549,7 @@ ExecuteTest(TestCase *testItem) {
* Prints usage information
*/
void
printUsage() {
PrintUsage() {
printf("Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST]\n");
printf(" [--name-contains SUBSTR] [--show-tests]\n");
printf(" [--xml] [--xsl [STYLESHEET]] [--help]\n");
@@ -597,7 +599,7 @@ ParseOptions(int argc, char *argv[])
testName = argv[++i];
} else {
printf("runner: test name is missing\n");
printUsage();
PrintUsage();
exit(1);
}

@@ -625,7 +627,7 @@ ParseOptions(int argc, char *argv[])
substring = argv[++i];
} else {
printf("runner: substring of test name is missing\n");
printUsage();
PrintUsage();
exit(1);
}

@@ -640,20 +642,24 @@ ParseOptions(int argc, char *argv[])
suiteName = argv[++i];
} else {
printf("runner: suite name is missing\n");
printUsage();
PrintUsage();
exit(1);
}

memset(selected_suite_name, 0, NAME_BUFFER_SIZE);
strcpy(selected_suite_name, suiteName);
}
else if(SDL_strcmp(arg, "--version") == 0) {
fprintf(stdout, "SDL test harness (version %s)\n", PACKAGE_VERSION);
exit(0);
}
else if(SDL_strcmp(arg, "--help") == 0 || SDL_strcmp(arg, "-h") == 0) {
printUsage();
PrintUsage();
exit(0);
}
else {
printf("runner: unknown command '%s'\n", arg);
printUsage();
PrintUsage();
exit(0);
}
}
@@ -85,7 +85,7 @@ XMLOutputter(const int currentIdentLevel,
if(ValidateString(message)) {
int ident = 0;
for( ; ident < currentIdentLevel && prevEOL; ++ident) {
printf(" "); // \todo make configurable?
fprintf(stdout, " "); // \todo make configurable?
}

prevEOL = EOL;

0 comments on commit 42c7976

Please sign in to comment.