diff options
-rw-r--r-- | test/test.c | 19 | ||||
-rw-r--r-- | test/test.h | 28 | ||||
-rw-r--r-- | test/testmtx.c | 2 |
3 files changed, 36 insertions, 13 deletions
diff --git a/test/test.c b/test/test.c index c56a23552..9510eb39d 100644 --- a/test/test.c +++ b/test/test.c @@ -135,32 +135,35 @@ void test_emit_token(char token) { /*
* Assertions.
*/
-void test_fail(char * msg) {
+bool_t _test_fail(char * msg) {
local_fail = TRUE;
global_fail = TRUE;
failmsg = msg;
+ return TRUE;
}
-void test_assert(bool_t condition, char * msg) {
+bool_t _test_assert(bool_t condition, char * msg) {
if (!condition)
- test_fail(msg);
+ return _test_fail(msg);
+ return FALSE;
}
-void test_assert_sequence(char *expected) {
+bool_t _test_assert_sequence(char *expected) {
char *cp = tokens_buffer;
while (cp < tokp) {
if (*cp++ != *expected++)
- test_fail(NULL);
+ return _test_fail(NULL);
}
if (*expected)
- test_fail(NULL);
+ return _test_fail(NULL);
+ return FALSE;
}
-void test_assert_time_window(systime_t start, systime_t end) {
+bool_t _test_assert_time_window(systime_t start, systime_t end) {
- test_assert(chSysInTimeWindow(start, end), "time window error");
+ return _test_assert(chSysInTimeWindow(start, end), "time window error");
}
/*
diff --git a/test/test.h b/test/test.h index bc777fabb..864b12e4f 100644 --- a/test/test.h +++ b/test/test.h @@ -46,10 +46,10 @@ extern "C" { void test_print(char *msgp);
void test_println(char *msgp);
void test_emit_token(char token);
- void test_fail(char * msg);
- void test_assert(bool_t condition, char * msg);
- void test_assert_sequence(char *expected);
- void test_assert_time_window(systime_t start, systime_t end);
+ bool_t _test_fail(char * msg);
+ bool_t _test_assert(bool_t condition, char * msg);
+ bool_t _test_assert_sequence(char *expected);
+ bool_t _test_assert_time_window(systime_t start, systime_t end);
void test_terminate_threads(void);
void test_wait_threads(void);
systime_t test_wait_tick(void);
@@ -62,6 +62,26 @@ extern "C" { }
#endif
+#define test_fail(msg) { \
+ test_fail(msg); \
+ return; \
+}
+
+#define test_assert(condition, msg) { \
+ if (_test_assert(condition, msg)) \
+ return; \
+}
+
+#define test_assert_sequence(expected) { \
+ if (_test_assert_sequence(expected)) \
+ return; \
+}
+
+#define test_assert_time_window(start, end) { \
+ if (_test_assert_time_window(start, end)) \
+ return; \
+}
+
extern Thread *threads[MAX_THREADS];
extern void *wa[MAX_THREADS];
extern bool_t test_timer_done;
diff --git a/test/testmtx.c b/test/testmtx.c index 6c1beea28..0bf69cbf7 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -58,8 +58,8 @@ static void mtx1_execute(void) { threads[3] = chThdCreateStatic(wa[3], STKSIZE, prio+4, thread1, "B");
threads[4] = chThdCreateStatic(wa[4], STKSIZE, prio+5, thread1, "A");
chMtxUnlock();
- test_assert(prio == chThdGetPriority(), "priority return failure");
test_wait_threads();
+ test_assert(prio == chThdGetPriority(), "priority return failure");
test_assert_sequence("ABCDE");
}
|