Changes to the test suite in order to save RAM on AVR targets.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@917 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2009-04-25 11:12:10 +00:00
parent c031b80726
commit a2a8822648
12 changed files with 181 additions and 170 deletions

View File

@ -96,6 +96,8 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- CHANGE: Removed the chMsgSendWithEvent() function. It is rarely used and
the functionality can be re-created with a compound atomic operation. Also
removed the CH_USE_MESSAGES_EVENT configuration option.
- CHANGE: Modified the test suite assertions in order to save RAM on the AVR
targets. The test suit now uses much less string space.
*** 1.2.0 ***
- Added license exception text to the 1.2.0 branch.

View File

@ -49,7 +49,7 @@ static const struct testcase **patterns[] = {
};
static bool_t local_fail, global_fail;
static char *failmsg;
static unsigned failpoint;
static char tokens_buffer[MAX_TOKENS];
static char *tokp;
static WORKING_AREA(waT0, THREADS_STACK_SIZE);
@ -118,35 +118,35 @@ void test_emit_token(char token) {
/*
* Assertions.
*/
bool_t _test_fail(char * msg) {
bool_t _test_fail(unsigned point) {
local_fail = TRUE;
global_fail = TRUE;
failmsg = msg;
failpoint = point;
return TRUE;
}
bool_t _test_assert(bool_t condition, char * msg) {
bool_t _test_assert(unsigned point, bool_t condition) {
if (!condition)
return _test_fail(msg);
return _test_fail(point);
return FALSE;
}
bool_t _test_assert_sequence(char *expected) {
bool_t _test_assert_sequence(unsigned point, char *expected) {
char *cp = tokens_buffer;
while (cp < tokp) {
if (*cp++ != *expected++)
return _test_fail(NULL);
return _test_fail(point);
}
if (*expected)
return _test_fail(NULL);
return _test_fail(point);
return FALSE;
}
bool_t _test_assert_time_window(systime_t start, systime_t end) {
bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end) {
return _test_assert(chTimeIsWithin(start, end), "time window error");
return _test_assert(point, chTimeIsWithin(start, end));
}
/*
@ -256,14 +256,11 @@ msg_t TestThread(void *p) {
test_println(")");
execute_test(patterns[i][j]);
if (local_fail) {
test_print("--- Result: FAIL (");
if (failmsg)
test_print(failmsg);
else {
test_print("sequence error: ");
test_print("--- Result: FAIL (#");
test_printn(failpoint);
test_print(" [");
print_tokens();
}
test_println(")");
test_println("])");
}
else
test_println("--- Result: SUCCESS");

View File

@ -55,10 +55,10 @@ extern "C" {
void test_print(char *msgp);
void test_println(char *msgp);
void test_emit_token(char token);
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);
bool_t _test_fail(unsigned point);
bool_t _test_assert(unsigned point, bool_t condition);
bool_t _test_assert_sequence(unsigned point, char *expected);
bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end);
void test_terminate_threads(void);
void test_wait_threads(void);
systime_t test_wait_tick(void);
@ -71,23 +71,23 @@ extern "C" {
}
#endif
#define test_fail(msg) { \
test_fail(msg); \
#define test_fail(point) { \
test_fail(point); \
return; \
}
#define test_assert(condition, msg) { \
if (_test_assert(condition, msg)) \
#define test_assert(point, condition, msg) { \
if (_test_assert(point, condition)) \
return; \
}
#define test_assert_sequence(expected) { \
if (_test_assert_sequence(expected)) \
#define test_assert_sequence(point, expected) { \
if (_test_assert_sequence(point, expected)) \
return; \
}
#define test_assert_time_window(start, end) { \
if (_test_assert_time_window(start, end)) \
#define test_assert_time_window(point, start, end) { \
if (_test_assert_time_window(point, start, end)) \
return; \
}

View File

@ -49,20 +49,20 @@ static void dyn1_execute(void) {
threads[2] = chThdCreateFromHeap(THD_WA_SIZE(0x10000000),
prio-3, thread, "C");
test_assert((threads[0] != NULL) &&
test_assert(1, (threads[0] != NULL) &&
(threads[1] != NULL) &&
(threads[2] == NULL) &&
(threads[3] == NULL) &&
(threads[4] == NULL),
"#1"); /* Thread creation failed.*/
"thread creation failed");
/* Claiming the memory from terminated threads. */
test_wait_threads();
test_assert_sequence("AB");
test_assert_sequence(2, "AB");
/* Heap status checked again.*/
test_assert(chHeapStatus(&n) == 1, "#2"); /* Heap fragmented.*/
test_assert(n == sz, "#3"); /* Heap size changed.*/
test_assert(3, chHeapStatus(&n) == 1, "heap fragmented");
test_assert(4, n == sz, "heap size changed");
}
}
@ -102,21 +102,21 @@ static void dyn2_execute(void) {
threads[3] = chThdCreateFromMemoryPool(&mp1, prio-4, thread, "D");
threads[4] = chThdCreateFromMemoryPool(&mp1, prio-5, thread, "E");
test_assert((threads[0] != NULL) &&
test_assert(1, (threads[0] != NULL) &&
(threads[1] != NULL) &&
(threads[2] != NULL) &&
(threads[3] != NULL) &&
(threads[4] == NULL),
"#1"); /* Thread creation failed.*/
"thread creation failed");
/* Claiming the memory from terminated threads. */
test_wait_threads();
test_assert_sequence("ABCD");
test_assert_sequence(2, "ABCD");
/* Now the pool must be full again. */
for (i = 0; i < 4; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "#2"); /* Pool list empty.*/
test_assert(chPoolAlloc(&mp1) == NULL, "#3"); /* Pool list not empty.*/
test_assert(3, chPoolAlloc(&mp1) != NULL, "pool list empty");
test_assert(4, chPoolAlloc(&mp1) == NULL, "pool list not empty");
}
const struct testcase testdyn2 = {

View File

@ -51,17 +51,17 @@ static void evt1_execute(void) {
chEvtInit(&es1);
chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es1, &el2, 2);
test_assert(chEvtIsListening(&es1), "#1"); /* Must not be empty */
test_assert(1, chEvtIsListening(&es1), "no listener");
chEvtUnregister(&es1, &el1);
test_assert(chEvtIsListening(&es1), "#2"); /* Must not be empty */
test_assert(2, chEvtIsListening(&es1), "no listener");
chEvtUnregister(&es1, &el2);
test_assert(!chEvtIsListening(&es1), "#3"); /* Stuck listener.*/
test_assert(3, !chEvtIsListening(&es1), "stuck listener");
/*
* Testing chEvtDispatch().
*/
chEvtDispatch(evhndl, 7);
test_assert_sequence("ABC");
test_assert_sequence(4, "ABC");
}
const struct testcase testevt1 = {
@ -106,11 +106,11 @@ static void evt2_execute(void) {
*/
chEvtPend(5);
m = chEvtWaitOne(ALL_EVENTS);
test_assert(m == 1, "#1"); /* Single bit error.*/
test_assert(1, m == 1, "single event error");
m = chEvtWaitOne(ALL_EVENTS);
test_assert(m == 4, "#2"); /* Single bit error.*/
test_assert(2, m == 4, "single event error");
m = chEvtClear(0);
test_assert(m == 0, "#3"); /* Stuck bit.*/
test_assert(3, m == 0, "stuck event");
/*
* Test on chEvtWaitOne() with wait.
@ -120,10 +120,10 @@ static void evt2_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
thread1, chThdSelf());
m = chEvtWaitOne(ALL_EVENTS);
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
test_assert(m == 1, "#5"); /* Single bit error.*/
test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY);
test_assert(5, m == 1, "single event error");
m = chEvtClear(0);
test_assert(m == 0, "#6"); /* Stuck bit.*/
test_assert(6, m == 0, "stuck event");
test_wait_threads();
/*
@ -131,9 +131,9 @@ static void evt2_execute(void) {
*/
chEvtPend(5);
m = chEvtWaitAny(ALL_EVENTS);
test_assert(m == 5, "#7"); /* Unexpected pending bit.*/
test_assert(7, m == 5, "unexpected pending bit");
m = chEvtClear(0);
test_assert(m == 0, "#8"); /* Stuck bit.*/
test_assert(8, m == 0, "stuck event");
/*
* Test on chEvtWaitAny() with wait.
@ -143,10 +143,10 @@ static void evt2_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
thread1, chThdSelf());
m = chEvtWaitAny(ALL_EVENTS);
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
test_assert(m == 1, "#9"); /* Single bit error.*/
test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY);
test_assert(10, m == 1, "single event error");
m = chEvtClear(0);
test_assert(m == 0, "#10"); /* Stuck bit.*/
test_assert(11, m == 0, "stuck event");
test_wait_threads();
/*
@ -161,14 +161,14 @@ static void evt2_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
thread2, "A");
m = chEvtWaitAll(5);
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY);
m = chEvtClear(0);
test_assert(m == 0, "#11"); /* Stuck event.*/
test_assert(13, m == 0, "stuck event");
test_wait_threads();
chEvtUnregister(&es1, &el1);
chEvtUnregister(&es2, &el2);
test_assert(!chEvtIsListening(&es1), "#12"); /* Stuck listener.*/
test_assert(!chEvtIsListening(&es2), "#13"); /* Stuck listener.*/
test_assert(14, !chEvtIsListening(&es1), "stuck listener");
test_assert(15, !chEvtIsListening(&es2), "stuck listener");
}
const struct testcase testevt2 = {
@ -196,17 +196,17 @@ static void evt3_execute(void) {
* Tests various timeout situations.
*/
m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE);
test_assert(m == 0, "#1");
test_assert(1, m == 0, "spurious event");
m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE);
test_assert(m == 0, "#2");
test_assert(2, m == 0, "spurious event");
m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE);
test_assert(m == 0, "#3");
test_assert(3, m == 0, "spurious event");
m = chEvtWaitOneTimeout(ALL_EVENTS, 10);
test_assert(m == 0, "#4");
test_assert(4, m == 0, "spurious event");
m = chEvtWaitAnyTimeout(ALL_EVENTS, 10);
test_assert(m == 0, "#5");
test_assert(5, m == 0, "spurious event");
m = chEvtWaitAllTimeout(ALL_EVENTS, 10);
test_assert(m == 0, "#6");
test_assert(6, m == 0, "spurious event");
#endif
}

View File

@ -47,7 +47,7 @@ static void heap1_execute(void) {
chHeapFree(p1); /* Does not merge */
chHeapFree(p2); /* Merges backward */
chHeapFree(p3); /* Merges both sides */
test_assert(chHeapStatus(&n) == 1, "#1"); /* Heap fragmented.*/
test_assert(1, chHeapStatus(&n) == 1, "heap fragmented");
/* Reverse order */
p1 = chHeapAlloc(SIZE);
@ -56,26 +56,26 @@ static void heap1_execute(void) {
chHeapFree(p3); /* Merges forward */
chHeapFree(p2); /* Merges forward */
chHeapFree(p1); /* Merges forward */
test_assert(chHeapStatus(&n) == 1, "#2"); /* Heap fragmented.*/
test_assert(2, chHeapStatus(&n) == 1, "heap fragmented");
/* Small fragments handling */
p1 = chHeapAlloc(SIZE + 1);
p2 = chHeapAlloc(SIZE);
chHeapFree(p1);
test_assert(chHeapStatus(&n) == 2, "#3"); /* Heap must contain 2 blocks.*/
test_assert(3, chHeapStatus(&n) == 2, "invalid state");
p1 = chHeapAlloc(SIZE);
test_assert(chHeapStatus(&n) == 1, "#4"); /* Heap fragmented.*/
test_assert(4, chHeapStatus(&n) == 1, "heap fragmented");
chHeapFree(p2);
chHeapFree(p1);
/* Allocate all handling */
(void)chHeapStatus(&n);
p1 = chHeapAlloc(n);
test_assert(chHeapStatus(&n) == 0, "#5"); /* Heap must be empty.*/
test_assert(5, chHeapStatus(&n) == 0, "not empty");
chHeapFree(p1);
test_assert(chHeapStatus(&n) == 1, "#6"); /* Heap fragmented.*/
test_assert(n == sz, "#7"); /* Heap size changed.*/
test_assert(6, chHeapStatus(&n) == 1, "heap fragmented");
test_assert(7, n == sz, "size changed");
}
else {
test_print("--- Size : ");

View File

@ -46,63 +46,63 @@ static void mbox1_execute(void) {
/*
* Testing initial space.
*/
test_assert(chMBGetEmpty(&mb1) == MB_SIZE, "#1");
test_assert(1, chMBGetEmpty(&mb1) == MB_SIZE, "wrong size");
/*
* Testing enqueuing and backward circularity.
*/
for (i = 0; i < MB_SIZE - 1; i++) {
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == RDY_OK, "#2");
test_assert(2, msg1 == RDY_OK, "wrong wake-up message");
}
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
test_assert(msg1 == RDY_OK, "#3");
test_assert(3, msg1 == RDY_OK, "wrong wake-up message");
/*
* Testing post timeout.
*/
msg1 = chMBPost(&mb1, 'X', 1);
test_assert(msg1 == RDY_TIMEOUT, "#4");
test_assert(4, msg1 == RDY_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
*/
test_assert(chMBGetEmpty(&mb1) == 0, "#5");
test_assert(chMBGetFull(&mb1) == MB_SIZE, "#6");
test_assert(mb1.mb_rdptr == mb1.mb_wrptr, "#7");
test_assert(5, chMBGetEmpty(&mb1) == 0, "still empty");
test_assert(6, chMBGetFull(&mb1) == MB_SIZE, "not full");
test_assert(7, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/*
* Testing dequeuing.
*/
for (i = 0; i < MB_SIZE; i++) {
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == RDY_OK, "#8");
test_assert(8, msg1 == RDY_OK, "wrong wake-up message");
test_emit_token(msg2);
}
test_assert_sequence("ABCDE");
test_assert_sequence(9, "ABCDE");
/*
* Testing buffer circularity.
*/
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
test_assert(msg1 == RDY_OK, "#9");
test_assert(10, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE);
test_assert(msg1 == RDY_OK, "#10");
test_assert(mb1.mb_buffer == mb1.mb_wrptr, "#11");
test_assert(mb1.mb_buffer == mb1.mb_rdptr, "#12");
test_assert(11, msg1 == RDY_OK, "wrong wake-up message");
test_assert(12, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert(13, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
/*
* Testing fetch timeout.
*/
msg1 = chMBFetch(&mb1, &msg2, 1);
test_assert(msg1 == RDY_TIMEOUT, "#13");
test_assert(14, msg1 == RDY_TIMEOUT, "wrong wake-up message");
/*
* Testing final conditions.
*/
test_assert(chMBGetEmpty(&mb1) == MB_SIZE, "#14");
test_assert(chMBGetFull(&mb1) == 0, "#15");
test_assert(mb1.mb_rdptr == mb1.mb_wrptr, "#16");
test_assert(15, chMBGetEmpty(&mb1) == MB_SIZE, "not empty");
test_assert(16, chMBGetFull(&mb1) == 0, "still full");
test_assert(17, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/*
* Testing reset.
@ -112,10 +112,10 @@ static void mbox1_execute(void) {
/*
* Re-testing final conditions.
*/
test_assert(chMBGetEmpty(&mb1) == MB_SIZE, "#17");
test_assert(chMBGetFull(&mb1) == 0, "#18");
test_assert(mb1.mb_rdptr == mb1.mb_wrptr, "#19");
test_assert(mb1.mb_buffer == mb1.mb_wrptr, "#20");
test_assert(18, chMBGetEmpty(&mb1) == MB_SIZE, "not empty");
test_assert(19, chMBGetFull(&mb1) == 0, "still full");
test_assert(20, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert(21, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
}
const struct testcase testmbox1 = {

View File

@ -51,7 +51,7 @@ static void msg1_execute(void) {
test_emit_token(msg);
chMsgRelease(msg = chMsgWait());
test_emit_token(msg);
test_assert_sequence("ABC");
test_assert_sequence(1, "ABC");
/*
* Testing message fetch using chMsgGet().
@ -59,15 +59,15 @@ static void msg1_execute(void) {
* the receiver.
*/
msg = chMsgGet();
test_assert(msg != 0, "#1");
test_assert(1, msg != 0, "no message");
chMsgRelease(0);
test_assert(msg == 'D', "#2");
test_assert(2, msg == 'D', "wrong message");
/*
* Must not have pending messages.
*/
msg = chMsgGet();
test_assert(msg == 0, "#3");
test_assert(3, msg == 0, "unknown message");
}
const struct testcase testmsg1 = {

View File

@ -57,8 +57,8 @@ static void mtx1_execute(void) {
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
chMtxUnlock();
test_wait_threads();
test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
test_assert_sequence("ABCDE");
test_assert(1, prio == chThdGetPriority(), "wrong priority level");
test_assert_sequence(2, "ABCDE");
}
const struct testcase testmtx1 = {
@ -116,7 +116,7 @@ static void mtx2_execute(void) {
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-3, thread3, "C");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-2, thread4, "B");
test_wait_threads();
test_assert_sequence("ABC");
test_assert_sequence(1, "ABC");
}
const struct testcase testmtx2 = {
@ -204,7 +204,7 @@ static void mtx3_execute(void) {
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread8, "B");
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread9, "A");
test_wait_threads();
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
}
const struct testcase testmtx3 = {
@ -250,40 +250,40 @@ static void mtx4_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread13, "B");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread14, "A");
chMtxLock(&m2);
test_assert(chThdGetPriority() == p, "#1");
test_assert(1, chThdGetPriority() == p, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p1, "#2");
test_assert(2, chThdGetPriority() == p1, "wrong priority level");
chMtxLock(&m1);
test_assert(chThdGetPriority() == p1, "#3");
test_assert(3, chThdGetPriority() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p2, "#4");
test_assert(4, chThdGetPriority() == p2, "wrong priority level");
chMtxUnlock();
test_assert(chThdGetPriority() == p1, "#5");
test_assert(5, chThdGetPriority() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p1, "#6");
test_assert(6, chThdGetPriority() == p1, "wrong priority level");
chMtxUnlockAll();
test_assert(chThdGetPriority() == p, "#7");
test_assert(7, chThdGetPriority() == p, "wrong priority level");
test_wait_threads();
/* Test repeated in order to cover chMtxUnlockS().*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread13, "D");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread14, "C");
chMtxLock(&m2);
test_assert(chThdGetPriority() == p, "#8");
test_assert(8, chThdGetPriority() == p, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p1, "#9");
test_assert(9, chThdGetPriority() == p1, "wrong priority level");
chMtxLock(&m1);
test_assert(chThdGetPriority() == p1, "#10");
test_assert(10, chThdGetPriority() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p2, "#11");
test_assert(11, chThdGetPriority() == p2, "wrong priority level");
chSysLock();
chMtxUnlockS();
chSysUnlock();
test_assert(chThdGetPriority() == p1, "#12");
test_assert(12, chThdGetPriority() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
test_assert(chThdGetPriority() == p1, "#13");
test_assert(13, chThdGetPriority() == p1, "wrong priority level");
chMtxUnlockAll();
test_assert(chThdGetPriority() == p, "#14");
test_assert(14, chThdGetPriority() == p, "wrong priority level");
test_wait_threads();
}
@ -311,18 +311,18 @@ static void mtx5_execute(void) {
prio = chThdGetPriority();
b = chMtxTryLock(&m1);
test_assert(b, "#1");
test_assert(1, b, "already locked");
b = chMtxTryLock(&m1);
test_assert(!b, "#2");
test_assert(2, !b, "not locked");
chSysLock();
chMtxUnlockS();
chSysUnlock();
test_assert(isempty(&m1.m_queue), "#3"); /* Queue not empty */
test_assert(m1.m_owner == NULL, "#4"); /* Owned */
test_assert(chThdGetPriority() == prio, "#5");
test_assert(3, isempty(&m1.m_queue), "queue not empty");
test_assert(4, m1.m_owner == NULL, "still owned");
test_assert(5, chThdGetPriority() == prio, "wrong priority level");
}
const struct testcase testmtx5 = {
@ -370,7 +370,7 @@ static void mtx6_execute(void) {
chSchRescheduleS();
chSysUnlock();
test_wait_threads();
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
}
const struct testcase testmtx6 = {
@ -402,7 +402,7 @@ static void mtx7_execute(void) {
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A");
chCondBroadcast(&c1);
test_wait_threads();
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
}
const struct testcase testmtx7 = {
@ -452,7 +452,7 @@ static void mtx8_execute(void) {
chCondSignal(&c1);
chCondSignal(&c1);
test_wait_threads();
test_assert_sequence("ABC");
test_assert_sequence(1, "ABC");
}
const struct testcase testmtx8 = {

View File

@ -44,10 +44,10 @@ static void pools1_execute(void) {
/* Empting the pool again. */
for (i = 0; i < MAX_THREADS; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "#1"); /* Pool list empty.*/
test_assert(1, chPoolAlloc(&mp1) != NULL, "list empty");
/* Now must be empty. */
test_assert(chPoolAlloc(&mp1) == NULL, "#2"); /* Pool list not empty.*/
test_assert(2, chPoolAlloc(&mp1) == NULL, "list not empty");
}
const struct testcase testpools1 = {

View File

@ -58,9 +58,9 @@ static void sem1_execute(void) {
chSemSignal(&sem1);
test_wait_threads();
#if CH_USE_SEMAPHORES_PRIORITY
test_assert_sequence("ADCEB");
test_assert_sequence(1, "ADCEB");
#else
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
#endif
}
@ -101,19 +101,20 @@ static void sem2_execute(void) {
* Testing special case TIME_IMMEDIATE.
*/
msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE);
test_assert(msg == RDY_TIMEOUT, "#1");
test_assert(isempty(&sem1.s_queue), "#2"); /* Queue not empty */
test_assert(sem1.s_cnt == 0, "#3"); /* Counter not zero */
test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message");
test_assert(2, isempty(&sem1.s_queue), "queue not empty");
test_assert(3, sem1.s_cnt == 0, "counter not zero");
/*
* Testing not timeout condition.
*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2, "A");
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
thread2, "A");
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_wait_threads();
test_assert(msg == RDY_OK, "#4");
test_assert(isempty(&sem1.s_queue), "#5"); /* Queue not empty */
test_assert(sem1.s_cnt == 0, "#6"); /* Counter not zero */
test_assert(4, msg == RDY_OK, "wrong wake-up message");
test_assert(5, isempty(&sem1.s_queue), "queue not empty");
test_assert(6, sem1.s_cnt == 0, "counter not zero");
/*
* Testing timeout condition.
@ -123,12 +124,12 @@ static void sem2_execute(void) {
for (i = 0; i < 5; i++) {
test_emit_token('A' + i);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_assert(msg == RDY_TIMEOUT, "#7");
test_assert(isempty(&sem1.s_queue), "#8"); /* Queue not empty */
test_assert(sem1.s_cnt == 0, "#9"); /* Counter not zero */
test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message");
test_assert(8, isempty(&sem1.s_queue), "queue not empty");
test_assert(9, sem1.s_cnt == 0, "counter not zero");
}
test_assert_sequence("ABCDE");
test_assert_time_window(target_time, target_time + ALLOWED_DELAY);
test_assert_sequence(10, "ABCDE");
test_assert_time_window(11, target_time, target_time + ALLOWED_DELAY);
}
const struct testcase testsem2 = {
@ -161,12 +162,12 @@ static void sem3_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, "A");
chSemSignalWait(&sem1, &sem1);
test_assert(isempty(&sem1.s_queue), "#1"); /* Queue not empty */
test_assert(sem1.s_cnt == 0, "#2"); /* Counter not zero */
test_assert(1, isempty(&sem1.s_queue), "queue not empty");
test_assert(2, sem1.s_cnt == 0, "counter not zero");
chSemSignalWait(&sem1, &sem1);
test_assert(isempty(&sem1.s_queue), "#3"); /* Queue not empty */
test_assert(sem1.s_cnt == 0, "#4"); /* Counter not zero */
test_assert(3, isempty(&sem1.s_queue), "queue not empty");
test_assert(4, sem1.s_cnt == 0, "counter not zero");
}
const struct testcase testsem3 = {

View File

@ -40,7 +40,7 @@ static void thd1_execute(void) {
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
test_wait_threads();
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
}
const struct testcase testthd1 = {
@ -63,7 +63,7 @@ static void thd2_execute(void) {
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
test_wait_threads();
test_assert_sequence("ABCDE");
test_assert_sequence(1, "ABCDE");
}
const struct testcase testthd2 = {
@ -83,30 +83,41 @@ static void thd3_execute(void) {
prio = chThdGetPriority();
p1 = chThdSetPriority(prio + 1);
test_assert(p1 == prio, "#1");
test_assert(chThdGetPriority() == prio + 1, "#2");
test_assert(1, p1 == prio,
"unexpected returned priority level");
test_assert(2, chThdGetPriority() == prio + 1,
"unexpected priority level");
p1 = chThdSetPriority(p1);
test_assert(p1 == prio + 1, "#3");
test_assert(chThdGetPriority() == prio, "#4");
test_assert(3, p1 == prio + 1,
"unexpected returned priority level");
test_assert(4, chThdGetPriority() == prio,
"unexpected priority level");
#if CH_USE_MUTEXES
/* Simulates a priority boost situation (p_prio > p_realprio).*/
chSysLock();
chThdSelf()->p_prio += 2;
chSysUnlock();
test_assert(chThdGetPriority() == prio + 2, "#5");
test_assert(5, chThdGetPriority() == prio + 2,
"unexpected priority level");
/* Tries to raise but below the boost level. */
p1 = chThdSetPriority(prio + 1);
test_assert(p1 == prio, "#6");
test_assert(chThdSelf()->p_prio == prio + 2, "#7");
test_assert(chThdSelf()->p_realprio == prio + 1, "#8");
test_assert(6, p1 == prio,
"unexpected returned priority level");
test_assert(7, chThdSelf()->p_prio == prio + 2,
"unexpected priority level");
test_assert(8, chThdSelf()->p_realprio == prio + 1,
"unexpected returned real priority level");
/* Tries to raise above the boost level. */
p1 = chThdSetPriority(prio + 3);
test_assert(p1 == prio + 1, "#9");
test_assert(chThdSelf()->p_prio == prio + 3, "#10");
test_assert(chThdSelf()->p_realprio == prio + 3, "#11");
test_assert(9, p1 == prio + 1,
"unexpected returned priority level");
test_assert(10, chThdSelf()->p_prio == prio + 3,
"unexpected priority level");
test_assert(11, chThdSelf()->p_realprio == prio + 3,
"unexpected real priority level");
chSysLock();
chThdSelf()->p_prio = prio;
@ -135,22 +146,22 @@ static void thd4_execute(void) {
/* Timeouts in microseconds.*/
time = chTimeNow();
chThdSleepMicroseconds(100000);
test_assert_time_window(time + US2ST(100000), time + US2ST(100000) + 1);
test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1);
/* Timeouts in milliseconds.*/
time = chTimeNow();
chThdSleepMilliseconds(100);
test_assert_time_window(time + MS2ST(100), time + MS2ST(100) + 1);
test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1);
/* Timeouts in seconds.*/
time = chTimeNow();
chThdSleepSeconds(1);
test_assert_time_window(time + S2ST(1), time + S2ST(1) + 1);
test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1);
/* Absolute timelines.*/
time = chTimeNow() + MS2ST(100);
chThdSleepUntil(time);
test_assert_time_window(time, time + 1);
test_assert_time_window(4, time, time + 1);
}
const struct testcase testthd4 = {