summaryrefslogtreecommitdiff
path: root/test/test-automation
diff options
context:
space:
mode:
authorMarkus Kauppila <markus.kauppila@gmail.com>2011-08-28 21:00:38 +0300
committerMarkus Kauppila <markus.kauppila@gmail.com>2011-08-28 21:00:38 +0300
commit563087583c1d0ab73613e94e626fbd4f0702b736 (patch)
tree06ab8ab3740a6c1418316bec15c7d8b777fdd7d8 /test/test-automation
parent11d7f5dda6d71ebc7f8fd421ef294690ace744d4 (diff)
Test cases executed in their own process can now bail out if
assertion fails. Note: Bailing out doesn't work with --in-proc option.
Diffstat (limited to 'test/test-automation')
-rw-r--r--test/test-automation/include/SDL_test.h2
-rw-r--r--test/test-automation/src/libSDLtest/SDL_test.c20
-rw-r--r--test/test-automation/src/runner/runner.c4
-rw-r--r--test/test-automation/tests/testdummy/testdummy.c2
4 files changed, 23 insertions, 5 deletions
diff --git a/test/test-automation/include/SDL_test.h b/test/test-automation/include/SDL_test.h
index d5f208ad..85a4ddf1 100644
--- a/test/test-automation/include/SDL_test.h
+++ b/test/test-automation/include/SDL_test.h
@@ -69,7 +69,7 @@ typedef struct TestCaseReference {
*
* \param execKey Execution key for the test
*/
-void _InitTestEnvironment(Uint64 execKey);
+void _InitTestEnvironment(Uint64 execKey, SDL_bool inproc);
/*!
* Deinitializes the test environment and
diff --git a/test/test-automation/src/libSDLtest/SDL_test.c b/test/test-automation/src/libSDLtest/SDL_test.c
index 265cc1b3..baae64ff 100644
--- a/test/test-automation/src/libSDLtest/SDL_test.c
+++ b/test/test-automation/src/libSDLtest/SDL_test.c
@@ -40,11 +40,16 @@ int _testAssertsFailed;
/*! \brief counts the passed asserts */
int _testAssertsPassed;
+/*! \brief is the execution done in-process? */
+SDL_bool canBailOut;
+
void
-_InitTestEnvironment(Uint64 execKey)
+_InitTestEnvironment(Uint64 execKey, SDL_bool inproc)
{
InitFuzzer(execKey);
+ canBailOut = inproc == 0;
+
_testReturnValue = TEST_RESULT_PASS;
_testAssertsFailed = 0;
_testAssertsPassed = 0;
@@ -87,7 +92,10 @@ AssertEquals(int expected, int actual, char *message, ...)
_testReturnValue = TEST_RESULT_FAILURE;
_testAssertsFailed++;
- } else {
+
+ if(canBailOut)
+ exit(TEST_RESULT_FAILURE); // bail out from the test
+ } else {
AssertWithValues("AssertEquals", 1, buf,
actual, expected, time(0));
@@ -95,6 +103,7 @@ AssertEquals(int expected, int actual, char *message, ...)
}
}
+
void
AssertTrue(int condition, char *message, ...)
{
@@ -109,6 +118,9 @@ AssertTrue(int condition, char *message, ...)
_testReturnValue = TEST_RESULT_FAILURE;
_testAssertsFailed++;
+
+ if(canBailOut)
+ exit(TEST_RESULT_FAILURE); // bail out from the test
} else {
Assert("AssertTrue", 1, buf, time(0));
@@ -131,6 +143,7 @@ AssertPass(char *message, ...)
_testAssertsPassed++;
}
+
void
AssertFail(char *message, ...)
{
@@ -145,5 +158,8 @@ AssertFail(char *message, ...)
_testReturnValue = TEST_RESULT_FAILURE;
_testAssertsFailed++;
+
+ if(canBailOut)
+ exit(TEST_RESULT_FAILURE); // bail out from the test
}
diff --git a/test/test-automation/src/runner/runner.c b/test/test-automation/src/runner/runner.c
index 71666c53..8b7368be 100644
--- a/test/test-automation/src/runner/runner.c
+++ b/test/test-automation/src/runner/runner.c
@@ -44,7 +44,7 @@
//!< Function pointer to a test case function
typedef void (*TestCaseFp)(void *arg);
//!< Function pointer to a test case init function
-typedef void (*InitTestInvironmentFp)(Uint64);
+typedef void (*InitTestInvironmentFp)(Uint64, SDL_bool);
//!< Function pointer to a test case quit function
typedef int (*QuitTestInvironmentFp)(void);
//!< Function pointer to a test case set up function
@@ -825,7 +825,7 @@ RunTest(TestCase *testCase, Uint64 execKey)
}
}
- testCase->initTestEnvironment(execKey);
+ testCase->initTestEnvironment(execKey, execute_inproc);
if(testCase->testSetUp) {
testCase->testSetUp(0x0);
diff --git a/test/test-automation/tests/testdummy/testdummy.c b/test/test-automation/tests/testdummy/testdummy.c
index cfb59ac5..63cf0470 100644
--- a/test/test-automation/tests/testdummy/testdummy.c
+++ b/test/test-automation/tests/testdummy/testdummy.c
@@ -142,6 +142,8 @@ test_dummy2(void *arg)
char *msg = "eello";
//msg[0] = 'H';
AssertTrue(1, "Assert message");
+ AssertTrue(0, "Assert message");
+ AssertTrue(1, "Assert message");
}
void