git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@489 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
69d06df416
commit
a701fdfd14
19
test/test.c
19
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");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
28
test/test.h
28
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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue