diff --git a/test/test-automation/Makefile.am b/test/test-automation/Makefile.am index e14ea848c..5c1c26f3d 100644 --- a/test/test-automation/Makefile.am +++ b/test/test-automation/Makefile.am @@ -3,7 +3,7 @@ ACLOCAL_AMFLAGS = -I acinclude -I build-scripts SUBDIRS = testdummy testrect testplatform testaudio testsurface bin_PROGRAMS = runner -runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c logger_helpers.c +runner_SOURCES = runner.c SDL_test.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` diff --git a/test/test-automation/SDL_test.c b/test/test-automation/SDL_test.c index 0564d3017..ac959648d 100644 --- a/test/test-automation/SDL_test.c +++ b/test/test-automation/SDL_test.c @@ -72,7 +72,7 @@ AssertEquals(int expected, int actual, char *message, ...) SDL_vsnprintf( buf, sizeof(buf), message, args ); va_end( args ); - if(expected != expected) { + if(expected != actual) { AssertWithValues("AssertEquals", 0, buf, actual, expected, time(0)); _testReturnValue = TEST_RESULT_FAILURE; diff --git a/test/test-automation/SDL_test.h b/test/test-automation/SDL_test.h index e56c2a8d9..26a40c170 100644 --- a/test/test-automation/SDL_test.h +++ b/test/test-automation/SDL_test.h @@ -90,7 +90,7 @@ int _CountFailedAsserts(); * \param actual The actual value of tested variable * \param message Message that will be printed */ -void AssertEquals(const int expected, const int actual, char *message, ...); +void AssertEquals(int expected, int actual, char *message, ...); /*! * Assert function. Tests if the given condition is true. True in diff --git a/test/test-automation/logger.c b/test/test-automation/logger.c deleted file mode 100644 index 034ee4a56..000000000 --- a/test/test-automation/logger.c +++ /dev/null @@ -1,13 +0,0 @@ - -#include -#include -#include -#include - -#include - -#include "logger.h" -#include "xml_logger.h" -#include "plain_logger.h" - - diff --git a/test/test-automation/logger.h b/test/test-automation/logger.h index 116b99a81..4f1053680 100644 --- a/test/test-automation/logger.h +++ b/test/test-automation/logger.h @@ -45,7 +45,7 @@ typedef void (*AssertFp)(const char *assertName, int assertResult, const char *assertMessage, time_t eventTime); typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult, - const char *assertMessage, int actualValue, int excpected, + const char *assertMessage, int actualValue, int expected, time_t eventTime); typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed, diff --git a/test/test-automation/plain_logger.c b/test/test-automation/plain_logger.c index 44997141b..7ba24a308 100644 --- a/test/test-automation/plain_logger.c +++ b/test/test-automation/plain_logger.c @@ -15,22 +15,29 @@ static int indentLevel; /*! * Prints out the output of the logger * - * \param currentIdentLevel The currently used indentation level + * \param currentIndentLevel The currently used indentation level * \param message The message to be printed out */ int -Output(const int currentIdentLevel, const char *message, ...) +Output(const int currentIndentLevel, const char *message, ...) { - va_list list; - va_start(list, message); int ident = 0; - for( ; ident < currentIdentLevel; ++ident) { + for( ; ident < currentIndentLevel; ++ident) { fprintf(stdout, " "); // \todo make configurable? } - char buffer[1024]; - SDL_vsnprintf(buffer, sizeof(buffer), message, list); + + char buffer[1024]; + memset(buffer, 0, 1024); + + va_list list; + va_start(list, message); + + SDL_vsnprintf(buffer, 1024, message, list); + + va_end(list); + fprintf(stdout, "%s\n", buffer); fflush(stdout); @@ -121,11 +128,11 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage, void PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage, - int actualValue, int expected, time_t eventTime) + int actualValue, int expectedValue, time_t eventTime) { const char *result = (assertResult) ? "passed" : "failed"; - Output(indentLevel, "%s: %s (expected %d, actualValue &d) - %s", - assertName, result, expected, actualValue, assertMessage); + Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s", + assertName, result, expectedValue, actualValue, assertMessage); } void diff --git a/test/test-automation/runner.c b/test/test-automation/runner.c index 72d98504b..25d7e543d 100644 --- a/test/test-automation/runner.c +++ b/test/test-automation/runner.c @@ -586,9 +586,11 @@ LoadCountFailedAssertsFunction(void *suite) { /* - * Execute the test + * Execute a test. Loads the test, executes it and + * returns the tests return value to the caller. * * \param testItem Test to be executed + * \param test result */ int RunTest(TestCase *testItem) { @@ -629,8 +631,8 @@ void KillHungTest(int signum) { } /*! - * Executes a test case. Loads the test, executes it and - * returns the tests return value to the caller. + * Sets up a test case. Decideds wheter the test will + * be executed in-proc or out-of-proc. * * \param testItem The test case that will be executed * \return The return value of the test. Zero means success, non-zero failure. diff --git a/test/test-automation/testdummy/testdummy.c b/test/test-automation/testdummy/testdummy.c index dd8e864a6..9e0b0746b 100644 --- a/test/test-automation/testdummy/testdummy.c +++ b/test/test-automation/testdummy/testdummy.c @@ -88,8 +88,7 @@ TearDown(void *arg) void dummycase1(void *arg) { - //AssertEquals(5, 5, "Assert message"); - while(1); + AssertEquals(5, 5, "Assert message"); } void diff --git a/test/test-automation/xml_logger.c b/test/test-automation/xml_logger.c index 03aae4a11..296b12694 100644 --- a/test/test-automation/xml_logger.c +++ b/test/test-automation/xml_logger.c @@ -76,18 +76,18 @@ static int prevEOL = YES; * * \todo Make the destination of the output changeable (defaults to stdout) * - * \param identLevel the indent level of the message + * \param currentIndentLevel 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, +XMLOutputter(const int currentIndentLevel, int EOL, const char *message) { if(ValidateString(message)) { int ident = 0; - for( ; ident < currentIdentLevel && prevEOL; ++ident) { + for( ; ident < currentIndentLevel && prevEOL; ++ident) { fprintf(stdout, " "); // \todo make configurable? }