From 0d96f5c78e54d267ef1ca230fe20af1ca090e1d6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 12:21:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5859 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 4 ++-- test/testevt.c | 6 +++--- test/testmtx.c | 4 ++-- test/testsem.c | 2 +- test/testthd.c | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index 1de688a28..b7c92ceaf 100644 --- a/test/test.c +++ b/test/test.c @@ -183,7 +183,7 @@ bool_t _test_assert_sequence(unsigned point, char *expected) { bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end) { - return _test_assert(point, chTimeIsWithin(start, end)); + return _test_assert(point, chVTIsSystemTimeWithin(start, end)); } /* @@ -245,7 +245,7 @@ void test_cpu_pulse(unsigned duration) { systime_t test_wait_tick(void) { chThdSleep(1); - return chTimeNow(); + return chVTGetSystemTime(); } /* diff --git a/test/testevt.c b/test/testevt.c index 0a014374e..d1291c406 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -166,7 +166,7 @@ static void evt2_execute(void) { * Test on chEvtWaitOne() with wait. */ test_wait_tick(); - target_time = chTimeNow() + MS2ST(50); + target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, thread1, chThdSelf()); m = chEvtWaitOne(ALL_EVENTS); @@ -189,7 +189,7 @@ static void evt2_execute(void) { * Test on chEvtWaitAny() with wait. */ test_wait_tick(); - target_time = chTimeNow() + MS2ST(50); + target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, thread1, chThdSelf()); m = chEvtWaitAny(ALL_EVENTS); @@ -207,7 +207,7 @@ static void evt2_execute(void) { chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es2, &el2, 4); test_wait_tick(); - target_time = chTimeNow() + MS2ST(50); + target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, thread2, "A"); m = chEvtWaitAll(5); diff --git a/test/testmtx.c b/test/testmtx.c index 149f47d11..f83a9744a 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -191,7 +191,7 @@ static void mtx2_execute(void) { systime_t time; test_wait_tick(); - time = chTimeNow(); + time = chVTGetSystemTime(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2H, 0); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2M, 0); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2L, 0); @@ -309,7 +309,7 @@ static void mtx3_execute(void) { systime_t time; test_wait_tick(); - time = chTimeNow(); + time = chVTGetSystemTime(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread3LL, 0); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread3L, 0); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread3M, 0); diff --git a/test/testsem.c b/test/testsem.c index d4b990797..20774b618 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -169,7 +169,7 @@ static void sem2_execute(void) { * Testing timeout condition. */ test_wait_tick(); - target_time = chTimeNow() + MS2ST(5 * 500); + target_time = chVTGetSystemTime() + MS2ST(5 * 500); for (i = 0; i < 5; i++) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, MS2ST(500)); diff --git a/test/testthd.c b/test/testthd.c index 35b413acf..9916ca253 100644 --- a/test/testthd.c +++ b/test/testthd.c @@ -192,22 +192,22 @@ static void thd4_execute(void) { test_wait_tick(); /* Timeouts in microseconds.*/ - time = chTimeNow(); + time = chVTGetSystemTime(); chThdSleepMicroseconds(100000); test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1); /* Timeouts in milliseconds.*/ - time = chTimeNow(); + time = chVTGetSystemTime(); chThdSleepMilliseconds(100); test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1); /* Timeouts in seconds.*/ - time = chTimeNow(); + time = chVTGetSystemTime(); chThdSleepSeconds(1); test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1); /* Absolute timelines.*/ - time = chTimeNow() + MS2ST(100); + time = chVTGetSystemTime() + MS2ST(100); chThdSleepUntil(time); test_assert_time_window(4, time, time + 1); } -- cgit v1.2.3 From 2e4ba09bb54f415e7f8fd66f4ccddbf421612820 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 16:12:33 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5860 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testmtx.c | 4 ++-- test/testsem.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/testmtx.c b/test/testmtx.c index f83a9744a..52b5cebd4 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -446,13 +446,13 @@ static void mtx5_execute(void) { chMtxUnlockS(); chSysUnlock(); - test_assert(3, isempty(&m1.m_queue), "queue not empty"); + test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); test_assert(4, m1.m_owner == NULL, "still owned"); test_assert(5, chThdGetPriority() == prio, "wrong priority level"); chMtxLock(&m1); chMtxUnlockAll(); - test_assert(6, isempty(&m1.m_queue), "queue not empty"); + test_assert(6, queue_isempty(&m1.m_queue), "queue not empty"); test_assert(7, m1.m_owner == NULL, "still owned"); } diff --git a/test/testsem.c b/test/testsem.c index 20774b618..3de2e68fb 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -151,7 +151,7 @@ static void sem2_execute(void) { */ msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message"); - test_assert(2, isempty(&sem1.s_queue), "queue not empty"); + test_assert(2, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(3, sem1.s_cnt == 0, "counter not zero"); /* @@ -162,7 +162,7 @@ static void sem2_execute(void) { msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_wait_threads(); test_assert(4, msg == RDY_OK, "wrong wake-up message"); - test_assert(5, isempty(&sem1.s_queue), "queue not empty"); + test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(6, sem1.s_cnt == 0, "counter not zero"); /* @@ -174,7 +174,7 @@ static void sem2_execute(void) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message"); - test_assert(8, isempty(&sem1.s_queue), "queue not empty"); + test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(9, sem1.s_cnt == 0, "counter not zero"); } test_assert_sequence(10, "ABCDE"); @@ -218,11 +218,11 @@ static void sem3_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0); chSemSignalWait(&sem1, &sem1); - test_assert(1, isempty(&sem1.s_queue), "queue not empty"); + test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(2, sem1.s_cnt == 0, "counter not zero"); chSemSignalWait(&sem1, &sem1); - test_assert(3, isempty(&sem1.s_queue), "queue not empty"); + test_assert(3, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(4, sem1.s_cnt == 0, "counter not zero"); } -- cgit v1.2.3 From 3b6423187e643f8d1005d5fca2617a5485bc16b8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 09:43:11 +0000 Subject: Started renaming the types to follow the _t convention. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5988 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 5b46023d8..7e801c743 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -507,8 +507,8 @@ static void bmk10_execute(void) { test_start_timer(1000); do { chSysLock(); - chVTSetI(&vt1, 1, tmo, NULL); - chVTSetI(&vt2, 10000, tmo, NULL); + chVTDoSetI(&vt1, 1, tmo, NULL); + chVTDoSetI(&vt2, 10000, tmo, NULL); chVTResetI(&vt1); chVTResetI(&vt2); chSysUnlock(); -- cgit v1.2.3 From 4245ba7659ecdaadd47b0cdd61f3255b83f87d4f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 11:48:43 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5994 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 7e801c743..1ed9f1409 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -633,7 +633,7 @@ ROMCONST struct testcase testbmk12 = { static void bmk13_execute(void) { test_print("--- System: "); - test_printn(sizeof(ReadyList) + sizeof(VTList) + + test_printn(sizeof(ready_list_t) + sizeof(VTList) + PORT_IDLE_THREAD_STACK_SIZE + (sizeof(Thread) + sizeof(struct intctx) + sizeof(struct extctx) + -- cgit v1.2.3 From 84e044f176cee7c6946b24c36c90f63534b5b369 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 12:22:31 +0000 Subject: Renamed Thread to thread_t. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5995 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 2 +- test/test.h | 2 +- test/testbmk.c | 12 ++++++------ test/testdyn.c | 6 +++--- test/testevt.c | 2 +- test/testmsg.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index b7c92ceaf..86e53499b 100644 --- a/test/test.c +++ b/test/test.c @@ -70,7 +70,7 @@ union test_buffers test; /* * Pointers to the spawned threads. */ -Thread *threads[MAX_THREADS]; +thread_t *threads[MAX_THREADS]; /* * Pointers to the working areas. diff --git a/test/test.h b/test/test.h index fbdfa27f0..136631d8f 100644 --- a/test/test.h +++ b/test/test.h @@ -162,7 +162,7 @@ extern "C" { } #if !defined(__DOXYGEN__) -extern Thread *threads[MAX_THREADS]; +extern thread_t *threads[MAX_THREADS]; extern union test_buffers test; extern void * ROMCONST wa[]; extern bool_t test_timer_done; diff --git a/test/testbmk.c b/test/testbmk.c index 1ed9f1409..e2f0df833 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -62,7 +62,7 @@ static Mutex mtx1; #endif static msg_t thread1(void *p) { - Thread *tp; + thread_t *tp; msg_t msg; (void)p; @@ -77,7 +77,7 @@ static msg_t thread1(void *p) { #ifdef __GNUC__ __attribute__((noinline)) #endif -static unsigned int msg_loop_test(Thread *tp) { +static unsigned int msg_loop_test(thread_t *tp) { uint32_t n = 0; test_wait_tick(); @@ -202,7 +202,7 @@ ROMCONST struct testcase testbmk3 = { msg_t thread4(void *p) { msg_t msg; - Thread *self = chThdSelf(); + thread_t *self = chThdSelf(); (void)p; chSysLock(); @@ -215,7 +215,7 @@ msg_t thread4(void *p) { } static void bmk4_execute(void) { - Thread *tp; + thread_t *tp; uint32_t n; tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL); @@ -635,12 +635,12 @@ static void bmk13_execute(void) { test_print("--- System: "); test_printn(sizeof(ready_list_t) + sizeof(VTList) + PORT_IDLE_THREAD_STACK_SIZE + - (sizeof(Thread) + sizeof(struct intctx) + + (sizeof(thread_t) + sizeof(struct intctx) + sizeof(struct extctx) + PORT_INT_REQUIRED_STACK) * 2); test_println(" bytes"); test_print("--- Thread: "); - test_printn(sizeof(Thread)); + test_printn(sizeof(thread_t)); test_println(" bytes"); test_print("--- Timer : "); test_printn(sizeof(VirtualTimer)); diff --git a/test/testdyn.c b/test/testdyn.c index 8e54c81a1..ebfb00a4b 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -188,8 +188,8 @@ ROMCONST struct testcase testdyn2 = { * coverage. */ -static bool_t regfind(Thread *tp) { - Thread *ftp; +static bool_t regfind(thread_t *tp) { + thread_t *ftp; bool_t found = FALSE; ftp = chRegFirstThread(); @@ -206,7 +206,7 @@ static void dyn3_setup(void) { } static void dyn3_execute(void) { - Thread *tp; + thread_t *tp; tprio_t prio = chThdGetPriority(); /* Testing references increase/decrease and final detach.*/ diff --git a/test/testevt.c b/test/testevt.c index d1291c406..5daa7f1e3 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -133,7 +133,7 @@ static void evt2_setup(void) { static msg_t thread1(void *p) { chThdSleepMilliseconds(50); - chEvtSignal((Thread *)p, 1); + chEvtSignal((thread_t *)p, 1); return 0; } diff --git a/test/testmsg.c b/test/testmsg.c index 3ffaa6bf7..7a1ef1175 100644 --- a/test/testmsg.c +++ b/test/testmsg.c @@ -65,7 +65,7 @@ static msg_t thread(void *p) { } static void msg1_execute(void) { - Thread *tp; + thread_t *tp; msg_t msg; /* -- cgit v1.2.3 From d58064a533743df77e52f9d76385a9e0ea1d0227 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 13:17:42 +0000 Subject: Still work in progress. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5996 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 2 +- test/testbmk.c | 12 ++++++------ test/testsem.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index 86e53499b..f88b402a7 100644 --- a/test/test.c +++ b/test/test.c @@ -257,7 +257,7 @@ systime_t test_wait_tick(void) { */ bool_t test_timer_done; -static VirtualTimer vt; +static virtual_timer_t vt; static void tmr(void *p) { (void)p; diff --git a/test/testbmk.c b/test/testbmk.c index e2f0df833..957f634ac 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -56,7 +56,7 @@ * @brief Kernel Benchmarks header file */ -static Semaphore sem1; +static semaphore_t sem1; #if CH_USE_MUTEXES || defined(__DOXYGEN__) static Mutex mtx1; #endif @@ -500,7 +500,7 @@ ROMCONST struct testcase testbmk9 = { static void tmo(void *param) {(void)param;} static void bmk10_execute(void) { - static VirtualTimer vt1, vt2; + static virtual_timer_t vt1, vt2; uint32_t n = 0; test_wait_tick(); @@ -633,7 +633,7 @@ ROMCONST struct testcase testbmk12 = { static void bmk13_execute(void) { test_print("--- System: "); - test_printn(sizeof(ready_list_t) + sizeof(VTList) + + test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + PORT_IDLE_THREAD_STACK_SIZE + (sizeof(thread_t) + sizeof(struct intctx) + sizeof(struct extctx) + @@ -643,10 +643,10 @@ static void bmk13_execute(void) { test_printn(sizeof(thread_t)); test_println(" bytes"); test_print("--- Timer : "); - test_printn(sizeof(VirtualTimer)); + test_printn(sizeof(virtual_timer_t)); test_println(" bytes"); test_print("--- Semaph: "); - test_printn(sizeof(Semaphore)); + test_printn(sizeof(semaphore_t)); test_println(" bytes"); #if CH_USE_EVENTS || defined(__DOXYGEN__) test_print("--- EventS: "); @@ -663,7 +663,7 @@ static void bmk13_execute(void) { #endif #if CH_USE_CONDVARS || defined(__DOXYGEN__) test_print("--- CondV.: "); - test_printn(sizeof(CondVar)); + test_printn(sizeof(condition_variable_t)); test_println(" bytes"); #endif #if CH_USE_QUEUES || defined(__DOXYGEN__) diff --git a/test/testsem.c b/test/testsem.c index 3de2e68fb..f4ca03c1a 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -244,12 +244,12 @@ ROMCONST struct testcase testsem3 = { */ static msg_t thread4(void *p) { - chBSemSignal((BinarySemaphore *)p); + chBSemSignal((binary_semaphore_t *)p); return 0; } static void sem4_execute(void) { - BinarySemaphore bsem; + binary_semaphore_t bsem; /* Creates a taken binary semaphore.*/ chBSemInit(&bsem, TRUE); -- cgit v1.2.3 From 25ddb1c801f06a3be7171e20dcfd46d11a75f112 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 14:51:35 +0000 Subject: First cleanup pass finished, queues and streams not yet removed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5999 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 10 +++++----- test/testdyn.c | 4 ++-- test/testevt.c | 4 ++-- test/testheap.c | 2 +- test/testmbox.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 957f634ac..e117d9120 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -58,7 +58,7 @@ static semaphore_t sem1; #if CH_USE_MUTEXES || defined(__DOXYGEN__) -static Mutex mtx1; +static mutex_t mtx1; #endif static msg_t thread1(void *p) { @@ -650,15 +650,15 @@ static void bmk13_execute(void) { test_println(" bytes"); #if CH_USE_EVENTS || defined(__DOXYGEN__) test_print("--- EventS: "); - test_printn(sizeof(EventSource)); + test_printn(sizeof(event_source_t)); test_println(" bytes"); test_print("--- EventL: "); - test_printn(sizeof(EventListener)); + test_printn(sizeof(event_listener_t)); test_println(" bytes"); #endif #if CH_USE_MUTEXES || defined(__DOXYGEN__) test_print("--- Mutex : "); - test_printn(sizeof(Mutex)); + test_printn(sizeof(mutex_t)); test_println(" bytes"); #endif #if CH_USE_CONDVARS || defined(__DOXYGEN__) @@ -673,7 +673,7 @@ static void bmk13_execute(void) { #endif #if CH_USE_MAILBOXES || defined(__DOXYGEN__) test_print("--- MailB.: "); - test_printn(sizeof(Mailbox)); + test_printn(sizeof(mailbox_t)); test_println(" bytes"); #endif } diff --git a/test/testdyn.c b/test/testdyn.c index ebfb00a4b..15664ee07 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -51,10 +51,10 @@ #if CH_USE_DYNAMIC || defined(__DOXYGEN__) #if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) -static MemoryHeap heap1; +static memory_heap_t heap1; #endif #if CH_USE_MEMPOOLS || defined(__DOXYGEN__) -static MemoryPool mp1; +static memory_pool_t mp1; #endif /** diff --git a/test/testevt.c b/test/testevt.c index 5daa7f1e3..188a6fe2e 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -83,7 +83,7 @@ static void h3(eventid_t id) {(void)id;test_emit_token('C');} static ROMCONST evhandler_t evhndl[] = {h1, h2, h3}; static void evt1_execute(void) { - EventListener el1, el2; + event_listener_t el1, el2; /* * Testing chEvtRegisterMask() and chEvtUnregister(). @@ -148,7 +148,7 @@ static msg_t thread2(void *p) { static void evt2_execute(void) { eventmask_t m; - EventListener el1, el2; + event_listener_t el1, el2; systime_t target_time; /* diff --git a/test/testheap.c b/test/testheap.c index 9baa95d82..e160143aa 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -48,7 +48,7 @@ #define SIZE 16 -static MemoryHeap test_heap; +static memory_heap_t test_heap; /** * @page test_heap_001 Allocation and fragmentation test diff --git a/test/testmbox.c b/test/testmbox.c index b1fe675cc..35a22b88c 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -155,7 +155,7 @@ static void mbox1_execute(void) { /* * Testing I-Class. */ - chSysLock() + chSysLock(); msg1 = chMBPostI(&mb1, 'A'); test_assert(22, msg1 == RDY_OK, "wrong wake-up message"); msg1 = chMBPostI(&mb1, 'B'); -- cgit v1.2.3 From 390ed322cb8f40cb9250021cde5f48acb928d291 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 07:24:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6001 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 6 +++--- test/testdyn.c | 6 +++--- test/testevt.c | 6 +++--- test/testheap.c | 2 +- test/testmbox.c | 2 +- test/testmtx.c | 28 ++++++++++++++-------------- test/testpools.c | 4 ++-- test/testsem.c | 8 ++++---- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index e117d9120..41d8d457d 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -348,7 +348,7 @@ static msg_t thread3(void *p) { static void bmk7_setup(void) { - chSemInit(&sem1, 0); + chSemObjectInit(&sem1, 0); } static void bmk7_execute(void) { @@ -541,7 +541,7 @@ ROMCONST struct testcase testbmk10 = { static void bmk11_setup(void) { - chSemInit(&sem1, 1); + chSemObjectInit(&sem1, 1); } static void bmk11_execute(void) { @@ -588,7 +588,7 @@ ROMCONST struct testcase testbmk11 = { static void bmk12_setup(void) { - chMtxInit(&mtx1); + chMtxObjectInit(&mtx1); } static void bmk12_execute(void) { diff --git a/test/testdyn.c b/test/testdyn.c index 15664ee07..3f157686d 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -77,7 +77,7 @@ static msg_t thread(void *p) { #if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) static void dyn1_setup(void) { - chHeapInit(&heap1, test.buffer, sizeof(union test_buffers)); + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); } static void dyn1_execute(void) { @@ -135,7 +135,7 @@ ROMCONST struct testcase testdyn1 = { static void dyn2_setup(void) { - chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); + chPoolObjectInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); } static void dyn2_execute(void) { @@ -202,7 +202,7 @@ static bool_t regfind(thread_t *tp) { static void dyn3_setup(void) { - chHeapInit(&heap1, test.buffer, sizeof(union test_buffers)); + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); } static void dyn3_execute(void) { diff --git a/test/testevt.c b/test/testevt.c index 188a6fe2e..80bc18ae7 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -88,7 +88,7 @@ static void evt1_execute(void) { /* * Testing chEvtRegisterMask() and chEvtUnregister(). */ - chEvtInit(&es1); + chEvtObjectInit(&es1); chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es1, &el2, 2); test_assert(1, chEvtIsListeningI(&es1), "no listener"); @@ -202,8 +202,8 @@ static void evt2_execute(void) { /* * Test on chEvtWaitAll(). */ - chEvtInit(&es1); - chEvtInit(&es2); + chEvtObjectInit(&es1); + chEvtObjectInit(&es2); chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es2, &el2, 4); test_wait_tick(); diff --git a/test/testheap.c b/test/testheap.c index e160143aa..667b64cb2 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -63,7 +63,7 @@ static memory_heap_t test_heap; static void heap1_setup(void) { - chHeapInit(&test_heap, test.buffer, sizeof(union test_buffers)); + chHeapObjectInit(&test_heap, test.buffer, sizeof(union test_buffers)); } static void heap1_execute(void) { diff --git a/test/testmbox.c b/test/testmbox.c index 35a22b88c..c9d554e16 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -70,7 +70,7 @@ static MAILBOX_DECL(mb1, test.wa.T0, MB_SIZE); static void mbox1_setup(void) { - chMBInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE); + chMBObjectInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE); } static void mbox1_execute(void) { diff --git a/test/testmtx.c b/test/testmtx.c index 52b5cebd4..caaf91409 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -83,7 +83,7 @@ static CONDVAR_DECL(c1); static void mtx1_setup(void) { - chMtxInit(&m1); + chMtxObjectInit(&m1); } static msg_t thread1(void *p) { @@ -150,7 +150,7 @@ ROMCONST struct testcase testmtx1 = { static void mtx2_setup(void) { - chMtxInit(&m1); + chMtxObjectInit(&m1); } /* Low priority thread */ @@ -240,8 +240,8 @@ ROMCONST struct testcase testmtx2 = { static void mtx3_setup(void) { - chMtxInit(&m1); /* Mutex B.*/ - chMtxInit(&m2); /* Mutex A.*/ + chMtxObjectInit(&m1); /* Mutex B.*/ + chMtxObjectInit(&m2); /* Mutex A.*/ } /* Lowest priority thread */ @@ -340,8 +340,8 @@ ROMCONST struct testcase testmtx3 = { static void mtx4_setup(void) { - chMtxInit(&m1); - chMtxInit(&m2); + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); } static msg_t thread4a(void *p) { @@ -427,7 +427,7 @@ ROMCONST struct testcase testmtx4 = { static void mtx5_setup(void) { - chMtxInit(&m1); + chMtxObjectInit(&m1); } static void mtx5_execute(void) { @@ -477,8 +477,8 @@ ROMCONST struct testcase testmtx5 = { static void mtx6_setup(void) { - chCondInit(&c1); - chMtxInit(&m1); + chCondObjectInit(&c1); + chMtxObjectInit(&m1); } static msg_t thread10(void *p) { @@ -529,8 +529,8 @@ ROMCONST struct testcase testmtx6 = { static void mtx7_setup(void) { - chCondInit(&c1); - chMtxInit(&m1); + chCondObjectInit(&c1); + chMtxObjectInit(&m1); } static void mtx7_execute(void) { @@ -564,9 +564,9 @@ ROMCONST struct testcase testmtx7 = { static void mtx8_setup(void) { - chCondInit(&c1); - chMtxInit(&m1); - chMtxInit(&m2); + chCondObjectInit(&c1); + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); } static msg_t thread11(void *p) { diff --git a/test/testpools.c b/test/testpools.c index 6515b256f..6ff669227 100644 --- a/test/testpools.c +++ b/test/testpools.c @@ -65,7 +65,7 @@ static void *null_provider(size_t size) { static void pools1_setup(void) { - chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); + chPoolObjectInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); } static void pools1_execute(void) { @@ -93,7 +93,7 @@ static void pools1_execute(void) { test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty"); /* Covering the case where a provider is unable to return more memory.*/ - chPoolInit(&mp1, 16, null_provider); + chPoolObjectInit(&mp1, 16, null_provider); test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory"); } diff --git a/test/testsem.c b/test/testsem.c index f4ca03c1a..b27540059 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -71,7 +71,7 @@ static SEMAPHORE_DECL(sem1, 0); static void sem1_setup(void) { - chSemInit(&sem1, 0); + chSemObjectInit(&sem1, 0); } static msg_t thread1(void *p) { @@ -127,7 +127,7 @@ ROMCONST struct testcase testsem1 = { static void sem2_setup(void) { - chSemInit(&sem1, 0); + chSemObjectInit(&sem1, 0); } static msg_t thread2(void *p) { @@ -203,7 +203,7 @@ ROMCONST struct testcase testsem2 = { static void sem3_setup(void) { - chSemInit(&sem1, 0); + chSemObjectInit(&sem1, 0); } static msg_t thread3(void *p) { @@ -252,7 +252,7 @@ static void sem4_execute(void) { binary_semaphore_t bsem; /* Creates a taken binary semaphore.*/ - chBSemInit(&bsem, TRUE); + chBSemObjectInit(&bsem, TRUE); chBSemReset(&bsem, TRUE); test_assert(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); -- cgit v1.2.3 From dc7b36df31f4d9dbd9a039319df74f4b2c8eed0c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 08:29:48 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6004 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 41d8d457d..5e423f34d 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -509,8 +509,8 @@ static void bmk10_execute(void) { chSysLock(); chVTDoSetI(&vt1, 1, tmo, NULL); chVTDoSetI(&vt2, 10000, tmo, NULL); - chVTResetI(&vt1); - chVTResetI(&vt2); + chVTDoResetI(&vt1); + chVTDoResetI(&vt2); chSysUnlock(); n++; #if defined(SIMULATOR) -- cgit v1.2.3 From 49d71a01abeefa000a4cd7a556052d826b096d49 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 10:12:44 +0000 Subject: Renamed or added prefix to all hernel configuration options. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6010 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 16 ++++++++-------- test/testdyn.c | 34 +++++++++++++++++----------------- test/testevt.c | 16 ++++++++-------- test/testheap.c | 8 ++++---- test/testmbox.c | 8 ++++---- test/testmsg.c | 8 ++++---- test/testmtx.c | 20 ++++++++++---------- test/testpools.c | 8 ++++---- test/testqueues.c | 8 ++++---- test/testsem.c | 18 +++++++++--------- test/testthd.c | 4 ++-- 11 files changed, 74 insertions(+), 74 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 5e423f34d..ce8b8d51e 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -57,7 +57,7 @@ */ static semaphore_t sem1; -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) static mutex_t mtx1; #endif @@ -575,7 +575,7 @@ ROMCONST struct testcase testbmk11 = { bmk11_execute }; -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) /** * @page test_benchmarks_012 Mutexes lock/unlock performance * @@ -648,7 +648,7 @@ static void bmk13_execute(void) { test_print("--- Semaph: "); test_printn(sizeof(semaphore_t)); test_println(" bytes"); -#if CH_USE_EVENTS || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) test_print("--- EventS: "); test_printn(sizeof(event_source_t)); test_println(" bytes"); @@ -656,22 +656,22 @@ static void bmk13_execute(void) { test_printn(sizeof(event_listener_t)); test_println(" bytes"); #endif -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) test_print("--- Mutex : "); test_printn(sizeof(mutex_t)); test_println(" bytes"); #endif -#if CH_USE_CONDVARS || defined(__DOXYGEN__) +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) test_print("--- CondV.: "); test_printn(sizeof(condition_variable_t)); test_println(" bytes"); #endif -#if CH_USE_QUEUES || defined(__DOXYGEN__) +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) test_print("--- Queue : "); test_printn(sizeof(GenericQueue)); test_println(" bytes"); #endif -#if CH_USE_MAILBOXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) test_print("--- MailB.: "); test_printn(sizeof(mailbox_t)); test_println(" bytes"); @@ -701,7 +701,7 @@ ROMCONST struct testcase * ROMCONST patternbmk[] = { &testbmk9, &testbmk10, &testbmk11, -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) &testbmk12, #endif &testbmk13, diff --git a/test/testdyn.c b/test/testdyn.c index 3f157686d..31fd0c005 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -31,9 +31,9 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_DYNAMIC - * - @p CH_USE_HEAP - * - @p CH_USE_MEMPOOLS + * - @p CH_CFG_USE_DYNAMIC + * - @p CH_CFG_USE_HEAP + * - @p CH_CFG_USE_MEMPOOLS * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -49,11 +49,11 @@ * @brief Dynamic thread APIs test header file */ -#if CH_USE_DYNAMIC || defined(__DOXYGEN__) -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) static memory_heap_t heap1; #endif -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) static memory_pool_t mp1; #endif @@ -74,7 +74,7 @@ static msg_t thread(void *p) { return 0; } -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) static void dyn1_setup(void) { chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); @@ -120,9 +120,9 @@ ROMCONST struct testcase testdyn1 = { NULL, dyn1_execute }; -#endif /* (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) */ +#endif /* (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) */ -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) /** * @page test_dynamic_002 Threads creation from Memory Pool * @@ -176,9 +176,9 @@ ROMCONST struct testcase testdyn2 = { NULL, dyn2_execute }; -#endif /* CH_USE_MEMPOOLS */ +#endif /* CH_CFG_USE_MEMPOOLS */ -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \ +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ defined(__DOXYGEN__) /** * @page test_dynamic_003 Registry and References test @@ -241,21 +241,21 @@ ROMCONST struct testcase testdyn3 = { NULL, dyn3_execute }; -#endif /* CH_USE_HEAP && CH_USE_REGISTRY */ -#endif /* CH_USE_DYNAMIC */ +#endif /* CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY */ +#endif /* CH_CFG_USE_DYNAMIC */ /** * @brief Test sequence for dynamic APIs. */ ROMCONST struct testcase * ROMCONST patterndyn[] = { -#if CH_USE_DYNAMIC || defined(__DOXYGEN__) -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) &testdyn1, #endif -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) &testdyn2, #endif -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \ +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ defined(__DOXYGEN__) &testdyn3, #endif diff --git a/test/testevt.c b/test/testevt.c index 80bc18ae7..bb9381139 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -30,8 +30,8 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_EVENTS - * - @p CH_USE_EVENTS_TIMEOUT + * - @p CH_CFG_USE_EVENTS + * - @p CH_CFG_USE_EVENTS_TIMEOUT * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -47,7 +47,7 @@ * @brief Events test header file */ -#if CH_USE_EVENTS || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) #define ALLOWED_DELAY MS2ST(5) @@ -228,7 +228,7 @@ ROMCONST struct testcase testevt2 = { evt2_execute }; -#if CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) /** * @page test_events_003 Events timeout * @@ -275,20 +275,20 @@ ROMCONST struct testcase testevt3 = { NULL, evt3_execute }; -#endif /* CH_USE_EVENTS_TIMEOUT */ +#endif /* CH_CFG_USE_EVENTS_TIMEOUT */ /** * @brief Test sequence for events. */ ROMCONST struct testcase * ROMCONST patternevt[] = { -#if CH_USE_EVENTS || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) &testevt1, &testevt2, -#if CH_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) &testevt3, #endif #endif NULL }; -#endif /* CH_USE_EVENTS */ +#endif /* CH_CFG_USE_EVENTS */ diff --git a/test/testheap.c b/test/testheap.c index 667b64cb2..d257a4362 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -30,7 +30,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_HEAP + * - @p CH_CFG_USE_HEAP * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -44,7 +44,7 @@ * @brief Heap header file */ -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) #define SIZE 16 @@ -146,13 +146,13 @@ ROMCONST struct testcase testheap1 = { heap1_execute }; -#endif /* CH_USE_HEAP.*/ +#endif /* CH_CFG_USE_HEAP.*/ /** * @brief Test sequence for heap. */ ROMCONST struct testcase * ROMCONST patternheap[] = { -#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) &testheap1, #endif NULL diff --git a/test/testmbox.c b/test/testmbox.c index c9d554e16..0ba52aa09 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -33,7 +33,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_MAILBOXES + * - @p CH_CFG_USE_MAILBOXES * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -47,7 +47,7 @@ * @brief Mailboxes header file */ -#if CH_USE_MAILBOXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) #define ALLOWED_DELAY MS2ST(5) #define MB_SIZE 5 @@ -226,13 +226,13 @@ ROMCONST struct testcase testmbox1 = { mbox1_execute }; -#endif /* CH_USE_MAILBOXES */ +#endif /* CH_CFG_USE_MAILBOXES */ /** * @brief Test sequence for mailboxes. */ ROMCONST struct testcase * ROMCONST patternmbox[] = { -#if CH_USE_MAILBOXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) &testmbox1, #endif NULL diff --git a/test/testmsg.c b/test/testmsg.c index 7a1ef1175..30d7f24dd 100644 --- a/test/testmsg.c +++ b/test/testmsg.c @@ -31,7 +31,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_MESSAGES + * - @p CH_CFG_USE_MESSAGES * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -45,7 +45,7 @@ * @brief Messages header file */ -#if CH_USE_MESSAGES || defined(__DOXYGEN__) +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) /** * @page test_msg_001 Messages Server loop @@ -95,13 +95,13 @@ ROMCONST struct testcase testmsg1 = { msg1_execute }; -#endif /* CH_USE_MESSAGES */ +#endif /* CH_CFG_USE_MESSAGES */ /** * @brief Test sequence for messages. */ ROMCONST struct testcase * ROMCONST patternmsg[] = { -#if CH_USE_MESSAGES || defined(__DOXYGEN__) +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) &testmsg1, #endif NULL diff --git a/test/testmtx.c b/test/testmtx.c index caaf91409..c775cb51b 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -33,8 +33,8 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_MUTEXES - * - @p CH_USE_CONDVARS + * - @p CH_CFG_USE_MUTEXES + * - @p CH_CFG_USE_CONDVARS * - @p CH_DBG_THREADS_PROFILING * . * In case some of the required options are not enabled then some or all tests @@ -56,7 +56,7 @@ * @brief Mutexes and CondVars test header file */ -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) #define ALLOWED_DELAY 5 @@ -67,7 +67,7 @@ */ static MUTEX_DECL(m1); static MUTEX_DECL(m2); -#if CH_USE_CONDVARS || defined(__DOXYGEN__) +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) static CONDVAR_DECL(c1); #endif @@ -463,7 +463,7 @@ ROMCONST struct testcase testmtx5 = { mtx5_execute }; -#if CH_USE_CONDVARS || defined(__DOXYGEN__) +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) /** * @page test_mtx_006 Condition Variable signal test * @@ -573,7 +573,7 @@ static msg_t thread11(void *p) { chMtxLock(&m2); chMtxLock(&m1); -#if CH_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__) +#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__) chCondWaitTimeout(&c1, TIME_INFINITE); #else chCondWait(&c1); @@ -610,14 +610,14 @@ ROMCONST struct testcase testmtx8 = { NULL, mtx8_execute }; -#endif /* CH_USE_CONDVARS */ -#endif /* CH_USE_MUTEXES */ +#endif /* CH_CFG_USE_CONDVARS */ +#endif /* CH_CFG_USE_MUTEXES */ /** * @brief Test sequence for mutexes. */ ROMCONST struct testcase * ROMCONST patternmtx[] = { -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) &testmtx1, #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) &testmtx2, @@ -625,7 +625,7 @@ ROMCONST struct testcase * ROMCONST patternmtx[] = { #endif &testmtx4, &testmtx5, -#if CH_USE_CONDVARS || defined(__DOXYGEN__) +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) &testmtx6, &testmtx7, &testmtx8, diff --git a/test/testpools.c b/test/testpools.c index 6ff669227..18063e111 100644 --- a/test/testpools.c +++ b/test/testpools.c @@ -30,7 +30,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_MEMPOOLS + * - @p CH_CFG_USE_MEMPOOLS * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -44,7 +44,7 @@ * @brief Memory Pools test header file */ -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) static MEMORYPOOL_DECL(mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); @@ -104,13 +104,13 @@ ROMCONST struct testcase testpools1 = { pools1_execute }; -#endif /* CH_USE_MEMPOOLS */ +#endif /* CH_CFG_USE_MEMPOOLS */ /* * @brief Test sequence for pools. */ ROMCONST struct testcase * ROMCONST patternpools[] = { -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) &testpools1, #endif NULL diff --git a/test/testqueues.c b/test/testqueues.c index 7f682ef8e..d19ca5e00 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -35,7 +35,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_QUEUES (and dependent options) + * - @p CH_CFG_USE_QUEUES (and dependent options) * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -50,7 +50,7 @@ * @brief I/O Queues test header file */ -#if CH_USE_QUEUES || defined(__DOXYGEN__) +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) #define TEST_QUEUES_SIZE 4 @@ -230,13 +230,13 @@ ROMCONST struct testcase testqueues2 = { NULL, queues2_execute }; -#endif /* CH_USE_QUEUES */ +#endif /* CH_CFG_USE_QUEUES */ /** * @brief Test sequence for queues. */ ROMCONST struct testcase * ROMCONST patternqueues[] = { -#if CH_USE_QUEUES || defined(__DOXYGEN__) +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) &testqueues1, &testqueues2, #endif diff --git a/test/testsem.c b/test/testsem.c index b27540059..9483a75d6 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -30,7 +30,7 @@ * *

Preconditions

* The module requires the following kernel options: - * - @p CH_USE_SEMAPHORES + * - @p CH_CFG_USE_SEMAPHORES * . * In case some of the required options are not enabled then some or all tests * may be skipped. @@ -47,7 +47,7 @@ * @brief Semaphores test header file */ -#if CH_USE_SEMAPHORES || defined(__DOXYGEN__) +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) #define ALLOWED_DELAY MS2ST(5) @@ -65,7 +65,7 @@ static SEMAPHORE_DECL(sem1, 0); * Five threads with randomized priorities are enqueued to a semaphore then * awakened one at time.
* The test expects that the threads reach their goal in FIFO order or - * priority order depending on the CH_USE_SEMAPHORES_PRIORITY configuration + * priority order depending on the CH_CFG_USE_SEMAPHORES_PRIORITY configuration * setting. */ @@ -94,7 +94,7 @@ static void sem1_execute(void) { chSemSignal(&sem1); chSemSignal(&sem1); test_wait_threads(); -#if CH_USE_SEMAPHORES_PRIORITY +#if CH_CFG_USE_SEMAPHORES_PRIORITY test_assert_sequence(1, "ADCEB"); #else test_assert_sequence(1, "ABCDE"); @@ -188,7 +188,7 @@ ROMCONST struct testcase testsem2 = { sem2_execute }; -#if CH_USE_SEMSW || defined(__DOXYGEN__) +#if CH_CFG_USE_SEMSW || defined(__DOXYGEN__) /** * @page test_sem_003 Atomic signal-wait test * @@ -232,7 +232,7 @@ ROMCONST struct testcase testsem3 = { NULL, sem3_execute }; -#endif /* CH_USE_SEMSW */ +#endif /* CH_CFG_USE_SEMSW */ /** * @page test_sem_004 Binary Wait and Signal @@ -284,16 +284,16 @@ ROMCONST struct testcase testsem4 = { NULL, sem4_execute }; -#endif /* CH_USE_SEMAPHORES */ +#endif /* CH_CFG_USE_SEMAPHORES */ /** * @brief Test sequence for semaphores. */ ROMCONST struct testcase * ROMCONST patternsem[] = { -#if CH_USE_SEMAPHORES || defined(__DOXYGEN__) +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) &testsem1, &testsem2, -#if CH_USE_SEMSW || defined(__DOXYGEN__) +#if CH_CFG_USE_SEMSW || defined(__DOXYGEN__) &testsem3, #endif &testsem4, diff --git a/test/testthd.c b/test/testthd.c index 9916ca253..af71a2041 100644 --- a/test/testthd.c +++ b/test/testthd.c @@ -119,7 +119,7 @@ ROMCONST struct testcase testthd2 = { *

Description

* A series of priority changes are performed on the current thread in order * to verify that the priority change happens as expected.
- * If the @p CH_USE_MUTEXES option is enabled then the priority changes are + * If the @p CH_CFG_USE_MUTEXES option is enabled then the priority changes are * also tested under priority inheritance boosted priority state. */ @@ -138,7 +138,7 @@ static void thd3_execute(void) { test_assert(4, chThdGetPriority() == prio, "unexpected priority level"); -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) /* Simulates a priority boost situation (p_prio > p_realprio).*/ chSysLock(); chThdSelf()->p_prio += 2; -- cgit v1.2.3 From cb5416a6606b575f0b6b3116925afbeaedb99a68 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 18:04:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6011 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testsem.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'test') diff --git a/test/testsem.c b/test/testsem.c index 9483a75d6..d73a5e11b 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -188,7 +188,6 @@ ROMCONST struct testcase testsem2 = { sem2_execute }; -#if CH_CFG_USE_SEMSW || defined(__DOXYGEN__) /** * @page test_sem_003 Atomic signal-wait test * @@ -232,7 +231,6 @@ ROMCONST struct testcase testsem3 = { NULL, sem3_execute }; -#endif /* CH_CFG_USE_SEMSW */ /** * @page test_sem_004 Binary Wait and Signal @@ -293,9 +291,7 @@ ROMCONST struct testcase * ROMCONST patternsem[] = { #if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) &testsem1, &testsem2, -#if CH_CFG_USE_SEMSW || defined(__DOXYGEN__) &testsem3, -#endif &testsem4, #endif NULL -- cgit v1.2.3 From 40f413d3c97a7694703938cd031ce15912b29ff7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 24 Jul 2013 14:54:26 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6025 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 2 +- test/testdyn.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index ce8b8d51e..293dbd607 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -207,7 +207,7 @@ msg_t thread4(void *p) { (void)p; chSysLock(); do { - chSchGoSleepS(THD_STATE_SUSPENDED); + chSchGoSleepS(CH_STATE_SUSPENDED); msg = self->p_u.rdymsg; } while (msg == RDY_OK); chSysUnlock(); diff --git a/test/testdyn.c b/test/testdyn.c index 31fd0c005..7ba281e31 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -224,11 +224,11 @@ static void dyn3_execute(void) { /* Detach and let the thread execute and terminate.*/ chThdRelease(tp); test_assert(6, tp->p_refs == 0, "detach failure"); - test_assert(7, tp->p_state == THD_STATE_READY, "invalid state"); + test_assert(7, tp->p_state == CH_STATE_READY, "invalid state"); test_assert(8, regfind(tp), "thread disappeared"); test_assert(9, regfind(tp), "thread disappeared"); chThdSleepMilliseconds(50); /* The thread just terminates. */ - test_assert(10, tp->p_state == THD_STATE_FINAL, "invalid state"); + test_assert(10, tp->p_state == CH_STATE_FINAL, "invalid state"); /* Clearing the zombie by scanning the registry.*/ test_assert(11, regfind(tp), "thread disappeared"); -- cgit v1.2.3 From 64403d8f188725bc5814813371382bc148956a83 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 30 Jul 2013 14:23:37 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6048 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 3 ++- test/testmbox.c | 2 +- test/testsem.c | 18 +++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 293dbd607..c04239817 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -218,7 +218,8 @@ static void bmk4_execute(void) { thread_t *tp; uint32_t n; - tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL); + tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, + thread4, NULL); n = 0; test_wait_tick(); test_start_timer(1000); diff --git a/test/testmbox.c b/test/testmbox.c index 0ba52aa09..1ca34dadc 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -80,7 +80,7 @@ static void mbox1_execute(void) { /* * Testing initial space. */ - test_assert(1, chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size"); + test_assert_lock(1, chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size"); /* * Testing enqueuing and backward circularity. diff --git a/test/testsem.c b/test/testsem.c index d73a5e11b..0810300ea 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -104,7 +104,7 @@ static void sem1_execute(void) { chSemAddCounterI(&sem1, 2); chSysUnlock(); test_wait_threads(); - test_assert(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); + test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); } ROMCONST struct testcase testsem1 = { @@ -252,7 +252,7 @@ static void sem4_execute(void) { /* Creates a taken binary semaphore.*/ chBSemObjectInit(&bsem, TRUE); chBSemReset(&bsem, TRUE); - test_assert(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); + test_assert_lock(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); /* Starts a signaler thread at a lower priority.*/ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, @@ -262,18 +262,18 @@ static void sem4_execute(void) { chBSemWait(&bsem); /* The binary semaphore is expected to be taken.*/ - test_assert(2, chBSemGetStateI(&bsem) == TRUE, "not taken"); - + test_assert_lock(2, chBSemGetStateI(&bsem) == TRUE, "not taken"); + /* Releasing it, check both the binary semaphore state and the underlying counter semaphore state..*/ chBSemSignal(&bsem); - test_assert(3, chBSemGetStateI(&bsem) == FALSE, "still taken"); - test_assert(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); - + test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "still taken"); + test_assert_lock(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); + /* Checking signaling overflow, the counter must not go beyond 1.*/ chBSemSignal(&bsem); - test_assert(3, chBSemGetStateI(&bsem) == FALSE, "taken"); - test_assert(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); + test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "taken"); + test_assert_lock(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); } ROMCONST struct testcase testsem4 = { -- cgit v1.2.3 From e619097f77edeceb5e8c38dc7e614c7fccd36cbf Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 4 Aug 2013 13:38:53 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6073 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index c04239817..3c0aed9df 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -442,6 +442,7 @@ ROMCONST struct testcase testbmk8 = { bmk8_execute }; +#if 0 /** * @page test_benchmarks_009 I/O Queues throughput * @@ -488,6 +489,7 @@ ROMCONST struct testcase testbmk9 = { NULL, bmk9_execute }; +#endif /** * @page test_benchmarks_010 Virtual Timers set/reset performance @@ -699,7 +701,7 @@ ROMCONST struct testcase * ROMCONST patternbmk[] = { &testbmk6, &testbmk7, &testbmk8, - &testbmk9, +// &testbmk9, &testbmk10, &testbmk11, #if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) -- cgit v1.2.3 From b5349cc22d7deade864d5ceb795a33af0a2eca15 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 6 Aug 2013 09:45:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6086 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 3c0aed9df..0dadc7652 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -637,10 +637,10 @@ static void bmk13_execute(void) { test_print("--- System: "); test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + - PORT_IDLE_THREAD_STACK_SIZE + + CH_PORT_IDLE_THREAD_STACK_SIZE + (sizeof(thread_t) + sizeof(struct intctx) + sizeof(struct extctx) + - PORT_INT_REQUIRED_STACK) * 2); + CH_PORT_INT_REQUIRED_STACK) * 2); test_println(" bytes"); test_print("--- Thread: "); test_printn(sizeof(thread_t)); -- cgit v1.2.3 From 7b51712449ffa10f260f60e6968257230fe63f15 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 13:43:56 +0000 Subject: Updated queues. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6112 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 2 +- test/testqueues.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 0dadc7652..372e2a669 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -671,7 +671,7 @@ static void bmk13_execute(void) { #endif #if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) test_print("--- Queue : "); - test_printn(sizeof(GenericQueue)); + test_printn(sizeof(io_queue_t)); test_println(" bytes"); #endif #if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) diff --git a/test/testqueues.c b/test/testqueues.c index d19ca5e00..6ef057f3a 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -54,7 +54,7 @@ #define TEST_QUEUES_SIZE 4 -static void notify(GenericQueue *qp) { +static void notify(io_queue_t *qp) { (void)qp; } @@ -77,7 +77,7 @@ static OUTPUTQUEUE_DECL(oq, test.wa.T1, TEST_QUEUES_SIZE, notify, NULL); static void queues1_setup(void) { - chIQInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); + chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); } static msg_t thread1(void *p) { @@ -164,7 +164,7 @@ ROMCONST struct testcase testqueues1 = { static void queues2_setup(void) { - chOQInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); + chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); } static msg_t thread2(void *p) { -- cgit v1.2.3 From 16712a78831d021d9ee40ade082aefafc9aea196 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 06:55:50 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6115 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 372e2a669..4ce953163 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -442,7 +442,7 @@ ROMCONST struct testcase testbmk8 = { bmk8_execute }; -#if 0 +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) /** * @page test_benchmarks_009 I/O Queues throughput * @@ -456,9 +456,9 @@ ROMCONST struct testcase testbmk8 = { static void bmk9_execute(void) { uint32_t n; static uint8_t ib[16]; - static InputQueue iq; + static input_queue_t iq; - chIQInit(&iq, ib, sizeof(ib), NULL, NULL); + chIQObjectInit(&iq, ib, sizeof(ib), NULL, NULL); n = 0; test_wait_tick(); test_start_timer(1000); @@ -489,7 +489,7 @@ ROMCONST struct testcase testbmk9 = { NULL, bmk9_execute }; -#endif +#endif /* CH_CFG_USE_QUEUES */ /** * @page test_benchmarks_010 Virtual Timers set/reset performance @@ -701,7 +701,9 @@ ROMCONST struct testcase * ROMCONST patternbmk[] = { &testbmk6, &testbmk7, &testbmk8, -// &testbmk9, +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + &testbmk9, +#endif &testbmk10, &testbmk11, #if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) -- cgit v1.2.3 From bfa3ba9f00d263a15d6d6b2dec2aa0b81058df27 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 16 Aug 2013 17:41:56 +0000 Subject: Turned more macros in inline functions. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6166 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 4 ++-- test/testbmk.c | 46 +++++++++++++++++++++--------------------- test/testdyn.c | 6 +++--- test/testevt.c | 10 +++++----- test/testmsg.c | 4 ++-- test/testmtx.c | 60 +++++++++++++++++++++++++++---------------------------- test/testqueues.c | 4 ++-- test/testsem.c | 18 ++++++++--------- test/testthd.c | 42 +++++++++++++++++++------------------- 9 files changed, 97 insertions(+), 97 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index f88b402a7..77759f5b8 100644 --- a/test/test.c +++ b/test/test.c @@ -224,10 +224,10 @@ void test_wait_threads(void) { void test_cpu_pulse(unsigned duration) { systime_t start, end, now; - start = chThdSelf()->p_time; + start = chThdGetTicksX(chThdGetSelfX()); end = start + MS2ST(duration); do { - now = chThdSelf()->p_time; + now = chThdGetTicksX(chThdGetSelfX()); #if defined(SIMULATOR) ChkIntSources(); #endif diff --git a/test/testbmk.c b/test/testbmk.c index 4ce953163..5149323a6 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -105,7 +105,7 @@ static unsigned int msg_loop_test(thread_t *tp) { static void bmk1_execute(void) { uint32_t n; - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread1, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, NULL); n = msg_loop_test(threads[0]); test_wait_threads(); test_print("--- Score : "); @@ -134,7 +134,7 @@ ROMCONST struct testcase testbmk1 = { static void bmk2_execute(void) { uint32_t n; - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); n = msg_loop_test(threads[0]); test_wait_threads(); test_print("--- Score : "); @@ -169,11 +169,11 @@ static msg_t thread2(void *p) { static void bmk3_execute(void) { uint32_t n; - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2, NULL); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2, NULL); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-4, thread2, NULL); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-5, thread2, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2, NULL); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2, NULL); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread2, NULL); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread2, NULL); n = msg_loop_test(threads[0]); test_wait_threads(); test_print("--- Score : "); @@ -202,7 +202,7 @@ ROMCONST struct testcase testbmk3 = { msg_t thread4(void *p) { msg_t msg; - thread_t *self = chThdSelf(); + thread_t *self = chThdGetSelfX(); (void)p; chSysLock(); @@ -218,7 +218,7 @@ static void bmk4_execute(void) { thread_t *tp; uint32_t n; - tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, + tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread4, NULL); n = 0; test_wait_tick(); @@ -267,7 +267,7 @@ static void bmk5_execute(void) { uint32_t n = 0; void *wap = wa[0]; - tprio_t prio = chThdGetPriority() - 1; + tprio_t prio = chThdGetPriorityX() - 1; test_wait_tick(); test_start_timer(1000); do { @@ -306,7 +306,7 @@ static void bmk6_execute(void) { uint32_t n = 0; void *wap = wa[0]; - tprio_t prio = chThdGetPriority() + 1; + tprio_t prio = chThdGetPriorityX() + 1; test_wait_tick(); test_start_timer(1000); do { @@ -342,7 +342,7 @@ ROMCONST struct testcase testbmk6 = { static msg_t thread3(void *p) { (void)p; - while (!chThdShouldTerminate()) + while (!chThdShouldTerminateX()) chSemWait(&sem1); return 0; } @@ -355,11 +355,11 @@ static void bmk7_setup(void) { static void bmk7_execute(void) { uint32_t n; - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL); n = 0; test_wait_tick(); @@ -410,7 +410,7 @@ static msg_t thread8(void *p) { #if defined(SIMULATOR) ChkIntSources(); #endif - } while(!chThdShouldTerminate()); + } while(!chThdShouldTerminateX()); return 0; } @@ -420,11 +420,11 @@ static void bmk8_execute(void) { n = 0; test_wait_tick(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); chThdSleepSeconds(1); test_terminate_threads(); diff --git a/test/testdyn.c b/test/testdyn.c index 7ba281e31..3eb3304d5 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -83,7 +83,7 @@ static void dyn1_setup(void) { static void dyn1_execute(void) { size_t n, sz; void *p1; - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); (void)chHeapStatus(&heap1, &sz); /* Starting threads from the heap. */ @@ -140,7 +140,7 @@ static void dyn2_setup(void) { static void dyn2_execute(void) { int i; - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); /* Adding the WAs to the pool. */ for (i = 0; i < 4; i++) @@ -207,7 +207,7 @@ static void dyn3_setup(void) { static void dyn3_execute(void) { thread_t *tp; - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); /* Testing references increase/decrease and final detach.*/ tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A"); diff --git a/test/testevt.c b/test/testevt.c index bb9381139..49507f067 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -167,8 +167,8 @@ static void evt2_execute(void) { */ test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, - thread1, chThdSelf()); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); m = chEvtWaitOne(ALL_EVENTS); test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY); test_assert(5, m == 1, "single event error"); @@ -190,8 +190,8 @@ static void evt2_execute(void) { */ test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, - thread1, chThdSelf()); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); m = chEvtWaitAny(ALL_EVENTS); test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY); test_assert(10, m == 1, "single event error"); @@ -208,7 +208,7 @@ static void evt2_execute(void) { chEvtRegisterMask(&es2, &el2, 4); test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread2, "A"); m = chEvtWaitAll(5); test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY); diff --git a/test/testmsg.c b/test/testmsg.c index 30d7f24dd..b3b2aedcd 100644 --- a/test/testmsg.c +++ b/test/testmsg.c @@ -71,8 +71,8 @@ static void msg1_execute(void) { /* * Testing the whole messages loop. */ - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() + 1, - thread, chThdSelf()); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1, + thread, chThdGetSelfX()); tp = chMsgWait(); msg = chMsgGet(tp); chMsgRelease(tp, msg); diff --git a/test/testmtx.c b/test/testmtx.c index c775cb51b..cd10fa986 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -96,7 +96,7 @@ static msg_t thread1(void *p) { static void mtx1_execute(void) { - tprio_t prio = chThdGetPriority(); /* Because priority inheritance.*/ + tprio_t prio = chThdGetPriorityX(); /* Because priority inheritance.*/ chMtxLock(&m1); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D"); @@ -105,7 +105,7 @@ static void mtx1_execute(void) { threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); chMtxUnlock(); test_wait_threads(); - test_assert(1, prio == chThdGetPriority(), "wrong priority level"); + test_assert(1, prio == chThdGetPriorityX(), "wrong priority level"); test_assert_sequence(2, "ABCDE"); } @@ -192,9 +192,9 @@ static void mtx2_execute(void) { test_wait_tick(); time = chVTGetSystemTime(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2H, 0); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2M, 0); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2L, 0); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2H, 0); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2M, 0); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2L, 0); test_wait_threads(); test_assert_sequence(1, "ABC"); test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY); @@ -310,11 +310,11 @@ static void mtx3_execute(void) { test_wait_tick(); time = chVTGetSystemTime(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread3LL, 0); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread3L, 0); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread3M, 0); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread3H, 0); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread3HH, 0); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0); test_wait_threads(); test_assert_sequence(1, "ABCDE"); test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY); @@ -365,46 +365,46 @@ static msg_t thread4b(void *p) { static void mtx4_execute(void) { tprio_t p, p1, p2; - p = chThdGetPriority(); + p = chThdGetPriorityX(); p1 = p + 1; p2 = p + 2; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A"); chMtxLock(&m2); - test_assert(1, chThdGetPriority() == p, "wrong priority level"); + test_assert(1, chThdGetPriorityX() == p, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(2, chThdGetPriority() == p1, "wrong priority level"); + test_assert(2, chThdGetPriorityX() == p1, "wrong priority level"); chMtxLock(&m1); - test_assert(3, chThdGetPriority() == p1, "wrong priority level"); + test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(4, chThdGetPriority() == p2, "wrong priority level"); + test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); chMtxUnlock(); - test_assert(5, chThdGetPriority() == p1, "wrong priority level"); + test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(6, chThdGetPriority() == p1, "wrong priority level"); + test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); chMtxUnlockAll(); - test_assert(7, chThdGetPriority() == p, "wrong priority level"); + test_assert(7, chThdGetPriorityX() == p, "wrong priority level"); test_wait_threads(); /* Test repeated in order to cover chMtxUnlockS().*/ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C"); chMtxLock(&m2); - test_assert(8, chThdGetPriority() == p, "wrong priority level"); + test_assert(8, chThdGetPriorityX() == p, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(9, chThdGetPriority() == p1, "wrong priority level"); + test_assert(9, chThdGetPriorityX() == p1, "wrong priority level"); chMtxLock(&m1); - test_assert(10, chThdGetPriority() == p1, "wrong priority level"); + test_assert(10, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(11, chThdGetPriority() == p2, "wrong priority level"); + test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); chSysLock(); chMtxUnlockS(); chSysUnlock(); - test_assert(12, chThdGetPriority() == p1, "wrong priority level"); + test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); - test_assert(13, chThdGetPriority() == p1, "wrong priority level"); + test_assert(13, chThdGetPriorityX() == p1, "wrong priority level"); chMtxUnlockAll(); - test_assert(14, chThdGetPriority() == p, "wrong priority level"); + test_assert(14, chThdGetPriorityX() == p, "wrong priority level"); test_wait_threads(); } @@ -434,7 +434,7 @@ static void mtx5_execute(void) { bool_t b; tprio_t prio; - prio = chThdGetPriority(); + prio = chThdGetPriorityX(); b = chMtxTryLock(&m1); test_assert(1, b, "already locked"); @@ -448,7 +448,7 @@ static void mtx5_execute(void) { test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); test_assert(4, m1.m_owner == NULL, "still owned"); - test_assert(5, chThdGetPriority() == prio, "wrong priority level"); + test_assert(5, chThdGetPriorityX() == prio, "wrong priority level"); chMtxLock(&m1); chMtxUnlockAll(); @@ -492,7 +492,7 @@ static msg_t thread10(void *p) { static void mtx6_execute(void) { - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); @@ -535,7 +535,7 @@ static void mtx7_setup(void) { static void mtx7_execute(void) { - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); @@ -594,7 +594,7 @@ static msg_t thread12(void *p) { static void mtx8_execute(void) { - tprio_t prio = chThdGetPriority(); + tprio_t prio = chThdGetPriorityX(); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A"); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B"); diff --git a/test/testqueues.c b/test/testqueues.c index 6ef057f3a..0d1bcc872 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -138,7 +138,7 @@ static void queues1_execute(void) { chIQResetI(&iq); chSysUnlock(); test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty"); test_wait_threads(); @@ -203,7 +203,7 @@ static void queues2_execute(void) { n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert_lock(7, chOQIsFullI(&oq), "not full"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread2, NULL); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty"); test_wait_threads(); diff --git a/test/testsem.c b/test/testsem.c index 0810300ea..0d74f3613 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -83,11 +83,11 @@ static msg_t thread1(void *p) { static void sem1_execute(void) { - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+1, thread1, "B"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread1, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+4, thread1, "D"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+2, thread1, "E"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E"); chSemSignal(&sem1); chSemSignal(&sem1); chSemSignal(&sem1); @@ -99,7 +99,7 @@ static void sem1_execute(void) { #else test_assert_sequence(1, "ABCDE"); #endif - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); chSysLock(); chSemAddCounterI(&sem1, 2); chSysUnlock(); @@ -157,7 +157,7 @@ static void sem2_execute(void) { /* * Testing not timeout condition. */ - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1, + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread2, 0); msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_wait_threads(); @@ -215,7 +215,7 @@ static msg_t thread3(void *p) { static void sem3_execute(void) { - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0); chSemSignalWait(&sem1, &sem1); test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(2, sem1.s_cnt == 0, "counter not zero"); @@ -256,7 +256,7 @@ static void sem4_execute(void) { /* Starts a signaler thread at a lower priority.*/ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, - chThdGetPriority()-1, thread4, &bsem); + chThdGetPriorityX()-1, thread4, &bsem); /* Waits to be signaled.*/ chBSemWait(&bsem); diff --git a/test/testthd.c b/test/testthd.c index af71a2041..34de252a8 100644 --- a/test/testthd.c +++ b/test/testthd.c @@ -65,11 +65,11 @@ static msg_t thread(void *p) { static void thd1_execute(void) { - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); test_wait_threads(); test_assert_sequence(1, "ABCDE"); } @@ -93,13 +93,13 @@ ROMCONST struct testcase testthd1 = { static void thd2_execute(void) { - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); /* Done this way for coverage of chThdCreateI() and chThdResume().*/ chSysLock(); - threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C"); + threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); chSysUnlock(); chThdResume(threads[2]); test_wait_threads(); @@ -126,47 +126,47 @@ ROMCONST struct testcase testthd2 = { static void thd3_execute(void) { tprio_t prio, p1; - prio = chThdGetPriority(); + prio = chThdGetPriorityX(); p1 = chThdSetPriority(prio + 1); test_assert(1, p1 == prio, "unexpected returned priority level"); - test_assert(2, chThdGetPriority() == prio + 1, + test_assert(2, chThdGetPriorityX() == prio + 1, "unexpected priority level"); p1 = chThdSetPriority(p1); test_assert(3, p1 == prio + 1, "unexpected returned priority level"); - test_assert(4, chThdGetPriority() == prio, + test_assert(4, chThdGetPriorityX() == prio, "unexpected priority level"); #if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) /* Simulates a priority boost situation (p_prio > p_realprio).*/ chSysLock(); - chThdSelf()->p_prio += 2; + chThdGetSelfX()->p_prio += 2; chSysUnlock(); - test_assert(5, chThdGetPriority() == prio + 2, + test_assert(5, chThdGetPriorityX() == prio + 2, "unexpected priority level"); /* Tries to raise but below the boost level. */ p1 = chThdSetPriority(prio + 1); test_assert(6, p1 == prio, "unexpected returned priority level"); - test_assert(7, chThdSelf()->p_prio == prio + 2, + test_assert(7, chThdGetSelfX()->p_prio == prio + 2, "unexpected priority level"); - test_assert(8, chThdSelf()->p_realprio == prio + 1, + test_assert(8, chThdGetSelfX()->p_realprio == prio + 1, "unexpected returned real priority level"); /* Tries to raise above the boost level. */ p1 = chThdSetPriority(prio + 3); test_assert(9, p1 == prio + 1, "unexpected returned priority level"); - test_assert(10, chThdSelf()->p_prio == prio + 3, + test_assert(10, chThdGetSelfX()->p_prio == prio + 3, "unexpected priority level"); - test_assert(11, chThdSelf()->p_realprio == prio + 3, + test_assert(11, chThdGetSelfX()->p_realprio == prio + 3, "unexpected real priority level"); chSysLock(); - chThdSelf()->p_prio = prio; - chThdSelf()->p_realprio = prio; + chThdGetSelfX()->p_prio = prio; + chThdGetSelfX()->p_realprio = prio; chSysUnlock(); #endif } -- cgit v1.2.3 From 4f49b546b101841d523df17806bea67b269a2a85 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 17 Aug 2013 11:04:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6167 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testthd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testthd.c b/test/testthd.c index 34de252a8..522e54b9b 100644 --- a/test/testthd.c +++ b/test/testthd.c @@ -97,11 +97,11 @@ static void thd2_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); - /* Done this way for coverage of chThdCreateI() and chThdResume().*/ + /* Done this way for coverage of chThdCreateI() and chThdStart().*/ chSysLock(); threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); chSysUnlock(); - chThdResume(threads[2]); + chThdStart(threads[2]); test_wait_threads(); test_assert_sequence(1, "ABCDE"); } -- cgit v1.2.3 From 155ef8ed75b12442fde1d80e4ca880d0e7f7c1f1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 17 Aug 2013 11:52:50 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6169 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 12 ++++++------ test/testmbox.c | 46 +++++++++++++++++++++++----------------------- test/testsem.c | 6 +++--- 3 files changed, 32 insertions(+), 32 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index 5149323a6..fe43c6aff 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -209,7 +209,7 @@ msg_t thread4(void *p) { do { chSchGoSleepS(CH_STATE_SUSPENDED); msg = self->p_u.rdymsg; - } while (msg == RDY_OK); + } while (msg == MSG_OK); chSysUnlock(); return 0; } @@ -225,10 +225,10 @@ static void bmk4_execute(void) { test_start_timer(1000); do { chSysLock(); - chSchWakeupS(tp, RDY_OK); - chSchWakeupS(tp, RDY_OK); - chSchWakeupS(tp, RDY_OK); - chSchWakeupS(tp, RDY_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); chSysUnlock(); n += 4; #if defined(SIMULATOR) @@ -236,7 +236,7 @@ static void bmk4_execute(void) { #endif } while (!test_timer_done); chSysLock(); - chSchWakeupS(tp, RDY_TIMEOUT); + chSchWakeupS(tp, MSG_TIMEOUT); chSysUnlock(); test_wait_threads(); diff --git a/test/testmbox.c b/test/testmbox.c index 1ca34dadc..a9f57e961 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -87,26 +87,26 @@ static void mbox1_execute(void) { */ for (i = 0; i < MB_SIZE - 1; i++) { msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); - test_assert(2, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(2, msg1 == MSG_OK, "wrong wake-up message"); } msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE); - test_assert(3, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(3, msg1 == MSG_OK, "wrong wake-up message"); /* * Testing post timeout. */ msg1 = chMBPost(&mb1, 'X', 1); - test_assert(4, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message"); chSysLock(); msg1 = chMBPostI(&mb1, 'X'); chSysUnlock(); - test_assert(5, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message"); msg1 = chMBPostAhead(&mb1, 'X', 1); - test_assert(6, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message"); chSysLock(); msg1 = chMBPostAheadI(&mb1, 'X'); chSysUnlock(); - test_assert(7, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message"); /* * Testing final conditions. @@ -120,7 +120,7 @@ static void mbox1_execute(void) { */ for (i = 0; i < MB_SIZE; i++) { msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); - test_assert(11, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(11, msg1 == MSG_OK, "wrong wake-up message"); test_emit_token(msg2); } test_assert_sequence(12, "ABCDE"); @@ -129,9 +129,9 @@ static void mbox1_execute(void) { * Testing buffer circularity. */ msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); - test_assert(13, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(13, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); - test_assert(14, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(14, msg1 == MSG_OK, "wrong wake-up message"); test_assert(15, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); test_assert(16, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); @@ -139,11 +139,11 @@ static void mbox1_execute(void) { * Testing fetch timeout. */ msg1 = chMBFetch(&mb1, &msg2, 1); - test_assert(17, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message"); chSysLock(); msg1 = chMBFetchI(&mb1, &msg2); chSysUnlock(); - test_assert(18, msg1 == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message"); /* * Testing final conditions. @@ -157,22 +157,22 @@ static void mbox1_execute(void) { */ chSysLock(); msg1 = chMBPostI(&mb1, 'A'); - test_assert(22, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(22, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostI(&mb1, 'B'); - test_assert(23, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(23, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostI(&mb1, 'C'); - test_assert(24, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(24, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostI(&mb1, 'D'); - test_assert(25, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(25, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostI(&mb1, 'E'); chSysUnlock(); - test_assert(26, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(26, msg1 == MSG_OK, "wrong wake-up message"); test_assert(27, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); for (i = 0; i < MB_SIZE; i++) { chSysLock(); msg1 = chMBFetchI(&mb1, &msg2); chSysUnlock(); - test_assert(28, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(28, msg1 == MSG_OK, "wrong wake-up message"); test_emit_token(msg2); } test_assert_sequence(29, "ABCDE"); @@ -182,22 +182,22 @@ static void mbox1_execute(void) { chSysLock(); msg1 = chMBPostAheadI(&mb1, 'E'); - test_assert(33, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(33, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostAheadI(&mb1, 'D'); - test_assert(34, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(34, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostAheadI(&mb1, 'C'); - test_assert(35, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(35, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostAheadI(&mb1, 'B'); - test_assert(36, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(36, msg1 == MSG_OK, "wrong wake-up message"); msg1 = chMBPostAheadI(&mb1, 'A'); chSysUnlock(); - test_assert(37, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(37, msg1 == MSG_OK, "wrong wake-up message"); test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); for (i = 0; i < MB_SIZE; i++) { chSysLock(); msg1 = chMBFetchI(&mb1, &msg2); chSysUnlock(); - test_assert(39, msg1 == RDY_OK, "wrong wake-up message"); + test_assert(39, msg1 == MSG_OK, "wrong wake-up message"); test_emit_token(msg2); } test_assert_sequence(40, "ABCDE"); diff --git a/test/testsem.c b/test/testsem.c index 0d74f3613..604a6954d 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -150,7 +150,7 @@ static void sem2_execute(void) { * Testing special case TIME_IMMEDIATE. */ msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); - test_assert(1, msg == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(1, msg == MSG_TIMEOUT, "wrong wake-up message"); test_assert(2, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(3, sem1.s_cnt == 0, "counter not zero"); @@ -161,7 +161,7 @@ static void sem2_execute(void) { thread2, 0); msg = chSemWaitTimeout(&sem1, MS2ST(500)); test_wait_threads(); - test_assert(4, msg == RDY_OK, "wrong wake-up message"); + test_assert(4, msg == MSG_OK, "wrong wake-up message"); test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(6, sem1.s_cnt == 0, "counter not zero"); @@ -173,7 +173,7 @@ static void sem2_execute(void) { for (i = 0; i < 5; i++) { test_emit_token('A' + i); msg = chSemWaitTimeout(&sem1, MS2ST(500)); - test_assert(7, msg == RDY_TIMEOUT, "wrong wake-up message"); + test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message"); test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty"); test_assert(9, sem1.s_cnt == 0, "counter not zero"); } -- cgit v1.2.3 From 56b4e6432b20f5e7b46a7699e7e47aff3b042e16 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 2 Sep 2013 12:10:10 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6248 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testbmk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/testbmk.c b/test/testbmk.c index fe43c6aff..551a001a1 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -638,8 +638,8 @@ static void bmk13_execute(void) { test_print("--- System: "); test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + CH_PORT_IDLE_THREAD_STACK_SIZE + - (sizeof(thread_t) + sizeof(struct intctx) + - sizeof(struct extctx) + + (sizeof(thread_t) + sizeof(struct port_intctx) + + sizeof(struct port_extctx) + CH_PORT_INT_REQUIRED_STACK) * 2); test_println(" bytes"); test_print("--- Thread: "); -- cgit v1.2.3 From 9d0c6fb8bf7bf63c137d7c19fdefc7760d2f133a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 3 Sep 2013 08:48:20 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6250 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 12 ++++++------ test/test.h | 10 +++++----- test/testdyn.c | 4 ++-- test/testmtx.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index 77759f5b8..58cad43c3 100644 --- a/test/test.c +++ b/test/test.c @@ -56,7 +56,7 @@ static ROMCONST struct testcase * ROMCONST *patterns[] = { NULL }; -static bool_t local_fail, global_fail; +static bool local_fail, global_fail; static unsigned failpoint; static char tokens_buffer[MAX_TOKENS]; static char *tokp; @@ -154,7 +154,7 @@ void test_emit_token(char token) { /* * Assertions. */ -bool_t _test_fail(unsigned point) { +bool _test_fail(unsigned point) { local_fail = TRUE; global_fail = TRUE; @@ -162,14 +162,14 @@ bool_t _test_fail(unsigned point) { return TRUE; } -bool_t _test_assert(unsigned point, bool_t condition) { +bool _test_assert(unsigned point, bool condition) { if (!condition) return _test_fail(point); return FALSE; } -bool_t _test_assert_sequence(unsigned point, char *expected) { +bool _test_assert_sequence(unsigned point, char *expected) { char *cp = tokens_buffer; while (cp < tokp) { if (*cp++ != *expected++) @@ -181,7 +181,7 @@ bool_t _test_assert_sequence(unsigned point, char *expected) { return FALSE; } -bool_t _test_assert_time_window(unsigned point, systime_t start, systime_t end) { +bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) { return _test_assert(point, chVTIsSystemTimeWithin(start, end)); } @@ -255,7 +255,7 @@ systime_t test_wait_tick(void) { /** * @brief Set to @p TRUE when the test timer reaches its deadline. */ -bool_t test_timer_done; +bool test_timer_done; static virtual_timer_t vt; static void tmr(void *p) { diff --git a/test/test.h b/test/test.h index 136631d8f..1088d0517 100644 --- a/test/test.h +++ b/test/test.h @@ -84,10 +84,10 @@ extern "C" { void test_print(const char *msgp); void test_println(const char *msgp); void test_emit_token(char token); - 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); + bool _test_fail(unsigned point); + bool _test_assert(unsigned point, bool condition); + bool _test_assert_sequence(unsigned point, char *expected); + bool _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); @@ -165,7 +165,7 @@ extern "C" { extern thread_t *threads[MAX_THREADS]; extern union test_buffers test; extern void * ROMCONST wa[]; -extern bool_t test_timer_done; +extern bool test_timer_done; #endif #endif /* _TEST_H_ */ diff --git a/test/testdyn.c b/test/testdyn.c index 3eb3304d5..cd73e73ce 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -188,9 +188,9 @@ ROMCONST struct testcase testdyn2 = { * coverage. */ -static bool_t regfind(thread_t *tp) { +static bool regfind(thread_t *tp) { thread_t *ftp; - bool_t found = FALSE; + bool found = false; ftp = chRegFirstThread(); do { diff --git a/test/testmtx.c b/test/testmtx.c index cd10fa986..b40242d3d 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -431,7 +431,7 @@ static void mtx5_setup(void) { } static void mtx5_execute(void) { - bool_t b; + bool b; tprio_t prio; prio = chThdGetPriorityX(); -- cgit v1.2.3 From 3368f57424db121a96207e9ee6f5e9f746d34ca6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 3 Sep 2013 09:51:32 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/test.c | 14 +++++++------- test/test.h | 12 ++++++------ test/testbmk.c | 4 ++-- test/testdyn.c | 11 +++++++---- test/testpools.c | 4 ++-- 5 files changed, 24 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index 58cad43c3..0750a0d80 100644 --- a/test/test.c +++ b/test/test.c @@ -322,19 +322,19 @@ msg_t TestThread(void *p) { test_println(CH_KERNEL_VERSION); test_print("*** Compiled: "); test_println(__DATE__ " - " __TIME__); -#ifdef CH_COMPILER_NAME +#ifdef PORT_COMPILER_NAME test_print("*** Compiler: "); - test_println(CH_COMPILER_NAME); + test_println(PORT_COMPILER_NAME); #endif test_print("*** Architecture: "); - test_println(CH_ARCHITECTURE_NAME); -#ifdef CH_CORE_VARIANT_NAME + test_println(PORT_ARCHITECTURE_NAME); +#ifdef PORT_CORE_VARIANT_NAME test_print("*** Core Variant: "); - test_println(CH_CORE_VARIANT_NAME); + test_println(PORT_CORE_VARIANT_NAME); #endif -#ifdef CH_PORT_INFO +#ifdef PORT_INFO test_print("*** Port Info: "); - test_println(CH_PORT_INFO); + test_println(PORT_INFO); #endif #ifdef PLATFORM_NAME test_print("*** Platform: "); diff --git a/test/test.h b/test/test.h index 1088d0517..1b40a48e0 100644 --- a/test/test.h +++ b/test/test.h @@ -51,7 +51,7 @@ #else #define THREADS_STACK_SIZE 128 #endif -#define WA_SIZE THD_WA_SIZE(THREADS_STACK_SIZE) +#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) /** * @brief Structure representing a test case. @@ -66,11 +66,11 @@ struct testcase { #ifndef __DOXYGEN__ union test_buffers { struct { - WORKING_AREA(T0, THREADS_STACK_SIZE); - WORKING_AREA(T1, THREADS_STACK_SIZE); - WORKING_AREA(T2, THREADS_STACK_SIZE); - WORKING_AREA(T3, THREADS_STACK_SIZE); - WORKING_AREA(T4, THREADS_STACK_SIZE); + THD_WORKING_AREA(T0, THREADS_STACK_SIZE); + THD_WORKING_AREA(T1, THREADS_STACK_SIZE); + THD_WORKING_AREA(T2, THREADS_STACK_SIZE); + THD_WORKING_AREA(T3, THREADS_STACK_SIZE); + THD_WORKING_AREA(T4, THREADS_STACK_SIZE); } wa; uint8_t buffer[WA_SIZE * 5]; }; diff --git a/test/testbmk.c b/test/testbmk.c index 551a001a1..2a3b7c1b5 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -637,10 +637,10 @@ static void bmk13_execute(void) { test_print("--- System: "); test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + - CH_PORT_IDLE_THREAD_STACK_SIZE + + PORT_IDLE_THREAD_STACK_SIZE + (sizeof(thread_t) + sizeof(struct port_intctx) + sizeof(struct port_extctx) + - CH_PORT_INT_REQUIRED_STACK) * 2); + PORT_INT_REQUIRED_STACK) * 2); test_println(" bytes"); test_print("--- Thread: "); test_printn(sizeof(thread_t)); diff --git a/test/testdyn.c b/test/testdyn.c index cd73e73ce..bf9f127a0 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -87,14 +87,17 @@ static void dyn1_execute(void) { (void)chHeapStatus(&heap1, &sz); /* Starting threads from the heap. */ - threads[0] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), + threads[0] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), prio-1, thread, "A"); - threads[1] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), + threads[1] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), prio-2, thread, "B"); /* Allocating the whole heap in order to make the thread creation fail.*/ (void)chHeapStatus(&heap1, &n); p1 = chHeapAlloc(&heap1, n); - threads[2] = chThdCreateFromHeap(&heap1, THD_WA_SIZE(THREADS_STACK_SIZE), + threads[2] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), prio-3, thread, "C"); chHeapFree(p1); @@ -135,7 +138,7 @@ ROMCONST struct testcase testdyn1 = { static void dyn2_setup(void) { - chPoolObjectInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); } static void dyn2_execute(void) { diff --git a/test/testpools.c b/test/testpools.c index 18063e111..3037846ea 100644 --- a/test/testpools.c +++ b/test/testpools.c @@ -46,7 +46,7 @@ #if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) -static MEMORYPOOL_DECL(mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); +static MEMORYPOOL_DECL(mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); /** * @page test_pools_001 Allocation and enqueuing test @@ -65,7 +65,7 @@ static void *null_provider(size_t size) { static void pools1_setup(void) { - chPoolObjectInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE), NULL); + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); } static void pools1_execute(void) { -- cgit v1.2.3 From 5a70ffdbf38323a58d2e1fa6289ad7caea1fe12a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 12 Nov 2013 11:05:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6464 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testmtx.c | 1 + test/testsem.c | 1 + 2 files changed, 2 insertions(+) (limited to 'test') diff --git a/test/testmtx.c b/test/testmtx.c index b40242d3d..c9ba9e093 100644 --- a/test/testmtx.c +++ b/test/testmtx.c @@ -399,6 +399,7 @@ static void mtx4_execute(void) { test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); chSysLock(); chMtxUnlockS(); + chSchRescheduleS(); chSysUnlock(); test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); diff --git a/test/testsem.c b/test/testsem.c index 604a6954d..cb7f13bc2 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -102,6 +102,7 @@ static void sem1_execute(void) { threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); chSysLock(); chSemAddCounterI(&sem1, 2); + chSchRescheduleS(); chSysUnlock(); test_wait_threads(); test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); -- cgit v1.2.3 From 743291a761e8ede91007bc6a8e4ecaefa13d6e9e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 10:34:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6688 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/chtest.c | 288 +++++++++++++++++++++++++++++++++ test/lib/chtest.h | 186 +++++++++++++++++++++ test/lib/templates/test_root.c | 44 +++++ test/lib/templates/test_root.h | 49 ++++++ test/lib/templates/test_sequence_XXX.c | 97 +++++++++++ test/lib/templates/test_sequence_XXX.h | 22 +++ 6 files changed, 686 insertions(+) create mode 100644 test/lib/chtest.c create mode 100644 test/lib/chtest.h create mode 100644 test/lib/templates/test_root.c create mode 100644 test/lib/templates/test_root.h create mode 100644 test/lib/templates/test_sequence_XXX.c create mode 100644 test/lib/templates/test_sequence_XXX.h (limited to 'test') diff --git a/test/lib/chtest.c b/test/lib/chtest.c new file mode 100644 index 000000000..9d6cb8d02 --- /dev/null +++ b/test/lib/chtest.c @@ -0,0 +1,288 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file ch_test.c + * @brief Unit Tests Engine module code. + * + * @addtogroup CH_TEST + * @{ + */ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/*===========================================================================*/ +/* Module local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Test step being executed. + */ +unsigned test_step; + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +static bool test_local_fail; +static bool test_global_fail; +static const char *test_failure_message; +static char test_tokens_buffer[TEST_MAX_TOKENS]; +static char *test_tokp; +static BaseSequentialStream *test_chp; + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + +static void clear_tokens(void) { + + test_tokp = test_tokens_buffer; +} + +static void print_tokens(void) { + char *cp = test_tokens_buffer; + + while (cp < test_tokp) + streamPut(test_chp, *cp++); +} + +static void execute_test(const testcase_t *tcp) { + + /* Initialization */ + clear_tokens(); + test_local_fail = FALSE; + + if (tcp->setup != NULL) + tcp->setup(); + tcp->execute(); + if (tcp->teardown != NULL) + tcp->teardown(); +} + +static void print_line(void) { + unsigned i; + + for (i = 0; i < 76; i++) + streamPut(test_chp, '-'); + streamWrite(test_chp, (const uint8_t *)"\r\n", 2); +} + +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + +bool _test_fail(const char *msg) { + + test_local_fail = TRUE; + test_global_fail = TRUE; + test_failure_message = msg; + return TRUE; +} + +bool _test_assert(bool condition, const char *msg) { + + if (!condition) + return _test_fail(msg); + return FALSE; +} + +bool _test_assert_sequence(char *expected, const char *msg) { + char *cp = test_tokens_buffer; + + while (cp < test_tokp) { + if (*cp++ != *expected++) + return _test_fail(msg); + } + + if (*expected) + return _test_fail(msg); + + clear_tokens(); + + return FALSE; +} + +bool _test_assert_time_window(systime_t start, + systime_t end, + const char *msg) { + + return _test_assert(osalVTIsSystemTimeWithin(start, end), msg); +} + +/** + * @brief Prints a decimal unsigned number. + * + * @param[in] n the number to be printed + * + * @api + */ +void test_printn(uint32_t n) { + char buf[16], *p; + + if (!n) + streamPut(test_chp, '0'); + else { + p = buf; + while (n) + *p++ = (n % 10) + '0', n /= 10; + while (p > buf) + streamPut(test_chp, *--p); + } +} + +/** + * @brief Prints a line without final end-of-line. + * + * @param[in] msgp the message + * + * @api + */ +void test_print(const char *msgp) { + + while (*msgp) + streamPut(test_chp, *msgp++); +} + +/** + * @brief Prints a line. + * + * @param[in] msgp the message + * + * @api + */ +void test_println(const char *msgp) { + + test_print(msgp); + streamWrite(test_chp, (const uint8_t *)"\r\n", 2); +} + +/** + * @brief Emits a token into the tokens buffer. + * + * @param[in] token the token as a char + * + * @api + */ +void test_emit_token(char token) { + + osalSysLock(); + if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) + *test_tokp++ = token; + osalSysUnlock(); +} + +/** + * @brief Emits a token into the tokens buffer from a critical zone. + * + * @param[in] token the token as a char + * + * @iclass + */ +void test_emit_token_i(char token) { + + if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) + *test_tokp++ = token; +} + +/** + * @brief Test execution thread function. + * + * @param[in] stream pointer to a @p BaseSequentialStream object for test + * output + * @return A failure boolean value casted to @p msg_t. + * @retval FALSE if no errors occurred. + * @retval TRUE if one or more tests failed. + * + * @api + */ +msg_t test_execute(BaseSequentialStream *stream) { + int i, j; + + test_chp = stream; + test_println(""); +#if defined(TEST_SUITE_NAME) + test_println("*** " TEST_SUITE_NAME); +#else + test_println("*** ChibiOS test suite"); +#endif + test_println("***"); + test_print("*** Compiled: "); + test_println(__DATE__ " - " __TIME__); +#ifdef PLATFORM_NAME + test_print("*** Platform: "); + test_println(PLATFORM_NAME); +#endif +#ifdef BOARD_NAME + test_print("*** Test Board: "); + test_println(BOARD_NAME); +#endif + test_println(""); + + test_global_fail = FALSE; + i = 0; + while (test_suite[i]) { + j = 0; + while (test_suite[i][j]) { + print_line(); + test_print("--- Test Case "); + test_printn(i + 1); + test_print("."); + test_printn(j + 1); + test_print(" ("); + test_print(test_suite[i][j]->name); + test_println(")"); +#if TEST_DELAY_BETWEEN_TESTS > 0 + osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS); +#endif + execute_test(test_suite[i][j]); + if (test_local_fail) { + test_print("--- Result: FAILURE (#"); + test_printn(test_step); + test_print(" ["); + print_tokens(); + test_print("] \""); + test_print(test_failure_message); + test_println("\")"); + } + else + test_println("--- Result: SUCCESS"); + j++; + } + i++; + } + print_line(); + test_println(""); + test_print("Final result: "); + if (test_global_fail) + test_println("FAILURE"); + else + test_println("SUCCESS"); + + return (msg_t)test_global_fail; +} + +/** @} */ diff --git a/test/lib/chtest.h b/test/lib/chtest.h new file mode 100644 index 000000000..c8e03490c --- /dev/null +++ b/test/lib/chtest.h @@ -0,0 +1,186 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file ch_test.h + * @brief Unit Tests Engine Module macros and structures. + * + * @addtogroup CH_TEST + * @{ + */ + +#ifndef _CH_TEST_H_ +#define _CH_TEST_H_ + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @brief Maximum number of entries in the tokens buffer. + */ +#if !defined(TEST_MAX_TOKENS) || defined(__DOXYGEN__) +#define TEST_MAX_TOKENS 16 +#endif + +/** + * @brief Delay inserted between test cases. + */ +#if !defined(TEST_DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) +#define TEST_DELAY_BETWEEN_TESTS 200 +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Structure representing a test case. + */ +typedef struct { + const char *name; /**< @brief Test case name. */ + void (*setup)(void); /**< @brief Test case preparation function. */ + void (*teardown)(void); /**< @brief Test case clean up function. */ + void (*execute)(void); /**< @brief Test case execution function. */ +} testcase_t; + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/** + * @brief Sets the step identifier. + * + * @param[in] step the step number + */ +#define test_set_step(step) test_step = (step) + +/** + * @brief Test failure enforcement. + * @note This function can only be called from test_case execute context. + * + * @param[in] msg failure message as string + * + * @api + */ +#define test_fail(msg) { \ + _test_fail(msg); \ + return; \ +} + +/** + * @brief Test assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert(condition, msg) { \ + if (_test_assert(condition, msg)) \ + return; \ +} + +/** + * @brief Test assertion with lock. + * @note This function can only be called from test_case execute context. + * + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_lock(condition, msg) { \ + osalSysLock(); \ + if (_test_assert(condition, msg)) { \ + osalSysUnlock(); \ + return; \ + } \ + osalSysUnlock(); \ +} + +/** + * @brief Test sequence assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] expected string to be matched with the tokens buffer + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_sequence(expected, msg) { \ + if (_test_assert_sequence(expected, msg)) \ + return; \ +} + +/** + * @brief Test time window assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] start initial time in the window (included) + * @param[in] end final time in the window (not included) + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_time_window(start, end, msg) { \ + if (_test_assert_time_window(start, end, msg)) \ + return; \ +} + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) +extern unsigned test_step; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + bool _test_fail(const char *message); + bool _test_assert(bool condition, const char *msg); + bool _test_assert_sequence(char *expected, const char *msg); + bool _test_assert_time_window(systime_t start, + systime_t end, + const char *msg); + void test_printn(uint32_t n); + void test_print(const char *msgp); + void test_println(const char *msgp); + void test_emit_token(char token); + void test_emit_token_i(char token); + msg_t test_execute(BaseSequentialStream *stream); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +#endif /* _CH_TEST_H_ */ + +/** @} */ diff --git a/test/lib/templates/test_root.c b/test/lib/templates/test_root.c new file mode 100644 index 000000000..8fb2ec9b9 --- /dev/null +++ b/test/lib/templates/test_root.c @@ -0,0 +1,44 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.c + * @brief Test Suite root structures code. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Array of all the test sequences. + */ +const testcase_t * const *test_suite[] = { + NULL +}; + +/*===========================================================================*/ +/* Shared code. */ +/*===========================================================================*/ + +/** @} */ diff --git a/test/lib/templates/test_root.h b/test/lib/templates/test_root.h new file mode 100644 index 000000000..3d26ecd50 --- /dev/null +++ b/test/lib/templates/test_root.h @@ -0,0 +1,49 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.h + * @brief Test Suite root structures header. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#ifndef _TEST_ROOT_H_ +#define _TEST_ROOT_H_ + +#include "test_000.h" + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern const testcase_t * const *test_suite[]; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Shared definitions. */ +/*===========================================================================*/ + +#endif /* _TEST_ROOT_H_ */ + +/** @} */ diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c new file mode 100644 index 000000000..3fb1df8e0 --- /dev/null +++ b/test/lib/templates/test_sequence_XXX.c @@ -0,0 +1,97 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_XXX Sequence brief description + * + * File: @ref test_sequence_XXX.c + * + *

Description

+ * Sequence detailed description. + * + *

Test Cases

+ * - @subpage test_XXX_000 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +#if TEST_XXX_000_CONDITION || defined(__DOXYGEN__) +/** + * @page test_XXX_000 Brief description + * + *

Description

+ * Detailed description. + * + *

Conditions

+ * This test is only executed if the following preprocessor condition + * evaluates to true: + * - TEST_XXX_000_CONDITION + * . + * + *

Test Steps

+ * - Step description. + * . + */ + +static void test_XXX_000_setup(void) { + +} + +static void test_XXX_000}_teardown(void) { + +} + +static void test_XXX_000_execute(void) { + + /* Step description.*/ + test_set_step(1); + { + } +} + +static const testcase_t test_XXX_000 = { + "Brief description", + test_XXX_000_setup, + test_XXX_000_teardown, + test_XXX_000_execute +}; + #endif /* TEST_XXX_000_CONDITION */ + + /**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Sequence brief description. + */ +const testcase_t * const test_sequence_XXX[] = { +#if TEST_XXX_000_CONDITION || defined(__DOXYGEN__) + &test_XXX_000, +#endif + NULL +}; diff --git a/test/lib/templates/test_sequence_XXX.h b/test/lib/templates/test_sequence_XXX.h new file mode 100644 index 000000000..86578fdca --- /dev/null +++ b/test/lib/templates/test_sequence_XXX.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TEST_SEQUENCE_XXX_H_ +#define _TEST_SEQUENCE_XXX_H_ + +extern const testcase_t * const test_sequence_XXX[]; + +#endif /* _TEST_SEQUENCE_XXX_H_ */ -- cgit v1.2.3 From 7b3457b64feb6109153ca5d6bfe7fc87d09e9a3a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 10:35:43 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6689 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/test.mk | 7 ++++ test/rt/test_sequence_000.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ test/rt/test_sequence_000.h | 22 ++++++++++ 3 files changed, 126 insertions(+) create mode 100644 test/rt/test.mk create mode 100644 test/rt/test_sequence_000.c create mode 100644 test/rt/test_sequence_000.h (limited to 'test') diff --git a/test/rt/test.mk b/test/rt/test.mk new file mode 100644 index 000000000..92dda7d81 --- /dev/null +++ b/test/rt/test.mk @@ -0,0 +1,7 @@ +# List of all the ChibiOS/RT test files. +TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ + ${CHIBIOS}/test/rt/test_sequence_000.c + +# Required include directories +TESTINC = ${CHIBIOS}/test/lib \ + ${CHIBIOS}/test/rt diff --git a/test/rt/test_sequence_000.c b/test/rt/test_sequence_000.c new file mode 100644 index 000000000..efe81b6da --- /dev/null +++ b/test/rt/test_sequence_000.c @@ -0,0 +1,97 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_000 Sequence brief description + * + * File: @ref test_sequence_000.c + * + *

Description

+ * Sequence detailed description. + * + *

Test Cases

+ * - @subpage test_000_000 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +/** + * @page test_000_000 Brief description + * + *

Description

+ * Detailed description. + * + *

Conditions

+ * This test is only executed if the following preprocessor condition + * evaluates to true: + * - TEST_000_000_CONDITION + * . + * + *

Test Steps

+ * - Step description. + * . + */ + +static void test_000_000_setup(void) { + +} + +static void test_000_000}_teardown(void) { + +} + +static void test_000_000_execute(void) { + + /* Step description.*/ + test_set_step(1); + { + } +} + +static const testcase_t test_000_000 = { + "Brief description", + test_000_000_setup, + test_000_000_teardown, + test_000_000_execute +}; + #endif /* TEST_000_000_CONDITION */ + + /**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Sequence brief description. + */ +const testcase_t * const test_sequence_000[] = { +#if TEST_000_000_CONDITION || defined(__DOXYGEN__) + &test_000_000, +#endif + NULL +}; diff --git a/test/rt/test_sequence_000.h b/test/rt/test_sequence_000.h new file mode 100644 index 000000000..72aaaf374 --- /dev/null +++ b/test/rt/test_sequence_000.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TEST_SEQUENCE_000_H_ +#define _TEST_SEQUENCE_000_H_ + +extern const testcase_t * const test_sequence_000[]; + +#endif /* _TEST_SEQUENCE_000_H_ */ -- cgit v1.2.3 From c7abfb0b3c6820020f8b8a5de3721baf7e8fca0e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 10:40:17 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6690 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/ch_test.c | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test/lib/ch_test.h | 186 ++++++++++++++++++++++++++++++++++ test/lib/chtest.c | 288 ----------------------------------------------------- test/lib/chtest.h | 186 ---------------------------------- 4 files changed, 474 insertions(+), 474 deletions(-) create mode 100644 test/lib/ch_test.c create mode 100644 test/lib/ch_test.h delete mode 100644 test/lib/chtest.c delete mode 100644 test/lib/chtest.h (limited to 'test') diff --git a/test/lib/ch_test.c b/test/lib/ch_test.c new file mode 100644 index 000000000..9d6cb8d02 --- /dev/null +++ b/test/lib/ch_test.c @@ -0,0 +1,288 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file ch_test.c + * @brief Unit Tests Engine module code. + * + * @addtogroup CH_TEST + * @{ + */ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/*===========================================================================*/ +/* Module local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Test step being executed. + */ +unsigned test_step; + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +static bool test_local_fail; +static bool test_global_fail; +static const char *test_failure_message; +static char test_tokens_buffer[TEST_MAX_TOKENS]; +static char *test_tokp; +static BaseSequentialStream *test_chp; + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + +static void clear_tokens(void) { + + test_tokp = test_tokens_buffer; +} + +static void print_tokens(void) { + char *cp = test_tokens_buffer; + + while (cp < test_tokp) + streamPut(test_chp, *cp++); +} + +static void execute_test(const testcase_t *tcp) { + + /* Initialization */ + clear_tokens(); + test_local_fail = FALSE; + + if (tcp->setup != NULL) + tcp->setup(); + tcp->execute(); + if (tcp->teardown != NULL) + tcp->teardown(); +} + +static void print_line(void) { + unsigned i; + + for (i = 0; i < 76; i++) + streamPut(test_chp, '-'); + streamWrite(test_chp, (const uint8_t *)"\r\n", 2); +} + +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + +bool _test_fail(const char *msg) { + + test_local_fail = TRUE; + test_global_fail = TRUE; + test_failure_message = msg; + return TRUE; +} + +bool _test_assert(bool condition, const char *msg) { + + if (!condition) + return _test_fail(msg); + return FALSE; +} + +bool _test_assert_sequence(char *expected, const char *msg) { + char *cp = test_tokens_buffer; + + while (cp < test_tokp) { + if (*cp++ != *expected++) + return _test_fail(msg); + } + + if (*expected) + return _test_fail(msg); + + clear_tokens(); + + return FALSE; +} + +bool _test_assert_time_window(systime_t start, + systime_t end, + const char *msg) { + + return _test_assert(osalVTIsSystemTimeWithin(start, end), msg); +} + +/** + * @brief Prints a decimal unsigned number. + * + * @param[in] n the number to be printed + * + * @api + */ +void test_printn(uint32_t n) { + char buf[16], *p; + + if (!n) + streamPut(test_chp, '0'); + else { + p = buf; + while (n) + *p++ = (n % 10) + '0', n /= 10; + while (p > buf) + streamPut(test_chp, *--p); + } +} + +/** + * @brief Prints a line without final end-of-line. + * + * @param[in] msgp the message + * + * @api + */ +void test_print(const char *msgp) { + + while (*msgp) + streamPut(test_chp, *msgp++); +} + +/** + * @brief Prints a line. + * + * @param[in] msgp the message + * + * @api + */ +void test_println(const char *msgp) { + + test_print(msgp); + streamWrite(test_chp, (const uint8_t *)"\r\n", 2); +} + +/** + * @brief Emits a token into the tokens buffer. + * + * @param[in] token the token as a char + * + * @api + */ +void test_emit_token(char token) { + + osalSysLock(); + if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) + *test_tokp++ = token; + osalSysUnlock(); +} + +/** + * @brief Emits a token into the tokens buffer from a critical zone. + * + * @param[in] token the token as a char + * + * @iclass + */ +void test_emit_token_i(char token) { + + if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) + *test_tokp++ = token; +} + +/** + * @brief Test execution thread function. + * + * @param[in] stream pointer to a @p BaseSequentialStream object for test + * output + * @return A failure boolean value casted to @p msg_t. + * @retval FALSE if no errors occurred. + * @retval TRUE if one or more tests failed. + * + * @api + */ +msg_t test_execute(BaseSequentialStream *stream) { + int i, j; + + test_chp = stream; + test_println(""); +#if defined(TEST_SUITE_NAME) + test_println("*** " TEST_SUITE_NAME); +#else + test_println("*** ChibiOS test suite"); +#endif + test_println("***"); + test_print("*** Compiled: "); + test_println(__DATE__ " - " __TIME__); +#ifdef PLATFORM_NAME + test_print("*** Platform: "); + test_println(PLATFORM_NAME); +#endif +#ifdef BOARD_NAME + test_print("*** Test Board: "); + test_println(BOARD_NAME); +#endif + test_println(""); + + test_global_fail = FALSE; + i = 0; + while (test_suite[i]) { + j = 0; + while (test_suite[i][j]) { + print_line(); + test_print("--- Test Case "); + test_printn(i + 1); + test_print("."); + test_printn(j + 1); + test_print(" ("); + test_print(test_suite[i][j]->name); + test_println(")"); +#if TEST_DELAY_BETWEEN_TESTS > 0 + osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS); +#endif + execute_test(test_suite[i][j]); + if (test_local_fail) { + test_print("--- Result: FAILURE (#"); + test_printn(test_step); + test_print(" ["); + print_tokens(); + test_print("] \""); + test_print(test_failure_message); + test_println("\")"); + } + else + test_println("--- Result: SUCCESS"); + j++; + } + i++; + } + print_line(); + test_println(""); + test_print("Final result: "); + if (test_global_fail) + test_println("FAILURE"); + else + test_println("SUCCESS"); + + return (msg_t)test_global_fail; +} + +/** @} */ diff --git a/test/lib/ch_test.h b/test/lib/ch_test.h new file mode 100644 index 000000000..c8e03490c --- /dev/null +++ b/test/lib/ch_test.h @@ -0,0 +1,186 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file ch_test.h + * @brief Unit Tests Engine Module macros and structures. + * + * @addtogroup CH_TEST + * @{ + */ + +#ifndef _CH_TEST_H_ +#define _CH_TEST_H_ + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @brief Maximum number of entries in the tokens buffer. + */ +#if !defined(TEST_MAX_TOKENS) || defined(__DOXYGEN__) +#define TEST_MAX_TOKENS 16 +#endif + +/** + * @brief Delay inserted between test cases. + */ +#if !defined(TEST_DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) +#define TEST_DELAY_BETWEEN_TESTS 200 +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Structure representing a test case. + */ +typedef struct { + const char *name; /**< @brief Test case name. */ + void (*setup)(void); /**< @brief Test case preparation function. */ + void (*teardown)(void); /**< @brief Test case clean up function. */ + void (*execute)(void); /**< @brief Test case execution function. */ +} testcase_t; + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/** + * @brief Sets the step identifier. + * + * @param[in] step the step number + */ +#define test_set_step(step) test_step = (step) + +/** + * @brief Test failure enforcement. + * @note This function can only be called from test_case execute context. + * + * @param[in] msg failure message as string + * + * @api + */ +#define test_fail(msg) { \ + _test_fail(msg); \ + return; \ +} + +/** + * @brief Test assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert(condition, msg) { \ + if (_test_assert(condition, msg)) \ + return; \ +} + +/** + * @brief Test assertion with lock. + * @note This function can only be called from test_case execute context. + * + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_lock(condition, msg) { \ + osalSysLock(); \ + if (_test_assert(condition, msg)) { \ + osalSysUnlock(); \ + return; \ + } \ + osalSysUnlock(); \ +} + +/** + * @brief Test sequence assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] expected string to be matched with the tokens buffer + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_sequence(expected, msg) { \ + if (_test_assert_sequence(expected, msg)) \ + return; \ +} + +/** + * @brief Test time window assertion. + * @note This function can only be called from test_case execute context. + * + * @param[in] start initial time in the window (included) + * @param[in] end final time in the window (not included) + * @param[in] msg failure message as string + * + * @api + */ +#define test_assert_time_window(start, end, msg) { \ + if (_test_assert_time_window(start, end, msg)) \ + return; \ +} + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) +extern unsigned test_step; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + bool _test_fail(const char *message); + bool _test_assert(bool condition, const char *msg); + bool _test_assert_sequence(char *expected, const char *msg); + bool _test_assert_time_window(systime_t start, + systime_t end, + const char *msg); + void test_printn(uint32_t n); + void test_print(const char *msgp); + void test_println(const char *msgp); + void test_emit_token(char token); + void test_emit_token_i(char token); + msg_t test_execute(BaseSequentialStream *stream); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +#endif /* _CH_TEST_H_ */ + +/** @} */ diff --git a/test/lib/chtest.c b/test/lib/chtest.c deleted file mode 100644 index 9d6cb8d02..000000000 --- a/test/lib/chtest.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file ch_test.c - * @brief Unit Tests Engine module code. - * - * @addtogroup CH_TEST - * @{ - */ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/*===========================================================================*/ -/* Module local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module exported variables. */ -/*===========================================================================*/ - -/** - * @brief Test step being executed. - */ -unsigned test_step; - -/*===========================================================================*/ -/* Module local types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local variables. */ -/*===========================================================================*/ - -static bool test_local_fail; -static bool test_global_fail; -static const char *test_failure_message; -static char test_tokens_buffer[TEST_MAX_TOKENS]; -static char *test_tokp; -static BaseSequentialStream *test_chp; - -/*===========================================================================*/ -/* Module local functions. */ -/*===========================================================================*/ - -static void clear_tokens(void) { - - test_tokp = test_tokens_buffer; -} - -static void print_tokens(void) { - char *cp = test_tokens_buffer; - - while (cp < test_tokp) - streamPut(test_chp, *cp++); -} - -static void execute_test(const testcase_t *tcp) { - - /* Initialization */ - clear_tokens(); - test_local_fail = FALSE; - - if (tcp->setup != NULL) - tcp->setup(); - tcp->execute(); - if (tcp->teardown != NULL) - tcp->teardown(); -} - -static void print_line(void) { - unsigned i; - - for (i = 0; i < 76; i++) - streamPut(test_chp, '-'); - streamWrite(test_chp, (const uint8_t *)"\r\n", 2); -} - -/*===========================================================================*/ -/* Module exported functions. */ -/*===========================================================================*/ - -bool _test_fail(const char *msg) { - - test_local_fail = TRUE; - test_global_fail = TRUE; - test_failure_message = msg; - return TRUE; -} - -bool _test_assert(bool condition, const char *msg) { - - if (!condition) - return _test_fail(msg); - return FALSE; -} - -bool _test_assert_sequence(char *expected, const char *msg) { - char *cp = test_tokens_buffer; - - while (cp < test_tokp) { - if (*cp++ != *expected++) - return _test_fail(msg); - } - - if (*expected) - return _test_fail(msg); - - clear_tokens(); - - return FALSE; -} - -bool _test_assert_time_window(systime_t start, - systime_t end, - const char *msg) { - - return _test_assert(osalVTIsSystemTimeWithin(start, end), msg); -} - -/** - * @brief Prints a decimal unsigned number. - * - * @param[in] n the number to be printed - * - * @api - */ -void test_printn(uint32_t n) { - char buf[16], *p; - - if (!n) - streamPut(test_chp, '0'); - else { - p = buf; - while (n) - *p++ = (n % 10) + '0', n /= 10; - while (p > buf) - streamPut(test_chp, *--p); - } -} - -/** - * @brief Prints a line without final end-of-line. - * - * @param[in] msgp the message - * - * @api - */ -void test_print(const char *msgp) { - - while (*msgp) - streamPut(test_chp, *msgp++); -} - -/** - * @brief Prints a line. - * - * @param[in] msgp the message - * - * @api - */ -void test_println(const char *msgp) { - - test_print(msgp); - streamWrite(test_chp, (const uint8_t *)"\r\n", 2); -} - -/** - * @brief Emits a token into the tokens buffer. - * - * @param[in] token the token as a char - * - * @api - */ -void test_emit_token(char token) { - - osalSysLock(); - if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) - *test_tokp++ = token; - osalSysUnlock(); -} - -/** - * @brief Emits a token into the tokens buffer from a critical zone. - * - * @param[in] token the token as a char - * - * @iclass - */ -void test_emit_token_i(char token) { - - if (test_tokp < &test_tokens_buffer[TEST_MAX_TOKENS]) - *test_tokp++ = token; -} - -/** - * @brief Test execution thread function. - * - * @param[in] stream pointer to a @p BaseSequentialStream object for test - * output - * @return A failure boolean value casted to @p msg_t. - * @retval FALSE if no errors occurred. - * @retval TRUE if one or more tests failed. - * - * @api - */ -msg_t test_execute(BaseSequentialStream *stream) { - int i, j; - - test_chp = stream; - test_println(""); -#if defined(TEST_SUITE_NAME) - test_println("*** " TEST_SUITE_NAME); -#else - test_println("*** ChibiOS test suite"); -#endif - test_println("***"); - test_print("*** Compiled: "); - test_println(__DATE__ " - " __TIME__); -#ifdef PLATFORM_NAME - test_print("*** Platform: "); - test_println(PLATFORM_NAME); -#endif -#ifdef BOARD_NAME - test_print("*** Test Board: "); - test_println(BOARD_NAME); -#endif - test_println(""); - - test_global_fail = FALSE; - i = 0; - while (test_suite[i]) { - j = 0; - while (test_suite[i][j]) { - print_line(); - test_print("--- Test Case "); - test_printn(i + 1); - test_print("."); - test_printn(j + 1); - test_print(" ("); - test_print(test_suite[i][j]->name); - test_println(")"); -#if TEST_DELAY_BETWEEN_TESTS > 0 - osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS); -#endif - execute_test(test_suite[i][j]); - if (test_local_fail) { - test_print("--- Result: FAILURE (#"); - test_printn(test_step); - test_print(" ["); - print_tokens(); - test_print("] \""); - test_print(test_failure_message); - test_println("\")"); - } - else - test_println("--- Result: SUCCESS"); - j++; - } - i++; - } - print_line(); - test_println(""); - test_print("Final result: "); - if (test_global_fail) - test_println("FAILURE"); - else - test_println("SUCCESS"); - - return (msg_t)test_global_fail; -} - -/** @} */ diff --git a/test/lib/chtest.h b/test/lib/chtest.h deleted file mode 100644 index c8e03490c..000000000 --- a/test/lib/chtest.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file ch_test.h - * @brief Unit Tests Engine Module macros and structures. - * - * @addtogroup CH_TEST - * @{ - */ - -#ifndef _CH_TEST_H_ -#define _CH_TEST_H_ - -/*===========================================================================*/ -/* Module constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module pre-compile time settings. */ -/*===========================================================================*/ - -/** - * @brief Maximum number of entries in the tokens buffer. - */ -#if !defined(TEST_MAX_TOKENS) || defined(__DOXYGEN__) -#define TEST_MAX_TOKENS 16 -#endif - -/** - * @brief Delay inserted between test cases. - */ -#if !defined(TEST_DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) -#define TEST_DELAY_BETWEEN_TESTS 200 -#endif - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Structure representing a test case. - */ -typedef struct { - const char *name; /**< @brief Test case name. */ - void (*setup)(void); /**< @brief Test case preparation function. */ - void (*teardown)(void); /**< @brief Test case clean up function. */ - void (*execute)(void); /**< @brief Test case execution function. */ -} testcase_t; - -/*===========================================================================*/ -/* Module macros. */ -/*===========================================================================*/ - -/** - * @brief Sets the step identifier. - * - * @param[in] step the step number - */ -#define test_set_step(step) test_step = (step) - -/** - * @brief Test failure enforcement. - * @note This function can only be called from test_case execute context. - * - * @param[in] msg failure message as string - * - * @api - */ -#define test_fail(msg) { \ - _test_fail(msg); \ - return; \ -} - -/** - * @brief Test assertion. - * @note This function can only be called from test_case execute context. - * - * @param[in] condition a boolean expression that must be verified to be true - * @param[in] msg failure message as string - * - * @api - */ -#define test_assert(condition, msg) { \ - if (_test_assert(condition, msg)) \ - return; \ -} - -/** - * @brief Test assertion with lock. - * @note This function can only be called from test_case execute context. - * - * @param[in] condition a boolean expression that must be verified to be true - * @param[in] msg failure message as string - * - * @api - */ -#define test_assert_lock(condition, msg) { \ - osalSysLock(); \ - if (_test_assert(condition, msg)) { \ - osalSysUnlock(); \ - return; \ - } \ - osalSysUnlock(); \ -} - -/** - * @brief Test sequence assertion. - * @note This function can only be called from test_case execute context. - * - * @param[in] expected string to be matched with the tokens buffer - * @param[in] msg failure message as string - * - * @api - */ -#define test_assert_sequence(expected, msg) { \ - if (_test_assert_sequence(expected, msg)) \ - return; \ -} - -/** - * @brief Test time window assertion. - * @note This function can only be called from test_case execute context. - * - * @param[in] start initial time in the window (included) - * @param[in] end final time in the window (not included) - * @param[in] msg failure message as string - * - * @api - */ -#define test_assert_time_window(start, end, msg) { \ - if (_test_assert_time_window(start, end, msg)) \ - return; \ -} - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) -extern unsigned test_step; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - bool _test_fail(const char *message); - bool _test_assert(bool condition, const char *msg); - bool _test_assert_sequence(char *expected, const char *msg); - bool _test_assert_time_window(systime_t start, - systime_t end, - const char *msg); - void test_printn(uint32_t n); - void test_print(const char *msgp); - void test_println(const char *msgp); - void test_emit_token(char token); - void test_emit_token_i(char token); - msg_t test_execute(BaseSequentialStream *stream); -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Module inline functions. */ -/*===========================================================================*/ - -#endif /* _CH_TEST_H_ */ - -/** @} */ -- cgit v1.2.3 From 5e65b9fce1697a5b1dfdd53c10baa6f2e2aeaf66 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 10:52:25 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6691 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/ch_test.c | 5 ++-- test/lib/templates/test_root.c | 1 + test/lib/templates/test_root.h | 10 +++++++- test/rt/test.mk | 1 + test/rt/test_root.c | 45 +++++++++++++++++++++++++++++++++ test/rt/test_root.h | 57 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 test/rt/test_root.c create mode 100644 test/rt/test_root.h (limited to 'test') diff --git a/test/lib/ch_test.c b/test/lib/ch_test.c index 9d6cb8d02..c8735ba5b 100644 --- a/test/lib/ch_test.c +++ b/test/lib/ch_test.c @@ -130,7 +130,8 @@ bool _test_assert_time_window(systime_t start, systime_t end, const char *msg) { - return _test_assert(osalVTIsSystemTimeWithin(start, end), msg); + return _test_assert(osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end), + msg); } /** @@ -256,7 +257,7 @@ msg_t test_execute(BaseSequentialStream *stream) { test_print(test_suite[i][j]->name); test_println(")"); #if TEST_DELAY_BETWEEN_TESTS > 0 - osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS); + osalThreadSleep(OSAL_MS2ST(TEST_DELAY_BETWEEN_TESTS)); #endif execute_test(test_suite[i][j]); if (test_local_fail) { diff --git a/test/lib/templates/test_root.c b/test/lib/templates/test_root.c index 8fb2ec9b9..47e8c67e4 100644 --- a/test/lib/templates/test_root.c +++ b/test/lib/templates/test_root.c @@ -34,6 +34,7 @@ * @brief Array of all the test sequences. */ const testcase_t * const *test_suite[] = { + test_sequence_000, NULL }; diff --git a/test/lib/templates/test_root.h b/test/lib/templates/test_root.h index 3d26ecd50..f32b386f8 100644 --- a/test/lib/templates/test_root.h +++ b/test/lib/templates/test_root.h @@ -25,7 +25,15 @@ #ifndef _TEST_ROOT_H_ #define _TEST_ROOT_H_ -#include "test_000.h" +#include "test_sequence_000.h" + +/*===========================================================================*/ +/* Default definitions. */ +/*===========================================================================*/ + +/* Global test suite name, it is printed on top of the test + report header.*/ +#define TEST_SUITE_NAME "Test Suite" /*===========================================================================*/ /* External declarations. */ diff --git a/test/rt/test.mk b/test/rt/test.mk index 92dda7d81..6abe29dfe 100644 --- a/test/rt/test.mk +++ b/test/rt/test.mk @@ -1,5 +1,6 @@ # List of all the ChibiOS/RT test files. TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ + ${CHIBIOS}/test/rt/test_root.c \ ${CHIBIOS}/test/rt/test_sequence_000.c # Required include directories diff --git a/test/rt/test_root.c b/test/rt/test_root.c new file mode 100644 index 000000000..47e8c67e4 --- /dev/null +++ b/test/rt/test_root.c @@ -0,0 +1,45 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.c + * @brief Test Suite root structures code. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Array of all the test sequences. + */ +const testcase_t * const *test_suite[] = { + test_sequence_000, + NULL +}; + +/*===========================================================================*/ +/* Shared code. */ +/*===========================================================================*/ + +/** @} */ diff --git a/test/rt/test_root.h b/test/rt/test_root.h new file mode 100644 index 000000000..fb6fea873 --- /dev/null +++ b/test/rt/test_root.h @@ -0,0 +1,57 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.h + * @brief Test Suite root structures header. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#ifndef _TEST_ROOT_H_ +#define _TEST_ROOT_H_ + +#include "test_sequence_000.h" + +/*===========================================================================*/ +/* Default definitions. */ +/*===========================================================================*/ + +/* Global test suite name, it is printed on top of the test + report header.*/ +#define TEST_SUITE_NAME "ChibiOS/RT Test Suite" + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern const testcase_t * const *test_suite[]; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Shared definitions. */ +/*===========================================================================*/ + +#endif /* _TEST_ROOT_H_ */ + +/** @} */ -- cgit v1.2.3 From 7c1bfd409dc3e12b9a5bafff94f845598b96f67c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 10:58:17 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6692 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/ch_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/lib/ch_test.c b/test/lib/ch_test.c index c8735ba5b..cb1df734f 100644 --- a/test/lib/ch_test.c +++ b/test/lib/ch_test.c @@ -257,7 +257,7 @@ msg_t test_execute(BaseSequentialStream *stream) { test_print(test_suite[i][j]->name); test_println(")"); #if TEST_DELAY_BETWEEN_TESTS > 0 - osalThreadSleep(OSAL_MS2ST(TEST_DELAY_BETWEEN_TESTS)); + osalThreadSleepMilliseconds(TEST_DELAY_BETWEEN_TESTS); #endif execute_test(test_suite[i][j]); if (test_local_fail) { -- cgit v1.2.3 From 1ef57ed011384517ebaf13bd098653caac32d3df Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 11:21:03 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6693 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test.mk | 8 ++++ test/nil/test_root.c | 45 ++++++++++++++++++++ test/nil/test_root.h | 57 ++++++++++++++++++++++++++ test/nil/test_sequence_000.c | 97 ++++++++++++++++++++++++++++++++++++++++++++ test/nil/test_sequence_000.h | 22 ++++++++++ test/rt/test.mk | 8 ---- test/rt/test_root.c | 45 -------------------- test/rt/test_root.h | 57 -------------------------- test/rt/test_sequence_000.c | 97 -------------------------------------------- test/rt/test_sequence_000.h | 22 ---------- 10 files changed, 229 insertions(+), 229 deletions(-) create mode 100644 test/nil/test.mk create mode 100644 test/nil/test_root.c create mode 100644 test/nil/test_root.h create mode 100644 test/nil/test_sequence_000.c create mode 100644 test/nil/test_sequence_000.h delete mode 100644 test/rt/test.mk delete mode 100644 test/rt/test_root.c delete mode 100644 test/rt/test_root.h delete mode 100644 test/rt/test_sequence_000.c delete mode 100644 test/rt/test_sequence_000.h (limited to 'test') diff --git a/test/nil/test.mk b/test/nil/test.mk new file mode 100644 index 000000000..6abe29dfe --- /dev/null +++ b/test/nil/test.mk @@ -0,0 +1,8 @@ +# List of all the ChibiOS/RT test files. +TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ + ${CHIBIOS}/test/rt/test_root.c \ + ${CHIBIOS}/test/rt/test_sequence_000.c + +# Required include directories +TESTINC = ${CHIBIOS}/test/lib \ + ${CHIBIOS}/test/rt diff --git a/test/nil/test_root.c b/test/nil/test_root.c new file mode 100644 index 000000000..47e8c67e4 --- /dev/null +++ b/test/nil/test_root.c @@ -0,0 +1,45 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.c + * @brief Test Suite root structures code. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Array of all the test sequences. + */ +const testcase_t * const *test_suite[] = { + test_sequence_000, + NULL +}; + +/*===========================================================================*/ +/* Shared code. */ +/*===========================================================================*/ + +/** @} */ diff --git a/test/nil/test_root.h b/test/nil/test_root.h new file mode 100644 index 000000000..fb6fea873 --- /dev/null +++ b/test/nil/test_root.h @@ -0,0 +1,57 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test_root.h + * @brief Test Suite root structures header. + * + * @addtogroup CH_TEST_ROOT + * @{ + */ + +#ifndef _TEST_ROOT_H_ +#define _TEST_ROOT_H_ + +#include "test_sequence_000.h" + +/*===========================================================================*/ +/* Default definitions. */ +/*===========================================================================*/ + +/* Global test suite name, it is printed on top of the test + report header.*/ +#define TEST_SUITE_NAME "ChibiOS/RT Test Suite" + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern const testcase_t * const *test_suite[]; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Shared definitions. */ +/*===========================================================================*/ + +#endif /* _TEST_ROOT_H_ */ + +/** @} */ diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c new file mode 100644 index 000000000..efe81b6da --- /dev/null +++ b/test/nil/test_sequence_000.c @@ -0,0 +1,97 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_000 Sequence brief description + * + * File: @ref test_sequence_000.c + * + *

Description

+ * Sequence detailed description. + * + *

Test Cases

+ * - @subpage test_000_000 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +/** + * @page test_000_000 Brief description + * + *

Description

+ * Detailed description. + * + *

Conditions

+ * This test is only executed if the following preprocessor condition + * evaluates to true: + * - TEST_000_000_CONDITION + * . + * + *

Test Steps

+ * - Step description. + * . + */ + +static void test_000_000_setup(void) { + +} + +static void test_000_000}_teardown(void) { + +} + +static void test_000_000_execute(void) { + + /* Step description.*/ + test_set_step(1); + { + } +} + +static const testcase_t test_000_000 = { + "Brief description", + test_000_000_setup, + test_000_000_teardown, + test_000_000_execute +}; + #endif /* TEST_000_000_CONDITION */ + + /**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Sequence brief description. + */ +const testcase_t * const test_sequence_000[] = { +#if TEST_000_000_CONDITION || defined(__DOXYGEN__) + &test_000_000, +#endif + NULL +}; diff --git a/test/nil/test_sequence_000.h b/test/nil/test_sequence_000.h new file mode 100644 index 000000000..72aaaf374 --- /dev/null +++ b/test/nil/test_sequence_000.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TEST_SEQUENCE_000_H_ +#define _TEST_SEQUENCE_000_H_ + +extern const testcase_t * const test_sequence_000[]; + +#endif /* _TEST_SEQUENCE_000_H_ */ diff --git a/test/rt/test.mk b/test/rt/test.mk deleted file mode 100644 index 6abe29dfe..000000000 --- a/test/rt/test.mk +++ /dev/null @@ -1,8 +0,0 @@ -# List of all the ChibiOS/RT test files. -TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ - ${CHIBIOS}/test/rt/test_root.c \ - ${CHIBIOS}/test/rt/test_sequence_000.c - -# Required include directories -TESTINC = ${CHIBIOS}/test/lib \ - ${CHIBIOS}/test/rt diff --git a/test/rt/test_root.c b/test/rt/test_root.c deleted file mode 100644 index 47e8c67e4..000000000 --- a/test/rt/test_root.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file test_root.c - * @brief Test Suite root structures code. - * - * @addtogroup CH_TEST_ROOT - * @{ - */ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/*===========================================================================*/ -/* Module exported variables. */ -/*===========================================================================*/ - -/** - * @brief Array of all the test sequences. - */ -const testcase_t * const *test_suite[] = { - test_sequence_000, - NULL -}; - -/*===========================================================================*/ -/* Shared code. */ -/*===========================================================================*/ - -/** @} */ diff --git a/test/rt/test_root.h b/test/rt/test_root.h deleted file mode 100644 index fb6fea873..000000000 --- a/test/rt/test_root.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file test_root.h - * @brief Test Suite root structures header. - * - * @addtogroup CH_TEST_ROOT - * @{ - */ - -#ifndef _TEST_ROOT_H_ -#define _TEST_ROOT_H_ - -#include "test_sequence_000.h" - -/*===========================================================================*/ -/* Default definitions. */ -/*===========================================================================*/ - -/* Global test suite name, it is printed on top of the test - report header.*/ -#define TEST_SUITE_NAME "ChibiOS/RT Test Suite" - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -extern const testcase_t * const *test_suite[]; - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Shared definitions. */ -/*===========================================================================*/ - -#endif /* _TEST_ROOT_H_ */ - -/** @} */ diff --git a/test/rt/test_sequence_000.c b/test/rt/test_sequence_000.c deleted file mode 100644 index efe81b6da..000000000 --- a/test/rt/test_sequence_000.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @page test_sequence_000 Sequence brief description - * - * File: @ref test_sequence_000.c - * - *

Description

- * Sequence detailed description. - * - *

Test Cases

- * - @subpage test_000_000 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) -/** - * @page test_000_000 Brief description - * - *

Description

- * Detailed description. - * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - TEST_000_000_CONDITION - * . - * - *

Test Steps

- * - Step description. - * . - */ - -static void test_000_000_setup(void) { - -} - -static void test_000_000}_teardown(void) { - -} - -static void test_000_000_execute(void) { - - /* Step description.*/ - test_set_step(1); - { - } -} - -static const testcase_t test_000_000 = { - "Brief description", - test_000_000_setup, - test_000_000_teardown, - test_000_000_execute -}; - #endif /* TEST_000_000_CONDITION */ - - /**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Sequence brief description. - */ -const testcase_t * const test_sequence_000[] = { -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) - &test_000_000, -#endif - NULL -}; diff --git a/test/rt/test_sequence_000.h b/test/rt/test_sequence_000.h deleted file mode 100644 index 72aaaf374..000000000 --- a/test/rt/test_sequence_000.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TEST_SEQUENCE_000_H_ -#define _TEST_SEQUENCE_000_H_ - -extern const testcase_t * const test_sequence_000[]; - -#endif /* _TEST_SEQUENCE_000_H_ */ -- cgit v1.2.3 From c082a87062ebb9414ec223e9bf7ea8959a717488 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 13:01:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6694 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/templates/test_sequence_XXX.c | 2 +- test/nil/test.mk | 6 +- test/nil/test_root.h | 2 + test/nil/test_sequence_000.c | 118 +++++++++++++++++++++++++++------ 4 files changed, 103 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c index 3fb1df8e0..2d46efac8 100644 --- a/test/lib/templates/test_sequence_XXX.c +++ b/test/lib/templates/test_sequence_XXX.c @@ -80,7 +80,7 @@ static const testcase_t test_XXX_000 = { test_XXX_000_teardown, test_XXX_000_execute }; - #endif /* TEST_XXX_000_CONDITION */ +#endif /* TEST_XXX_000_CONDITION */ /**************************************************************************** * Exported data. diff --git a/test/nil/test.mk b/test/nil/test.mk index 6abe29dfe..a69e80e08 100644 --- a/test/nil/test.mk +++ b/test/nil/test.mk @@ -1,8 +1,8 @@ # List of all the ChibiOS/RT test files. TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ - ${CHIBIOS}/test/rt/test_root.c \ - ${CHIBIOS}/test/rt/test_sequence_000.c + ${CHIBIOS}/test/nil/test_root.c \ + ${CHIBIOS}/test/nil/test_sequence_000.c # Required include directories TESTINC = ${CHIBIOS}/test/lib \ - ${CHIBIOS}/test/rt + ${CHIBIOS}/test/nil diff --git a/test/nil/test_root.h b/test/nil/test_root.h index fb6fea873..42463fc03 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -25,6 +25,8 @@ #ifndef _TEST_ROOT_H_ #define _TEST_ROOT_H_ +#include "nil.h" + #include "test_sequence_000.h" /*===========================================================================*/ diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c index efe81b6da..7b56a3908 100644 --- a/test/nil/test_sequence_000.c +++ b/test/nil/test_sequence_000.c @@ -19,12 +19,12 @@ #include "test_root.h" /** - * @page test_sequence_000 Sequence brief description + * @page test_sequence_000 Threads Functionality * * File: @ref test_sequence_000.c * *

Description

- * Sequence detailed description. + * This sequence tests the ChibiOS/Nil functionalities related to threading. * *

Test Cases

* - @subpage test_000_000 @@ -40,47 +40,120 @@ * Test cases. ****************************************************************************/ -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +#if TRUE || defined(__DOXYGEN__) /** - * @page test_000_000 Brief description + * @page test_000_000 System Tick Counter functionality * *

Description

- * Detailed description. + * The functionality of the API @p chVTGetSystemTimeX() is tested. * *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - TEST_000_000_CONDITION - * . + * None. * *

Test Steps

- * - Step description. + * - A System Tick Counter increment is expected, the test simply hangs if + * it does not happen. * . */ -static void test_000_000_setup(void) { +static void test_000_000_execute(void) { + systime_t time; + /* A System Tick Counter increment is expected, the test simply hangs if + it does not happen.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + while (time == chVTGetSystemTimeX()) { + } + } } -static void test_000_000}_teardown(void) { +static const testcase_t test_000_000 = { + "Brief description", + NULL, + NULL, + test_000_000_execute +}; +#endif /* TEST_000_000_CONDITION */ -} +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_000_001 Thread Sleep functionality + * + *

Description

+ * The functionality of the API @p chThdSleep() and derivatives is tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The current system time is read then a sleep is performed for 100 system + * ticks and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100000 + * microseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100 + * milliseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 1 + * second and on exit the system time is verified again. + * . + */ -static void test_000_000_execute(void) { +static void test_000_001_execute(void) { + systime_t time; - /* Step description.*/ + /* The current system time is read then a sleep is performed for 100 system + ticks and on exit the system time is verified again.*/ test_set_step(1); { + time = chVTGetSystemTimeX(); + chThdSleep(100); + test_assert_time_window(time + 100, + time + 101, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 100000 + microseconds and on exit the system time is verified again.*/ + test_set_step(2); + { + time = chVTGetSystemTimeX(); + chThdSleepMicroseconds(100); + test_assert_time_window(time + US2ST(100), + time + US2ST(100) + 1, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 100 + milliseconds and on exit the system time is verified again.*/ + test_set_step(3); + { + time = chVTGetSystemTimeX(); + chThdSleepMicroseconds(100); + test_assert_time_window(time + MS2ST(100), + time + MS2ST(100) + 1, + "out of time window"); + } + + /* The current system time is read then a sleep is performed for 1 + second and on exit the system time is verified again.*/ + test_set_step(4); + { + time = chVTGetSystemTimeX(); + chThdSleepSeconds(1); + test_assert_time_window(time + S2ST(1), + time + S2ST(1) + 1, + "out of time window"); } } -static const testcase_t test_000_000 = { +static const testcase_t test_000_001 = { "Brief description", - test_000_000_setup, - test_000_000_teardown, - test_000_000_execute + NULL, + NULL, + test_000_001_execute }; - #endif /* TEST_000_000_CONDITION */ +#endif /* TEST_000_001_CONDITION */ /**************************************************************************** * Exported data. @@ -90,8 +163,11 @@ static const testcase_t test_000_000 = { * @brief Sequence brief description. */ const testcase_t * const test_sequence_000[] = { -#if TEST_000_000_CONDITION || defined(__DOXYGEN__) +#if 1 || defined(__DOXYGEN__) &test_000_000, +#endif +#if 1 || defined(__DOXYGEN__) + &test_000_001, #endif NULL }; -- cgit v1.2.3 From 12a2f695cfb4de204b5114a958e31689f961b98c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 13:29:29 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6695 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test_sequence_000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c index 7b56a3908..a61ce4108 100644 --- a/test/nil/test_sequence_000.c +++ b/test/nil/test_sequence_000.c @@ -129,7 +129,7 @@ static void test_000_001_execute(void) { test_set_step(3); { time = chVTGetSystemTimeX(); - chThdSleepMicroseconds(100); + chThdSleepMilliseconds(100); test_assert_time_window(time + MS2ST(100), time + MS2ST(100) + 1, "out of time window"); -- cgit v1.2.3 From 4fc90c99b72c00ab803a018bf55dd4ad75960224 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 15:36:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6696 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/templates/test_sequence_XXX.c | 2 +- test/nil/test.mk | 3 +- test/nil/test_root.c | 1 + test/nil/test_root.h | 3 +- test/nil/test_sequence_000.c | 26 +++-- test/nil/test_sequence_001.c | 182 +++++++++++++++++++++++++++++++++ test/nil/test_sequence_001.h | 22 ++++ 7 files changed, 228 insertions(+), 11 deletions(-) create mode 100644 test/nil/test_sequence_001.c create mode 100644 test/nil/test_sequence_001.h (limited to 'test') diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c index 2d46efac8..6ff377e94 100644 --- a/test/lib/templates/test_sequence_XXX.c +++ b/test/lib/templates/test_sequence_XXX.c @@ -62,7 +62,7 @@ static void test_XXX_000_setup(void) { } -static void test_XXX_000}_teardown(void) { +static void test_XXX_000_teardown(void) { } diff --git a/test/nil/test.mk b/test/nil/test.mk index a69e80e08..1cb5641cf 100644 --- a/test/nil/test.mk +++ b/test/nil/test.mk @@ -1,7 +1,8 @@ # List of all the ChibiOS/RT test files. TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ ${CHIBIOS}/test/nil/test_root.c \ - ${CHIBIOS}/test/nil/test_sequence_000.c + ${CHIBIOS}/test/nil/test_sequence_000.c \ + ${CHIBIOS}/test/nil/test_sequence_001.c # Required include directories TESTINC = ${CHIBIOS}/test/lib \ diff --git a/test/nil/test_root.c b/test/nil/test_root.c index 47e8c67e4..94f88f2a4 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -35,6 +35,7 @@ */ const testcase_t * const *test_suite[] = { test_sequence_000, + test_sequence_001, NULL }; diff --git a/test/nil/test_root.h b/test/nil/test_root.h index 42463fc03..58e0790a4 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -28,6 +28,7 @@ #include "nil.h" #include "test_sequence_000.h" +#include "test_sequence_001.h" /*===========================================================================*/ /* Default definitions. */ @@ -35,7 +36,7 @@ /* Global test suite name, it is printed on top of the test report header.*/ -#define TEST_SUITE_NAME "ChibiOS/RT Test Suite" +#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite" /*===========================================================================*/ /* External declarations. */ diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c index a61ce4108..6d1dede6c 100644 --- a/test/nil/test_sequence_000.c +++ b/test/nil/test_sequence_000.c @@ -24,10 +24,11 @@ * File: @ref test_sequence_000.c * *

Description

- * This sequence tests the ChibiOS/Nil functionalities related to threading. + * This sequence tests the ChibiOS/NIL functionalities related to threading. * *

Test Cases

* - @subpage test_000_000 + * - @subpage test_000_001 * . */ @@ -70,12 +71,12 @@ static void test_000_000_execute(void) { } static const testcase_t test_000_000 = { - "Brief description", + "System Tick Counter functionality", NULL, NULL, test_000_000_execute }; -#endif /* TEST_000_000_CONDITION */ +#endif /* TRUE */ #if TRUE || defined(__DOXYGEN__) /** @@ -109,7 +110,7 @@ static void test_000_001_execute(void) { time = chVTGetSystemTimeX(); chThdSleep(100); test_assert_time_window(time + 100, - time + 101, + time + 100 + 1, "out of time window"); } @@ -145,15 +146,24 @@ static void test_000_001_execute(void) { time + S2ST(1) + 1, "out of time window"); } + + test_set_step(5); + { + time = chVTGetSystemTimeX(); + chThdSleepUntil(time + 100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + } } static const testcase_t test_000_001 = { - "Brief description", + "Thread Sleep functionality", NULL, NULL, test_000_001_execute }; -#endif /* TEST_000_001_CONDITION */ +#endif /* TRUE */ /**************************************************************************** * Exported data. @@ -163,10 +173,10 @@ static const testcase_t test_000_001 = { * @brief Sequence brief description. */ const testcase_t * const test_sequence_000[] = { -#if 1 || defined(__DOXYGEN__) +#if TRUE || defined(__DOXYGEN__) &test_000_000, #endif -#if 1 || defined(__DOXYGEN__) +#if TRUE || defined(__DOXYGEN__) &test_000_001, #endif NULL diff --git a/test/nil/test_sequence_001.c b/test/nil/test_sequence_001.c new file mode 100644 index 000000000..0157541d5 --- /dev/null +++ b/test/nil/test_sequence_001.c @@ -0,0 +1,182 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_001 Semaphores functionality + * + * File: @ref test_sequence_001.c + * + *

Description

+ * This sequence tests the ChibiOS/NIL functionalities related to semaphores. + * + *

Test Cases

+ * - @subpage test_001_000 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +static semaphore_t sem1; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_001_000 Semaphores primitives, no state change + * + *

Description

+ * Wait, Signal and Reset primitives are tested. The testing thread does not + * trigger a state change. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chSemWait() is invoked, the Semaphore counter is tested + * for correct value after the call. + * - The function chSemSignal() is invoked, the Semaphore counter is tested + * for correct value after the call. + * - The function chSemReset() is invoked, the Semaphore counter is tested + * for correct value after the call. + * . + */ + +static void test_001_000_setup(void) { + + chSemObjectInit(&sem1, 1); +} + +static void test_001_000_teardown(void) { + + chSemReset(&sem1, 0); +} + +static void test_001_000_execute(void) { + + /* The function chSemWait() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(1); + { + chSemWait(&sem1); + test_assert_lock(chSemGetCounterI(&sem1) == 0, + "wrong counter value"); + } + + /* The function chSemSignal() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(2); + { + chSemSignal(&sem1); + test_assert_lock(chSemGetCounterI(&sem1) == 1, + "wrong counter value"); + } + + /* The function chSemReset() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(3); + { + chSemReset(&sem1, 2); + test_assert_lock(chSemGetCounterI(&sem1) == 2, + "wrong counter value"); + } +} + +static const testcase_t test_001_000 = { + "Brief description", + test_001_000_setup, + test_001_000_teardown, + test_001_000_execute +}; +#endif /* TRUE */ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_001_000 Semaphores timeout + * + *

Description

+ * Timeouts on semaphores are tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chSemWaitTimeout() is invoked, after return the system + * time, the counter and the returned message are tested. + * . + */ + +static void test_001_001_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void test_001_001_teardown(void) { + + chSemReset(&sem1, 0); +} + +static void test_001_001_execute(void) { + systime_t time; + msg_t msg; + + /* The function chSemWaitTimeout() is invoked, after return the system + time, the counter and the returned message are tested.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + msg = chSemWaitTimeout(&sem1, 100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + test_assert_lock(chSemGetCounterI(&sem1) == 0, + "wrong counter value"); + test_assert(MSG_TIMEOUT == msg, + "wrong timeout message"); + } +} + +static const testcase_t test_001_001 = { + "Brief description", + test_001_001_setup, + test_001_001_teardown, + test_001_001_execute +}; +#endif /* TRUE */ + + /**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Sequence brief description. + */ +const testcase_t * const test_sequence_001[] = { +#if TRUE || defined(__DOXYGEN__) + &test_001_000, +#endif +#if TRUE || defined(__DOXYGEN__) + &test_001_001, +#endif + NULL +}; diff --git a/test/nil/test_sequence_001.h b/test/nil/test_sequence_001.h new file mode 100644 index 000000000..47ae8315b --- /dev/null +++ b/test/nil/test_sequence_001.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TEST_SEQUENCE_001_H_ +#define _TEST_SEQUENCE_001_H_ + +extern const testcase_t * const test_sequence_001[]; + +#endif /* _TEST_SEQUENCE_001_H_ */ -- cgit v1.2.3 From be1b2cbd33b1a8e1522bdb727de1c2845295fabf Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 15:37:51 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6697 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test_sequence_000.c | 183 ------------------------------------------- test/nil/test_sequence_000.h | 22 ------ test/nil/test_sequence_001.c | 165 +++++++++++++++++++------------------- test/nil/test_sequence_001.h | 8 +- test/nil/test_sequence_002.c | 182 ++++++++++++++++++++++++++++++++++++++++++ test/nil/test_sequence_002.h | 22 ++++++ 6 files changed, 291 insertions(+), 291 deletions(-) delete mode 100644 test/nil/test_sequence_000.c delete mode 100644 test/nil/test_sequence_000.h create mode 100644 test/nil/test_sequence_002.c create mode 100644 test/nil/test_sequence_002.h (limited to 'test') diff --git a/test/nil/test_sequence_000.c b/test/nil/test_sequence_000.c deleted file mode 100644 index 6d1dede6c..000000000 --- a/test/nil/test_sequence_000.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @page test_sequence_000 Threads Functionality - * - * File: @ref test_sequence_000.c - * - *

Description

- * This sequence tests the ChibiOS/NIL functionalities related to threading. - * - *

Test Cases

- * - @subpage test_000_000 - * - @subpage test_000_001 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -#if TRUE || defined(__DOXYGEN__) -/** - * @page test_000_000 System Tick Counter functionality - * - *

Description

- * The functionality of the API @p chVTGetSystemTimeX() is tested. - * - *

Conditions

- * None. - * - *

Test Steps

- * - A System Tick Counter increment is expected, the test simply hangs if - * it does not happen. - * . - */ - -static void test_000_000_execute(void) { - systime_t time; - - /* A System Tick Counter increment is expected, the test simply hangs if - it does not happen.*/ - test_set_step(1); - { - time = chVTGetSystemTimeX(); - while (time == chVTGetSystemTimeX()) { - } - } -} - -static const testcase_t test_000_000 = { - "System Tick Counter functionality", - NULL, - NULL, - test_000_000_execute -}; -#endif /* TRUE */ - -#if TRUE || defined(__DOXYGEN__) -/** - * @page test_000_001 Thread Sleep functionality - * - *

Description

- * The functionality of the API @p chThdSleep() and derivatives is tested. - * - *

Conditions

- * None. - * - *

Test Steps

- * - The current system time is read then a sleep is performed for 100 system - * ticks and on exit the system time is verified again. - * - The current system time is read then a sleep is performed for 100000 - * microseconds and on exit the system time is verified again. - * - The current system time is read then a sleep is performed for 100 - * milliseconds and on exit the system time is verified again. - * - The current system time is read then a sleep is performed for 1 - * second and on exit the system time is verified again. - * . - */ - -static void test_000_001_execute(void) { - systime_t time; - - /* The current system time is read then a sleep is performed for 100 system - ticks and on exit the system time is verified again.*/ - test_set_step(1); - { - time = chVTGetSystemTimeX(); - chThdSleep(100); - test_assert_time_window(time + 100, - time + 100 + 1, - "out of time window"); - } - - /* The current system time is read then a sleep is performed for 100000 - microseconds and on exit the system time is verified again.*/ - test_set_step(2); - { - time = chVTGetSystemTimeX(); - chThdSleepMicroseconds(100); - test_assert_time_window(time + US2ST(100), - time + US2ST(100) + 1, - "out of time window"); - } - - /* The current system time is read then a sleep is performed for 100 - milliseconds and on exit the system time is verified again.*/ - test_set_step(3); - { - time = chVTGetSystemTimeX(); - chThdSleepMilliseconds(100); - test_assert_time_window(time + MS2ST(100), - time + MS2ST(100) + 1, - "out of time window"); - } - - /* The current system time is read then a sleep is performed for 1 - second and on exit the system time is verified again.*/ - test_set_step(4); - { - time = chVTGetSystemTimeX(); - chThdSleepSeconds(1); - test_assert_time_window(time + S2ST(1), - time + S2ST(1) + 1, - "out of time window"); - } - - test_set_step(5); - { - time = chVTGetSystemTimeX(); - chThdSleepUntil(time + 100); - test_assert_time_window(time + 100, - time + 100 + 1, - "out of time window"); - } -} - -static const testcase_t test_000_001 = { - "Thread Sleep functionality", - NULL, - NULL, - test_000_001_execute -}; -#endif /* TRUE */ - - /**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Sequence brief description. - */ -const testcase_t * const test_sequence_000[] = { -#if TRUE || defined(__DOXYGEN__) - &test_000_000, -#endif -#if TRUE || defined(__DOXYGEN__) - &test_000_001, -#endif - NULL -}; diff --git a/test/nil/test_sequence_000.h b/test/nil/test_sequence_000.h deleted file mode 100644 index 72aaaf374..000000000 --- a/test/nil/test_sequence_000.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TEST_SEQUENCE_000_H_ -#define _TEST_SEQUENCE_000_H_ - -extern const testcase_t * const test_sequence_000[]; - -#endif /* _TEST_SEQUENCE_000_H_ */ diff --git a/test/nil/test_sequence_001.c b/test/nil/test_sequence_001.c index 0157541d5..6d1dede6c 100644 --- a/test/nil/test_sequence_001.c +++ b/test/nil/test_sequence_001.c @@ -19,15 +19,16 @@ #include "test_root.h" /** - * @page test_sequence_001 Semaphores functionality + * @page test_sequence_000 Threads Functionality * - * File: @ref test_sequence_001.c + * File: @ref test_sequence_000.c * *

Description

- * This sequence tests the ChibiOS/NIL functionalities related to semaphores. + * This sequence tests the ChibiOS/NIL functionalities related to threading. * *

Test Cases

- * - @subpage test_001_000 + * - @subpage test_000_000 + * - @subpage test_000_001 * . */ @@ -35,7 +36,6 @@ * Shared code. ****************************************************************************/ -static semaphore_t sem1; /**************************************************************************** * Test cases. @@ -43,124 +43,125 @@ static semaphore_t sem1; #if TRUE || defined(__DOXYGEN__) /** - * @page test_001_000 Semaphores primitives, no state change + * @page test_000_000 System Tick Counter functionality * *

Description

- * Wait, Signal and Reset primitives are tested. The testing thread does not - * trigger a state change. + * The functionality of the API @p chVTGetSystemTimeX() is tested. * *

Conditions

* None. * *

Test Steps

- * - The function chSemWait() is invoked, the Semaphore counter is tested - * for correct value after the call. - * - The function chSemSignal() is invoked, the Semaphore counter is tested - * for correct value after the call. - * - The function chSemReset() is invoked, the Semaphore counter is tested - * for correct value after the call. + * - A System Tick Counter increment is expected, the test simply hangs if + * it does not happen. * . */ -static void test_001_000_setup(void) { - - chSemObjectInit(&sem1, 1); -} - -static void test_001_000_teardown(void) { - - chSemReset(&sem1, 0); -} - -static void test_001_000_execute(void) { +static void test_000_000_execute(void) { + systime_t time; - /* The function chSemWait() is invoked, the Semaphore counter is tested - for correct value after the call.*/ + /* A System Tick Counter increment is expected, the test simply hangs if + it does not happen.*/ test_set_step(1); { - chSemWait(&sem1); - test_assert_lock(chSemGetCounterI(&sem1) == 0, - "wrong counter value"); - } - - /* The function chSemSignal() is invoked, the Semaphore counter is tested - for correct value after the call.*/ - test_set_step(2); - { - chSemSignal(&sem1); - test_assert_lock(chSemGetCounterI(&sem1) == 1, - "wrong counter value"); - } - - /* The function chSemReset() is invoked, the Semaphore counter is tested - for correct value after the call.*/ - test_set_step(3); - { - chSemReset(&sem1, 2); - test_assert_lock(chSemGetCounterI(&sem1) == 2, - "wrong counter value"); + time = chVTGetSystemTimeX(); + while (time == chVTGetSystemTimeX()) { + } } } -static const testcase_t test_001_000 = { - "Brief description", - test_001_000_setup, - test_001_000_teardown, - test_001_000_execute +static const testcase_t test_000_000 = { + "System Tick Counter functionality", + NULL, + NULL, + test_000_000_execute }; #endif /* TRUE */ #if TRUE || defined(__DOXYGEN__) /** - * @page test_001_000 Semaphores timeout + * @page test_000_001 Thread Sleep functionality * *

Description

- * Timeouts on semaphores are tested. + * The functionality of the API @p chThdSleep() and derivatives is tested. * *

Conditions

* None. * *

Test Steps

- * - The function chSemWaitTimeout() is invoked, after return the system - * time, the counter and the returned message are tested. + * - The current system time is read then a sleep is performed for 100 system + * ticks and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100000 + * microseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 100 + * milliseconds and on exit the system time is verified again. + * - The current system time is read then a sleep is performed for 1 + * second and on exit the system time is verified again. * . */ -static void test_001_001_setup(void) { +static void test_000_001_execute(void) { + systime_t time; - chSemObjectInit(&sem1, 0); -} + /* The current system time is read then a sleep is performed for 100 system + ticks and on exit the system time is verified again.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + chThdSleep(100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + } -static void test_001_001_teardown(void) { + /* The current system time is read then a sleep is performed for 100000 + microseconds and on exit the system time is verified again.*/ + test_set_step(2); + { + time = chVTGetSystemTimeX(); + chThdSleepMicroseconds(100); + test_assert_time_window(time + US2ST(100), + time + US2ST(100) + 1, + "out of time window"); + } - chSemReset(&sem1, 0); -} + /* The current system time is read then a sleep is performed for 100 + milliseconds and on exit the system time is verified again.*/ + test_set_step(3); + { + time = chVTGetSystemTimeX(); + chThdSleepMilliseconds(100); + test_assert_time_window(time + MS2ST(100), + time + MS2ST(100) + 1, + "out of time window"); + } -static void test_001_001_execute(void) { - systime_t time; - msg_t msg; + /* The current system time is read then a sleep is performed for 1 + second and on exit the system time is verified again.*/ + test_set_step(4); + { + time = chVTGetSystemTimeX(); + chThdSleepSeconds(1); + test_assert_time_window(time + S2ST(1), + time + S2ST(1) + 1, + "out of time window"); + } - /* The function chSemWaitTimeout() is invoked, after return the system - time, the counter and the returned message are tested.*/ - test_set_step(1); + test_set_step(5); { time = chVTGetSystemTimeX(); - msg = chSemWaitTimeout(&sem1, 100); + chThdSleepUntil(time + 100); test_assert_time_window(time + 100, time + 100 + 1, "out of time window"); - test_assert_lock(chSemGetCounterI(&sem1) == 0, - "wrong counter value"); - test_assert(MSG_TIMEOUT == msg, - "wrong timeout message"); } } -static const testcase_t test_001_001 = { - "Brief description", - test_001_001_setup, - test_001_001_teardown, - test_001_001_execute +static const testcase_t test_000_001 = { + "Thread Sleep functionality", + NULL, + NULL, + test_000_001_execute }; #endif /* TRUE */ @@ -171,12 +172,12 @@ static const testcase_t test_001_001 = { /** * @brief Sequence brief description. */ -const testcase_t * const test_sequence_001[] = { +const testcase_t * const test_sequence_000[] = { #if TRUE || defined(__DOXYGEN__) - &test_001_000, + &test_000_000, #endif #if TRUE || defined(__DOXYGEN__) - &test_001_001, + &test_000_001, #endif NULL }; diff --git a/test/nil/test_sequence_001.h b/test/nil/test_sequence_001.h index 47ae8315b..72aaaf374 100644 --- a/test/nil/test_sequence_001.h +++ b/test/nil/test_sequence_001.h @@ -14,9 +14,9 @@ limitations under the License. */ -#ifndef _TEST_SEQUENCE_001_H_ -#define _TEST_SEQUENCE_001_H_ +#ifndef _TEST_SEQUENCE_000_H_ +#define _TEST_SEQUENCE_000_H_ -extern const testcase_t * const test_sequence_001[]; +extern const testcase_t * const test_sequence_000[]; -#endif /* _TEST_SEQUENCE_001_H_ */ +#endif /* _TEST_SEQUENCE_000_H_ */ diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c new file mode 100644 index 000000000..0157541d5 --- /dev/null +++ b/test/nil/test_sequence_002.c @@ -0,0 +1,182 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_001 Semaphores functionality + * + * File: @ref test_sequence_001.c + * + *

Description

+ * This sequence tests the ChibiOS/NIL functionalities related to semaphores. + * + *

Test Cases

+ * - @subpage test_001_000 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +static semaphore_t sem1; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_001_000 Semaphores primitives, no state change + * + *

Description

+ * Wait, Signal and Reset primitives are tested. The testing thread does not + * trigger a state change. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chSemWait() is invoked, the Semaphore counter is tested + * for correct value after the call. + * - The function chSemSignal() is invoked, the Semaphore counter is tested + * for correct value after the call. + * - The function chSemReset() is invoked, the Semaphore counter is tested + * for correct value after the call. + * . + */ + +static void test_001_000_setup(void) { + + chSemObjectInit(&sem1, 1); +} + +static void test_001_000_teardown(void) { + + chSemReset(&sem1, 0); +} + +static void test_001_000_execute(void) { + + /* The function chSemWait() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(1); + { + chSemWait(&sem1); + test_assert_lock(chSemGetCounterI(&sem1) == 0, + "wrong counter value"); + } + + /* The function chSemSignal() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(2); + { + chSemSignal(&sem1); + test_assert_lock(chSemGetCounterI(&sem1) == 1, + "wrong counter value"); + } + + /* The function chSemReset() is invoked, the Semaphore counter is tested + for correct value after the call.*/ + test_set_step(3); + { + chSemReset(&sem1, 2); + test_assert_lock(chSemGetCounterI(&sem1) == 2, + "wrong counter value"); + } +} + +static const testcase_t test_001_000 = { + "Brief description", + test_001_000_setup, + test_001_000_teardown, + test_001_000_execute +}; +#endif /* TRUE */ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_001_000 Semaphores timeout + * + *

Description

+ * Timeouts on semaphores are tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chSemWaitTimeout() is invoked, after return the system + * time, the counter and the returned message are tested. + * . + */ + +static void test_001_001_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void test_001_001_teardown(void) { + + chSemReset(&sem1, 0); +} + +static void test_001_001_execute(void) { + systime_t time; + msg_t msg; + + /* The function chSemWaitTimeout() is invoked, after return the system + time, the counter and the returned message are tested.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + msg = chSemWaitTimeout(&sem1, 100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + test_assert_lock(chSemGetCounterI(&sem1) == 0, + "wrong counter value"); + test_assert(MSG_TIMEOUT == msg, + "wrong timeout message"); + } +} + +static const testcase_t test_001_001 = { + "Brief description", + test_001_001_setup, + test_001_001_teardown, + test_001_001_execute +}; +#endif /* TRUE */ + + /**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Sequence brief description. + */ +const testcase_t * const test_sequence_001[] = { +#if TRUE || defined(__DOXYGEN__) + &test_001_000, +#endif +#if TRUE || defined(__DOXYGEN__) + &test_001_001, +#endif + NULL +}; diff --git a/test/nil/test_sequence_002.h b/test/nil/test_sequence_002.h new file mode 100644 index 000000000..47ae8315b --- /dev/null +++ b/test/nil/test_sequence_002.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TEST_SEQUENCE_001_H_ +#define _TEST_SEQUENCE_001_H_ + +extern const testcase_t * const test_sequence_001[]; + +#endif /* _TEST_SEQUENCE_001_H_ */ -- cgit v1.2.3 From 7f3221216d3e50c69db7d3f08595db7cfccd4424 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 10 Feb 2014 15:47:18 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6698 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/templates/test_sequence_XXX.c | 26 +++++++++--------- test/nil/test.mk | 4 +-- test/nil/test_root.c | 2 +- test/nil/test_root.h | 2 +- test/nil/test_sequence_001.c | 30 ++++++++++----------- test/nil/test_sequence_001.h | 8 +++--- test/nil/test_sequence_002.c | 49 +++++++++++++++++----------------- test/nil/test_sequence_002.h | 8 +++--- 8 files changed, 65 insertions(+), 64 deletions(-) (limited to 'test') diff --git a/test/lib/templates/test_sequence_XXX.c b/test/lib/templates/test_sequence_XXX.c index 6ff377e94..af16e544e 100644 --- a/test/lib/templates/test_sequence_XXX.c +++ b/test/lib/templates/test_sequence_XXX.c @@ -27,7 +27,7 @@ * Sequence detailed description. * *

Test Cases

- * - @subpage test_XXX_000 + * - @subpage test_XXX_001 * . */ @@ -42,7 +42,7 @@ #if TEST_XXX_000_CONDITION || defined(__DOXYGEN__) /** - * @page test_XXX_000 Brief description + * @page test_XXX_001 Brief description * *

Description

* Detailed description. @@ -50,7 +50,7 @@ *

Conditions

* This test is only executed if the following preprocessor condition * evaluates to true: - * - TEST_XXX_000_CONDITION + * - TEST_XXX_001_CONDITION * . * *

Test Steps

@@ -58,15 +58,15 @@ * . */ -static void test_XXX_000_setup(void) { +static void test_XXX_001_setup(void) { } -static void test_XXX_000_teardown(void) { +static void test_XXX_001_teardown(void) { } -static void test_XXX_000_execute(void) { +static void test_XXX_001_execute(void) { /* Step description.*/ test_set_step(1); @@ -74,13 +74,13 @@ static void test_XXX_000_execute(void) { } } -static const testcase_t test_XXX_000 = { +static const testcase_t test_XXX_001 = { "Brief description", - test_XXX_000_setup, - test_XXX_000_teardown, - test_XXX_000_execute + test_XXX_001_setup, + test_XXX_001_teardown, + test_XXX_001_execute }; -#endif /* TEST_XXX_000_CONDITION */ +#endif /* TEST_XXX_001_CONDITION */ /**************************************************************************** * Exported data. @@ -90,8 +90,8 @@ static const testcase_t test_XXX_000 = { * @brief Sequence brief description. */ const testcase_t * const test_sequence_XXX[] = { -#if TEST_XXX_000_CONDITION || defined(__DOXYGEN__) - &test_XXX_000, +#if TEST_XXX_001_CONDITION || defined(__DOXYGEN__) + &test_XXX_001, #endif NULL }; diff --git a/test/nil/test.mk b/test/nil/test.mk index 1cb5641cf..b0da9731a 100644 --- a/test/nil/test.mk +++ b/test/nil/test.mk @@ -1,8 +1,8 @@ # List of all the ChibiOS/RT test files. TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ ${CHIBIOS}/test/nil/test_root.c \ - ${CHIBIOS}/test/nil/test_sequence_000.c \ - ${CHIBIOS}/test/nil/test_sequence_001.c + ${CHIBIOS}/test/nil/test_sequence_001.c \ + ${CHIBIOS}/test/nil/test_sequence_002.c # Required include directories TESTINC = ${CHIBIOS}/test/lib \ diff --git a/test/nil/test_root.c b/test/nil/test_root.c index 94f88f2a4..fb835b88d 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -34,8 +34,8 @@ * @brief Array of all the test sequences. */ const testcase_t * const *test_suite[] = { - test_sequence_000, test_sequence_001, + test_sequence_002, NULL }; diff --git a/test/nil/test_root.h b/test/nil/test_root.h index 58e0790a4..0d000c415 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -27,8 +27,8 @@ #include "nil.h" -#include "test_sequence_000.h" #include "test_sequence_001.h" +#include "test_sequence_002.h" /*===========================================================================*/ /* Default definitions. */ diff --git a/test/nil/test_sequence_001.c b/test/nil/test_sequence_001.c index 6d1dede6c..7d967ef0d 100644 --- a/test/nil/test_sequence_001.c +++ b/test/nil/test_sequence_001.c @@ -19,16 +19,16 @@ #include "test_root.h" /** - * @page test_sequence_000 Threads Functionality + * @page test_sequence_001 Threads Functionality * - * File: @ref test_sequence_000.c + * File: @ref test_sequence_001.c * *

Description

* This sequence tests the ChibiOS/NIL functionalities related to threading. * *

Test Cases

- * - @subpage test_000_000 - * - @subpage test_000_001 + * - @subpage test_001_001 + * - @subpage test_001_002 * . */ @@ -43,7 +43,7 @@ #if TRUE || defined(__DOXYGEN__) /** - * @page test_000_000 System Tick Counter functionality + * @page test_001_001 System Tick Counter functionality * *

Description

* The functionality of the API @p chVTGetSystemTimeX() is tested. @@ -57,7 +57,7 @@ * . */ -static void test_000_000_execute(void) { +static void test_001_001_execute(void) { systime_t time; /* A System Tick Counter increment is expected, the test simply hangs if @@ -70,17 +70,17 @@ static void test_000_000_execute(void) { } } -static const testcase_t test_000_000 = { +static const testcase_t test_001_001 = { "System Tick Counter functionality", NULL, NULL, - test_000_000_execute + test_001_001_execute }; #endif /* TRUE */ #if TRUE || defined(__DOXYGEN__) /** - * @page test_000_001 Thread Sleep functionality + * @page test_001_002 Thread Sleep functionality * *

Description

* The functionality of the API @p chThdSleep() and derivatives is tested. @@ -100,7 +100,7 @@ static const testcase_t test_000_000 = { * . */ -static void test_000_001_execute(void) { +static void test_001_002_execute(void) { systime_t time; /* The current system time is read then a sleep is performed for 100 system @@ -157,11 +157,11 @@ static void test_000_001_execute(void) { } } -static const testcase_t test_000_001 = { +static const testcase_t test_001_002 = { "Thread Sleep functionality", NULL, NULL, - test_000_001_execute + test_001_002_execute }; #endif /* TRUE */ @@ -172,12 +172,12 @@ static const testcase_t test_000_001 = { /** * @brief Sequence brief description. */ -const testcase_t * const test_sequence_000[] = { +const testcase_t * const test_sequence_001[] = { #if TRUE || defined(__DOXYGEN__) - &test_000_000, + &test_001_001, #endif #if TRUE || defined(__DOXYGEN__) - &test_000_001, + &test_001_002, #endif NULL }; diff --git a/test/nil/test_sequence_001.h b/test/nil/test_sequence_001.h index 72aaaf374..47ae8315b 100644 --- a/test/nil/test_sequence_001.h +++ b/test/nil/test_sequence_001.h @@ -14,9 +14,9 @@ limitations under the License. */ -#ifndef _TEST_SEQUENCE_000_H_ -#define _TEST_SEQUENCE_000_H_ +#ifndef _TEST_SEQUENCE_001_H_ +#define _TEST_SEQUENCE_001_H_ -extern const testcase_t * const test_sequence_000[]; +extern const testcase_t * const test_sequence_001[]; -#endif /* _TEST_SEQUENCE_000_H_ */ +#endif /* _TEST_SEQUENCE_001_H_ */ diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c index 0157541d5..cc9f03b08 100644 --- a/test/nil/test_sequence_002.c +++ b/test/nil/test_sequence_002.c @@ -19,15 +19,16 @@ #include "test_root.h" /** - * @page test_sequence_001 Semaphores functionality + * @page test_sequence_002 Semaphores functionality * - * File: @ref test_sequence_001.c + * File: @ref test_sequence_002.c * *

Description

* This sequence tests the ChibiOS/NIL functionalities related to semaphores. * *

Test Cases

- * - @subpage test_001_000 + * - @subpage test_002_001 + * - @subpage test_002_002 * . */ @@ -43,7 +44,7 @@ static semaphore_t sem1; #if TRUE || defined(__DOXYGEN__) /** - * @page test_001_000 Semaphores primitives, no state change + * @page test_002_001 Semaphore primitives, no state change * *

Description

* Wait, Signal and Reset primitives are tested. The testing thread does not @@ -62,17 +63,17 @@ static semaphore_t sem1; * . */ -static void test_001_000_setup(void) { +static void test_002_001_setup(void) { chSemObjectInit(&sem1, 1); } -static void test_001_000_teardown(void) { +static void test_002_001_teardown(void) { chSemReset(&sem1, 0); } -static void test_001_000_execute(void) { +static void test_002_001_execute(void) { /* The function chSemWait() is invoked, the Semaphore counter is tested for correct value after the call.*/ @@ -102,17 +103,17 @@ static void test_001_000_execute(void) { } } -static const testcase_t test_001_000 = { - "Brief description", - test_001_000_setup, - test_001_000_teardown, - test_001_000_execute +static const testcase_t test_002_001 = { + "semaphore primitives, no state change", + test_002_001_setup, + test_002_001_teardown, + test_002_001_execute }; #endif /* TRUE */ #if TRUE || defined(__DOXYGEN__) /** - * @page test_001_000 Semaphores timeout + * @page test_002_002 Semaphore timeouts * *

Description

* Timeouts on semaphores are tested. @@ -126,17 +127,17 @@ static const testcase_t test_001_000 = { * . */ -static void test_001_001_setup(void) { +static void test_002_002_setup(void) { chSemObjectInit(&sem1, 0); } -static void test_001_001_teardown(void) { +static void test_002_002_teardown(void) { chSemReset(&sem1, 0); } -static void test_001_001_execute(void) { +static void test_002_002_execute(void) { systime_t time; msg_t msg; @@ -156,11 +157,11 @@ static void test_001_001_execute(void) { } } -static const testcase_t test_001_001 = { - "Brief description", - test_001_001_setup, - test_001_001_teardown, - test_001_001_execute +static const testcase_t test_002_002 = { + "semaphore timeouts", + test_002_002_setup, + test_002_002_teardown, + test_002_002_execute }; #endif /* TRUE */ @@ -171,12 +172,12 @@ static const testcase_t test_001_001 = { /** * @brief Sequence brief description. */ -const testcase_t * const test_sequence_001[] = { +const testcase_t * const test_sequence_002[] = { #if TRUE || defined(__DOXYGEN__) - &test_001_000, + &test_002_001, #endif #if TRUE || defined(__DOXYGEN__) - &test_001_001, + &test_002_002, #endif NULL }; diff --git a/test/nil/test_sequence_002.h b/test/nil/test_sequence_002.h index 47ae8315b..e72d037e3 100644 --- a/test/nil/test_sequence_002.h +++ b/test/nil/test_sequence_002.h @@ -14,9 +14,9 @@ limitations under the License. */ -#ifndef _TEST_SEQUENCE_001_H_ -#define _TEST_SEQUENCE_001_H_ +#ifndef _TEST_SEQUENCE_002_H_ +#define _TEST_SEQUENCE_002_H_ -extern const testcase_t * const test_sequence_001[]; +extern const testcase_t * const test_sequence_002[]; -#endif /* _TEST_SEQUENCE_001_H_ */ +#endif /* _TEST_SEQUENCE_002_H_ */ -- cgit v1.2.3 From 47f0e8fb7f337b65f848bf4cd59577d3967d0862 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 11 Feb 2014 09:21:53 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6699 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/lib/ch_test.h | 6 ++ test/nil/test_root.c | 27 +++++++++ test/nil/test_root.h | 3 + test/nil/test_sequence_002.c | 135 +++++++++++++++++++++++++++++++++++-------- 4 files changed, 147 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/lib/ch_test.h b/test/lib/ch_test.h index c8e03490c..2795f48dc 100644 --- a/test/lib/ch_test.h +++ b/test/lib/ch_test.h @@ -181,6 +181,12 @@ extern "C" { /* Module inline functions. */ /*===========================================================================*/ +/*===========================================================================*/ +/* Late inclusions. */ +/*===========================================================================*/ + +#include "test_root.h" + #endif /* _CH_TEST_H_ */ /** @} */ diff --git a/test/nil/test_root.c b/test/nil/test_root.c index fb835b88d..cd3c8b681 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -43,4 +43,31 @@ const testcase_t * const *test_suite[] = { /* Shared code. */ /*===========================================================================*/ +semaphore_t gsem1, gsem2; + +/* + * Support thread. + */ +THD_WORKING_AREA(wa_test_support, 128); +THD_FUNCTION(test_support, arg) { + + (void)arg; + + /* Initializing global resources.*/ + chSemObjectInit(&gsem1, 0); + chSemObjectInit(&gsem2, 0); + + /* Waiting for button push and activation of the test suite.*/ + while (true) { + chSysLock(); + if (chSemGetCounterI(&gsem1) < 0) + chSemSignalI(&gsem1); + chSemResetI(&gsem2, 0); + chSchRescheduleS(); + chSysUnlock(); + + chThdSleepMilliseconds(500); + } +} + /** @} */ diff --git a/test/nil/test_root.h b/test/nil/test_root.h index 0d000c415..51a100922 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -47,6 +47,9 @@ extern const testcase_t * const *test_suite[]; #ifdef __cplusplus extern "C" { #endif + extern semaphore_t gsem1, gsem2; + extern THD_WORKING_AREA(wa_test_support, 128); + THD_FUNCTION(test_support, arg); #ifdef __cplusplus } #endif diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c index cc9f03b08..9fa425c18 100644 --- a/test/nil/test_sequence_002.c +++ b/test/nil/test_sequence_002.c @@ -19,12 +19,13 @@ #include "test_root.h" /** - * @page test_sequence_002 Semaphores functionality + * @page test_sequence_002 Synchronization primitives * * File: @ref test_sequence_002.c * *

Description

- * This sequence tests the ChibiOS/NIL functionalities related to semaphores. + * This sequence tests the ChibiOS/NIL functionalities related to + * threads synchronization. * *

Test Cases

* - @subpage test_002_001 @@ -54,12 +55,12 @@ static semaphore_t sem1; * None. * *

Test Steps

- * - The function chSemWait() is invoked, the Semaphore counter is tested - * for correct value after the call. - * - The function chSemSignal() is invoked, the Semaphore counter is tested - * for correct value after the call. - * - The function chSemReset() is invoked, the Semaphore counter is tested - * for correct value after the call. + * - The function chSemWait() is invoked, after return the counter and + * the returned message are tested. + * - The function chSemSignal() is invoked, after return the counter + * is tested. + * - The function chSemReset() is invoked, after return the counter + * is tested. * . */ @@ -75,17 +76,21 @@ static void test_002_001_teardown(void) { static void test_002_001_execute(void) { - /* The function chSemWait() is invoked, the Semaphore counter is tested - for correct value after the call.*/ + /* The function chSemWait() is invoked, after return the counter and + the returned message are tested.*/ test_set_step(1); { - chSemWait(&sem1); + msg_t msg; + + msg = chSemWait(&sem1); test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value"); + test_assert(MSG_OK == msg, + "wrong timeout message"); } - /* The function chSemSignal() is invoked, the Semaphore counter is tested - for correct value after the call.*/ + /* The function chSemSignal() is invoked, after return the counter + is tested.*/ test_set_step(2); { chSemSignal(&sem1); @@ -93,8 +98,8 @@ static void test_002_001_execute(void) { "wrong counter value"); } - /* The function chSemReset() is invoked, the Semaphore counter is tested - for correct value after the call.*/ + /* The function chSemReset() is invoked, after return the counter + is tested.*/ test_set_step(3); { chSemReset(&sem1, 2); @@ -113,17 +118,16 @@ static const testcase_t test_002_001 = { #if TRUE || defined(__DOXYGEN__) /** - * @page test_002_002 Semaphore timeouts + * @page test_002_002 Semaphore primitives, with state change * *

Description

- * Timeouts on semaphores are tested. + * Wait, Signal and Reset primitives are tested. The testing thread + * triggers a state change. * *

Conditions

* None. * *

Test Steps

- * - The function chSemWaitTimeout() is invoked, after return the system - * time, the counter and the returned message are tested. * . */ @@ -138,6 +142,71 @@ static void test_002_002_teardown(void) { } static void test_002_002_execute(void) { + + /* The function chSemWait() is invoked, after return the counter and + the returned message are tested. The semaphore is signaled by another + thread.*/ + test_set_step(1); + { + msg_t msg; + + msg = chSemWait(&gsem1); + test_assert_lock(chSemGetCounterI(&gsem1) == 0, + "wrong counter value"); + test_assert(MSG_OK == msg, + "wrong timeout message"); + } + + /* The function chSemWait() is invoked, after return the counter and + the returned message are tested. The semaphore is reset by another + thread.*/ + test_set_step(2); + { + msg_t msg; + + msg = chSemWait(&gsem2); + test_assert_lock(chSemGetCounterI(&gsem2) == 0, + "wrong counter value"); + test_assert(MSG_RESET == msg, + "wrong timeout message"); + } +} + +static const testcase_t test_002_002 = { + "semaphore primitives, with state change", + test_002_002_setup, + test_002_002_teardown, + test_002_002_execute +}; +#endif /* TRUE */ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_002_003 Semaphores timeout + * + *

Description

+ * Timeout on semaphores is tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chSemWaitTimeout() is invoked, after return the system + * time, the counter and the returned message are tested. + * . + */ + +static void test_002_003_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void test_002_003_teardown(void) { + + chSemReset(&sem1, 0); +} + +static void test_002_003_execute(void) { systime_t time; msg_t msg; @@ -155,13 +224,28 @@ static void test_002_002_execute(void) { test_assert(MSG_TIMEOUT == msg, "wrong timeout message"); } + + /* The function chSemWait() is invoked, after return the system + time, the counter and the returned message are tested.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + msg = chSemWaitTimeout(&sem1, 100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + test_assert_lock(chSemGetCounterI(&sem1) == 0, + "wrong counter value"); + test_assert(MSG_TIMEOUT == msg, + "wrong timeout message"); + } } -static const testcase_t test_002_002 = { - "semaphore timeouts", - test_002_002_setup, - test_002_002_teardown, - test_002_002_execute +static const testcase_t test_002_003 = { + "semaphores timeout", + test_002_003_setup, + test_002_003_teardown, + test_002_003_execute }; #endif /* TRUE */ @@ -178,6 +262,9 @@ const testcase_t * const test_sequence_002[] = { #endif #if TRUE || defined(__DOXYGEN__) &test_002_002, +#endif +#if TRUE || defined(__DOXYGEN__) + &test_002_003, #endif NULL }; -- cgit v1.2.3 From 4541bd732acf21e30f40f5b6c991172e2e350cb0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 11 Feb 2014 09:59:20 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6700 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test_root.c | 2 + test/nil/test_root.h | 1 + test/nil/test_sequence_002.c | 87 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/nil/test_root.c b/test/nil/test_root.c index cd3c8b681..49c1d7862 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -44,6 +44,7 @@ const testcase_t * const *test_suite[] = { /*===========================================================================*/ semaphore_t gsem1, gsem2; +thread_reference_t gtr1; /* * Support thread. @@ -63,6 +64,7 @@ THD_FUNCTION(test_support, arg) { if (chSemGetCounterI(&gsem1) < 0) chSemSignalI(&gsem1); chSemResetI(&gsem2, 0); + chThdResumeI(>r1, MSG_OK); chSchRescheduleS(); chSysUnlock(); diff --git a/test/nil/test_root.h b/test/nil/test_root.h index 51a100922..f3ae952d6 100644 --- a/test/nil/test_root.h +++ b/test/nil/test_root.h @@ -48,6 +48,7 @@ extern const testcase_t * const *test_suite[]; extern "C" { #endif extern semaphore_t gsem1, gsem2; + extern thread_reference_t gtr1; extern THD_WORKING_AREA(wa_test_support, 128); THD_FUNCTION(test_support, arg); #ifdef __cplusplus diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c index 9fa425c18..ddb6379ff 100644 --- a/test/nil/test_sequence_002.c +++ b/test/nil/test_sequence_002.c @@ -38,6 +38,7 @@ ****************************************************************************/ static semaphore_t sem1; +static thread_reference_t tr1; /**************************************************************************** * Test cases. @@ -86,7 +87,7 @@ static void test_002_001_execute(void) { test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value"); test_assert(MSG_OK == msg, - "wrong timeout message"); + "wrong returned message"); } /* The function chSemSignal() is invoked, after return the counter @@ -128,6 +129,12 @@ static const testcase_t test_002_001 = { * None. * *

Test Steps

+ * - The function chSemWait() is invoked, after return the counter and + * the returned message are tested. The semaphore is signaled by another + * thread. + * - The function chSemWait() is invoked, after return the counter and + * the returned message are tested. The semaphore is reset by another + * thread. * . */ @@ -154,7 +161,7 @@ static void test_002_002_execute(void) { test_assert_lock(chSemGetCounterI(&gsem1) == 0, "wrong counter value"); test_assert(MSG_OK == msg, - "wrong timeout message"); + "wrong returned message"); } /* The function chSemWait() is invoked, after return the counter and @@ -168,7 +175,7 @@ static void test_002_002_execute(void) { test_assert_lock(chSemGetCounterI(&gsem2) == 0, "wrong counter value"); test_assert(MSG_RESET == msg, - "wrong timeout message"); + "wrong returned message"); } } @@ -225,9 +232,9 @@ static void test_002_003_execute(void) { "wrong timeout message"); } - /* The function chSemWait() is invoked, after return the system + /* The function chSemWaitTimeout() is invoked, after return the system time, the counter and the returned message are tested.*/ - test_set_step(1); + test_set_step(2); { time = chVTGetSystemTimeX(); msg = chSemWaitTimeout(&sem1, 100); @@ -247,6 +254,73 @@ static const testcase_t test_002_003 = { test_002_003_teardown, test_002_003_execute }; +#endif /* TRUE */ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_002_004 Suspend and Resume functionality + * + *

Description

+ * The functionality of chThdSuspendTimeoutS() and chThdResumeI() is + * tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - The function chThdSuspendTimeoutS() is invoked, the thread is + * remotely resumed with message @p MSG_OK. On return the message + * and the state of the reference are tested. + * - The function chThdSuspendTimeoutS() is invoked, the thread is + * not resumed so a timeout must occur. On return the message + * and the state of the reference are tested. + * . + */ + +static void test_002_004_setup(void) { + + tr1 = NULL; +} + +static void test_002_004_execute(void) { + systime_t time; + msg_t msg; + + /* The function chThdSuspendTimeoutS() is invoked, the thread is + remotely resumed with message @p MSG_OK. On return the message + and the state of the reference are tested.*/ + test_set_step(1); + { + msg = chThdSuspendTimeoutS(>r1, TIME_INFINITE); + test_assert(NULL == gtr1, + "not NULL"); + test_assert(MSG_OK == msg, + "wrong returned message"); + } + + /* The function chThdSuspendTimeoutS() is invoked, the thread is + not resumed so a timeout must occur. On return the message + and the state of the reference are tested.*/ + test_set_step(2); + { + time = chVTGetSystemTimeX(); + msg = chThdSuspendTimeoutS(>r1, 100); + test_assert_time_window(time + 100, + time + 100 + 1, + "out of time window"); + test_assert(NULL == gtr1, + "not NULL"); + test_assert(MSG_TIMEOUT == msg, + "wrong returned message"); + } +} + +static const testcase_t test_002_004 = { + "suspend and resume functionality", + test_002_004_setup, + NULL, + test_002_004_execute +}; #endif /* TRUE */ /**************************************************************************** @@ -265,6 +339,9 @@ const testcase_t * const test_sequence_002[] = { #endif #if TRUE || defined(__DOXYGEN__) &test_002_003, +#endif +#if TRUE || defined(__DOXYGEN__) + &test_002_004, #endif NULL }; -- cgit v1.2.3 From 7f3e0e57b2a13aa4797a8409e6e63671cb6d6993 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 11 Feb 2014 13:00:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6701 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/test_root.c | 6 +-- test/nil/test_sequence_002.c | 108 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 101 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/nil/test_root.c b/test/nil/test_root.c index 49c1d7862..a8efacba7 100644 --- a/test/nil/test_root.c +++ b/test/nil/test_root.c @@ -51,8 +51,7 @@ thread_reference_t gtr1; */ THD_WORKING_AREA(wa_test_support, 128); THD_FUNCTION(test_support, arg) { - - (void)arg; + thread_t *tp = (thread_t *)arg; /* Initializing global resources.*/ chSemObjectInit(&gsem1, 0); @@ -65,10 +64,11 @@ THD_FUNCTION(test_support, arg) { chSemSignalI(&gsem1); chSemResetI(&gsem2, 0); chThdResumeI(>r1, MSG_OK); + chEvtSignalI(tp, 0x55); chSchRescheduleS(); chSysUnlock(); - chThdSleepMilliseconds(500); + chThdSleepMilliseconds(250); } } diff --git a/test/nil/test_sequence_002.c b/test/nil/test_sequence_002.c index ddb6379ff..a687e7f0f 100644 --- a/test/nil/test_sequence_002.c +++ b/test/nil/test_sequence_002.c @@ -222,9 +222,9 @@ static void test_002_003_execute(void) { test_set_step(1); { time = chVTGetSystemTimeX(); - msg = chSemWaitTimeout(&sem1, 100); - test_assert_time_window(time + 100, - time + 100 + 1, + msg = chSemWaitTimeout(&sem1, MS2ST(1000)); + test_assert_time_window(time + MS2ST(1000), + time + MS2ST(1000) + 1, "out of time window"); test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value"); @@ -237,9 +237,9 @@ static void test_002_003_execute(void) { test_set_step(2); { time = chVTGetSystemTimeX(); - msg = chSemWaitTimeout(&sem1, 100); - test_assert_time_window(time + 100, - time + 100 + 1, + msg = chSemWaitTimeout(&sem1, MS2ST(1000)); + test_assert_time_window(time + MS2ST(1000), + time + MS2ST(1000) + 1, "out of time window"); test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value"); @@ -304,11 +304,11 @@ static void test_002_004_execute(void) { test_set_step(2); { time = chVTGetSystemTimeX(); - msg = chThdSuspendTimeoutS(>r1, 100); - test_assert_time_window(time + 100, - time + 100 + 1, + msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000)); + test_assert_time_window(time + MS2ST(1000), + time + MS2ST(1000) + 1, "out of time window"); - test_assert(NULL == gtr1, + test_assert(NULL == tr1, "not NULL"); test_assert(MSG_TIMEOUT == msg, "wrong returned message"); @@ -321,6 +321,91 @@ static const testcase_t test_002_004 = { NULL, test_002_004_execute }; +#endif /* TRUE */ + +#if TRUE || defined(__DOXYGEN__) +/** + * @page test_002_005 Events functionality + * + *

Description

+ * Event flags functionality is tested. + * + *

Conditions

+ * None. + * + *

Test Steps

+ * - A set of event flags are set on the current thread then the + * function chVTGetSystemTimeX() is invoked, the function is supposed to + * return immediately because the event flags are already pending, + * after return the events mask is tested. + * - The pending event flags mask is cleared then the function + * chVTGetSystemTimeX() is invoked, after return the events + * mask is tested. The thread is signaled by another thread. + * - + * . The function chVTGetSystemTimeX() is invoked, no event can + * wakeup the thread, the function must return because timeout. + */ + +static void test_002_005_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void test_002_005_execute(void) { + systime_t time; + eventmask_t events; + + /* A set of event flags are set on the current thread then the + function chVTGetSystemTimeX() is invoked, the function is supposed to + return immediately because the event flags are already pending, + after return the events mask is tested.*/ + test_set_step(1); + { + time = chVTGetSystemTimeX(); + chEvtSignalI(chThdGetSelfX(), 0x55); + events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000)); + test_assert((eventmask_t)0 != events, + "timed out"); + test_assert((eventmask_t)0x55 == events, + "wrong events mask"); + } + + /* The pending event flags mask is cleared then the function + chVTGetSystemTimeX() is invoked, after return the events + mask is tested. The thread is signaled by another thread.*/ + test_set_step(2); + { + time = chVTGetSystemTimeX(); + chThdGetSelfX()->epmask = 0; + events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000)); + test_assert((eventmask_t)0 != events, + "timed out"); + test_assert((eventmask_t)0x55 == events, + "wrong events mask"); + } + + /* The function chVTGetSystemTimeX() is invoked, no event can + wakeup the thread, the function must return because timeout.*/ + test_set_step(3); + { + chSysLock(); + time = chVTGetSystemTimeX(); + events = chEvtWaitAnyTimeoutS(0, MS2ST(1000)); + chSysUnlock(); + test_assert_time_window(time + MS2ST(1000), + time + MS2ST(1000) + 1, + "out of time window"); + test_assert((eventmask_t)0 == events, + "wrong events mask"); + } +} + +static const testcase_t test_002_005 = { + "events functionality", + test_002_005_setup, + NULL, + test_002_005_execute +}; #endif /* TRUE */ /**************************************************************************** @@ -342,6 +427,9 @@ const testcase_t * const test_sequence_002[] = { #endif #if TRUE || defined(__DOXYGEN__) &test_002_004, +#endif +#if TRUE || defined(__DOXYGEN__) + &test_002_005, #endif NULL }; -- cgit v1.2.3 From 7a62416558fc56fdfcf45786102e60f1a314fe77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 11 Feb 2014 13:08:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6704 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/coverage/Makefile | 156 ---------- test/coverage/chconf.h | 532 -------------------------------- test/coverage/halconf.h | 312 ------------------- test/coverage/main.c | 51 ---- test/coverage/readme.txt | 6 - test/rt/coverage/Makefile | 156 ++++++++++ test/rt/coverage/chconf.h | 532 ++++++++++++++++++++++++++++++++ test/rt/coverage/halconf.h | 312 +++++++++++++++++++ test/rt/coverage/main.c | 51 ++++ test/rt/coverage/readme.txt | 6 + test/rt/test.c | 390 ++++++++++++++++++++++++ test/rt/test.dox | 82 +++++ test/rt/test.h | 173 +++++++++++ test/rt/test.mk | 16 + test/rt/testbmk.c | 715 ++++++++++++++++++++++++++++++++++++++++++++ test/rt/testbmk.h | 22 ++ test/rt/testdyn.c | 267 +++++++++++++++++ test/rt/testdyn.h | 22 ++ test/rt/testevt.c | 294 ++++++++++++++++++ test/rt/testevt.h | 22 ++ test/rt/testheap.c | 159 ++++++++++ test/rt/testheap.h | 22 ++ test/rt/testmbox.c | 239 +++++++++++++++ test/rt/testmbox.h | 22 ++ test/rt/testmsg.c | 108 +++++++ test/rt/testmsg.h | 22 ++ test/rt/testmtx.c | 636 +++++++++++++++++++++++++++++++++++++++ test/rt/testmtx.h | 22 ++ test/rt/testpools.c | 117 ++++++++ test/rt/testpools.h | 22 ++ test/rt/testqueues.c | 244 +++++++++++++++ test/rt/testqueues.h | 22 ++ test/rt/testsem.c | 299 ++++++++++++++++++ test/rt/testsem.h | 22 ++ test/rt/testthd.c | 231 ++++++++++++++ test/rt/testthd.h | 22 ++ test/test.c | 390 ------------------------ test/test.dox | 82 ----- test/test.h | 173 ----------- test/test.mk | 16 - test/testbmk.c | 715 -------------------------------------------- test/testbmk.h | 22 -- test/testdyn.c | 267 ----------------- test/testdyn.h | 22 -- test/testevt.c | 294 ------------------ test/testevt.h | 22 -- test/testheap.c | 159 ---------- test/testheap.h | 22 -- test/testmbox.c | 239 --------------- test/testmbox.h | 22 -- test/testmsg.c | 108 ------- test/testmsg.h | 22 -- test/testmtx.c | 636 --------------------------------------- test/testmtx.h | 22 -- test/testpools.c | 117 -------- test/testpools.h | 22 -- test/testqueues.c | 244 --------------- test/testqueues.h | 22 -- test/testsem.c | 299 ------------------ test/testsem.h | 22 -- test/testthd.c | 231 -------------- test/testthd.h | 22 -- 62 files changed, 5269 insertions(+), 5269 deletions(-) delete mode 100644 test/coverage/Makefile delete mode 100644 test/coverage/chconf.h delete mode 100644 test/coverage/halconf.h delete mode 100644 test/coverage/main.c delete mode 100644 test/coverage/readme.txt create mode 100644 test/rt/coverage/Makefile create mode 100644 test/rt/coverage/chconf.h create mode 100644 test/rt/coverage/halconf.h create mode 100644 test/rt/coverage/main.c create mode 100644 test/rt/coverage/readme.txt create mode 100644 test/rt/test.c create mode 100644 test/rt/test.dox create mode 100644 test/rt/test.h create mode 100644 test/rt/test.mk create mode 100644 test/rt/testbmk.c create mode 100644 test/rt/testbmk.h create mode 100644 test/rt/testdyn.c create mode 100644 test/rt/testdyn.h create mode 100644 test/rt/testevt.c create mode 100644 test/rt/testevt.h create mode 100644 test/rt/testheap.c create mode 100644 test/rt/testheap.h create mode 100644 test/rt/testmbox.c create mode 100644 test/rt/testmbox.h create mode 100644 test/rt/testmsg.c create mode 100644 test/rt/testmsg.h create mode 100644 test/rt/testmtx.c create mode 100644 test/rt/testmtx.h create mode 100644 test/rt/testpools.c create mode 100644 test/rt/testpools.h create mode 100644 test/rt/testqueues.c create mode 100644 test/rt/testqueues.h create mode 100644 test/rt/testsem.c create mode 100644 test/rt/testsem.h create mode 100644 test/rt/testthd.c create mode 100644 test/rt/testthd.h delete mode 100644 test/test.c delete mode 100644 test/test.dox delete mode 100644 test/test.h delete mode 100644 test/test.mk delete mode 100644 test/testbmk.c delete mode 100644 test/testbmk.h delete mode 100644 test/testdyn.c delete mode 100644 test/testdyn.h delete mode 100644 test/testevt.c delete mode 100644 test/testevt.h delete mode 100644 test/testheap.c delete mode 100644 test/testheap.h delete mode 100644 test/testmbox.c delete mode 100644 test/testmbox.h delete mode 100644 test/testmsg.c delete mode 100644 test/testmsg.h delete mode 100644 test/testmtx.c delete mode 100644 test/testmtx.h delete mode 100644 test/testpools.c delete mode 100644 test/testpools.h delete mode 100644 test/testqueues.c delete mode 100644 test/testqueues.h delete mode 100644 test/testsem.c delete mode 100644 test/testsem.h delete mode 100644 test/testthd.c delete mode 100644 test/testthd.h (limited to 'test') diff --git a/test/coverage/Makefile b/test/coverage/Makefile deleted file mode 100644 index d19014202..000000000 --- a/test/coverage/Makefile +++ /dev/null @@ -1,156 +0,0 @@ -# -# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!! -# -############################################################################################## -# -# On command line: -# -# make all = Create project -# -# make clean = Clean project files. -# -# To rebuild project do "make clean" and "make all". -# - -############################################################################################## -# Start of default section -# - -TRGT = mingw32- -CC = $(TRGT)gcc -AS = $(TRGT)gcc -x assembler-with-cpp -COV = gcov - -# List all default C defines here, like -D_DEBUG=1 -DDEFS = -DSIMULATOR - -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = - -# List all default directories to look for include files here -DINCDIR = - -# List the default directory to look for the libraries here -DLIBDIR = - -# List all default libraries here -DLIBS = -lws2_32 - -# Must be a directory in ${CHIBIOS}/os/hal/platforms -HOST_TYPE = Win32 - -# -# End of default section -############################################################################################## - -############################################################################################## -# Start of user section -# - -# Define project name here -PROJECT = ch - -# Define linker script file here -LDSCRIPT= - -# List all user C define here, like -D_DEBUG=1 -UDEFS = - -# Define ASM defines here -UADEFS = - -# Imported source files -CHIBIOS = ../.. -include $(CHIBIOS)/boards/simulator/board.mk -include ${CHIBIOS}/os/hal/hal.mk -include ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/platform.mk -include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk -include ${CHIBIOS}/os/kernel/kernel.mk -include ${CHIBIOS}/test/test.mk - -# List C source files here -SRC = ${PORTSRC} \ - ${KERNSRC} \ - ${TESTSRC} \ - ${HALSRC} \ - ${PLATFORMSRC} \ - $(BOARDSRC) \ - ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/console.c \ - main.c - -# List ASM source files here -ASRC = - -# List all user directories here -UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ - $(CHIBIOS)/os/various - -# List the user directory to look for the libraries here -ULIBDIR = - -# List all user libraries here -ULIBS = - -# Define optimisation level here -OPT = -ggdb -O0 -fomit-frame-pointer -fprofile-arcs -ftest-coverage - -# -# End of user defines -############################################################################################## - - -INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) -LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) -DEFS = $(DDEFS) $(UDEFS) -ADEFS = $(DADEFS) $(UADEFS) -OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) -LIBS = $(DLIBS) $(ULIBS) - -LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch -lgcov $(LIBDIR) -ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm -Wa,-alms=$(<:.c=.lst) $(DEFS) - -# Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d - -# -# makefile rules -# - -all: $(OBJS) $(PROJECT).exe - -%o : %c - $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ - -%o : %s - $(AS) -c $(ASFLAGS) $< -o $@ - -%exe: $(OBJS) - $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ - -.PHONY: gcov -gcov: - -mkdir gcov - $(COV) -u $(subst /,\,$(KERNSRC)) - -mv -f *.gcov ./gcov - -.PHONY: clean -clean: - -rm -f $(OBJS) - -rm -f $(PROJECT).exe - -rm -f $(PROJECT).map - -rm -f $(SRC:.c=.c.bak) - -rm -f $(SRC:.c=.lst) - -rm -f $(SRC:.c=.gcno) - -rm -f $(SRC:.c=.gcda) - -rm -f $(ASRC:.s=.s.bak) - -rm -f $(ASRC:.s=.lst) - -rm -fR .dep - -# -# Include the dependency files, should be the last of the makefile -# --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - -# *** EOF *** diff --git a/test/coverage/chconf.h b/test/coverage/chconf.h deleted file mode 100644 index 8b0f88662..000000000 --- a/test/coverage/chconf.h +++ /dev/null @@ -1,532 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/chconf.h - * @brief Configuration file template. - * @details A copy of this file must be placed in each project directory, it - * contains the application specific kernel settings. - * - * @addtogroup config - * @details Kernel related settings and hooks. - * @{ - */ - -#ifndef _CHCONF_H_ -#define _CHCONF_H_ - -/*===========================================================================*/ -/** - * @name Kernel parameters and options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief System tick frequency. - * @details Frequency of the system timer that drives the system ticks. This - * setting also defines the system tick time unit. - */ -#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) -#define CH_FREQUENCY 1000 -#endif - -/** - * @brief Round robin interval. - * @details This constant is the number of system ticks allowed for the - * threads before preemption occurs. Setting this value to zero - * disables the preemption for threads with equal priority and the - * round robin becomes cooperative. Note that higher priority - * threads can still preempt, the kernel is always preemptive. - * - * @note Disabling the round robin preemption makes the kernel more compact - * and generally faster. - */ -#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) -#define CH_TIME_QUANTUM 20 -#endif - -/** - * @brief Managed RAM size. - * @details Size of the RAM area to be managed by the OS. If set to zero - * then the whole available RAM is used. The core memory is made - * available to the heap allocator and/or can be used directly through - * the simplified core memory allocator. - * - * @note In order to let the OS manage the whole RAM the linker script must - * provide the @p __heap_base__ and @p __heap_end__ symbols. - * @note Requires @p CH_USE_MEMCORE. - */ -#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) -#define CH_MEMCORE_SIZE 0x20000 -#endif - -/** - * @brief Idle thread automatic spawn suppression. - * @details When this option is activated the function @p chSysInit() - * does not spawn the idle thread automatically. The application has - * then the responsibility to do one of the following: - * - Spawn a custom idle thread at priority @p IDLEPRIO. - * - Change the main() thread priority to @p IDLEPRIO then enter - * an endless loop. In this scenario the @p main() thread acts as - * the idle thread. - * . - * @note Unless an idle thread is spawned the @p main() thread must not - * enter a sleep state. - */ -#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__) -#define CH_NO_IDLE_THREAD FALSE -#endif - -/** @} */ - -/*===========================================================================*/ -/** - * @name Performance options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief OS optimization. - * @details If enabled then time efficient rather than space efficient code - * is used when two possible implementations exist. - * - * @note This is not related to the compiler optimization options. - * @note The default is @p TRUE. - */ -#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) -#define CH_OPTIMIZE_SPEED FALSE -#endif - -/** @} */ - -/*===========================================================================*/ -/** - * @name Subsystem options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Threads registry APIs. - * @details If enabled then the registry APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) -#define CH_USE_REGISTRY TRUE -#endif - -/** - * @brief Threads synchronization APIs. - * @details If enabled then the @p chThdWait() function is included in - * the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) -#define CH_USE_WAITEXIT TRUE -#endif - -/** - * @brief Semaphores APIs. - * @details If enabled then the Semaphores APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) -#define CH_USE_SEMAPHORES TRUE -#endif - -/** - * @brief Semaphores queuing mode. - * @details If enabled then the threads are enqueued on semaphores by - * priority rather than in FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special requirements. - * @note Requires @p CH_USE_SEMAPHORES. - */ -#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) -#define CH_USE_SEMAPHORES_PRIORITY FALSE -#endif - -/** - * @brief Atomic semaphore API. - * @details If enabled then the semaphores the @p chSemSignalWait() API - * is included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_SEMAPHORES. - */ -#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) -#define CH_USE_SEMSW TRUE -#endif - -/** - * @brief Mutexes APIs. - * @details If enabled then the mutexes APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) -#define CH_USE_MUTEXES TRUE -#endif - -/** - * @brief Conditional Variables APIs. - * @details If enabled then the conditional variables APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_MUTEXES. - */ -#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) -#define CH_USE_CONDVARS TRUE -#endif - -/** - * @brief Conditional Variables APIs with timeout. - * @details If enabled then the conditional variables APIs with timeout - * specification are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_CONDVARS. - */ -#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) -#define CH_USE_CONDVARS_TIMEOUT TRUE -#endif - -/** - * @brief Events Flags APIs. - * @details If enabled then the event flags APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) -#define CH_USE_EVENTS TRUE -#endif - -/** - * @brief Events Flags APIs with timeout. - * @details If enabled then the events APIs with timeout specification - * are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_EVENTS. - */ -#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) -#define CH_USE_EVENTS_TIMEOUT TRUE -#endif - -/** - * @brief Synchronous Messages APIs. - * @details If enabled then the synchronous messages APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) -#define CH_USE_MESSAGES TRUE -#endif - -/** - * @brief Synchronous Messages queuing mode. - * @details If enabled then messages are served by priority rather than in - * FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special requirements. - * @note Requires @p CH_USE_MESSAGES. - */ -#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) -#define CH_USE_MESSAGES_PRIORITY FALSE -#endif - -/** - * @brief Mailboxes APIs. - * @details If enabled then the asynchronous messages (mailboxes) APIs are - * included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_SEMAPHORES. - */ -#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) -#define CH_USE_MAILBOXES TRUE -#endif - -/** - * @brief I/O Queues APIs. - * @details If enabled then the I/O queues APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) -#define CH_USE_QUEUES TRUE -#endif - -/** - * @brief Core Memory Manager APIs. - * @details If enabled then the core memory manager APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) -#define CH_USE_MEMCORE TRUE -#endif - -/** - * @brief Heap Allocator APIs. - * @details If enabled then the memory heap allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or - * @p CH_USE_SEMAPHORES. - * @note Mutexes are recommended. - */ -#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) -#define CH_USE_HEAP TRUE -#endif - -/** - * @brief C-runtime allocator. - * @details If enabled the the heap allocator APIs just wrap the C-runtime - * @p malloc() and @p free() functions. - * - * @note The default is @p FALSE. - * @note Requires @p CH_USE_HEAP. - * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the - * appropriate documentation. - */ -#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) -#define CH_USE_MALLOC_HEAP FALSE -#endif - -/** - * @brief Memory Pools Allocator APIs. - * @details If enabled then the memory pools allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) -#define CH_USE_MEMPOOLS TRUE -#endif - -/** - * @brief Dynamic Threads APIs. - * @details If enabled then the dynamic threads creation APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_WAITEXIT. - * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. - */ -#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) -#define CH_USE_DYNAMIC TRUE -#endif - -/** @} */ - -/*===========================================================================*/ -/** - * @name Debug options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Debug option, system state check. - * @details If enabled the correct call protocol for system APIs is checked - * at runtime. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) -#define CH_DBG_SYSTEM_STATE_CHECK FALSE -#endif - -/** - * @brief Debug option, parameters checks. - * @details If enabled then the checks on the API functions input - * parameters are activated. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_CHECKS FALSE -#endif - -/** - * @brief Debug option, consistency checks. - * @details If enabled then all the assertions in the kernel code are - * activated. This includes consistency checks inside the kernel, - * runtime anomalies and port-defined checks. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_ASSERTS FALSE -#endif - -/** - * @brief Debug option, trace buffer. - * @details If enabled then the context switch circular trace buffer is - * activated. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_TRACE TRUE -#endif - -/** - * @brief Debug option, stack checks. - * @details If enabled then a runtime stack check is performed. - * - * @note The default is @p FALSE. - * @note The stack check is performed in a architecture/port dependent way. - * It may not be implemented or some ports. - * @note The default failure mode is to halt the system with the global - * @p panic_msg variable set to @p NULL. - */ -#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_STACK_CHECK FALSE -#endif - -/** - * @brief Debug option, stacks initialization. - * @details If enabled then the threads working area is filled with a byte - * value when a thread is created. This can be useful for the - * runtime measurement of the used stack. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) -#define CH_DBG_FILL_THREADS TRUE -#endif - -/** - * @brief Debug option, threads profiling. - * @details If enabled then a field is added to the @p Thread structure that - * counts the system ticks occurred while executing the thread. - * - * @note The default is @p TRUE. - * @note This debug option is defaulted to TRUE because it is required by - * some test cases into the test suite. - */ -#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) -#define CH_DBG_THREADS_PROFILING TRUE -#endif - -/** @} */ - -/*===========================================================================*/ -/** - * @name Kernel hooks - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Threads descriptor structure extension. - * @details User fields added to the end of the @p Thread structure. - */ -#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) -#define THREAD_EXT_FIELDS \ - /* Add threads custom fields here.*/ -#endif - -/** - * @brief Threads initialization hook. - * @details User initialization code added to the @p chThdInit() API. - * - * @note It is invoked from within @p chThdInit() and implicitly from all - * the threads creation APIs. - */ -#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__) -#define THREAD_EXT_INIT_HOOK(tp) { \ - /* Add threads initialization code here.*/ \ -} -#endif - -/** - * @brief Threads finalization hook. - * @details User finalization code added to the @p chThdExit() API. - * - * @note It is inserted into lock zone. - * @note It is also invoked when the threads simply return in order to - * terminate. - */ -#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__) -#define THREAD_EXT_EXIT_HOOK(tp) { \ - /* Add threads finalization code here.*/ \ -} -#endif - -/** - * @brief Context switch hook. - * @details This hook is invoked just before switching between threads. - */ -#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__) -#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \ - /* System halt code here.*/ \ -} -#endif - -/** - * @brief Idle Loop hook. - * @details This hook is continuously invoked by the idle thread loop. - */ -#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) -#define IDLE_LOOP_HOOK() { \ - /* Idle loop code here.*/ \ -} -#endif - -/** - * @brief System tick event hook. - * @details This hook is invoked in the system tick handler immediately - * after processing the virtual timers queue. - */ -#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__) -#define SYSTEM_TICK_EVENT_HOOK() { \ - /* System tick event code here.*/ \ -} -#endif - - -/** - * @brief System halt hook. - * @details This hook is invoked in case to a system halting error before - * the system is halted. - */ -#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) -#define SYSTEM_HALT_HOOK() { \ - /* System halt code here.*/ \ -} -#endif - -/** @} */ - -/*===========================================================================*/ -/* Port-specific settings (override port settings defaulted in chcore.h). */ -/*===========================================================================*/ - -#endif /* _CHCONF_H_ */ - -/** @} */ diff --git a/test/coverage/halconf.h b/test/coverage/halconf.h deleted file mode 100644 index 516a705a2..000000000 --- a/test/coverage/halconf.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/halconf.h - * @brief HAL configuration header. - * @details HAL configuration file, this file allows to enable or disable the - * various device drivers from your application. You may also use - * this file in order to override the device drivers default settings. - * - * @addtogroup HAL_CONF - * @{ - */ - -#ifndef _HALCONF_H_ -#define _HALCONF_H_ - -/*#include "mcuconf.h"*/ - -/** - * @brief Enables the TM subsystem. - */ -#if !defined(HAL_USE_TM) || defined(__DOXYGEN__) -#define HAL_USE_TM FALSE -#endif - -/** - * @brief Enables the PAL subsystem. - */ -#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL FALSE -#endif - -/** - * @brief Enables the ADC subsystem. - */ -#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -#define HAL_USE_ADC FALSE -#endif - -/** - * @brief Enables the CAN subsystem. - */ -#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -#define HAL_USE_CAN FALSE -#endif - -/** - * @brief Enables the EXT subsystem. - */ -#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) -#define HAL_USE_EXT FALSE -#endif - -/** - * @brief Enables the GPT subsystem. - */ -#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE -#endif - -/** - * @brief Enables the I2C subsystem. - */ -#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -#define HAL_USE_I2C FALSE -#endif - -/** - * @brief Enables the ICU subsystem. - */ -#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU FALSE -#endif - -/** - * @brief Enables the MAC subsystem. - */ -#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -#define HAL_USE_MAC FALSE -#endif - -/** - * @brief Enables the MMC_SPI subsystem. - */ -#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -#define HAL_USE_MMC_SPI FALSE -#endif - -/** - * @brief Enables the PWM subsystem. - */ -#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM FALSE -#endif - -/** - * @brief Enables the RTC subsystem. - */ -#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC FALSE -#endif - -/** - * @brief Enables the SDC subsystem. - */ -#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -#define HAL_USE_SDC FALSE -#endif - -/** - * @brief Enables the SERIAL subsystem. - */ -#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE -#endif - -/** - * @brief Enables the SERIAL over USB subsystem. - */ -#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL_USB FALSE -#endif - -/** - * @brief Enables the SPI subsystem. - */ -#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI FALSE -#endif - -/** - * @brief Enables the UART subsystem. - */ -#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -#define HAL_USE_UART FALSE -#endif - -/** - * @brief Enables the USB subsystem. - */ -#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -#define HAL_USE_USB FALSE -#endif - -/*===========================================================================*/ -/* ADC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -#define ADC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* CAN driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Sleep mode related APIs inclusion switch. - */ -#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -#define CAN_USE_SLEEP_MODE TRUE -#endif - -/*===========================================================================*/ -/* I2C driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the mutual exclusion APIs on the I2C bus. - */ -#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* MAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -#define MAC_USE_ZERO_COPY FALSE -#endif - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE -#endif - -/*===========================================================================*/ -/* MMC_SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SDC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Number of initialization attempts before rejecting the card. - * @note Attempts are performed at 10mS intervals. - */ -#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -#define SDC_INIT_RETRY 100 -#endif - -/** - * @brief Include support for MMC cards. - * @note MMC support is not yet implemented so this option must be kept - * at @p FALSE. - */ -#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -#define SDC_MMC_SUPPORT FALSE -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - */ -#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -#define SDC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SERIAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Default bit rate. - * @details Configuration parameter, this is the baud rate selected for the - * default configuration. - */ -#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 -#endif - -/** - * @brief Serial buffers size. - * @details Configuration parameter, you can change the depth of the queue - * buffers depending on the requirements of your application. - * @note The default is 64 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 -#endif - -/*===========================================================================*/ -/* SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE -#endif - -#endif /* _HALCONF_H_ */ - -/** @} */ diff --git a/test/coverage/main.c b/test/coverage/main.c deleted file mode 100644 index c4f257f0d..000000000 --- a/test/coverage/main.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include -#include -#include - -#include "ch.h" -#include "hal.h" -#include "test.h" -#include "console.h" - -/* - * Simulator main. - */ -int main(int argc, char *argv[]) { - msg_t result; - - (void)argc; - (void)argv; - - /* - * System initializations. - * - HAL initialization, this also initializes the configured device drivers - * and performs the board-specific initializations. - * - Kernel initialization, the main() function becomes a thread and the - * RTOS is active. - */ - halInit(); - conInit(); - chSysInit(); - - result = TestThread(&CD1); - if (result) - exit(1); - else - exit(0); -} diff --git a/test/coverage/readme.txt b/test/coverage/readme.txt deleted file mode 100644 index fc3595112..000000000 --- a/test/coverage/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -In order to compute the code coverage: - -- Build the test application: make -- Run the test suite: ch -- Compute the code coverage: make gcov -- Clear everything: make clean diff --git a/test/rt/coverage/Makefile b/test/rt/coverage/Makefile new file mode 100644 index 000000000..d19014202 --- /dev/null +++ b/test/rt/coverage/Makefile @@ -0,0 +1,156 @@ +# +# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!! +# +############################################################################################## +# +# On command line: +# +# make all = Create project +# +# make clean = Clean project files. +# +# To rebuild project do "make clean" and "make all". +# + +############################################################################################## +# Start of default section +# + +TRGT = mingw32- +CC = $(TRGT)gcc +AS = $(TRGT)gcc -x assembler-with-cpp +COV = gcov + +# List all default C defines here, like -D_DEBUG=1 +DDEFS = -DSIMULATOR + +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = + +# List all default directories to look for include files here +DINCDIR = + +# List the default directory to look for the libraries here +DLIBDIR = + +# List all default libraries here +DLIBS = -lws2_32 + +# Must be a directory in ${CHIBIOS}/os/hal/platforms +HOST_TYPE = Win32 + +# +# End of default section +############################################################################################## + +############################################################################################## +# Start of user section +# + +# Define project name here +PROJECT = ch + +# Define linker script file here +LDSCRIPT= + +# List all user C define here, like -D_DEBUG=1 +UDEFS = + +# Define ASM defines here +UADEFS = + +# Imported source files +CHIBIOS = ../.. +include $(CHIBIOS)/boards/simulator/board.mk +include ${CHIBIOS}/os/hal/hal.mk +include ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/platform.mk +include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk +include ${CHIBIOS}/os/kernel/kernel.mk +include ${CHIBIOS}/test/test.mk + +# List C source files here +SRC = ${PORTSRC} \ + ${KERNSRC} \ + ${TESTSRC} \ + ${HALSRC} \ + ${PLATFORMSRC} \ + $(BOARDSRC) \ + ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/console.c \ + main.c + +# List ASM source files here +ASRC = + +# List all user directories here +UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(PLATFORMINC) $(BOARDINC) \ + $(CHIBIOS)/os/various + +# List the user directory to look for the libraries here +ULIBDIR = + +# List all user libraries here +ULIBS = + +# Define optimisation level here +OPT = -ggdb -O0 -fomit-frame-pointer -fprofile-arcs -ftest-coverage + +# +# End of user defines +############################################################################################## + + +INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) +LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) +DEFS = $(DDEFS) $(UDEFS) +ADEFS = $(DADEFS) $(UADEFS) +OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) +LIBS = $(DLIBS) $(ULIBS) + +LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch -lgcov $(LIBDIR) +ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm -Wa,-alms=$(<:.c=.lst) $(DEFS) + +# Generate dependency information +CPFLAGS += -MD -MP -MF .dep/$(@F).d + +# +# makefile rules +# + +all: $(OBJS) $(PROJECT).exe + +%o : %c + $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ + +%o : %s + $(AS) -c $(ASFLAGS) $< -o $@ + +%exe: $(OBJS) + $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ + +.PHONY: gcov +gcov: + -mkdir gcov + $(COV) -u $(subst /,\,$(KERNSRC)) + -mv -f *.gcov ./gcov + +.PHONY: clean +clean: + -rm -f $(OBJS) + -rm -f $(PROJECT).exe + -rm -f $(PROJECT).map + -rm -f $(SRC:.c=.c.bak) + -rm -f $(SRC:.c=.lst) + -rm -f $(SRC:.c=.gcno) + -rm -f $(SRC:.c=.gcda) + -rm -f $(ASRC:.s=.s.bak) + -rm -f $(ASRC:.s=.lst) + -rm -fR .dep + +# +# Include the dependency files, should be the last of the makefile +# +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + +# *** EOF *** diff --git a/test/rt/coverage/chconf.h b/test/rt/coverage/chconf.h new file mode 100644 index 000000000..8b0f88662 --- /dev/null +++ b/test/rt/coverage/chconf.h @@ -0,0 +1,532 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef _CHCONF_H_ +#define _CHCONF_H_ + +/*===========================================================================*/ +/** + * @name Kernel parameters and options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System tick frequency. + * @details Frequency of the system timer that drives the system ticks. This + * setting also defines the system tick time unit. + */ +#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) +#define CH_FREQUENCY 1000 +#endif + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the preemption for threads with equal priority and the + * round robin becomes cooperative. Note that higher priority + * threads can still preempt, the kernel is always preemptive. + * + * @note Disabling the round robin preemption makes the kernel more compact + * and generally faster. + */ +#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) +#define CH_TIME_QUANTUM 20 +#endif + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_USE_MEMCORE. + */ +#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) +#define CH_MEMCORE_SIZE 0x20000 +#endif + +/** + * @brief Idle thread automatic spawn suppression. + * @details When this option is activated the function @p chSysInit() + * does not spawn the idle thread automatically. The application has + * then the responsibility to do one of the following: + * - Spawn a custom idle thread at priority @p IDLEPRIO. + * - Change the main() thread priority to @p IDLEPRIO then enter + * an endless loop. In this scenario the @p main() thread acts as + * the idle thread. + * . + * @note Unless an idle thread is spawned the @p main() thread must not + * enter a sleep state. + */ +#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__) +#define CH_NO_IDLE_THREAD FALSE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Performance options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) +#define CH_OPTIMIZE_SPEED FALSE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Subsystem options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Threads registry APIs. + * @details If enabled then the registry APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) +#define CH_USE_REGISTRY TRUE +#endif + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) +#define CH_USE_WAITEXIT TRUE +#endif + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) +#define CH_USE_SEMAPHORES TRUE +#endif + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special requirements. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) +#define CH_USE_SEMAPHORES_PRIORITY FALSE +#endif + +/** + * @brief Atomic semaphore API. + * @details If enabled then the semaphores the @p chSemSignalWait() API + * is included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) +#define CH_USE_SEMSW TRUE +#endif + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) +#define CH_USE_MUTEXES TRUE +#endif + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_MUTEXES. + */ +#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) +#define CH_USE_CONDVARS TRUE +#endif + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_CONDVARS. + */ +#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) +#define CH_USE_CONDVARS_TIMEOUT TRUE +#endif + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) +#define CH_USE_EVENTS TRUE +#endif + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_EVENTS. + */ +#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) +#define CH_USE_EVENTS_TIMEOUT TRUE +#endif + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) +#define CH_USE_MESSAGES TRUE +#endif + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special requirements. + * @note Requires @p CH_USE_MESSAGES. + */ +#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) +#define CH_USE_MESSAGES_PRIORITY FALSE +#endif + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) +#define CH_USE_MAILBOXES TRUE +#endif + +/** + * @brief I/O Queues APIs. + * @details If enabled then the I/O queues APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) +#define CH_USE_QUEUES TRUE +#endif + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) +#define CH_USE_MEMCORE TRUE +#endif + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or + * @p CH_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) +#define CH_USE_HEAP TRUE +#endif + +/** + * @brief C-runtime allocator. + * @details If enabled the the heap allocator APIs just wrap the C-runtime + * @p malloc() and @p free() functions. + * + * @note The default is @p FALSE. + * @note Requires @p CH_USE_HEAP. + * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the + * appropriate documentation. + */ +#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#define CH_USE_MALLOC_HEAP FALSE +#endif + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) +#define CH_USE_MEMPOOLS TRUE +#endif + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_WAITEXIT. + * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. + */ +#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) +#define CH_USE_DYNAMIC TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Debug options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Debug option, system state check. + * @details If enabled the correct call protocol for system APIs is checked + * at runtime. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) +#define CH_DBG_SYSTEM_STATE_CHECK FALSE +#endif + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_CHECKS FALSE +#endif + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_ASSERTS FALSE +#endif + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the context switch circular trace buffer is + * activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_TRACE TRUE +#endif + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. + * It may not be implemented or some ports. + * @note The default failure mode is to halt the system with the global + * @p panic_msg variable set to @p NULL. + */ +#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_STACK_CHECK FALSE +#endif + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) +#define CH_DBG_FILL_THREADS TRUE +#endif + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p Thread structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p TRUE. + * @note This debug option is defaulted to TRUE because it is required by + * some test cases into the test suite. + */ +#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) +#define CH_DBG_THREADS_PROFILING TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel hooks + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p Thread structure. + */ +#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) +#define THREAD_EXT_FIELDS \ + /* Add threads custom fields here.*/ +#endif + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p chThdInit() API. + * + * @note It is invoked from within @p chThdInit() and implicitly from all + * the threads creation APIs. + */ +#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__) +#define THREAD_EXT_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} +#endif + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + * + * @note It is inserted into lock zone. + * @note It is also invoked when the threads simply return in order to + * terminate. + */ +#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__) +#define THREAD_EXT_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} +#endif + +/** + * @brief Context switch hook. + * @details This hook is invoked just before switching between threads. + */ +#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__) +#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* System halt code here.*/ \ +} +#endif + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) +#define IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} +#endif + +/** + * @brief System tick event hook. + * @details This hook is invoked in the system tick handler immediately + * after processing the virtual timers queue. + */ +#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__) +#define SYSTEM_TICK_EVENT_HOOK() { \ + /* System tick event code here.*/ \ +} +#endif + + +/** + * @brief System halt hook. + * @details This hook is invoked in case to a system halting error before + * the system is halted. + */ +#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) +#define SYSTEM_HALT_HOOK() { \ + /* System halt code here.*/ \ +} +#endif + +/** @} */ + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in chcore.h). */ +/*===========================================================================*/ + +#endif /* _CHCONF_H_ */ + +/** @} */ diff --git a/test/rt/coverage/halconf.h b/test/rt/coverage/halconf.h new file mode 100644 index 000000000..516a705a2 --- /dev/null +++ b/test/rt/coverage/halconf.h @@ -0,0 +1,312 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef _HALCONF_H_ +#define _HALCONF_H_ + +/*#include "mcuconf.h"*/ + +/** + * @brief Enables the TM subsystem. + */ +#if !defined(HAL_USE_TM) || defined(__DOXYGEN__) +#define HAL_USE_TM FALSE +#endif + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL FALSE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the EXT subsystem. + */ +#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) +#define HAL_USE_EXT FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +#endif /* _HALCONF_H_ */ + +/** @} */ diff --git a/test/rt/coverage/main.c b/test/rt/coverage/main.c new file mode 100644 index 000000000..c4f257f0d --- /dev/null +++ b/test/rt/coverage/main.c @@ -0,0 +1,51 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include + +#include "ch.h" +#include "hal.h" +#include "test.h" +#include "console.h" + +/* + * Simulator main. + */ +int main(int argc, char *argv[]) { + msg_t result; + + (void)argc; + (void)argv; + + /* + * System initializations. + * - HAL initialization, this also initializes the configured device drivers + * and performs the board-specific initializations. + * - Kernel initialization, the main() function becomes a thread and the + * RTOS is active. + */ + halInit(); + conInit(); + chSysInit(); + + result = TestThread(&CD1); + if (result) + exit(1); + else + exit(0); +} diff --git a/test/rt/coverage/readme.txt b/test/rt/coverage/readme.txt new file mode 100644 index 000000000..fc3595112 --- /dev/null +++ b/test/rt/coverage/readme.txt @@ -0,0 +1,6 @@ +In order to compute the code coverage: + +- Build the test application: make +- Run the test suite: ch +- Compute the code coverage: make gcov +- Clear everything: make clean diff --git a/test/rt/test.c b/test/rt/test.c new file mode 100644 index 000000000..0750a0d80 --- /dev/null +++ b/test/rt/test.c @@ -0,0 +1,390 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test.c + * @brief Tests support code. + * + * @addtogroup test + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#include "test.h" +#include "testthd.h" +#include "testsem.h" +#include "testmtx.h" +#include "testmsg.h" +#include "testmbox.h" +#include "testevt.h" +#include "testheap.h" +#include "testpools.h" +#include "testdyn.h" +#include "testqueues.h" +#include "testbmk.h" + +/* + * Array of all the test patterns. + */ +static ROMCONST struct testcase * ROMCONST *patterns[] = { + patternthd, + patternsem, + patternmtx, + patternmsg, + patternmbox, + patternevt, + patternheap, + patternpools, + patterndyn, + patternqueues, + patternbmk, + NULL +}; + +static bool local_fail, global_fail; +static unsigned failpoint; +static char tokens_buffer[MAX_TOKENS]; +static char *tokp; + +/* + * Static working areas, the following areas can be used for threads or + * used as temporary buffers. + */ +union test_buffers test; + +/* + * Pointers to the spawned threads. + */ +thread_t *threads[MAX_THREADS]; + +/* + * Pointers to the working areas. + */ +void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2, + test.wa.T3, test.wa.T4}; + +/* + * Console output. + */ +static BaseSequentialStream *chp; + +/** + * @brief Prints a decimal unsigned number. + * + * @param[in] n the number to be printed + */ +void test_printn(uint32_t n) { + char buf[16], *p; + + if (!n) + chSequentialStreamPut(chp, '0'); + else { + p = buf; + while (n) + *p++ = (n % 10) + '0', n /= 10; + while (p > buf) + chSequentialStreamPut(chp, *--p); + } +} + +/** + * @brief Prints a line without final end-of-line. + * + * @param[in] msgp the message + */ +void test_print(const char *msgp) { + + while (*msgp) + chSequentialStreamPut(chp, *msgp++); +} + +/** + * @brief Prints a line. + * + * @param[in] msgp the message + */ +void test_println(const char *msgp) { + + test_print(msgp); + chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); +} + +/* + * Tokens. + */ +static void clear_tokens(void) { + + tokp = tokens_buffer; +} + +static void print_tokens(void) { + char *cp = tokens_buffer; + + while (cp < tokp) + chSequentialStreamPut(chp, *cp++); +} + +/** + * @brief Emits a token into the tokens buffer. + * + * @param[in] token the token as a char + */ +void test_emit_token(char token) { + + chSysLock(); + *tokp++ = token; + chSysUnlock(); +} + +/* + * Assertions. + */ +bool _test_fail(unsigned point) { + + local_fail = TRUE; + global_fail = TRUE; + failpoint = point; + return TRUE; +} + +bool _test_assert(unsigned point, bool condition) { + + if (!condition) + return _test_fail(point); + return FALSE; +} + +bool _test_assert_sequence(unsigned point, char *expected) { + char *cp = tokens_buffer; + while (cp < tokp) { + if (*cp++ != *expected++) + return _test_fail(point); + } + if (*expected) + return _test_fail(point); + clear_tokens(); + return FALSE; +} + +bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) { + + return _test_assert(point, chVTIsSystemTimeWithin(start, end)); +} + +/* + * Threads utils. + */ + +/** + * @brief Sets a termination request in all the test-spawned threads. + */ +void test_terminate_threads(void) { + int i; + + for (i = 0; i < MAX_THREADS; i++) + if (threads[i]) + chThdTerminate(threads[i]); +} + +/** + * @brief Waits for the completion of all the test-spawned threads. + */ +void test_wait_threads(void) { + int i; + + for (i = 0; i < MAX_THREADS; i++) + if (threads[i] != NULL) { + chThdWait(threads[i]); + threads[i] = NULL; + } +} + +#if CH_DBG_THREADS_PROFILING +/** + * @brief CPU pulse. + * @note The current implementation is not totally reliable. + * + * @param[in] duration CPU pulse duration in milliseconds + */ +void test_cpu_pulse(unsigned duration) { + systime_t start, end, now; + + start = chThdGetTicksX(chThdGetSelfX()); + end = start + MS2ST(duration); + do { + now = chThdGetTicksX(chThdGetSelfX()); +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } + while (end > start ? (now >= start) && (now < end) : + (now >= start) || (now < end)); +} +#endif + +/** + * @brief Delays execution until next system time tick. + * + * @return The system time. + */ +systime_t test_wait_tick(void) { + + chThdSleep(1); + return chVTGetSystemTime(); +} + +/* + * Timer utils. + */ + +/** + * @brief Set to @p TRUE when the test timer reaches its deadline. + */ +bool test_timer_done; + +static virtual_timer_t vt; +static void tmr(void *p) { + (void)p; + + test_timer_done = TRUE; +} + +/** + * @brief Starts the test timer. + * + * @param[in] ms time in milliseconds + */ +void test_start_timer(unsigned ms) { + + systime_t duration = MS2ST(ms); + test_timer_done = FALSE; + chVTSet(&vt, duration, tmr, NULL); +} + +/* + * Test suite execution. + */ +static void execute_test(const struct testcase *tcp) { + int i; + + /* Initialization */ + clear_tokens(); + local_fail = FALSE; + for (i = 0; i < MAX_THREADS; i++) + threads[i] = NULL; + + if (tcp->setup != NULL) + tcp->setup(); + tcp->execute(); + if (tcp->teardown != NULL) + tcp->teardown(); + + test_wait_threads(); +} + +static void print_line(void) { + unsigned i; + + for (i = 0; i < 76; i++) + chSequentialStreamPut(chp, '-'); + chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); +} + +/** + * @brief Test execution thread function. + * + * @param[in] p pointer to a @p BaseChannel object for test output + * @return A failure boolean value. + */ +msg_t TestThread(void *p) { + int i, j; + + chp = p; + test_println(""); + test_println("*** ChibiOS/RT test suite"); + test_println("***"); + test_print("*** Kernel: "); + test_println(CH_KERNEL_VERSION); + test_print("*** Compiled: "); + test_println(__DATE__ " - " __TIME__); +#ifdef PORT_COMPILER_NAME + test_print("*** Compiler: "); + test_println(PORT_COMPILER_NAME); +#endif + test_print("*** Architecture: "); + test_println(PORT_ARCHITECTURE_NAME); +#ifdef PORT_CORE_VARIANT_NAME + test_print("*** Core Variant: "); + test_println(PORT_CORE_VARIANT_NAME); +#endif +#ifdef PORT_INFO + test_print("*** Port Info: "); + test_println(PORT_INFO); +#endif +#ifdef PLATFORM_NAME + test_print("*** Platform: "); + test_println(PLATFORM_NAME); +#endif +#ifdef BOARD_NAME + test_print("*** Test Board: "); + test_println(BOARD_NAME); +#endif + test_println(""); + + global_fail = FALSE; + i = 0; + while (patterns[i]) { + j = 0; + while (patterns[i][j]) { + print_line(); + test_print("--- Test Case "); + test_printn(i + 1); + test_print("."); + test_printn(j + 1); + test_print(" ("); + test_print(patterns[i][j]->name); + test_println(")"); +#if DELAY_BETWEEN_TESTS > 0 + chThdSleepMilliseconds(DELAY_BETWEEN_TESTS); +#endif + execute_test(patterns[i][j]); + if (local_fail) { + test_print("--- Result: FAILURE (#"); + test_printn(failpoint); + test_print(" ["); + print_tokens(); + test_println("])"); + } + else + test_println("--- Result: SUCCESS"); + j++; + } + i++; + } + print_line(); + test_println(""); + test_print("Final result: "); + if (global_fail) + test_println("FAILURE"); + else + test_println("SUCCESS"); + + return (msg_t)global_fail; +} + +/** @} */ diff --git a/test/rt/test.dox b/test/rt/test.dox new file mode 100644 index 000000000..87c68320b --- /dev/null +++ b/test/rt/test.dox @@ -0,0 +1,82 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @defgroup test Test Runtime + * @details Runtime code for the test suite execution, this code is not part + * of the OS and should not be included in user applications. + */ + +/** + * @page testsuite Testing Strategy + *

Description

+ * Most of the ChibiOS/RT demos link a set of software modules (test suite) in + * order to verify the proper working of the kernel, the port and the demo + * itself. + * + *

Strategy by Component

+ * The OS components are tested in various modes depending on their importance: + * - Kernel. The kernel code is subject to rigorous testing. The test + * suite aims to test all the kernel code and reach a code coverage + * as close to 100% as possible. In addition to the code coverage, the kernel + * code is tested for functionality and benchmarked for speed + * and size before each stable release. In addition to the code + * coverage and functional testing a batch compilation test is + * performed before each release, the kernel is compiled by alternatively + * enabling and disabling all the various configuration options, the + * kernel code is expected to compile without errors nor warnings and + * execute the test suite without failures (a specific simulator is used + * for this execution test, it is done automatically by a script because + * the entire sequence can take hours).
+ * All the tests results are included as reports in the OS distribution + * under ./docs/reports. + * - Ports. The port code is tested by executing the kernel test + * suite on the target hardware. A port is validated only if it passes all + * the tests. Speed and size benchmarks for all the supported architectures + * are performed, both size and speed regressions are monitored. + * - HAL. The HAL high level code and device drivers implementations + * are tested through specific test applications under ./testhal. + * - Various. The miscellaneous code is tested by use in the various + * demos. + * - External Code. Not tested, external libraries or components are + * used as-is or with minor patching where required, problems are usually + * reported upstream. + * . + *

Kernel Test Suite

+ * The kernel test suite is divided in modules or test sequences. Each Test + * Module performs a series of tests on a specified kernel subsystem or + * subsystems and can report a failure/success status and/or a performance + * index as the test suite output.
+ * The test suite is usually activated in the demo applications by pressing a + * button on the target board, see the readme file into the various demos + * directories. The test suite output is usually sent through a serial port + * and can be examined by using a terminal emulator program. + * + *

Kernel Test Modules

+ * + * - @subpage test_threads + * - @subpage test_dynamic + * - @subpage test_msg + * - @subpage test_sem + * - @subpage test_mtx + * - @subpage test_events + * - @subpage test_mbox + * - @subpage test_queues + * - @subpage test_heap + * - @subpage test_pools + * - @subpage test_benchmarks + * . + */ diff --git a/test/rt/test.h b/test/rt/test.h new file mode 100644 index 000000000..1b40a48e0 --- /dev/null +++ b/test/rt/test.h @@ -0,0 +1,173 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file test.h + * @brief Tests support header. + * + * @addtogroup test + * @{ + */ + +#ifndef _TEST_H_ +#define _TEST_H_ + +/** + * @brief Delay inserted between test cases. + */ +#if !defined(DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) +#define DELAY_BETWEEN_TESTS 200 +#endif + +/** + * @brief If @p TRUE then benchmarks are not included. + */ +#if !defined(TEST_NO_BENCHMARKS) || defined(__DOXYGEN__) +#define TEST_NO_BENCHMARKS FALSE +#endif + +#define MAX_THREADS 5 +#define MAX_TOKENS 16 + +#if defined(CH_ARCHITECTURE_AVR) || defined(CH_ARCHITECTURE_MSP430) +#define THREADS_STACK_SIZE 48 +#elif defined(CH_ARCHITECTURE_STM8) +#define THREADS_STACK_SIZE 64 +#elif defined(CH_ARCHITECTURE_SIMIA32) +#define THREADS_STACK_SIZE 512 +#else +#define THREADS_STACK_SIZE 128 +#endif +#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) + +/** + * @brief Structure representing a test case. + */ +struct testcase { + const char *name; /**< @brief Test case name. */ + void (*setup)(void); /**< @brief Test case preparation function. */ + void (*teardown)(void); /**< @brief Test case clean up function. */ + void (*execute)(void); /**< @brief Test case execution function. */ +}; + +#ifndef __DOXYGEN__ +union test_buffers { + struct { + THD_WORKING_AREA(T0, THREADS_STACK_SIZE); + THD_WORKING_AREA(T1, THREADS_STACK_SIZE); + THD_WORKING_AREA(T2, THREADS_STACK_SIZE); + THD_WORKING_AREA(T3, THREADS_STACK_SIZE); + THD_WORKING_AREA(T4, THREADS_STACK_SIZE); + } wa; + uint8_t buffer[WA_SIZE * 5]; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + msg_t TestThread(void *p); + void test_printn(uint32_t n); + void test_print(const char *msgp); + void test_println(const char *msgp); + void test_emit_token(char token); + bool _test_fail(unsigned point); + bool _test_assert(unsigned point, bool condition); + bool _test_assert_sequence(unsigned point, char *expected); + bool _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); + void test_start_timer(unsigned ms); +#if CH_DBG_THREADS_PROFILING + void test_cpu_pulse(unsigned duration); +#endif +#if defined(WIN32) + void ChkIntSources(void); +#endif +#ifdef __cplusplus +} +#endif + +/** + * @brief Test failure enforcement. + */ +#define test_fail(point) { \ + _test_fail(point); \ + return; \ +} + +/** + * @brief Test assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message + */ +#define test_assert(point, condition, msg) { \ + if (_test_assert(point, condition)) \ + return; \ +} + +/** + * @brief Test assertion with lock. + * + * @param[in] point numeric assertion identifier + * @param[in] condition a boolean expression that must be verified to be true + * @param[in] msg failure message + */ +#define test_assert_lock(point, condition, msg) { \ + chSysLock(); \ + if (_test_assert(point, condition)) { \ + chSysUnlock(); \ + return; \ + } \ + chSysUnlock(); \ +} + +/** + * @brief Test sequence assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] expected string to be matched with the tokens buffer + */ +#define test_assert_sequence(point, expected) { \ + if (_test_assert_sequence(point, expected)) \ + return; \ +} + +/** + * @brief Test time window assertion. + * + * @param[in] point numeric assertion identifier + * @param[in] start initial time in the window (included) + * @param[in] end final time in the window (not included) + */ +#define test_assert_time_window(point, start, end) { \ + if (_test_assert_time_window(point, start, end)) \ + return; \ +} + +#if !defined(__DOXYGEN__) +extern thread_t *threads[MAX_THREADS]; +extern union test_buffers test; +extern void * ROMCONST wa[]; +extern bool test_timer_done; +#endif + +#endif /* _TEST_H_ */ + +/** @} */ diff --git a/test/rt/test.mk b/test/rt/test.mk new file mode 100644 index 000000000..3f740288c --- /dev/null +++ b/test/rt/test.mk @@ -0,0 +1,16 @@ +# List of all the ChibiOS/RT test files. +TESTSRC = ${CHIBIOS}/test/test.c \ + ${CHIBIOS}/test/testthd.c \ + ${CHIBIOS}/test/testsem.c \ + ${CHIBIOS}/test/testmtx.c \ + ${CHIBIOS}/test/testmsg.c \ + ${CHIBIOS}/test/testmbox.c \ + ${CHIBIOS}/test/testevt.c \ + ${CHIBIOS}/test/testheap.c \ + ${CHIBIOS}/test/testpools.c \ + ${CHIBIOS}/test/testdyn.c \ + ${CHIBIOS}/test/testqueues.c \ + ${CHIBIOS}/test/testbmk.c + +# Required include directories +TESTINC = ${CHIBIOS}/test diff --git a/test/rt/testbmk.c b/test/rt/testbmk.c new file mode 100644 index 000000000..2a3b7c1b5 --- /dev/null +++ b/test/rt/testbmk.c @@ -0,0 +1,715 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_benchmarks Kernel Benchmarks + * + * File: @ref testbmk.c + * + *

Description

+ * This module implements a series of system benchmarks. The benchmarks are + * useful as a stress test and as a reference when comparing ChibiOS/RT + * with similar systems. + * + *

Objective

+ * Objective of the test module is to provide a performance index for the + * most critical system subsystems. The performance numbers allow to + * discover performance regressions between successive ChibiOS/RT releases. + * + *

Preconditions

+ * None. + * + *

Test Cases

+ * - @subpage test_benchmarks_001 + * - @subpage test_benchmarks_002 + * - @subpage test_benchmarks_003 + * - @subpage test_benchmarks_004 + * - @subpage test_benchmarks_005 + * - @subpage test_benchmarks_006 + * - @subpage test_benchmarks_007 + * - @subpage test_benchmarks_008 + * - @subpage test_benchmarks_009 + * - @subpage test_benchmarks_010 + * - @subpage test_benchmarks_011 + * - @subpage test_benchmarks_012 + * - @subpage test_benchmarks_013 + * . + * @file testbmk.c Kernel Benchmarks + * @brief Kernel Benchmarks source file + * @file testbmk.h + * @brief Kernel Benchmarks header file + */ + +static semaphore_t sem1; +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) +static mutex_t mtx1; +#endif + +static msg_t thread1(void *p) { + thread_t *tp; + msg_t msg; + + (void)p; + do { + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + } while (msg); + return 0; +} + +#ifdef __GNUC__ +__attribute__((noinline)) +#endif +static unsigned int msg_loop_test(thread_t *tp) { + + uint32_t n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + (void)chMsgSend(tp, 1); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + (void)chMsgSend(tp, 0); + return n; +} + +/** + * @page test_benchmarks_001 Messages performance #1 + * + *

Description

+ * A message server thread is created with a lower priority than the client + * thread, the messages throughput per second is measured and the result + * printed in the output log. + */ + +static void bmk1_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk1 = { + "Benchmark, messages #1", + NULL, + NULL, + bmk1_execute +}; + +/** + * @page test_benchmarks_002 Messages performance #2 + * + *

Description

+ * A message server thread is created with an higher priority than the client + * thread, the messages throughput per second is measured and the result + * printed in the output log. + */ + +static void bmk2_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk2 = { + "Benchmark, messages #2", + NULL, + NULL, + bmk2_execute +}; + +static msg_t thread2(void *p) { + + return (msg_t)p; +} + +/** + * @page test_benchmarks_003 Messages performance #3 + * + *

Description

+ * A message server thread is created with an higher priority than the client + * thread, four lower priority threads crowd the ready list, the messages + * throughput per second is measured while the ready list and the result + * printed in the output log. + */ + +static void bmk3_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2, NULL); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2, NULL); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread2, NULL); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread2, NULL); + n = msg_loop_test(threads[0]); + test_wait_threads(); + test_print("--- Score : "); + test_printn(n); + test_print(" msgs/S, "); + test_printn(n << 1); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk3 = { + "Benchmark, messages #3", + NULL, + NULL, + bmk3_execute +}; + +/** + * @page test_benchmarks_004 Context Switch performance + * + *

Description

+ * A thread is created that just performs a @p chSchGoSleepS() into a loop, + * the thread is awakened as fast is possible by the tester thread.
+ * The Context Switch performance is calculated by measuring the number of + * iterations after a second of continuous operations. + */ + +msg_t thread4(void *p) { + msg_t msg; + thread_t *self = chThdGetSelfX(); + + (void)p; + chSysLock(); + do { + chSchGoSleepS(CH_STATE_SUSPENDED); + msg = self->p_u.rdymsg; + } while (msg == MSG_OK); + chSysUnlock(); + return 0; +} + +static void bmk4_execute(void) { + thread_t *tp; + uint32_t n; + + tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, + thread4, NULL); + n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + chSysLock(); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSchWakeupS(tp, MSG_OK); + chSysUnlock(); + n += 4; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + chSysLock(); + chSchWakeupS(tp, MSG_TIMEOUT); + chSysUnlock(); + + test_wait_threads(); + test_print("--- Score : "); + test_printn(n * 2); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk4 = { + "Benchmark, context switch", + NULL, + NULL, + bmk4_execute +}; + +/** + * @page test_benchmarks_005 Threads performance, full cycle + * + *

Description

+ * Threads are continuously created and terminated into a loop. A full + * @p chThdCreateStatic() / @p chThdExit() / @p chThdWait() cycle is performed + * in each iteration.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk5_execute(void) { + + uint32_t n = 0; + void *wap = wa[0]; + tprio_t prio = chThdGetPriorityX() - 1; + test_wait_tick(); + test_start_timer(1000); + do { + chThdWait(chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL)); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n); + test_println(" threads/S"); +} + +ROMCONST struct testcase testbmk5 = { + "Benchmark, threads, full cycle", + NULL, + NULL, + bmk5_execute +}; + +/** + * @page test_benchmarks_006 Threads performance, create/exit only + * + *

Description

+ * Threads are continuously created and terminated into a loop. A partial + * @p chThdCreateStatic() / @p chThdExit() cycle is performed in each + * iteration, the @p chThdWait() is not necessary because the thread is + * created at an higher priority so there is no need to wait for it to + * terminate.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk6_execute(void) { + + uint32_t n = 0; + void *wap = wa[0]; + tprio_t prio = chThdGetPriorityX() + 1; + test_wait_tick(); + test_start_timer(1000); + do { + chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n); + test_println(" threads/S"); +} + +ROMCONST struct testcase testbmk6 = { + "Benchmark, threads, create only", + NULL, + NULL, + bmk6_execute +}; + +/** + * @page test_benchmarks_007 Mass reschedule performance + * + *

Description

+ * Five threads are created and atomically rescheduled by resetting the + * semaphore where they are waiting on. The operation is performed into a + * continuous loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static msg_t thread3(void *p) { + + (void)p; + while (!chThdShouldTerminateX()) + chSemWait(&sem1); + return 0; +} + +static void bmk7_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static void bmk7_execute(void) { + uint32_t n; + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL); + + n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + chSemReset(&sem1, 0); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_terminate_threads(); + chSemReset(&sem1, 0); + test_wait_threads(); + + test_print("--- Score : "); + test_printn(n); + test_print(" reschedules/S, "); + test_printn(n * 6); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk7 = { + "Benchmark, mass reschedule, 5 threads", + bmk7_setup, + NULL, + bmk7_execute +}; + +/** + * @page test_benchmarks_008 I/O Round-Robin voluntary reschedule. + * + *

Description

+ * Five threads are created at equal priority, each thread just increases a + * variable and yields.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static msg_t thread8(void *p) { + + do { + chThdYield(); + chThdYield(); + chThdYield(); + chThdYield(); + (*(uint32_t *)p) += 4; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while(!chThdShouldTerminateX()); + return 0; +} + +static void bmk8_execute(void) { + uint32_t n; + + n = 0; + test_wait_tick(); + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); + + chThdSleepSeconds(1); + test_terminate_threads(); + test_wait_threads(); + + test_print("--- Score : "); + test_printn(n); + test_println(" ctxswc/S"); +} + +ROMCONST struct testcase testbmk8 = { + "Benchmark, round robin context switching", + NULL, + NULL, + bmk8_execute +}; + +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_009 I/O Queues throughput + * + *

Description

+ * Four bytes are written and then read from an @p InputQueue into a continuous + * loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk9_execute(void) { + uint32_t n; + static uint8_t ib[16]; + static input_queue_t iq; + + chIQObjectInit(&iq, ib, sizeof(ib), NULL, NULL); + n = 0; + test_wait_tick(); + test_start_timer(1000); + do { + chSysLock(); + chIQPutI(&iq, 0); + chIQPutI(&iq, 1); + chIQPutI(&iq, 2); + chIQPutI(&iq, 3); + chSysUnlock(); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + (void)chIQGet(&iq); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" bytes/S"); +} + +ROMCONST struct testcase testbmk9 = { + "Benchmark, I/O Queues throughput", + NULL, + NULL, + bmk9_execute +}; +#endif /* CH_CFG_USE_QUEUES */ + +/** + * @page test_benchmarks_010 Virtual Timers set/reset performance + * + *

Description

+ * A virtual timer is set and immediately reset into a continuous loop.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void tmo(void *param) {(void)param;} + +static void bmk10_execute(void) { + static virtual_timer_t vt1, vt2; + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chSysLock(); + chVTDoSetI(&vt1, 1, tmo, NULL); + chVTDoSetI(&vt2, 10000, tmo, NULL); + chVTDoResetI(&vt1); + chVTDoResetI(&vt2); + chSysUnlock(); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 2); + test_println(" timers/S"); +} + +ROMCONST struct testcase testbmk10 = { + "Benchmark, virtual timers set/reset", + NULL, + NULL, + bmk10_execute +}; + +/** + * @page test_benchmarks_011 Semaphores wait/signal performance + * + *

Description

+ * A counting semaphore is taken/released into a continuous loop, no Context + * Switch happens because the counter is always non negative.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk11_setup(void) { + + chSemObjectInit(&sem1, 1); +} + +static void bmk11_execute(void) { + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + chSemWait(&sem1); + chSemSignal(&sem1); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" wait+signal/S"); +} + +ROMCONST struct testcase testbmk11 = { + "Benchmark, semaphores wait/signal", + bmk11_setup, + NULL, + bmk11_execute +}; + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) +/** + * @page test_benchmarks_012 Mutexes lock/unlock performance + * + *

Description

+ * A mutex is locked/unlocked into a continuous loop, no Context Switch happens + * because there are no other threads asking for the mutex.
+ * The performance is calculated by measuring the number of iterations after + * a second of continuous operations. + */ + +static void bmk12_setup(void) { + + chMtxObjectInit(&mtx1); +} + +static void bmk12_execute(void) { + uint32_t n = 0; + + test_wait_tick(); + test_start_timer(1000); + do { + chMtxLock(&mtx1); + chMtxUnlock(); + chMtxLock(&mtx1); + chMtxUnlock(); + chMtxLock(&mtx1); + chMtxUnlock(); + chMtxLock(&mtx1); + chMtxUnlock(); + n++; +#if defined(SIMULATOR) + ChkIntSources(); +#endif + } while (!test_timer_done); + test_print("--- Score : "); + test_printn(n * 4); + test_println(" lock+unlock/S"); +} + +ROMCONST struct testcase testbmk12 = { + "Benchmark, mutexes lock/unlock", + bmk12_setup, + NULL, + bmk12_execute +}; +#endif + +/** + * @page test_benchmarks_013 RAM Footprint + * + *

Description

+ * The memory size of the various kernel objects is printed. + */ + +static void bmk13_execute(void) { + + test_print("--- System: "); + test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + + PORT_IDLE_THREAD_STACK_SIZE + + (sizeof(thread_t) + sizeof(struct port_intctx) + + sizeof(struct port_extctx) + + PORT_INT_REQUIRED_STACK) * 2); + test_println(" bytes"); + test_print("--- Thread: "); + test_printn(sizeof(thread_t)); + test_println(" bytes"); + test_print("--- Timer : "); + test_printn(sizeof(virtual_timer_t)); + test_println(" bytes"); + test_print("--- Semaph: "); + test_printn(sizeof(semaphore_t)); + test_println(" bytes"); +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + test_print("--- EventS: "); + test_printn(sizeof(event_source_t)); + test_println(" bytes"); + test_print("--- EventL: "); + test_printn(sizeof(event_listener_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + test_print("--- Mutex : "); + test_printn(sizeof(mutex_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) + test_print("--- CondV.: "); + test_printn(sizeof(condition_variable_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + test_print("--- Queue : "); + test_printn(sizeof(io_queue_t)); + test_println(" bytes"); +#endif +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + test_print("--- MailB.: "); + test_printn(sizeof(mailbox_t)); + test_println(" bytes"); +#endif +} + +ROMCONST struct testcase testbmk13 = { + "Benchmark, RAM footprint", + NULL, + NULL, + bmk13_execute +}; + +/** + * @brief Test sequence for benchmarks. + */ +ROMCONST struct testcase * ROMCONST patternbmk[] = { +#if !TEST_NO_BENCHMARKS + &testbmk1, + &testbmk2, + &testbmk3, + &testbmk4, + &testbmk5, + &testbmk6, + &testbmk7, + &testbmk8, +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + &testbmk9, +#endif + &testbmk10, + &testbmk11, +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + &testbmk12, +#endif + &testbmk13, +#endif + NULL +}; diff --git a/test/rt/testbmk.h b/test/rt/testbmk.h new file mode 100644 index 000000000..8d7514f74 --- /dev/null +++ b/test/rt/testbmk.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTBMK_H_ +#define _TESTBMK_H_ + +extern ROMCONST struct testcase * ROMCONST patternbmk[]; + +#endif /* _TESTBMK_H_ */ diff --git a/test/rt/testdyn.c b/test/rt/testdyn.c new file mode 100644 index 000000000..bf9f127a0 --- /dev/null +++ b/test/rt/testdyn.c @@ -0,0 +1,267 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_dynamic Dynamic APIs test + * + * File: @ref testdyn.c + * + *

Description

+ * This module implements the test sequence for the dynamic thread creation + * APIs. + * + *

Objective

+ * Objective of the test module is to cover 100% of the dynamic APIs code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_DYNAMIC + * - @p CH_CFG_USE_HEAP + * - @p CH_CFG_USE_MEMPOOLS + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_dynamic_001 + * - @subpage test_dynamic_002 + * - @subpage test_dynamic_003 + * . + * @file testdyn.c + * @brief Dynamic thread APIs test source file + * @file testdyn.h + * @brief Dynamic thread APIs test header file + */ + +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +static memory_heap_t heap1; +#endif +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) +static memory_pool_t mp1; +#endif + +/** + * @page test_dynamic_001 Threads creation from Memory Heap + * + *

Description

+ * Two threads are started by allocating the memory from the Memory Heap then + * the remaining heap space is arbitrarily allocated and a third tread startup + * is attempted.
+ * The test expects the first two threads to successfully start and the last + * one to fail. + */ + +static msg_t thread(void *p) { + + test_emit_token(*(char *)p); + return 0; +} + +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +static void dyn1_setup(void) { + + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); +} + +static void dyn1_execute(void) { + size_t n, sz; + void *p1; + tprio_t prio = chThdGetPriorityX(); + + (void)chHeapStatus(&heap1, &sz); + /* Starting threads from the heap. */ + threads[0] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), + prio-1, thread, "A"); + threads[1] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), + prio-2, thread, "B"); + /* Allocating the whole heap in order to make the thread creation fail.*/ + (void)chHeapStatus(&heap1, &n); + p1 = chHeapAlloc(&heap1, n); + threads[2] = chThdCreateFromHeap(&heap1, + THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), + prio-3, thread, "C"); + chHeapFree(p1); + + test_assert(1, (threads[0] != NULL) && + (threads[1] != NULL) && + (threads[2] == NULL) && + (threads[3] == NULL) && + (threads[4] == NULL), + "thread creation failed"); + + /* Claiming the memory from terminated threads. */ + test_wait_threads(); + test_assert_sequence(2, "AB"); + + /* Heap status checked again.*/ + test_assert(3, chHeapStatus(&heap1, &n) == 1, "heap fragmented"); + test_assert(4, n == sz, "heap size changed"); +} + +ROMCONST struct testcase testdyn1 = { + "Dynamic APIs, threads creation from heap", + dyn1_setup, + NULL, + dyn1_execute +}; +#endif /* (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) */ + +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) +/** + * @page test_dynamic_002 Threads creation from Memory Pool + * + *

Description

+ * Five thread creation are attempted from a pool containing only four + * elements.
+ * The test expects the first four threads to successfully start and the last + * one to fail. + */ + +static void dyn2_setup(void) { + + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); +} + +static void dyn2_execute(void) { + int i; + tprio_t prio = chThdGetPriorityX(); + + /* Adding the WAs to the pool. */ + for (i = 0; i < 4; i++) + chPoolFree(&mp1, wa[i]); + + /* Starting threads from the memory pool. */ + threads[0] = chThdCreateFromMemoryPool(&mp1, prio-1, thread, "A"); + threads[1] = chThdCreateFromMemoryPool(&mp1, prio-2, thread, "B"); + threads[2] = chThdCreateFromMemoryPool(&mp1, prio-3, thread, "C"); + threads[3] = chThdCreateFromMemoryPool(&mp1, prio-4, thread, "D"); + threads[4] = chThdCreateFromMemoryPool(&mp1, prio-5, thread, "E"); + + test_assert(1, (threads[0] != NULL) && + (threads[1] != NULL) && + (threads[2] != NULL) && + (threads[3] != NULL) && + (threads[4] == NULL), + "thread creation failed"); + + /* Claiming the memory from terminated threads. */ + test_wait_threads(); + test_assert_sequence(2, "ABCD"); + + /* Now the pool must be full again. */ + for (i = 0; i < 4; i++) + test_assert(3, chPoolAlloc(&mp1) != NULL, "pool list empty"); + test_assert(4, chPoolAlloc(&mp1) == NULL, "pool list not empty"); +} + +ROMCONST struct testcase testdyn2 = { + "Dynamic APIs, threads creation from memory pool", + dyn2_setup, + NULL, + dyn2_execute +}; +#endif /* CH_CFG_USE_MEMPOOLS */ + +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ + defined(__DOXYGEN__) +/** + * @page test_dynamic_003 Registry and References test + * + *

Description

+ * Registry and Thread References APIs are tested for functionality and + * coverage. + */ + +static bool regfind(thread_t *tp) { + thread_t *ftp; + bool found = false; + + ftp = chRegFirstThread(); + do { + found |= ftp == tp; + ftp = chRegNextThread(ftp); + } while (ftp != NULL); + return found; +} + +static void dyn3_setup(void) { + + chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); +} + +static void dyn3_execute(void) { + thread_t *tp; + tprio_t prio = chThdGetPriorityX(); + + /* Testing references increase/decrease and final detach.*/ + tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A"); + test_assert(1, tp->p_refs == 1, "wrong initial reference counter"); + chThdAddRef(tp); + test_assert(2, tp->p_refs == 2, "references increase failure"); + chThdRelease(tp); + test_assert(3, tp->p_refs == 1, "references decrease failure"); + + /* Verify the new threads count.*/ + test_assert(4, regfind(tp), "thread missing from registry"); + test_assert(5, regfind(tp), "thread disappeared"); + + /* Detach and let the thread execute and terminate.*/ + chThdRelease(tp); + test_assert(6, tp->p_refs == 0, "detach failure"); + test_assert(7, tp->p_state == CH_STATE_READY, "invalid state"); + test_assert(8, regfind(tp), "thread disappeared"); + test_assert(9, regfind(tp), "thread disappeared"); + chThdSleepMilliseconds(50); /* The thread just terminates. */ + test_assert(10, tp->p_state == CH_STATE_FINAL, "invalid state"); + + /* Clearing the zombie by scanning the registry.*/ + test_assert(11, regfind(tp), "thread disappeared"); + test_assert(12, !regfind(tp), "thread still in registry"); +} + +ROMCONST struct testcase testdyn3 = { + "Dynamic APIs, registry and references", + dyn3_setup, + NULL, + dyn3_execute +}; +#endif /* CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY */ +#endif /* CH_CFG_USE_DYNAMIC */ + +/** + * @brief Test sequence for dynamic APIs. + */ +ROMCONST struct testcase * ROMCONST patterndyn[] = { +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) + &testdyn1, +#endif +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + &testdyn2, +#endif +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ + defined(__DOXYGEN__) + &testdyn3, +#endif +#endif + NULL +}; diff --git a/test/rt/testdyn.h b/test/rt/testdyn.h new file mode 100644 index 000000000..6b25dbb30 --- /dev/null +++ b/test/rt/testdyn.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTDYN_H_ +#define _TESTDYN_H_ + +extern ROMCONST struct testcase * ROMCONST patterndyn[]; + +#endif /* _TESTDYN_H_ */ diff --git a/test/rt/testevt.c b/test/rt/testevt.c new file mode 100644 index 000000000..49507f067 --- /dev/null +++ b/test/rt/testevt.c @@ -0,0 +1,294 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_events Events test + * + * File: @ref testevt.c + * + *

Description

+ * This module implements the test sequence for the @ref events subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref events subsystem. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_EVENTS + * - @p CH_CFG_USE_EVENTS_TIMEOUT + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_events_001 + * - @subpage test_events_002 + * - @subpage test_events_003 + * . + * @file testevt.c + * @brief Events test source file + * @file testevt.h + * @brief Events test header file + */ + +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(5) + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static EVENTSOURCE_DECL(es1); +static EVENTSOURCE_DECL(es2); + +/** + * @page test_events_001 Events registration and dispatch + * + *

Description

+ * Two event listeners are registered on an event source and then unregistered + * in the same order.
+ * The test expects that the even source has listeners after the registrations + * and after the first unregistration, then, after the second unegistration, + * the test expects no more listeners.
+ * In the second part the test dispatches three event flags and verifies that + * the associated event handlers are invoked in LSb-first order. + */ + +static void evt1_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static void h1(eventid_t id) {(void)id;test_emit_token('A');} +static void h2(eventid_t id) {(void)id;test_emit_token('B');} +static void h3(eventid_t id) {(void)id;test_emit_token('C');} +static ROMCONST evhandler_t evhndl[] = {h1, h2, h3}; + +static void evt1_execute(void) { + event_listener_t el1, el2; + + /* + * Testing chEvtRegisterMask() and chEvtUnregister(). + */ + chEvtObjectInit(&es1); + chEvtRegisterMask(&es1, &el1, 1); + chEvtRegisterMask(&es1, &el2, 2); + test_assert(1, chEvtIsListeningI(&es1), "no listener"); + chEvtUnregister(&es1, &el1); + test_assert(2, chEvtIsListeningI(&es1), "no listener"); + chEvtUnregister(&es1, &el2); + test_assert(3, !chEvtIsListeningI(&es1), "stuck listener"); + + /* + * Testing chEvtDispatch(). + */ + chEvtDispatch(evhndl, 7); + test_assert_sequence(4, "ABC"); +} + +ROMCONST struct testcase testevt1 = { + "Events, registration and dispatch", + evt1_setup, + NULL, + evt1_execute +}; + +/** + * @page test_events_002 Events wait and broadcast + * + *

Description

+ * In this test the following APIs are indipently tested by starting threads + * that signal/broadcast events after fixed delays: + * - @p chEvtWaitOne() + * - @p chEvtWaitAny() + * - @p chEvtWaitAll() + * . + * After each test phase the test verifies that the events have been served at + * the expected time and that there are no stuck event flags. + */ + +static void evt2_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static msg_t thread1(void *p) { + + chThdSleepMilliseconds(50); + chEvtSignal((thread_t *)p, 1); + return 0; +} + +static msg_t thread2(void *p) { + + (void)p; + chEvtBroadcast(&es1); + chThdSleepMilliseconds(50); + chEvtBroadcast(&es2); + return 0; +} + +static void evt2_execute(void) { + eventmask_t m; + event_listener_t el1, el2; + systime_t target_time; + + /* + * Test on chEvtWaitOne() without wait. + */ + chEvtAddEvents(5); + m = chEvtWaitOne(ALL_EVENTS); + test_assert(1, m == 1, "single event error"); + m = chEvtWaitOne(ALL_EVENTS); + test_assert(2, m == 4, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(3, m == 0, "stuck event"); + + /* + * Test on chEvtWaitOne() with wait. + */ + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); + m = chEvtWaitOne(ALL_EVENTS); + test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY); + test_assert(5, m == 1, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(6, m == 0, "stuck event"); + test_wait_threads(); + + /* + * Test on chEvtWaitAny() without wait. + */ + chEvtAddEvents(5); + m = chEvtWaitAny(ALL_EVENTS); + test_assert(7, m == 5, "unexpected pending bit"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(8, m == 0, "stuck event"); + + /* + * Test on chEvtWaitAny() with wait. + */ + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread1, chThdGetSelfX()); + m = chEvtWaitAny(ALL_EVENTS); + test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY); + test_assert(10, m == 1, "single event error"); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(11, m == 0, "stuck event"); + test_wait_threads(); + + /* + * Test on chEvtWaitAll(). + */ + chEvtObjectInit(&es1); + chEvtObjectInit(&es2); + chEvtRegisterMask(&es1, &el1, 1); + chEvtRegisterMask(&es2, &el2, 4); + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(50); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, + thread2, "A"); + m = chEvtWaitAll(5); + test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY); + m = chEvtGetAndClearEvents(ALL_EVENTS); + test_assert(13, m == 0, "stuck event"); + test_wait_threads(); + chEvtUnregister(&es1, &el1); + chEvtUnregister(&es2, &el2); + test_assert(14, !chEvtIsListeningI(&es1), "stuck listener"); + test_assert(15, !chEvtIsListeningI(&es2), "stuck listener"); +} + +ROMCONST struct testcase testevt2 = { + "Events, wait and broadcast", + evt2_setup, + NULL, + evt2_execute +}; + +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) +/** + * @page test_events_003 Events timeout + * + *

Description

+ * In this test the following APIs are let to timeout twice: immediatly and + * after 10ms: + * In this test the following APIs are indipently tested by starting threads + * that broadcast events after fixed delays: + * - @p chEvtWaitOneTimeout() + * - @p chEvtWaitAnyTimeout() + * - @p chEvtWaitAllTimeout() + * . + * After each test phase the test verifies that there are no stuck event flags. + */ + +static void evt3_setup(void) { + + chEvtGetAndClearEvents(ALL_EVENTS); +} + +static void evt3_execute(void) { + eventmask_t m; + + /* + * Tests various timeout situations. + */ + m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(1, m == 0, "spurious event"); + m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(2, m == 0, "spurious event"); + m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE); + test_assert(3, m == 0, "spurious event"); + m = chEvtWaitOneTimeout(ALL_EVENTS, 10); + test_assert(4, m == 0, "spurious event"); + m = chEvtWaitAnyTimeout(ALL_EVENTS, 10); + test_assert(5, m == 0, "spurious event"); + m = chEvtWaitAllTimeout(ALL_EVENTS, 10); + test_assert(6, m == 0, "spurious event"); +} + +ROMCONST struct testcase testevt3 = { + "Events, timeouts", + evt3_setup, + NULL, + evt3_execute +}; +#endif /* CH_CFG_USE_EVENTS_TIMEOUT */ + +/** + * @brief Test sequence for events. + */ +ROMCONST struct testcase * ROMCONST patternevt[] = { +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) + &testevt1, + &testevt2, +#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) + &testevt3, +#endif +#endif + NULL +}; + +#endif /* CH_CFG_USE_EVENTS */ diff --git a/test/rt/testevt.h b/test/rt/testevt.h new file mode 100644 index 000000000..7d189c17f --- /dev/null +++ b/test/rt/testevt.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTEVT_H_ +#define _TESTEVT_H_ + +extern ROMCONST struct testcase * ROMCONST patternevt[]; + +#endif /* _TESTEVT_H_ */ diff --git a/test/rt/testheap.c b/test/rt/testheap.c new file mode 100644 index 000000000..d257a4362 --- /dev/null +++ b/test/rt/testheap.c @@ -0,0 +1,159 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_heap Memory Heap test + * + * File: @ref testheap.c + * + *

Description

+ * This module implements the test sequence for the @ref heaps subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref heaps subsystem. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_HEAP + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_heap_001 + * . + * @file testheap.c + * @brief Heap test source file + * @file testheap.h + * @brief Heap header file + */ + +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) + +#define SIZE 16 + +static memory_heap_t test_heap; + +/** + * @page test_heap_001 Allocation and fragmentation test + * + *

Description

+ * Series of allocations/deallocations are performed in carefully designed + * sequences in order to stimulate all the possible code paths inside the + * allocator.
+ * The test expects to find the heap back to the initial status after each + * sequence. + */ + +static void heap1_setup(void) { + + chHeapObjectInit(&test_heap, test.buffer, sizeof(union test_buffers)); +} + +static void heap1_execute(void) { + void *p1, *p2, *p3; + size_t n, sz; + + /* Unrelated, for coverage only.*/ + (void)chCoreStatus(); + + /* + * Test on the default heap in order to cover the core allocator at + * least one time. + */ + (void)chHeapStatus(NULL, &sz); + p1 = chHeapAlloc(NULL, SIZE); + test_assert(1, p1 != NULL, "allocation failed"); + chHeapFree(p1); + p1 = chHeapAlloc(NULL, (size_t)-256); + test_assert(2, p1 == NULL, "allocation not failed"); + + /* Initial local heap state.*/ + (void)chHeapStatus(&test_heap, &sz); + + /* Same order.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + p3 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); /* Does not merge.*/ + chHeapFree(p2); /* Merges backward.*/ + chHeapFree(p3); /* Merges both sides.*/ + test_assert(3, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Reverse order.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + p3 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p3); /* Merges forward.*/ + chHeapFree(p2); /* Merges forward.*/ + chHeapFree(p1); /* Merges forward.*/ + test_assert(4, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Small fragments handling.*/ + p1 = chHeapAlloc(&test_heap, SIZE + 1); + p2 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); + test_assert(5, chHeapStatus(&test_heap, &n) == 2, "invalid state"); + p1 = chHeapAlloc(&test_heap, SIZE); + /* Note, the first situation happens when the alignment size is smaller + than the header size, the second in the other cases.*/ + test_assert(6, (chHeapStatus(&test_heap, &n) == 1) || + (chHeapStatus(&test_heap, &n) == 2), "heap fragmented"); + chHeapFree(p2); + chHeapFree(p1); + test_assert(7, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Skip fragment handling.*/ + p1 = chHeapAlloc(&test_heap, SIZE); + p2 = chHeapAlloc(&test_heap, SIZE); + chHeapFree(p1); + test_assert(8, chHeapStatus(&test_heap, &n) == 2, "invalid state"); + p1 = chHeapAlloc(&test_heap, SIZE * 2); /* Skips first fragment.*/ + chHeapFree(p1); + chHeapFree(p2); + test_assert(9, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + + /* Allocate all handling.*/ + (void)chHeapStatus(&test_heap, &n); + p1 = chHeapAlloc(&test_heap, n); + test_assert(10, chHeapStatus(&test_heap, &n) == 0, "not empty"); + chHeapFree(p1); + + test_assert(11, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); + test_assert(12, n == sz, "size changed"); +} + +ROMCONST struct testcase testheap1 = { + "Heap, allocation and fragmentation test", + heap1_setup, + NULL, + heap1_execute +}; + +#endif /* CH_CFG_USE_HEAP.*/ + +/** + * @brief Test sequence for heap. + */ +ROMCONST struct testcase * ROMCONST patternheap[] = { +#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) + &testheap1, +#endif + NULL +}; diff --git a/test/rt/testheap.h b/test/rt/testheap.h new file mode 100644 index 000000000..24d577445 --- /dev/null +++ b/test/rt/testheap.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTHEAP_H_ +#define _TESTHEAP_H_ + +extern ROMCONST struct testcase * ROMCONST patternheap[]; + +#endif /* _TESTHEAP_H_ */ diff --git a/test/rt/testmbox.c b/test/rt/testmbox.c new file mode 100644 index 000000000..a9f57e961 --- /dev/null +++ b/test/rt/testmbox.c @@ -0,0 +1,239 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_mbox Mailboxes test + * + * File: @ref testmbox.c + * + *

Description

+ * This module implements the test sequence for the @ref mailboxes subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref mailboxes + * subsystem code.
+ * Note that the @ref mailboxes subsystem depends on the @ref semaphores + * subsystem that has to met its testing objectives as well. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MAILBOXES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_mbox_001 + * . + * @file testmbox.c + * @brief Mailboxes test source file + * @file testmbox.h + * @brief Mailboxes header file + */ + +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(5) +#define MB_SIZE 5 + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static MAILBOX_DECL(mb1, test.wa.T0, MB_SIZE); + +/** + * @page test_mbox_001 Queuing and timeouts + * + *

Description

+ * Messages are posted/fetched from a mailbox in carefully designed sequences + * in order to stimulate all the possible code paths inside the mailbox.
+ * The test expects to find a consistent mailbox status after each operation. + */ + +static void mbox1_setup(void) { + + chMBObjectInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE); +} + +static void mbox1_execute(void) { + msg_t msg1, msg2; + unsigned i; + + /* + * Testing initial space. + */ + test_assert_lock(1, chMBGetFreeCountI(&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(2, msg1 == MSG_OK, "wrong wake-up message"); + } + msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE); + test_assert(3, msg1 == MSG_OK, "wrong wake-up message"); + + /* + * Testing post timeout. + */ + msg1 = chMBPost(&mb1, 'X', 1); + test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBPostI(&mb1, 'X'); + chSysUnlock(); + test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + msg1 = chMBPostAhead(&mb1, 'X', 1); + test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBPostAheadI(&mb1, 'X'); + chSysUnlock(); + test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + + /* + * Testing final conditions. + */ + test_assert_lock(8, chMBGetFreeCountI(&mb1) == 0, "still empty"); + test_assert_lock(9, chMBGetUsedCountI(&mb1) == MB_SIZE, "not full"); + test_assert_lock(10, 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(11, msg1 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(12, "ABCDE"); + + /* + * Testing buffer circularity. + */ + msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); + test_assert(13, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); + test_assert(14, msg1 == MSG_OK, "wrong wake-up message"); + test_assert(15, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); + test_assert(16, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); + + /* + * Testing fetch timeout. + */ + msg1 = chMBFetch(&mb1, &msg2, 1); + test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + chSysLock(); + msg1 = chMBFetchI(&mb1, &msg2); + chSysUnlock(); + test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message"); + + /* + * Testing final conditions. + */ + test_assert_lock(19, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(20, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert_lock(21, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + /* + * Testing I-Class. + */ + chSysLock(); + msg1 = chMBPostI(&mb1, 'A'); + test_assert(22, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'B'); + test_assert(23, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'C'); + test_assert(24, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'D'); + test_assert(25, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostI(&mb1, 'E'); + chSysUnlock(); + test_assert(26, msg1 == MSG_OK, "wrong wake-up message"); + test_assert(27, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + for (i = 0; i < MB_SIZE; i++) { + chSysLock(); + msg1 = chMBFetchI(&mb1, &msg2); + chSysUnlock(); + test_assert(28, msg1 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(29, "ABCDE"); + test_assert_lock(30, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(31, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert(32, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + chSysLock(); + msg1 = chMBPostAheadI(&mb1, 'E'); + test_assert(33, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'D'); + test_assert(34, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'C'); + test_assert(35, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'B'); + test_assert(36, msg1 == MSG_OK, "wrong wake-up message"); + msg1 = chMBPostAheadI(&mb1, 'A'); + chSysUnlock(); + test_assert(37, msg1 == MSG_OK, "wrong wake-up message"); + test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + for (i = 0; i < MB_SIZE; i++) { + chSysLock(); + msg1 = chMBFetchI(&mb1, &msg2); + chSysUnlock(); + test_assert(39, msg1 == MSG_OK, "wrong wake-up message"); + test_emit_token(msg2); + } + test_assert_sequence(40, "ABCDE"); + test_assert_lock(41, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(42, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert(43, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); + + /* + * Testing reset. + */ + chMBReset(&mb1); + + /* + * Re-testing final conditions. + */ + test_assert_lock(44, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); + test_assert_lock(45, chMBGetUsedCountI(&mb1) == 0, "still full"); + test_assert_lock(46, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); + test_assert_lock(47, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); +} + +ROMCONST struct testcase testmbox1 = { + "Mailboxes, queuing and timeouts", + mbox1_setup, + NULL, + mbox1_execute +}; + +#endif /* CH_CFG_USE_MAILBOXES */ + +/** + * @brief Test sequence for mailboxes. + */ +ROMCONST struct testcase * ROMCONST patternmbox[] = { +#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) + &testmbox1, +#endif + NULL +}; diff --git a/test/rt/testmbox.h b/test/rt/testmbox.h new file mode 100644 index 000000000..5b61ec888 --- /dev/null +++ b/test/rt/testmbox.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMBOX_H_ +#define _TESTMBOX_H_ + +extern ROMCONST struct testcase * ROMCONST patternmbox[]; + +#endif /* _TESTMBOX_H_ */ diff --git a/test/rt/testmsg.c b/test/rt/testmsg.c new file mode 100644 index 000000000..b3b2aedcd --- /dev/null +++ b/test/rt/testmsg.c @@ -0,0 +1,108 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_msg Messages test + * + * File: @ref testmsg.c + * + *

Description

+ * This module implements the test sequence for the @ref messages subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref messages + * subsystem code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MESSAGES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_msg_001 + * . + * @file testmsg.c + * @brief Messages test source file + * @file testmsg.h + * @brief Messages header file + */ + +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) + +/** + * @page test_msg_001 Messages Server loop + * + *

Description

+ * A thread is spawned that sends four messages back to the tester thread.
+ * The test expect to receive the messages in the correct sequence and to + * not find a fifth message waiting. + */ + +static msg_t thread(void *p) { + + chMsgSend(p, 'A'); + chMsgSend(p, 'B'); + chMsgSend(p, 'C'); + return 0; +} + +static void msg1_execute(void) { + thread_t *tp; + msg_t msg; + + /* + * Testing the whole messages loop. + */ + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1, + thread, chThdGetSelfX()); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + tp = chMsgWait(); + msg = chMsgGet(tp); + chMsgRelease(tp, msg); + test_emit_token(msg); + test_assert_sequence(1, "ABC"); +} + +ROMCONST struct testcase testmsg1 = { + "Messages, loop", + NULL, + NULL, + msg1_execute +}; + +#endif /* CH_CFG_USE_MESSAGES */ + +/** + * @brief Test sequence for messages. + */ +ROMCONST struct testcase * ROMCONST patternmsg[] = { +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) + &testmsg1, +#endif + NULL +}; diff --git a/test/rt/testmsg.h b/test/rt/testmsg.h new file mode 100644 index 000000000..47f072d14 --- /dev/null +++ b/test/rt/testmsg.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMSG_H_ +#define _TESTMSG_H_ + +extern ROMCONST struct testcase * ROMCONST patternmsg[]; + +#endif /* _TESTMSG_H_ */ diff --git a/test/rt/testmtx.c b/test/rt/testmtx.c new file mode 100644 index 000000000..c9ba9e093 --- /dev/null +++ b/test/rt/testmtx.c @@ -0,0 +1,636 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_mtx Mutexes test + * + * File: @ref testmtx.c + * + *

Description

+ * This module implements the test sequence for the @ref mutexes and + * @ref condvars subsystems.
+ * Tests on those subsystems are particularly critical because the system-wide + * implications of the Priority Inheritance mechanism. + * + *

Objective

+ * Objective of the test module is to cover 100% of the subsystems code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MUTEXES + * - @p CH_CFG_USE_CONDVARS + * - @p CH_DBG_THREADS_PROFILING + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_mtx_001 + * - @subpage test_mtx_002 + * - @subpage test_mtx_003 + * - @subpage test_mtx_004 + * - @subpage test_mtx_005 + * - @subpage test_mtx_006 + * - @subpage test_mtx_007 + * - @subpage test_mtx_008 + * . + * @file testmtx.c + * @brief Mutexes and CondVars test source file + * @file testmtx.h + * @brief Mutexes and CondVars test header file + */ + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY 5 + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static MUTEX_DECL(m1); +static MUTEX_DECL(m2); +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) +static CONDVAR_DECL(c1); +#endif + +/** + * @page test_mtx_001 Priority enqueuing test + * + *

Description

+ * Five threads, with increasing priority, are enqueued on a locked mutex then + * the mutex is unlocked.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static void mtx1_setup(void) { + + chMtxObjectInit(&m1); +} + +static msg_t thread1(void *p) { + + chMtxLock(&m1); + test_emit_token(*(char *)p); + chMtxUnlock(); + return 0; +} + +static void mtx1_execute(void) { + + tprio_t prio = chThdGetPriorityX(); /* Because priority inheritance.*/ + chMtxLock(&m1); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); + chMtxUnlock(); + test_wait_threads(); + test_assert(1, prio == chThdGetPriorityX(), "wrong priority level"); + test_assert_sequence(2, "ABCDE"); +} + +ROMCONST struct testcase testmtx1 = { + "Mutexes, priority enqueuing test", + mtx1_setup, + NULL, + mtx1_execute +}; + +#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) +/** + * @page test_mtx_002 Priority inheritance, simple case + * + *

Description

+ * Three threads are involved in the classic priority inversion scenario, a + * medium priority thread tries to starve an high priority thread by + * blocking a low priority thread into a mutex lock zone.
+ * The test expects the threads to reach their goal in increasing priority + * order by rearranging their priorities in order to avoid the priority + * inversion trap. + * + *

Scenario

+ * This weird looking diagram should explain what happens in the test case: + * @code + * Time ----> 0 10 20 30 40 50 60 70 80 90 100 + * 0 ......AL++++++++++............2+++++++++++AU0---------------++++++G... + * 1 ..................++++++++++++------------------++++++++++++G......... + * 2 .............................AL..........++++++AUG................... + * ^ ^ + * Legend: + * 0..2 - Priority levels + * +++ - Running + * --- - Ready + * ... - Waiting or Terminated + * xL - Lock operation on mutex 'x' + * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' + * G - Goal + * ^ - Priority transition (boost or return). + * @endcode + */ + +static void mtx2_setup(void) { + + chMtxObjectInit(&m1); +} + +/* Low priority thread */ +static msg_t thread2L(void *p) { + + (void)p; + chMtxLock(&m1); + test_cpu_pulse(40); + chMtxUnlock(); + test_cpu_pulse(10); + test_emit_token('C'); + return 0; +} + +/* Medium priority thread */ +static msg_t thread2M(void *p) { + + (void)p; + chThdSleepMilliseconds(20); + test_cpu_pulse(40); + test_emit_token('B'); + return 0; +} + +/* High priority thread */ +static msg_t thread2H(void *p) { + + (void)p; + chThdSleepMilliseconds(40); + chMtxLock(&m1); + test_cpu_pulse(10); + chMtxUnlock(); + test_emit_token('A'); + return 0; +} + +static void mtx2_execute(void) { + systime_t time; + + test_wait_tick(); + time = chVTGetSystemTime(); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2H, 0); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2M, 0); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2L, 0); + test_wait_threads(); + test_assert_sequence(1, "ABC"); + test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY); +} + +ROMCONST struct testcase testmtx2 = { + "Mutexes, priority inheritance, simple case", + mtx2_setup, + NULL, + mtx2_execute +}; + +/** + * @page test_mtx_003 Priority inheritance, complex case + * + *

Description

+ * Five threads are involved in the complex priority inversion scenario, + * please refer to the diagram below for the complete scenario.
+ * The test expects the threads to perform their operations in increasing + * priority order by rearranging their priorities in order to avoid the + * priority inversion trap. + * + *

Scenario

+ * This weird looking diagram should explain what happens in the test case: + * @code + * Time ----> 0 10 20 30 40 50 60 70 80 90 100 110 + * 0 ......BL++++------------2+++++------4+++++BU0---------------------------G..... + * 1 ............AL++++2+++++BL----------4-----++++++BU4+++AU1---------------G..... + * 2 ..................AL----------------------------------------------++++++AUG... + * 3 ..............................+++++++-----------------------++++++G........... + * 4 ....................................AL................++++++AUG............... + * ^ ^ ^ ^ ^ ^ + * Legend: + * 0..4 - Priority levels + * +++ - Running + * --- - Ready + * ... - Waiting or Terminated + * xL - Lock operation on mutex 'x' + * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' + * ^ - Priority transition (boost or return). + * @endcode + */ + +static void mtx3_setup(void) { + + chMtxObjectInit(&m1); /* Mutex B.*/ + chMtxObjectInit(&m2); /* Mutex A.*/ +} + +/* Lowest priority thread */ +static msg_t thread3LL(void *p) { + + (void)p; + chMtxLock(&m1); + test_cpu_pulse(30); + chMtxUnlock(); + test_emit_token('E'); + return 0; +} + +/* Low priority thread */ +static msg_t thread3L(void *p) { + + (void)p; + chThdSleepMilliseconds(10); + chMtxLock(&m2); + test_cpu_pulse(20); + chMtxLock(&m1); + test_cpu_pulse(10); + chMtxUnlock(); + test_cpu_pulse(10); + chMtxUnlock(); + test_emit_token('D'); + return 0; +} + +/* Medium priority thread */ +static msg_t thread3M(void *p) { + + (void)p; + chThdSleepMilliseconds(20); + chMtxLock(&m2); + test_cpu_pulse(10); + chMtxUnlock(); + test_emit_token('C'); + return 0; +} + +/* High priority thread */ +static msg_t thread3H(void *p) { + + (void)p; + chThdSleepMilliseconds(40); + test_cpu_pulse(20); + test_emit_token('B'); + return 0; +} + +/* Highest priority thread */ +static msg_t thread3HH(void *p) { + + (void)p; + chThdSleepMilliseconds(50); + chMtxLock(&m2); + test_cpu_pulse(10); + chMtxUnlock(); + test_emit_token('A'); + return 0; +} + +static void mtx3_execute(void) { + systime_t time; + + test_wait_tick(); + time = chVTGetSystemTime(); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); + test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY); +} + +ROMCONST struct testcase testmtx3 = { + "Mutexes, priority inheritance, complex case", + mtx3_setup, + NULL, + mtx3_execute +}; +#endif /* CH_DBG_THREADS_PROFILING */ + +/** + * @page test_mtx_004 Priority return verification + * + *

Description

+ * Two threads are spawned that try to lock the mutexes locked by the tester + * thread with precise timing.
+ * The test expects that the priority changes caused by the priority + * inheritance algorithm happen at the right moment and with the right values. + */ + +static void mtx4_setup(void) { + + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); +} + +static msg_t thread4a(void *p) { + + (void)p; + chThdSleepMilliseconds(50); + chMtxLock(&m2); + chMtxUnlock(); + return 0; +} + +static msg_t thread4b(void *p) { + + (void)p; + chThdSleepMilliseconds(150); + chMtxLock(&m1); + chMtxUnlock(); + return 0; +} + +static void mtx4_execute(void) { + tprio_t p, p1, p2; + + p = chThdGetPriorityX(); + p1 = p + 1; + p2 = p + 2; + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A"); + chMtxLock(&m2); + test_assert(1, chThdGetPriorityX() == p, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(2, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxLock(&m1); + test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); + chMtxUnlock(); + test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxUnlockAll(); + test_assert(7, chThdGetPriorityX() == p, "wrong priority level"); + test_wait_threads(); + + /* Test repeated in order to cover chMtxUnlockS().*/ + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C"); + chMtxLock(&m2); + test_assert(8, chThdGetPriorityX() == p, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(9, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxLock(&m1); + test_assert(10, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); + chSysLock(); + chMtxUnlockS(); + chSchRescheduleS(); + chSysUnlock(); + test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); + chThdSleepMilliseconds(100); + test_assert(13, chThdGetPriorityX() == p1, "wrong priority level"); + chMtxUnlockAll(); + test_assert(14, chThdGetPriorityX() == p, "wrong priority level"); + test_wait_threads(); +} + +ROMCONST struct testcase testmtx4 = { + "Mutexes, priority return", + mtx4_setup, + NULL, + mtx4_execute +}; + +/** + * @page test_mtx_005 Mutex status + * + *

Description

+ * Various tests on the mutex structure status after performing some lock and + * unlock operations.
+ * The test expects that the internal mutex status is consistent after each + * operation. + */ + +static void mtx5_setup(void) { + + chMtxObjectInit(&m1); +} + +static void mtx5_execute(void) { + bool b; + tprio_t prio; + + prio = chThdGetPriorityX(); + + b = chMtxTryLock(&m1); + test_assert(1, b, "already locked"); + + b = chMtxTryLock(&m1); + test_assert(2, !b, "not locked"); + + chSysLock(); + chMtxUnlockS(); + chSysUnlock(); + + test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); + test_assert(4, m1.m_owner == NULL, "still owned"); + test_assert(5, chThdGetPriorityX() == prio, "wrong priority level"); + + chMtxLock(&m1); + chMtxUnlockAll(); + test_assert(6, queue_isempty(&m1.m_queue), "queue not empty"); + test_assert(7, m1.m_owner == NULL, "still owned"); +} + +ROMCONST struct testcase testmtx5 = { + "Mutexes, status", + mtx5_setup, + NULL, + mtx5_execute +}; + +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) +/** + * @page test_mtx_006 Condition Variable signal test + * + *

Description

+ * Five threads take a mutex and then enter a conditional variable queue, the + * tester thread then proceeds to signal the conditional variable five times + * atomically.
+ * The test expects the threads to reach their goal in increasing priority + * order regardless of the initial order. + */ + +static void mtx6_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); +} + +static msg_t thread10(void *p) { + + chMtxLock(&m1); + chCondWait(&c1); + test_emit_token(*(char *)p); + chMtxUnlock(); + return 0; +} + +static void mtx6_execute(void) { + + tprio_t prio = chThdGetPriorityX(); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); + chSysLock(); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chCondSignalI(&c1); + chSchRescheduleS(); + chSysUnlock(); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testmtx6 = { + "CondVar, signal test", + mtx6_setup, + NULL, + mtx6_execute +}; + +/** + * @page test_mtx_007 Condition Variable broadcast test + * + *

Description

+ * Five threads take a mutex and then enter a conditional variable queue, the + * tester thread then proceeds to broadcast the conditional variable.
+ * The test expects the threads to reach their goal in increasing priority + * order regardless of the initial order. + */ + +static void mtx7_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); +} + +static void mtx7_execute(void) { + + tprio_t prio = chThdGetPriorityX(); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); + chCondBroadcast(&c1); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testmtx7 = { + "CondVar, broadcast test", + mtx7_setup, + NULL, + mtx7_execute +}; + +/** + * @page test_mtx_008 Condition Variable priority boost test + * + *

Description

+ * This test case verifies the priority boost of a thread waiting on a + * conditional variable queue. It tests this very specific situation in order + * to complete the code coverage. + */ + +static void mtx8_setup(void) { + + chCondObjectInit(&c1); + chMtxObjectInit(&m1); + chMtxObjectInit(&m2); +} + +static msg_t thread11(void *p) { + + chMtxLock(&m2); + chMtxLock(&m1); +#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__) + chCondWaitTimeout(&c1, TIME_INFINITE); +#else + chCondWait(&c1); +#endif + test_emit_token(*(char *)p); + chMtxUnlock(); + chMtxUnlock(); + return 0; +} + +static msg_t thread12(void *p) { + + chMtxLock(&m2); + test_emit_token(*(char *)p); + chMtxUnlock(); + return 0; +} + +static void mtx8_execute(void) { + + tprio_t prio = chThdGetPriorityX(); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B"); + chCondSignal(&c1); + chCondSignal(&c1); + test_wait_threads(); + test_assert_sequence(1, "ABC"); +} + +ROMCONST struct testcase testmtx8 = { + "CondVar, boost test", + mtx8_setup, + NULL, + mtx8_execute +}; +#endif /* CH_CFG_USE_CONDVARS */ +#endif /* CH_CFG_USE_MUTEXES */ + +/** + * @brief Test sequence for mutexes. + */ +ROMCONST struct testcase * ROMCONST patternmtx[] = { +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + &testmtx1, +#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) + &testmtx2, + &testmtx3, +#endif + &testmtx4, + &testmtx5, +#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) + &testmtx6, + &testmtx7, + &testmtx8, +#endif +#endif + NULL +}; diff --git a/test/rt/testmtx.h b/test/rt/testmtx.h new file mode 100644 index 000000000..653c4ad24 --- /dev/null +++ b/test/rt/testmtx.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTMTX_H_ +#define _TESTMTX_H_ + +extern ROMCONST struct testcase * ROMCONST patternmtx[]; + +#endif /* _TESTMTX_H_ */ diff --git a/test/rt/testpools.c b/test/rt/testpools.c new file mode 100644 index 000000000..3037846ea --- /dev/null +++ b/test/rt/testpools.c @@ -0,0 +1,117 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_pools Memory Pools test + * + * File: @ref testpools.c + * + *

Description

+ * This module implements the test sequence for the @ref pools subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref pools code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_MEMPOOLS + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_pools_001 + * . + * @file testpools.c + * @brief Memory Pools test source file + * @file testpools.h + * @brief Memory Pools test header file + */ + +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + +static MEMORYPOOL_DECL(mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); + +/** + * @page test_pools_001 Allocation and enqueuing test + * + *

Description

+ * Five memory blocks are added to a memory pool then removed.
+ * The test expects to find the pool queue in the proper status after each + * operation. + */ + +static void *null_provider(size_t size) { + + (void)size; + return NULL; +} + +static void pools1_setup(void) { + + chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); +} + +static void pools1_execute(void) { + int i; + + /* Adding the WAs to the pool.*/ + chPoolLoadArray(&mp1, wa[0], MAX_THREADS); + + /* Emptying the pool.*/ + for (i = 0; i < MAX_THREADS; i++) + test_assert(1, chPoolAlloc(&mp1) != NULL, "list empty"); + + /* Now must be empty.*/ + test_assert(2, chPoolAlloc(&mp1) == NULL, "list not empty"); + + /* Adding the WAs to the pool, one by one this time.*/ + for (i = 0; i < MAX_THREADS; i++) + chPoolFree(&mp1, wa[i]); + + /* Emptying the pool again.*/ + for (i = 0; i < MAX_THREADS; i++) + test_assert(3, chPoolAlloc(&mp1) != NULL, "list empty"); + + /* Now must be empty again.*/ + test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty"); + + /* Covering the case where a provider is unable to return more memory.*/ + chPoolObjectInit(&mp1, 16, null_provider); + test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory"); +} + +ROMCONST struct testcase testpools1 = { + "Memory Pools, queue/dequeue", + pools1_setup, + NULL, + pools1_execute +}; + +#endif /* CH_CFG_USE_MEMPOOLS */ + +/* + * @brief Test sequence for pools. + */ +ROMCONST struct testcase * ROMCONST patternpools[] = { +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) + &testpools1, +#endif + NULL +}; diff --git a/test/rt/testpools.h b/test/rt/testpools.h new file mode 100644 index 000000000..3fe4ed0f6 --- /dev/null +++ b/test/rt/testpools.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTPOOLS_H_ +#define _TESTPOOLS_H_ + +extern ROMCONST struct testcase * ROMCONST patternpools[]; + +#endif /* _TESTPOOLS_H_ */ diff --git a/test/rt/testqueues.c b/test/rt/testqueues.c new file mode 100644 index 000000000..0d1bcc872 --- /dev/null +++ b/test/rt/testqueues.c @@ -0,0 +1,244 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_queues I/O Queues test + * + * File: @ref testqueues.c + * + *

Description

+ * This module implements the test sequence for the @ref io_queues subsystem. + * The tests are performed by inserting and removing data from queues and by + * checking both the queues status and the correct sequence of the extracted + * data. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref io_queues code.
+ * Note that the @ref io_queues subsystem depends on the @ref semaphores + * subsystem that has to met its testing objectives as well. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_QUEUES (and dependent options) + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_queues_001 + * - @subpage test_queues_002 + * . + * @file testqueues.c + * @brief I/O Queues test source file + * @file testqueues.h + * @brief I/O Queues test header file + */ + +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + +#define TEST_QUEUES_SIZE 4 + +static void notify(io_queue_t *qp) { + (void)qp; +} + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static INPUTQUEUE_DECL(iq, test.wa.T0, TEST_QUEUES_SIZE, notify, NULL); +static OUTPUTQUEUE_DECL(oq, test.wa.T1, TEST_QUEUES_SIZE, notify, NULL); + +/** + * @page test_queues_001 Input Queues functionality and APIs + * + *

Description

+ * This test case tests sysnchronos and asynchronous operations on an + * @p InputQueue object including timeouts. The queue state must remain + * consistent through the whole test. + */ + +static void queues1_setup(void) { + + chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); +} + +static msg_t thread1(void *p) { + + (void)p; + chIQGetTimeout(&iq, MS2ST(200)); + return 0; +} + +static void queues1_execute(void) { + unsigned i; + size_t n; + + /* Initial empty state */ + test_assert_lock(1, chIQIsEmptyI(&iq), "not empty"); + + /* Queue filling */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + test_assert_lock(2, chIQIsFullI(&iq), "still has space"); + test_assert_lock(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL"); + + /* Queue emptying */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) + test_emit_token(chIQGet(&iq)); + test_assert_lock(4, chIQIsEmptyI(&iq), "still full"); + test_assert_sequence(5, "ABCD"); + + /* Queue filling again */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + + /* Reading the whole thing */ + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); + test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); + test_assert_lock(7, chIQIsEmptyI(&iq), "still full"); + + /* Queue filling again */ + chSysLock(); + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + chSysUnlock(); + + /* Partial reads */ + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert_lock(10, chIQIsEmptyI(&iq), "still full"); + + /* Testing reset */ + chSysLock(); + chIQPutI(&iq, 0); + chIQResetI(&iq); + chSysUnlock(); + test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); + test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty"); + test_wait_threads(); + + /* Timeout */ + test_assert(13, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); +} + +ROMCONST struct testcase testqueues1 = { + "Queues, input queues", + queues1_setup, + NULL, + queues1_execute +}; + +/** + * @page test_queues_002 Output Queues functionality and APIs + * + *

Description

+ * This test case tests sysnchronos and asynchronous operations on an + * @p OutputQueue object including timeouts. The queue state must remain + * consistent through the whole test. + */ + +static void queues2_setup(void) { + + chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); +} + +static msg_t thread2(void *p) { + + (void)p; + chOQPutTimeout(&oq, 0, MS2ST(200)); + return 0; +} + +static void queues2_execute(void) { + unsigned i; + size_t n; + + /* Initial empty state */ + test_assert_lock(1, chOQIsEmptyI(&oq), "not empty"); + + /* Queue filling */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chOQPut(&oq, 'A' + i); + test_assert_lock(2, chOQIsFullI(&oq), "still has space"); + + /* Queue emptying */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) { + char c; + + chSysLock(); + c = chOQGetI(&oq); + chSysUnlock(); + test_emit_token(c); + } + test_assert_lock(3, chOQIsEmptyI(&oq), "still full"); + test_assert_sequence(4, "ABCD"); + test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY"); + + /* Writing the whole thing */ + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); + test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); + test_assert_lock(7, chOQIsFullI(&oq), "not full"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); + test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty"); + test_wait_threads(); + + /* Testing reset */ + chSysLock(); + chOQResetI(&oq); + chSysUnlock(); + test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full"); + + /* Partial writes */ + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert_lock(12, chOQIsFullI(&oq), "not full"); + + /* Timeout */ + test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); +} + +ROMCONST struct testcase testqueues2 = { + "Queues, output queues", + queues2_setup, + NULL, + queues2_execute +}; +#endif /* CH_CFG_USE_QUEUES */ + +/** + * @brief Test sequence for queues. + */ +ROMCONST struct testcase * ROMCONST patternqueues[] = { +#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) + &testqueues1, + &testqueues2, +#endif + NULL +}; diff --git a/test/rt/testqueues.h b/test/rt/testqueues.h new file mode 100644 index 000000000..fdfbc4359 --- /dev/null +++ b/test/rt/testqueues.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTQUEUES_H_ +#define _TESTQUEUES_H_ + +extern ROMCONST struct testcase * ROMCONST patternqueues[]; + +#endif /* _TESTQUEUES_H_ */ diff --git a/test/rt/testsem.c b/test/rt/testsem.c new file mode 100644 index 000000000..cb7f13bc2 --- /dev/null +++ b/test/rt/testsem.c @@ -0,0 +1,299 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_sem Semaphores test + * + * File: @ref testsem.c + * + *

Description

+ * This module implements the test sequence for the @ref semaphores subsystem. + * + *

Objective

+ * Objective of the test module is to cover 100% of the @ref semaphores code. + * + *

Preconditions

+ * The module requires the following kernel options: + * - @p CH_CFG_USE_SEMAPHORES + * . + * In case some of the required options are not enabled then some or all tests + * may be skipped. + * + *

Test Cases

+ * - @subpage test_sem_001 + * - @subpage test_sem_002 + * - @subpage test_sem_003 + * - @subpage test_sem_004 + * . + * @file testsem.c + * @brief Semaphores test source file + * @file testsem.h + * @brief Semaphores test header file + */ + +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + +#define ALLOWED_DELAY MS2ST(5) + +/* + * Note, the static initializers are not really required because the + * variables are explicitly initialized in each test case. It is done in order + * to test the macros. + */ +static SEMAPHORE_DECL(sem1, 0); + +/** + * @page test_sem_001 Enqueuing test + * + *

Description

+ * Five threads with randomized priorities are enqueued to a semaphore then + * awakened one at time.
+ * The test expects that the threads reach their goal in FIFO order or + * priority order depending on the CH_CFG_USE_SEMAPHORES_PRIORITY configuration + * setting. + */ + +static void sem1_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static msg_t thread1(void *p) { + + chSemWait(&sem1); + test_emit_token(*(char *)p); + return 0; +} + +static void sem1_execute(void) { + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E"); + chSemSignal(&sem1); + chSemSignal(&sem1); + chSemSignal(&sem1); + chSemSignal(&sem1); + chSemSignal(&sem1); + test_wait_threads(); +#if CH_CFG_USE_SEMAPHORES_PRIORITY + test_assert_sequence(1, "ADCEB"); +#else + test_assert_sequence(1, "ABCDE"); +#endif + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); + chSysLock(); + chSemAddCounterI(&sem1, 2); + chSchRescheduleS(); + chSysUnlock(); + test_wait_threads(); + test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); +} + +ROMCONST struct testcase testsem1 = { + "Semaphores, enqueuing", + sem1_setup, + NULL, + sem1_execute +}; + +/** + * @page test_sem_002 Timeout test + * + *

Description

+ * The three possible semaphore waiting modes (do not wait, wait with timeout, + * wait without timeout) are explored.
+ * The test expects that the semaphore wait function returns the correct value + * in each of the above scenario and that the semaphore structure status is + * correct after each operation. + */ + +static void sem2_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static msg_t thread2(void *p) { + + (void)p; + chThdSleepMilliseconds(50); + chSysLock(); + chSemSignalI(&sem1); /* For coverage reasons */ + chSchRescheduleS(); + chSysUnlock(); + return 0; +} + +static void sem2_execute(void) { + int i; + systime_t target_time; + msg_t msg; + + /* + * Testing special case TIME_IMMEDIATE. + */ + msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); + test_assert(1, msg == MSG_TIMEOUT, "wrong wake-up message"); + test_assert(2, queue_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, chThdGetPriorityX() - 1, + thread2, 0); + msg = chSemWaitTimeout(&sem1, MS2ST(500)); + test_wait_threads(); + test_assert(4, msg == MSG_OK, "wrong wake-up message"); + test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty"); + test_assert(6, sem1.s_cnt == 0, "counter not zero"); + + /* + * Testing timeout condition. + */ + test_wait_tick(); + target_time = chVTGetSystemTime() + MS2ST(5 * 500); + for (i = 0; i < 5; i++) { + test_emit_token('A' + i); + msg = chSemWaitTimeout(&sem1, MS2ST(500)); + test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message"); + test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty"); + test_assert(9, sem1.s_cnt == 0, "counter not zero"); + } + test_assert_sequence(10, "ABCDE"); + test_assert_time_window(11, target_time, target_time + ALLOWED_DELAY); +} + +ROMCONST struct testcase testsem2 = { + "Semaphores, timeout", + sem2_setup, + NULL, + sem2_execute +}; + +/** + * @page test_sem_003 Atomic signal-wait test + * + *

Description

+ * This test case explicitly addresses the @p chSemWaitSignal() function. A + * thread is created that performs a wait and a signal operations. + * The tester thread is awakened from an atomic wait/signal operation.
+ * The test expects that the semaphore wait function returns the correct value + * in each of the above scenario and that the semaphore structure status is + * correct after each operation. + */ + +static void sem3_setup(void) { + + chSemObjectInit(&sem1, 0); +} + +static msg_t thread3(void *p) { + + (void)p; + chSemWait(&sem1); + chSemSignal(&sem1); + return 0; +} + +static void sem3_execute(void) { + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0); + chSemSignalWait(&sem1, &sem1); + test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty"); + test_assert(2, sem1.s_cnt == 0, "counter not zero"); + + chSemSignalWait(&sem1, &sem1); + test_assert(3, queue_isempty(&sem1.s_queue), "queue not empty"); + test_assert(4, sem1.s_cnt == 0, "counter not zero"); +} + +ROMCONST struct testcase testsem3 = { + "Semaphores, atomic signal-wait", + sem3_setup, + NULL, + sem3_execute +}; + +/** + * @page test_sem_004 Binary Wait and Signal + * + *

Description

+ * This test case tests the binary semaphores functionality. The test both + * checks the binary semaphore status and the expected status of the underlying + * counting semaphore. + */ +static msg_t thread4(void *p) { + + chBSemSignal((binary_semaphore_t *)p); + return 0; +} + +static void sem4_execute(void) { + binary_semaphore_t bsem; + + /* Creates a taken binary semaphore.*/ + chBSemObjectInit(&bsem, TRUE); + chBSemReset(&bsem, TRUE); + test_assert_lock(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); + + /* Starts a signaler thread at a lower priority.*/ + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, + chThdGetPriorityX()-1, thread4, &bsem); + + /* Waits to be signaled.*/ + chBSemWait(&bsem); + + /* The binary semaphore is expected to be taken.*/ + test_assert_lock(2, chBSemGetStateI(&bsem) == TRUE, "not taken"); + + /* Releasing it, check both the binary semaphore state and the underlying + counter semaphore state..*/ + chBSemSignal(&bsem); + test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "still taken"); + test_assert_lock(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); + + /* Checking signaling overflow, the counter must not go beyond 1.*/ + chBSemSignal(&bsem); + test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "taken"); + test_assert_lock(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); +} + +ROMCONST struct testcase testsem4 = { + "Binary Semaphores, functionality", + NULL, + NULL, + sem4_execute +}; +#endif /* CH_CFG_USE_SEMAPHORES */ + +/** + * @brief Test sequence for semaphores. + */ +ROMCONST struct testcase * ROMCONST patternsem[] = { +#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) + &testsem1, + &testsem2, + &testsem3, + &testsem4, +#endif + NULL +}; diff --git a/test/rt/testsem.h b/test/rt/testsem.h new file mode 100644 index 000000000..94a8bfca8 --- /dev/null +++ b/test/rt/testsem.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTSEM_H_ +#define _TESTSEM_H_ + +extern ROMCONST struct testcase * ROMCONST patternsem[]; + +#endif /* _TESTSEM_H_ */ diff --git a/test/rt/testthd.c b/test/rt/testthd.c new file mode 100644 index 000000000..522e54b9b --- /dev/null +++ b/test/rt/testthd.c @@ -0,0 +1,231 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "ch.h" +#include "test.h" + +/** + * @page test_threads Threads and Scheduler test + * + * File: @ref testthd.c + * + *

Description

+ * This module implements the test sequence for the @ref scheduler, + * @ref threads and @ref time subsystems.
+ * Note that the tests on those subsystems are formally required but most of + * their functionality is already demonstrated because the test suite itself + * depends on them, anyway double check is good. + * + *

Objective

+ * Objective of the test module is to cover 100% of the subsystems code. + * + *

Preconditions

+ * None. + * + *

Test Cases

+ * - @subpage test_threads_001 + * - @subpage test_threads_002 + * - @subpage test_threads_003 + * - @subpage test_threads_004 + * . + * @file testthd.c + * @brief Threads and Scheduler test source file + * @file testthd.h + * @brief Threads and Scheduler test header file + */ + +/** + * @page test_threads_001 Ready List functionality #1 + * + *

Description

+ * Five threads, with increasing priority, are enqueued in the ready list + * and atomically executed.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static msg_t thread(void *p) { + + test_emit_token(*(char *)p); + return 0; +} + +static void thd1_execute(void) { + + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); + threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testthd1 = { + "Threads, enqueuing test #1", + NULL, + NULL, + thd1_execute +}; + +/** + * @page test_threads_002 Ready List functionality #2 + * + *

Description

+ * Five threads, with pseudo-random priority, are enqueued in the ready list + * and atomically executed.
+ * The test expects the threads to perform their operations in increasing + * priority order regardless of the initial order. + */ + +static void thd2_execute(void) { + + threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); + threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); + threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); + threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); + /* Done this way for coverage of chThdCreateI() and chThdStart().*/ + chSysLock(); + threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); + chSysUnlock(); + chThdStart(threads[2]); + test_wait_threads(); + test_assert_sequence(1, "ABCDE"); +} + +ROMCONST struct testcase testthd2 = { + "Threads, enqueuing test #2", + NULL, + NULL, + thd2_execute +}; + +/** + * @page test_threads_003 Threads priority change test + * + *

Description

+ * A series of priority changes are performed on the current thread in order + * to verify that the priority change happens as expected.
+ * If the @p CH_CFG_USE_MUTEXES option is enabled then the priority changes are + * also tested under priority inheritance boosted priority state. + */ + +static void thd3_execute(void) { + tprio_t prio, p1; + + prio = chThdGetPriorityX(); + p1 = chThdSetPriority(prio + 1); + test_assert(1, p1 == prio, + "unexpected returned priority level"); + test_assert(2, chThdGetPriorityX() == prio + 1, + "unexpected priority level"); + p1 = chThdSetPriority(p1); + test_assert(3, p1 == prio + 1, + "unexpected returned priority level"); + test_assert(4, chThdGetPriorityX() == prio, + "unexpected priority level"); + +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) + /* Simulates a priority boost situation (p_prio > p_realprio).*/ + chSysLock(); + chThdGetSelfX()->p_prio += 2; + chSysUnlock(); + test_assert(5, chThdGetPriorityX() == prio + 2, + "unexpected priority level"); + + /* Tries to raise but below the boost level. */ + p1 = chThdSetPriority(prio + 1); + test_assert(6, p1 == prio, + "unexpected returned priority level"); + test_assert(7, chThdGetSelfX()->p_prio == prio + 2, + "unexpected priority level"); + test_assert(8, chThdGetSelfX()->p_realprio == prio + 1, + "unexpected returned real priority level"); + + /* Tries to raise above the boost level. */ + p1 = chThdSetPriority(prio + 3); + test_assert(9, p1 == prio + 1, + "unexpected returned priority level"); + test_assert(10, chThdGetSelfX()->p_prio == prio + 3, + "unexpected priority level"); + test_assert(11, chThdGetSelfX()->p_realprio == prio + 3, + "unexpected real priority level"); + + chSysLock(); + chThdGetSelfX()->p_prio = prio; + chThdGetSelfX()->p_realprio = prio; + chSysUnlock(); +#endif +} + +ROMCONST struct testcase testthd3 = { + "Threads, priority change", + NULL, + NULL, + thd3_execute +}; + +/** + * @page test_threads_004 Threads delays test + * + *

Description

+ * Delay APIs and associated macros are tested, the invoking thread is verified + * to wake up at the exact expected time. + */ + +static void thd4_execute(void) { + systime_t time; + + test_wait_tick(); + + /* Timeouts in microseconds.*/ + time = chVTGetSystemTime(); + chThdSleepMicroseconds(100000); + test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1); + + /* Timeouts in milliseconds.*/ + time = chVTGetSystemTime(); + chThdSleepMilliseconds(100); + test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1); + + /* Timeouts in seconds.*/ + time = chVTGetSystemTime(); + chThdSleepSeconds(1); + test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1); + + /* Absolute timelines.*/ + time = chVTGetSystemTime() + MS2ST(100); + chThdSleepUntil(time); + test_assert_time_window(4, time, time + 1); +} + +ROMCONST struct testcase testthd4 = { + "Threads, delays", + NULL, + NULL, + thd4_execute +}; + +/** + * @brief Test sequence for threads. + */ +ROMCONST struct testcase * ROMCONST patternthd[] = { + &testthd1, + &testthd2, + &testthd3, + &testthd4, + NULL +}; diff --git a/test/rt/testthd.h b/test/rt/testthd.h new file mode 100644 index 000000000..f1e3a9475 --- /dev/null +++ b/test/rt/testthd.h @@ -0,0 +1,22 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _TESTRDY_H_ +#define _TESTRDY_H_ + +extern ROMCONST struct testcase * ROMCONST patternthd[]; + +#endif /* _TESTRDY_H_ */ diff --git a/test/test.c b/test/test.c deleted file mode 100644 index 0750a0d80..000000000 --- a/test/test.c +++ /dev/null @@ -1,390 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file test.c - * @brief Tests support code. - * - * @addtogroup test - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#include "test.h" -#include "testthd.h" -#include "testsem.h" -#include "testmtx.h" -#include "testmsg.h" -#include "testmbox.h" -#include "testevt.h" -#include "testheap.h" -#include "testpools.h" -#include "testdyn.h" -#include "testqueues.h" -#include "testbmk.h" - -/* - * Array of all the test patterns. - */ -static ROMCONST struct testcase * ROMCONST *patterns[] = { - patternthd, - patternsem, - patternmtx, - patternmsg, - patternmbox, - patternevt, - patternheap, - patternpools, - patterndyn, - patternqueues, - patternbmk, - NULL -}; - -static bool local_fail, global_fail; -static unsigned failpoint; -static char tokens_buffer[MAX_TOKENS]; -static char *tokp; - -/* - * Static working areas, the following areas can be used for threads or - * used as temporary buffers. - */ -union test_buffers test; - -/* - * Pointers to the spawned threads. - */ -thread_t *threads[MAX_THREADS]; - -/* - * Pointers to the working areas. - */ -void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2, - test.wa.T3, test.wa.T4}; - -/* - * Console output. - */ -static BaseSequentialStream *chp; - -/** - * @brief Prints a decimal unsigned number. - * - * @param[in] n the number to be printed - */ -void test_printn(uint32_t n) { - char buf[16], *p; - - if (!n) - chSequentialStreamPut(chp, '0'); - else { - p = buf; - while (n) - *p++ = (n % 10) + '0', n /= 10; - while (p > buf) - chSequentialStreamPut(chp, *--p); - } -} - -/** - * @brief Prints a line without final end-of-line. - * - * @param[in] msgp the message - */ -void test_print(const char *msgp) { - - while (*msgp) - chSequentialStreamPut(chp, *msgp++); -} - -/** - * @brief Prints a line. - * - * @param[in] msgp the message - */ -void test_println(const char *msgp) { - - test_print(msgp); - chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); -} - -/* - * Tokens. - */ -static void clear_tokens(void) { - - tokp = tokens_buffer; -} - -static void print_tokens(void) { - char *cp = tokens_buffer; - - while (cp < tokp) - chSequentialStreamPut(chp, *cp++); -} - -/** - * @brief Emits a token into the tokens buffer. - * - * @param[in] token the token as a char - */ -void test_emit_token(char token) { - - chSysLock(); - *tokp++ = token; - chSysUnlock(); -} - -/* - * Assertions. - */ -bool _test_fail(unsigned point) { - - local_fail = TRUE; - global_fail = TRUE; - failpoint = point; - return TRUE; -} - -bool _test_assert(unsigned point, bool condition) { - - if (!condition) - return _test_fail(point); - return FALSE; -} - -bool _test_assert_sequence(unsigned point, char *expected) { - char *cp = tokens_buffer; - while (cp < tokp) { - if (*cp++ != *expected++) - return _test_fail(point); - } - if (*expected) - return _test_fail(point); - clear_tokens(); - return FALSE; -} - -bool _test_assert_time_window(unsigned point, systime_t start, systime_t end) { - - return _test_assert(point, chVTIsSystemTimeWithin(start, end)); -} - -/* - * Threads utils. - */ - -/** - * @brief Sets a termination request in all the test-spawned threads. - */ -void test_terminate_threads(void) { - int i; - - for (i = 0; i < MAX_THREADS; i++) - if (threads[i]) - chThdTerminate(threads[i]); -} - -/** - * @brief Waits for the completion of all the test-spawned threads. - */ -void test_wait_threads(void) { - int i; - - for (i = 0; i < MAX_THREADS; i++) - if (threads[i] != NULL) { - chThdWait(threads[i]); - threads[i] = NULL; - } -} - -#if CH_DBG_THREADS_PROFILING -/** - * @brief CPU pulse. - * @note The current implementation is not totally reliable. - * - * @param[in] duration CPU pulse duration in milliseconds - */ -void test_cpu_pulse(unsigned duration) { - systime_t start, end, now; - - start = chThdGetTicksX(chThdGetSelfX()); - end = start + MS2ST(duration); - do { - now = chThdGetTicksX(chThdGetSelfX()); -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } - while (end > start ? (now >= start) && (now < end) : - (now >= start) || (now < end)); -} -#endif - -/** - * @brief Delays execution until next system time tick. - * - * @return The system time. - */ -systime_t test_wait_tick(void) { - - chThdSleep(1); - return chVTGetSystemTime(); -} - -/* - * Timer utils. - */ - -/** - * @brief Set to @p TRUE when the test timer reaches its deadline. - */ -bool test_timer_done; - -static virtual_timer_t vt; -static void tmr(void *p) { - (void)p; - - test_timer_done = TRUE; -} - -/** - * @brief Starts the test timer. - * - * @param[in] ms time in milliseconds - */ -void test_start_timer(unsigned ms) { - - systime_t duration = MS2ST(ms); - test_timer_done = FALSE; - chVTSet(&vt, duration, tmr, NULL); -} - -/* - * Test suite execution. - */ -static void execute_test(const struct testcase *tcp) { - int i; - - /* Initialization */ - clear_tokens(); - local_fail = FALSE; - for (i = 0; i < MAX_THREADS; i++) - threads[i] = NULL; - - if (tcp->setup != NULL) - tcp->setup(); - tcp->execute(); - if (tcp->teardown != NULL) - tcp->teardown(); - - test_wait_threads(); -} - -static void print_line(void) { - unsigned i; - - for (i = 0; i < 76; i++) - chSequentialStreamPut(chp, '-'); - chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 2); -} - -/** - * @brief Test execution thread function. - * - * @param[in] p pointer to a @p BaseChannel object for test output - * @return A failure boolean value. - */ -msg_t TestThread(void *p) { - int i, j; - - chp = p; - test_println(""); - test_println("*** ChibiOS/RT test suite"); - test_println("***"); - test_print("*** Kernel: "); - test_println(CH_KERNEL_VERSION); - test_print("*** Compiled: "); - test_println(__DATE__ " - " __TIME__); -#ifdef PORT_COMPILER_NAME - test_print("*** Compiler: "); - test_println(PORT_COMPILER_NAME); -#endif - test_print("*** Architecture: "); - test_println(PORT_ARCHITECTURE_NAME); -#ifdef PORT_CORE_VARIANT_NAME - test_print("*** Core Variant: "); - test_println(PORT_CORE_VARIANT_NAME); -#endif -#ifdef PORT_INFO - test_print("*** Port Info: "); - test_println(PORT_INFO); -#endif -#ifdef PLATFORM_NAME - test_print("*** Platform: "); - test_println(PLATFORM_NAME); -#endif -#ifdef BOARD_NAME - test_print("*** Test Board: "); - test_println(BOARD_NAME); -#endif - test_println(""); - - global_fail = FALSE; - i = 0; - while (patterns[i]) { - j = 0; - while (patterns[i][j]) { - print_line(); - test_print("--- Test Case "); - test_printn(i + 1); - test_print("."); - test_printn(j + 1); - test_print(" ("); - test_print(patterns[i][j]->name); - test_println(")"); -#if DELAY_BETWEEN_TESTS > 0 - chThdSleepMilliseconds(DELAY_BETWEEN_TESTS); -#endif - execute_test(patterns[i][j]); - if (local_fail) { - test_print("--- Result: FAILURE (#"); - test_printn(failpoint); - test_print(" ["); - print_tokens(); - test_println("])"); - } - else - test_println("--- Result: SUCCESS"); - j++; - } - i++; - } - print_line(); - test_println(""); - test_print("Final result: "); - if (global_fail) - test_println("FAILURE"); - else - test_println("SUCCESS"); - - return (msg_t)global_fail; -} - -/** @} */ diff --git a/test/test.dox b/test/test.dox deleted file mode 100644 index 87c68320b..000000000 --- a/test/test.dox +++ /dev/null @@ -1,82 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @defgroup test Test Runtime - * @details Runtime code for the test suite execution, this code is not part - * of the OS and should not be included in user applications. - */ - -/** - * @page testsuite Testing Strategy - *

Description

- * Most of the ChibiOS/RT demos link a set of software modules (test suite) in - * order to verify the proper working of the kernel, the port and the demo - * itself. - * - *

Strategy by Component

- * The OS components are tested in various modes depending on their importance: - * - Kernel. The kernel code is subject to rigorous testing. The test - * suite aims to test all the kernel code and reach a code coverage - * as close to 100% as possible. In addition to the code coverage, the kernel - * code is tested for functionality and benchmarked for speed - * and size before each stable release. In addition to the code - * coverage and functional testing a batch compilation test is - * performed before each release, the kernel is compiled by alternatively - * enabling and disabling all the various configuration options, the - * kernel code is expected to compile without errors nor warnings and - * execute the test suite without failures (a specific simulator is used - * for this execution test, it is done automatically by a script because - * the entire sequence can take hours).
- * All the tests results are included as reports in the OS distribution - * under ./docs/reports. - * - Ports. The port code is tested by executing the kernel test - * suite on the target hardware. A port is validated only if it passes all - * the tests. Speed and size benchmarks for all the supported architectures - * are performed, both size and speed regressions are monitored. - * - HAL. The HAL high level code and device drivers implementations - * are tested through specific test applications under ./testhal. - * - Various. The miscellaneous code is tested by use in the various - * demos. - * - External Code. Not tested, external libraries or components are - * used as-is or with minor patching where required, problems are usually - * reported upstream. - * . - *

Kernel Test Suite

- * The kernel test suite is divided in modules or test sequences. Each Test - * Module performs a series of tests on a specified kernel subsystem or - * subsystems and can report a failure/success status and/or a performance - * index as the test suite output.
- * The test suite is usually activated in the demo applications by pressing a - * button on the target board, see the readme file into the various demos - * directories. The test suite output is usually sent through a serial port - * and can be examined by using a terminal emulator program. - * - *

Kernel Test Modules

- * - * - @subpage test_threads - * - @subpage test_dynamic - * - @subpage test_msg - * - @subpage test_sem - * - @subpage test_mtx - * - @subpage test_events - * - @subpage test_mbox - * - @subpage test_queues - * - @subpage test_heap - * - @subpage test_pools - * - @subpage test_benchmarks - * . - */ diff --git a/test/test.h b/test/test.h deleted file mode 100644 index 1b40a48e0..000000000 --- a/test/test.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file test.h - * @brief Tests support header. - * - * @addtogroup test - * @{ - */ - -#ifndef _TEST_H_ -#define _TEST_H_ - -/** - * @brief Delay inserted between test cases. - */ -#if !defined(DELAY_BETWEEN_TESTS) || defined(__DOXYGEN__) -#define DELAY_BETWEEN_TESTS 200 -#endif - -/** - * @brief If @p TRUE then benchmarks are not included. - */ -#if !defined(TEST_NO_BENCHMARKS) || defined(__DOXYGEN__) -#define TEST_NO_BENCHMARKS FALSE -#endif - -#define MAX_THREADS 5 -#define MAX_TOKENS 16 - -#if defined(CH_ARCHITECTURE_AVR) || defined(CH_ARCHITECTURE_MSP430) -#define THREADS_STACK_SIZE 48 -#elif defined(CH_ARCHITECTURE_STM8) -#define THREADS_STACK_SIZE 64 -#elif defined(CH_ARCHITECTURE_SIMIA32) -#define THREADS_STACK_SIZE 512 -#else -#define THREADS_STACK_SIZE 128 -#endif -#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) - -/** - * @brief Structure representing a test case. - */ -struct testcase { - const char *name; /**< @brief Test case name. */ - void (*setup)(void); /**< @brief Test case preparation function. */ - void (*teardown)(void); /**< @brief Test case clean up function. */ - void (*execute)(void); /**< @brief Test case execution function. */ -}; - -#ifndef __DOXYGEN__ -union test_buffers { - struct { - THD_WORKING_AREA(T0, THREADS_STACK_SIZE); - THD_WORKING_AREA(T1, THREADS_STACK_SIZE); - THD_WORKING_AREA(T2, THREADS_STACK_SIZE); - THD_WORKING_AREA(T3, THREADS_STACK_SIZE); - THD_WORKING_AREA(T4, THREADS_STACK_SIZE); - } wa; - uint8_t buffer[WA_SIZE * 5]; -}; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - msg_t TestThread(void *p); - void test_printn(uint32_t n); - void test_print(const char *msgp); - void test_println(const char *msgp); - void test_emit_token(char token); - bool _test_fail(unsigned point); - bool _test_assert(unsigned point, bool condition); - bool _test_assert_sequence(unsigned point, char *expected); - bool _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); - void test_start_timer(unsigned ms); -#if CH_DBG_THREADS_PROFILING - void test_cpu_pulse(unsigned duration); -#endif -#if defined(WIN32) - void ChkIntSources(void); -#endif -#ifdef __cplusplus -} -#endif - -/** - * @brief Test failure enforcement. - */ -#define test_fail(point) { \ - _test_fail(point); \ - return; \ -} - -/** - * @brief Test assertion. - * - * @param[in] point numeric assertion identifier - * @param[in] condition a boolean expression that must be verified to be true - * @param[in] msg failure message - */ -#define test_assert(point, condition, msg) { \ - if (_test_assert(point, condition)) \ - return; \ -} - -/** - * @brief Test assertion with lock. - * - * @param[in] point numeric assertion identifier - * @param[in] condition a boolean expression that must be verified to be true - * @param[in] msg failure message - */ -#define test_assert_lock(point, condition, msg) { \ - chSysLock(); \ - if (_test_assert(point, condition)) { \ - chSysUnlock(); \ - return; \ - } \ - chSysUnlock(); \ -} - -/** - * @brief Test sequence assertion. - * - * @param[in] point numeric assertion identifier - * @param[in] expected string to be matched with the tokens buffer - */ -#define test_assert_sequence(point, expected) { \ - if (_test_assert_sequence(point, expected)) \ - return; \ -} - -/** - * @brief Test time window assertion. - * - * @param[in] point numeric assertion identifier - * @param[in] start initial time in the window (included) - * @param[in] end final time in the window (not included) - */ -#define test_assert_time_window(point, start, end) { \ - if (_test_assert_time_window(point, start, end)) \ - return; \ -} - -#if !defined(__DOXYGEN__) -extern thread_t *threads[MAX_THREADS]; -extern union test_buffers test; -extern void * ROMCONST wa[]; -extern bool test_timer_done; -#endif - -#endif /* _TEST_H_ */ - -/** @} */ diff --git a/test/test.mk b/test/test.mk deleted file mode 100644 index 3f740288c..000000000 --- a/test/test.mk +++ /dev/null @@ -1,16 +0,0 @@ -# List of all the ChibiOS/RT test files. -TESTSRC = ${CHIBIOS}/test/test.c \ - ${CHIBIOS}/test/testthd.c \ - ${CHIBIOS}/test/testsem.c \ - ${CHIBIOS}/test/testmtx.c \ - ${CHIBIOS}/test/testmsg.c \ - ${CHIBIOS}/test/testmbox.c \ - ${CHIBIOS}/test/testevt.c \ - ${CHIBIOS}/test/testheap.c \ - ${CHIBIOS}/test/testpools.c \ - ${CHIBIOS}/test/testdyn.c \ - ${CHIBIOS}/test/testqueues.c \ - ${CHIBIOS}/test/testbmk.c - -# Required include directories -TESTINC = ${CHIBIOS}/test diff --git a/test/testbmk.c b/test/testbmk.c deleted file mode 100644 index 2a3b7c1b5..000000000 --- a/test/testbmk.c +++ /dev/null @@ -1,715 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_benchmarks Kernel Benchmarks - * - * File: @ref testbmk.c - * - *

Description

- * This module implements a series of system benchmarks. The benchmarks are - * useful as a stress test and as a reference when comparing ChibiOS/RT - * with similar systems. - * - *

Objective

- * Objective of the test module is to provide a performance index for the - * most critical system subsystems. The performance numbers allow to - * discover performance regressions between successive ChibiOS/RT releases. - * - *

Preconditions

- * None. - * - *

Test Cases

- * - @subpage test_benchmarks_001 - * - @subpage test_benchmarks_002 - * - @subpage test_benchmarks_003 - * - @subpage test_benchmarks_004 - * - @subpage test_benchmarks_005 - * - @subpage test_benchmarks_006 - * - @subpage test_benchmarks_007 - * - @subpage test_benchmarks_008 - * - @subpage test_benchmarks_009 - * - @subpage test_benchmarks_010 - * - @subpage test_benchmarks_011 - * - @subpage test_benchmarks_012 - * - @subpage test_benchmarks_013 - * . - * @file testbmk.c Kernel Benchmarks - * @brief Kernel Benchmarks source file - * @file testbmk.h - * @brief Kernel Benchmarks header file - */ - -static semaphore_t sem1; -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) -static mutex_t mtx1; -#endif - -static msg_t thread1(void *p) { - thread_t *tp; - msg_t msg; - - (void)p; - do { - tp = chMsgWait(); - msg = chMsgGet(tp); - chMsgRelease(tp, msg); - } while (msg); - return 0; -} - -#ifdef __GNUC__ -__attribute__((noinline)) -#endif -static unsigned int msg_loop_test(thread_t *tp) { - - uint32_t n = 0; - test_wait_tick(); - test_start_timer(1000); - do { - (void)chMsgSend(tp, 1); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - (void)chMsgSend(tp, 0); - return n; -} - -/** - * @page test_benchmarks_001 Messages performance #1 - * - *

Description

- * A message server thread is created with a lower priority than the client - * thread, the messages throughput per second is measured and the result - * printed in the output log. - */ - -static void bmk1_execute(void) { - uint32_t n; - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, NULL); - n = msg_loop_test(threads[0]); - test_wait_threads(); - test_print("--- Score : "); - test_printn(n); - test_print(" msgs/S, "); - test_printn(n << 1); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk1 = { - "Benchmark, messages #1", - NULL, - NULL, - bmk1_execute -}; - -/** - * @page test_benchmarks_002 Messages performance #2 - * - *

Description

- * A message server thread is created with an higher priority than the client - * thread, the messages throughput per second is measured and the result - * printed in the output log. - */ - -static void bmk2_execute(void) { - uint32_t n; - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); - n = msg_loop_test(threads[0]); - test_wait_threads(); - test_print("--- Score : "); - test_printn(n); - test_print(" msgs/S, "); - test_printn(n << 1); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk2 = { - "Benchmark, messages #2", - NULL, - NULL, - bmk2_execute -}; - -static msg_t thread2(void *p) { - - return (msg_t)p; -} - -/** - * @page test_benchmarks_003 Messages performance #3 - * - *

Description

- * A message server thread is created with an higher priority than the client - * thread, four lower priority threads crowd the ready list, the messages - * throughput per second is measured while the ready list and the result - * printed in the output log. - */ - -static void bmk3_execute(void) { - uint32_t n; - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2, NULL); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2, NULL); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread2, NULL); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread2, NULL); - n = msg_loop_test(threads[0]); - test_wait_threads(); - test_print("--- Score : "); - test_printn(n); - test_print(" msgs/S, "); - test_printn(n << 1); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk3 = { - "Benchmark, messages #3", - NULL, - NULL, - bmk3_execute -}; - -/** - * @page test_benchmarks_004 Context Switch performance - * - *

Description

- * A thread is created that just performs a @p chSchGoSleepS() into a loop, - * the thread is awakened as fast is possible by the tester thread.
- * The Context Switch performance is calculated by measuring the number of - * iterations after a second of continuous operations. - */ - -msg_t thread4(void *p) { - msg_t msg; - thread_t *self = chThdGetSelfX(); - - (void)p; - chSysLock(); - do { - chSchGoSleepS(CH_STATE_SUSPENDED); - msg = self->p_u.rdymsg; - } while (msg == MSG_OK); - chSysUnlock(); - return 0; -} - -static void bmk4_execute(void) { - thread_t *tp; - uint32_t n; - - tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, - thread4, NULL); - n = 0; - test_wait_tick(); - test_start_timer(1000); - do { - chSysLock(); - chSchWakeupS(tp, MSG_OK); - chSchWakeupS(tp, MSG_OK); - chSchWakeupS(tp, MSG_OK); - chSchWakeupS(tp, MSG_OK); - chSysUnlock(); - n += 4; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - chSysLock(); - chSchWakeupS(tp, MSG_TIMEOUT); - chSysUnlock(); - - test_wait_threads(); - test_print("--- Score : "); - test_printn(n * 2); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk4 = { - "Benchmark, context switch", - NULL, - NULL, - bmk4_execute -}; - -/** - * @page test_benchmarks_005 Threads performance, full cycle - * - *

Description

- * Threads are continuously created and terminated into a loop. A full - * @p chThdCreateStatic() / @p chThdExit() / @p chThdWait() cycle is performed - * in each iteration.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void bmk5_execute(void) { - - uint32_t n = 0; - void *wap = wa[0]; - tprio_t prio = chThdGetPriorityX() - 1; - test_wait_tick(); - test_start_timer(1000); - do { - chThdWait(chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL)); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n); - test_println(" threads/S"); -} - -ROMCONST struct testcase testbmk5 = { - "Benchmark, threads, full cycle", - NULL, - NULL, - bmk5_execute -}; - -/** - * @page test_benchmarks_006 Threads performance, create/exit only - * - *

Description

- * Threads are continuously created and terminated into a loop. A partial - * @p chThdCreateStatic() / @p chThdExit() cycle is performed in each - * iteration, the @p chThdWait() is not necessary because the thread is - * created at an higher priority so there is no need to wait for it to - * terminate.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void bmk6_execute(void) { - - uint32_t n = 0; - void *wap = wa[0]; - tprio_t prio = chThdGetPriorityX() + 1; - test_wait_tick(); - test_start_timer(1000); - do { - chThdCreateStatic(wap, WA_SIZE, prio, thread2, NULL); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n); - test_println(" threads/S"); -} - -ROMCONST struct testcase testbmk6 = { - "Benchmark, threads, create only", - NULL, - NULL, - bmk6_execute -}; - -/** - * @page test_benchmarks_007 Mass reschedule performance - * - *

Description

- * Five threads are created and atomically rescheduled by resetting the - * semaphore where they are waiting on. The operation is performed into a - * continuous loop.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static msg_t thread3(void *p) { - - (void)p; - while (!chThdShouldTerminateX()) - chSemWait(&sem1); - return 0; -} - -static void bmk7_setup(void) { - - chSemObjectInit(&sem1, 0); -} - -static void bmk7_execute(void) { - uint32_t n; - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL); - - n = 0; - test_wait_tick(); - test_start_timer(1000); - do { - chSemReset(&sem1, 0); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_terminate_threads(); - chSemReset(&sem1, 0); - test_wait_threads(); - - test_print("--- Score : "); - test_printn(n); - test_print(" reschedules/S, "); - test_printn(n * 6); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk7 = { - "Benchmark, mass reschedule, 5 threads", - bmk7_setup, - NULL, - bmk7_execute -}; - -/** - * @page test_benchmarks_008 I/O Round-Robin voluntary reschedule. - * - *

Description

- * Five threads are created at equal priority, each thread just increases a - * variable and yields.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static msg_t thread8(void *p) { - - do { - chThdYield(); - chThdYield(); - chThdYield(); - chThdYield(); - (*(uint32_t *)p) += 4; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while(!chThdShouldTerminateX()); - return 0; -} - -static void bmk8_execute(void) { - uint32_t n; - - n = 0; - test_wait_tick(); - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n); - - chThdSleepSeconds(1); - test_terminate_threads(); - test_wait_threads(); - - test_print("--- Score : "); - test_printn(n); - test_println(" ctxswc/S"); -} - -ROMCONST struct testcase testbmk8 = { - "Benchmark, round robin context switching", - NULL, - NULL, - bmk8_execute -}; - -#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) -/** - * @page test_benchmarks_009 I/O Queues throughput - * - *

Description

- * Four bytes are written and then read from an @p InputQueue into a continuous - * loop.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void bmk9_execute(void) { - uint32_t n; - static uint8_t ib[16]; - static input_queue_t iq; - - chIQObjectInit(&iq, ib, sizeof(ib), NULL, NULL); - n = 0; - test_wait_tick(); - test_start_timer(1000); - do { - chSysLock(); - chIQPutI(&iq, 0); - chIQPutI(&iq, 1); - chIQPutI(&iq, 2); - chIQPutI(&iq, 3); - chSysUnlock(); - (void)chIQGet(&iq); - (void)chIQGet(&iq); - (void)chIQGet(&iq); - (void)chIQGet(&iq); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n * 4); - test_println(" bytes/S"); -} - -ROMCONST struct testcase testbmk9 = { - "Benchmark, I/O Queues throughput", - NULL, - NULL, - bmk9_execute -}; -#endif /* CH_CFG_USE_QUEUES */ - -/** - * @page test_benchmarks_010 Virtual Timers set/reset performance - * - *

Description

- * A virtual timer is set and immediately reset into a continuous loop.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void tmo(void *param) {(void)param;} - -static void bmk10_execute(void) { - static virtual_timer_t vt1, vt2; - uint32_t n = 0; - - test_wait_tick(); - test_start_timer(1000); - do { - chSysLock(); - chVTDoSetI(&vt1, 1, tmo, NULL); - chVTDoSetI(&vt2, 10000, tmo, NULL); - chVTDoResetI(&vt1); - chVTDoResetI(&vt2); - chSysUnlock(); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n * 2); - test_println(" timers/S"); -} - -ROMCONST struct testcase testbmk10 = { - "Benchmark, virtual timers set/reset", - NULL, - NULL, - bmk10_execute -}; - -/** - * @page test_benchmarks_011 Semaphores wait/signal performance - * - *

Description

- * A counting semaphore is taken/released into a continuous loop, no Context - * Switch happens because the counter is always non negative.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void bmk11_setup(void) { - - chSemObjectInit(&sem1, 1); -} - -static void bmk11_execute(void) { - uint32_t n = 0; - - test_wait_tick(); - test_start_timer(1000); - do { - chSemWait(&sem1); - chSemSignal(&sem1); - chSemWait(&sem1); - chSemSignal(&sem1); - chSemWait(&sem1); - chSemSignal(&sem1); - chSemWait(&sem1); - chSemSignal(&sem1); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n * 4); - test_println(" wait+signal/S"); -} - -ROMCONST struct testcase testbmk11 = { - "Benchmark, semaphores wait/signal", - bmk11_setup, - NULL, - bmk11_execute -}; - -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) -/** - * @page test_benchmarks_012 Mutexes lock/unlock performance - * - *

Description

- * A mutex is locked/unlocked into a continuous loop, no Context Switch happens - * because there are no other threads asking for the mutex.
- * The performance is calculated by measuring the number of iterations after - * a second of continuous operations. - */ - -static void bmk12_setup(void) { - - chMtxObjectInit(&mtx1); -} - -static void bmk12_execute(void) { - uint32_t n = 0; - - test_wait_tick(); - test_start_timer(1000); - do { - chMtxLock(&mtx1); - chMtxUnlock(); - chMtxLock(&mtx1); - chMtxUnlock(); - chMtxLock(&mtx1); - chMtxUnlock(); - chMtxLock(&mtx1); - chMtxUnlock(); - n++; -#if defined(SIMULATOR) - ChkIntSources(); -#endif - } while (!test_timer_done); - test_print("--- Score : "); - test_printn(n * 4); - test_println(" lock+unlock/S"); -} - -ROMCONST struct testcase testbmk12 = { - "Benchmark, mutexes lock/unlock", - bmk12_setup, - NULL, - bmk12_execute -}; -#endif - -/** - * @page test_benchmarks_013 RAM Footprint - * - *

Description

- * The memory size of the various kernel objects is printed. - */ - -static void bmk13_execute(void) { - - test_print("--- System: "); - test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) + - PORT_IDLE_THREAD_STACK_SIZE + - (sizeof(thread_t) + sizeof(struct port_intctx) + - sizeof(struct port_extctx) + - PORT_INT_REQUIRED_STACK) * 2); - test_println(" bytes"); - test_print("--- Thread: "); - test_printn(sizeof(thread_t)); - test_println(" bytes"); - test_print("--- Timer : "); - test_printn(sizeof(virtual_timer_t)); - test_println(" bytes"); - test_print("--- Semaph: "); - test_printn(sizeof(semaphore_t)); - test_println(" bytes"); -#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) - test_print("--- EventS: "); - test_printn(sizeof(event_source_t)); - test_println(" bytes"); - test_print("--- EventL: "); - test_printn(sizeof(event_listener_t)); - test_println(" bytes"); -#endif -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - test_print("--- Mutex : "); - test_printn(sizeof(mutex_t)); - test_println(" bytes"); -#endif -#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) - test_print("--- CondV.: "); - test_printn(sizeof(condition_variable_t)); - test_println(" bytes"); -#endif -#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) - test_print("--- Queue : "); - test_printn(sizeof(io_queue_t)); - test_println(" bytes"); -#endif -#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) - test_print("--- MailB.: "); - test_printn(sizeof(mailbox_t)); - test_println(" bytes"); -#endif -} - -ROMCONST struct testcase testbmk13 = { - "Benchmark, RAM footprint", - NULL, - NULL, - bmk13_execute -}; - -/** - * @brief Test sequence for benchmarks. - */ -ROMCONST struct testcase * ROMCONST patternbmk[] = { -#if !TEST_NO_BENCHMARKS - &testbmk1, - &testbmk2, - &testbmk3, - &testbmk4, - &testbmk5, - &testbmk6, - &testbmk7, - &testbmk8, -#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) - &testbmk9, -#endif - &testbmk10, - &testbmk11, -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - &testbmk12, -#endif - &testbmk13, -#endif - NULL -}; diff --git a/test/testbmk.h b/test/testbmk.h deleted file mode 100644 index 8d7514f74..000000000 --- a/test/testbmk.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTBMK_H_ -#define _TESTBMK_H_ - -extern ROMCONST struct testcase * ROMCONST patternbmk[]; - -#endif /* _TESTBMK_H_ */ diff --git a/test/testdyn.c b/test/testdyn.c deleted file mode 100644 index bf9f127a0..000000000 --- a/test/testdyn.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_dynamic Dynamic APIs test - * - * File: @ref testdyn.c - * - *

Description

- * This module implements the test sequence for the dynamic thread creation - * APIs. - * - *

Objective

- * Objective of the test module is to cover 100% of the dynamic APIs code. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_DYNAMIC - * - @p CH_CFG_USE_HEAP - * - @p CH_CFG_USE_MEMPOOLS - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_dynamic_001 - * - @subpage test_dynamic_002 - * - @subpage test_dynamic_003 - * . - * @file testdyn.c - * @brief Dynamic thread APIs test source file - * @file testdyn.h - * @brief Dynamic thread APIs test header file - */ - -#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) -static memory_heap_t heap1; -#endif -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) -static memory_pool_t mp1; -#endif - -/** - * @page test_dynamic_001 Threads creation from Memory Heap - * - *

Description

- * Two threads are started by allocating the memory from the Memory Heap then - * the remaining heap space is arbitrarily allocated and a third tread startup - * is attempted.
- * The test expects the first two threads to successfully start and the last - * one to fail. - */ - -static msg_t thread(void *p) { - - test_emit_token(*(char *)p); - return 0; -} - -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) -static void dyn1_setup(void) { - - chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); -} - -static void dyn1_execute(void) { - size_t n, sz; - void *p1; - tprio_t prio = chThdGetPriorityX(); - - (void)chHeapStatus(&heap1, &sz); - /* Starting threads from the heap. */ - threads[0] = chThdCreateFromHeap(&heap1, - THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), - prio-1, thread, "A"); - threads[1] = chThdCreateFromHeap(&heap1, - THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), - prio-2, thread, "B"); - /* Allocating the whole heap in order to make the thread creation fail.*/ - (void)chHeapStatus(&heap1, &n); - p1 = chHeapAlloc(&heap1, n); - threads[2] = chThdCreateFromHeap(&heap1, - THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), - prio-3, thread, "C"); - chHeapFree(p1); - - test_assert(1, (threads[0] != NULL) && - (threads[1] != NULL) && - (threads[2] == NULL) && - (threads[3] == NULL) && - (threads[4] == NULL), - "thread creation failed"); - - /* Claiming the memory from terminated threads. */ - test_wait_threads(); - test_assert_sequence(2, "AB"); - - /* Heap status checked again.*/ - test_assert(3, chHeapStatus(&heap1, &n) == 1, "heap fragmented"); - test_assert(4, n == sz, "heap size changed"); -} - -ROMCONST struct testcase testdyn1 = { - "Dynamic APIs, threads creation from heap", - dyn1_setup, - NULL, - dyn1_execute -}; -#endif /* (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) */ - -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) -/** - * @page test_dynamic_002 Threads creation from Memory Pool - * - *

Description

- * Five thread creation are attempted from a pool containing only four - * elements.
- * The test expects the first four threads to successfully start and the last - * one to fail. - */ - -static void dyn2_setup(void) { - - chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); -} - -static void dyn2_execute(void) { - int i; - tprio_t prio = chThdGetPriorityX(); - - /* Adding the WAs to the pool. */ - for (i = 0; i < 4; i++) - chPoolFree(&mp1, wa[i]); - - /* Starting threads from the memory pool. */ - threads[0] = chThdCreateFromMemoryPool(&mp1, prio-1, thread, "A"); - threads[1] = chThdCreateFromMemoryPool(&mp1, prio-2, thread, "B"); - threads[2] = chThdCreateFromMemoryPool(&mp1, prio-3, thread, "C"); - threads[3] = chThdCreateFromMemoryPool(&mp1, prio-4, thread, "D"); - threads[4] = chThdCreateFromMemoryPool(&mp1, prio-5, thread, "E"); - - test_assert(1, (threads[0] != NULL) && - (threads[1] != NULL) && - (threads[2] != NULL) && - (threads[3] != NULL) && - (threads[4] == NULL), - "thread creation failed"); - - /* Claiming the memory from terminated threads. */ - test_wait_threads(); - test_assert_sequence(2, "ABCD"); - - /* Now the pool must be full again. */ - for (i = 0; i < 4; i++) - test_assert(3, chPoolAlloc(&mp1) != NULL, "pool list empty"); - test_assert(4, chPoolAlloc(&mp1) == NULL, "pool list not empty"); -} - -ROMCONST struct testcase testdyn2 = { - "Dynamic APIs, threads creation from memory pool", - dyn2_setup, - NULL, - dyn2_execute -}; -#endif /* CH_CFG_USE_MEMPOOLS */ - -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ - defined(__DOXYGEN__) -/** - * @page test_dynamic_003 Registry and References test - * - *

Description

- * Registry and Thread References APIs are tested for functionality and - * coverage. - */ - -static bool regfind(thread_t *tp) { - thread_t *ftp; - bool found = false; - - ftp = chRegFirstThread(); - do { - found |= ftp == tp; - ftp = chRegNextThread(ftp); - } while (ftp != NULL); - return found; -} - -static void dyn3_setup(void) { - - chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); -} - -static void dyn3_execute(void) { - thread_t *tp; - tprio_t prio = chThdGetPriorityX(); - - /* Testing references increase/decrease and final detach.*/ - tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A"); - test_assert(1, tp->p_refs == 1, "wrong initial reference counter"); - chThdAddRef(tp); - test_assert(2, tp->p_refs == 2, "references increase failure"); - chThdRelease(tp); - test_assert(3, tp->p_refs == 1, "references decrease failure"); - - /* Verify the new threads count.*/ - test_assert(4, regfind(tp), "thread missing from registry"); - test_assert(5, regfind(tp), "thread disappeared"); - - /* Detach and let the thread execute and terminate.*/ - chThdRelease(tp); - test_assert(6, tp->p_refs == 0, "detach failure"); - test_assert(7, tp->p_state == CH_STATE_READY, "invalid state"); - test_assert(8, regfind(tp), "thread disappeared"); - test_assert(9, regfind(tp), "thread disappeared"); - chThdSleepMilliseconds(50); /* The thread just terminates. */ - test_assert(10, tp->p_state == CH_STATE_FINAL, "invalid state"); - - /* Clearing the zombie by scanning the registry.*/ - test_assert(11, regfind(tp), "thread disappeared"); - test_assert(12, !regfind(tp), "thread still in registry"); -} - -ROMCONST struct testcase testdyn3 = { - "Dynamic APIs, registry and references", - dyn3_setup, - NULL, - dyn3_execute -}; -#endif /* CH_CFG_USE_HEAP && CH_CFG_USE_REGISTRY */ -#endif /* CH_CFG_USE_DYNAMIC */ - -/** - * @brief Test sequence for dynamic APIs. - */ -ROMCONST struct testcase * ROMCONST patterndyn[] = { -#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) - &testdyn1, -#endif -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) - &testdyn2, -#endif -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP && CH_CFG_USE_REGISTRY) || \ - defined(__DOXYGEN__) - &testdyn3, -#endif -#endif - NULL -}; diff --git a/test/testdyn.h b/test/testdyn.h deleted file mode 100644 index 6b25dbb30..000000000 --- a/test/testdyn.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTDYN_H_ -#define _TESTDYN_H_ - -extern ROMCONST struct testcase * ROMCONST patterndyn[]; - -#endif /* _TESTDYN_H_ */ diff --git a/test/testevt.c b/test/testevt.c deleted file mode 100644 index 49507f067..000000000 --- a/test/testevt.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_events Events test - * - * File: @ref testevt.c - * - *

Description

- * This module implements the test sequence for the @ref events subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref events subsystem. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_EVENTS - * - @p CH_CFG_USE_EVENTS_TIMEOUT - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_events_001 - * - @subpage test_events_002 - * - @subpage test_events_003 - * . - * @file testevt.c - * @brief Events test source file - * @file testevt.h - * @brief Events test header file - */ - -#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) - -#define ALLOWED_DELAY MS2ST(5) - -/* - * Note, the static initializers are not really required because the - * variables are explicitly initialized in each test case. It is done in order - * to test the macros. - */ -static EVENTSOURCE_DECL(es1); -static EVENTSOURCE_DECL(es2); - -/** - * @page test_events_001 Events registration and dispatch - * - *

Description

- * Two event listeners are registered on an event source and then unregistered - * in the same order.
- * The test expects that the even source has listeners after the registrations - * and after the first unregistration, then, after the second unegistration, - * the test expects no more listeners.
- * In the second part the test dispatches three event flags and verifies that - * the associated event handlers are invoked in LSb-first order. - */ - -static void evt1_setup(void) { - - chEvtGetAndClearEvents(ALL_EVENTS); -} - -static void h1(eventid_t id) {(void)id;test_emit_token('A');} -static void h2(eventid_t id) {(void)id;test_emit_token('B');} -static void h3(eventid_t id) {(void)id;test_emit_token('C');} -static ROMCONST evhandler_t evhndl[] = {h1, h2, h3}; - -static void evt1_execute(void) { - event_listener_t el1, el2; - - /* - * Testing chEvtRegisterMask() and chEvtUnregister(). - */ - chEvtObjectInit(&es1); - chEvtRegisterMask(&es1, &el1, 1); - chEvtRegisterMask(&es1, &el2, 2); - test_assert(1, chEvtIsListeningI(&es1), "no listener"); - chEvtUnregister(&es1, &el1); - test_assert(2, chEvtIsListeningI(&es1), "no listener"); - chEvtUnregister(&es1, &el2); - test_assert(3, !chEvtIsListeningI(&es1), "stuck listener"); - - /* - * Testing chEvtDispatch(). - */ - chEvtDispatch(evhndl, 7); - test_assert_sequence(4, "ABC"); -} - -ROMCONST struct testcase testevt1 = { - "Events, registration and dispatch", - evt1_setup, - NULL, - evt1_execute -}; - -/** - * @page test_events_002 Events wait and broadcast - * - *

Description

- * In this test the following APIs are indipently tested by starting threads - * that signal/broadcast events after fixed delays: - * - @p chEvtWaitOne() - * - @p chEvtWaitAny() - * - @p chEvtWaitAll() - * . - * After each test phase the test verifies that the events have been served at - * the expected time and that there are no stuck event flags. - */ - -static void evt2_setup(void) { - - chEvtGetAndClearEvents(ALL_EVENTS); -} - -static msg_t thread1(void *p) { - - chThdSleepMilliseconds(50); - chEvtSignal((thread_t *)p, 1); - return 0; -} - -static msg_t thread2(void *p) { - - (void)p; - chEvtBroadcast(&es1); - chThdSleepMilliseconds(50); - chEvtBroadcast(&es2); - return 0; -} - -static void evt2_execute(void) { - eventmask_t m; - event_listener_t el1, el2; - systime_t target_time; - - /* - * Test on chEvtWaitOne() without wait. - */ - chEvtAddEvents(5); - m = chEvtWaitOne(ALL_EVENTS); - test_assert(1, m == 1, "single event error"); - m = chEvtWaitOne(ALL_EVENTS); - test_assert(2, m == 4, "single event error"); - m = chEvtGetAndClearEvents(ALL_EVENTS); - test_assert(3, m == 0, "stuck event"); - - /* - * Test on chEvtWaitOne() with wait. - */ - test_wait_tick(); - target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - thread1, chThdGetSelfX()); - m = chEvtWaitOne(ALL_EVENTS); - test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY); - test_assert(5, m == 1, "single event error"); - m = chEvtGetAndClearEvents(ALL_EVENTS); - test_assert(6, m == 0, "stuck event"); - test_wait_threads(); - - /* - * Test on chEvtWaitAny() without wait. - */ - chEvtAddEvents(5); - m = chEvtWaitAny(ALL_EVENTS); - test_assert(7, m == 5, "unexpected pending bit"); - m = chEvtGetAndClearEvents(ALL_EVENTS); - test_assert(8, m == 0, "stuck event"); - - /* - * Test on chEvtWaitAny() with wait. - */ - test_wait_tick(); - target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - thread1, chThdGetSelfX()); - m = chEvtWaitAny(ALL_EVENTS); - test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY); - test_assert(10, m == 1, "single event error"); - m = chEvtGetAndClearEvents(ALL_EVENTS); - test_assert(11, m == 0, "stuck event"); - test_wait_threads(); - - /* - * Test on chEvtWaitAll(). - */ - chEvtObjectInit(&es1); - chEvtObjectInit(&es2); - chEvtRegisterMask(&es1, &el1, 1); - chEvtRegisterMask(&es2, &el2, 4); - test_wait_tick(); - target_time = chVTGetSystemTime() + MS2ST(50); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, - thread2, "A"); - m = chEvtWaitAll(5); - test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY); - m = chEvtGetAndClearEvents(ALL_EVENTS); - test_assert(13, m == 0, "stuck event"); - test_wait_threads(); - chEvtUnregister(&es1, &el1); - chEvtUnregister(&es2, &el2); - test_assert(14, !chEvtIsListeningI(&es1), "stuck listener"); - test_assert(15, !chEvtIsListeningI(&es2), "stuck listener"); -} - -ROMCONST struct testcase testevt2 = { - "Events, wait and broadcast", - evt2_setup, - NULL, - evt2_execute -}; - -#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) -/** - * @page test_events_003 Events timeout - * - *

Description

- * In this test the following APIs are let to timeout twice: immediatly and - * after 10ms: - * In this test the following APIs are indipently tested by starting threads - * that broadcast events after fixed delays: - * - @p chEvtWaitOneTimeout() - * - @p chEvtWaitAnyTimeout() - * - @p chEvtWaitAllTimeout() - * . - * After each test phase the test verifies that there are no stuck event flags. - */ - -static void evt3_setup(void) { - - chEvtGetAndClearEvents(ALL_EVENTS); -} - -static void evt3_execute(void) { - eventmask_t m; - - /* - * Tests various timeout situations. - */ - m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE); - test_assert(1, m == 0, "spurious event"); - m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE); - test_assert(2, m == 0, "spurious event"); - m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE); - test_assert(3, m == 0, "spurious event"); - m = chEvtWaitOneTimeout(ALL_EVENTS, 10); - test_assert(4, m == 0, "spurious event"); - m = chEvtWaitAnyTimeout(ALL_EVENTS, 10); - test_assert(5, m == 0, "spurious event"); - m = chEvtWaitAllTimeout(ALL_EVENTS, 10); - test_assert(6, m == 0, "spurious event"); -} - -ROMCONST struct testcase testevt3 = { - "Events, timeouts", - evt3_setup, - NULL, - evt3_execute -}; -#endif /* CH_CFG_USE_EVENTS_TIMEOUT */ - -/** - * @brief Test sequence for events. - */ -ROMCONST struct testcase * ROMCONST patternevt[] = { -#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) - &testevt1, - &testevt2, -#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__) - &testevt3, -#endif -#endif - NULL -}; - -#endif /* CH_CFG_USE_EVENTS */ diff --git a/test/testevt.h b/test/testevt.h deleted file mode 100644 index 7d189c17f..000000000 --- a/test/testevt.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTEVT_H_ -#define _TESTEVT_H_ - -extern ROMCONST struct testcase * ROMCONST patternevt[]; - -#endif /* _TESTEVT_H_ */ diff --git a/test/testheap.c b/test/testheap.c deleted file mode 100644 index d257a4362..000000000 --- a/test/testheap.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_heap Memory Heap test - * - * File: @ref testheap.c - * - *

Description

- * This module implements the test sequence for the @ref heaps subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref heaps subsystem. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_HEAP - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_heap_001 - * . - * @file testheap.c - * @brief Heap test source file - * @file testheap.h - * @brief Heap header file - */ - -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) - -#define SIZE 16 - -static memory_heap_t test_heap; - -/** - * @page test_heap_001 Allocation and fragmentation test - * - *

Description

- * Series of allocations/deallocations are performed in carefully designed - * sequences in order to stimulate all the possible code paths inside the - * allocator.
- * The test expects to find the heap back to the initial status after each - * sequence. - */ - -static void heap1_setup(void) { - - chHeapObjectInit(&test_heap, test.buffer, sizeof(union test_buffers)); -} - -static void heap1_execute(void) { - void *p1, *p2, *p3; - size_t n, sz; - - /* Unrelated, for coverage only.*/ - (void)chCoreStatus(); - - /* - * Test on the default heap in order to cover the core allocator at - * least one time. - */ - (void)chHeapStatus(NULL, &sz); - p1 = chHeapAlloc(NULL, SIZE); - test_assert(1, p1 != NULL, "allocation failed"); - chHeapFree(p1); - p1 = chHeapAlloc(NULL, (size_t)-256); - test_assert(2, p1 == NULL, "allocation not failed"); - - /* Initial local heap state.*/ - (void)chHeapStatus(&test_heap, &sz); - - /* Same order.*/ - p1 = chHeapAlloc(&test_heap, SIZE); - p2 = chHeapAlloc(&test_heap, SIZE); - p3 = chHeapAlloc(&test_heap, SIZE); - chHeapFree(p1); /* Does not merge.*/ - chHeapFree(p2); /* Merges backward.*/ - chHeapFree(p3); /* Merges both sides.*/ - test_assert(3, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); - - /* Reverse order.*/ - p1 = chHeapAlloc(&test_heap, SIZE); - p2 = chHeapAlloc(&test_heap, SIZE); - p3 = chHeapAlloc(&test_heap, SIZE); - chHeapFree(p3); /* Merges forward.*/ - chHeapFree(p2); /* Merges forward.*/ - chHeapFree(p1); /* Merges forward.*/ - test_assert(4, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); - - /* Small fragments handling.*/ - p1 = chHeapAlloc(&test_heap, SIZE + 1); - p2 = chHeapAlloc(&test_heap, SIZE); - chHeapFree(p1); - test_assert(5, chHeapStatus(&test_heap, &n) == 2, "invalid state"); - p1 = chHeapAlloc(&test_heap, SIZE); - /* Note, the first situation happens when the alignment size is smaller - than the header size, the second in the other cases.*/ - test_assert(6, (chHeapStatus(&test_heap, &n) == 1) || - (chHeapStatus(&test_heap, &n) == 2), "heap fragmented"); - chHeapFree(p2); - chHeapFree(p1); - test_assert(7, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); - - /* Skip fragment handling.*/ - p1 = chHeapAlloc(&test_heap, SIZE); - p2 = chHeapAlloc(&test_heap, SIZE); - chHeapFree(p1); - test_assert(8, chHeapStatus(&test_heap, &n) == 2, "invalid state"); - p1 = chHeapAlloc(&test_heap, SIZE * 2); /* Skips first fragment.*/ - chHeapFree(p1); - chHeapFree(p2); - test_assert(9, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); - - /* Allocate all handling.*/ - (void)chHeapStatus(&test_heap, &n); - p1 = chHeapAlloc(&test_heap, n); - test_assert(10, chHeapStatus(&test_heap, &n) == 0, "not empty"); - chHeapFree(p1); - - test_assert(11, chHeapStatus(&test_heap, &n) == 1, "heap fragmented"); - test_assert(12, n == sz, "size changed"); -} - -ROMCONST struct testcase testheap1 = { - "Heap, allocation and fragmentation test", - heap1_setup, - NULL, - heap1_execute -}; - -#endif /* CH_CFG_USE_HEAP.*/ - -/** - * @brief Test sequence for heap. - */ -ROMCONST struct testcase * ROMCONST patternheap[] = { -#if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) - &testheap1, -#endif - NULL -}; diff --git a/test/testheap.h b/test/testheap.h deleted file mode 100644 index 24d577445..000000000 --- a/test/testheap.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTHEAP_H_ -#define _TESTHEAP_H_ - -extern ROMCONST struct testcase * ROMCONST patternheap[]; - -#endif /* _TESTHEAP_H_ */ diff --git a/test/testmbox.c b/test/testmbox.c deleted file mode 100644 index a9f57e961..000000000 --- a/test/testmbox.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_mbox Mailboxes test - * - * File: @ref testmbox.c - * - *

Description

- * This module implements the test sequence for the @ref mailboxes subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref mailboxes - * subsystem code.
- * Note that the @ref mailboxes subsystem depends on the @ref semaphores - * subsystem that has to met its testing objectives as well. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_MAILBOXES - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_mbox_001 - * . - * @file testmbox.c - * @brief Mailboxes test source file - * @file testmbox.h - * @brief Mailboxes header file - */ - -#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) - -#define ALLOWED_DELAY MS2ST(5) -#define MB_SIZE 5 - -/* - * Note, the static initializers are not really required because the - * variables are explicitly initialized in each test case. It is done in order - * to test the macros. - */ -static MAILBOX_DECL(mb1, test.wa.T0, MB_SIZE); - -/** - * @page test_mbox_001 Queuing and timeouts - * - *

Description

- * Messages are posted/fetched from a mailbox in carefully designed sequences - * in order to stimulate all the possible code paths inside the mailbox.
- * The test expects to find a consistent mailbox status after each operation. - */ - -static void mbox1_setup(void) { - - chMBObjectInit(&mb1, (msg_t *)test.wa.T0, MB_SIZE); -} - -static void mbox1_execute(void) { - msg_t msg1, msg2; - unsigned i; - - /* - * Testing initial space. - */ - test_assert_lock(1, chMBGetFreeCountI(&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(2, msg1 == MSG_OK, "wrong wake-up message"); - } - msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE); - test_assert(3, msg1 == MSG_OK, "wrong wake-up message"); - - /* - * Testing post timeout. - */ - msg1 = chMBPost(&mb1, 'X', 1); - test_assert(4, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - chSysLock(); - msg1 = chMBPostI(&mb1, 'X'); - chSysUnlock(); - test_assert(5, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - msg1 = chMBPostAhead(&mb1, 'X', 1); - test_assert(6, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - chSysLock(); - msg1 = chMBPostAheadI(&mb1, 'X'); - chSysUnlock(); - test_assert(7, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - - /* - * Testing final conditions. - */ - test_assert_lock(8, chMBGetFreeCountI(&mb1) == 0, "still empty"); - test_assert_lock(9, chMBGetUsedCountI(&mb1) == MB_SIZE, "not full"); - test_assert_lock(10, 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(11, msg1 == MSG_OK, "wrong wake-up message"); - test_emit_token(msg2); - } - test_assert_sequence(12, "ABCDE"); - - /* - * Testing buffer circularity. - */ - msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); - test_assert(13, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBFetch(&mb1, &msg2, TIME_INFINITE); - test_assert(14, msg1 == MSG_OK, "wrong wake-up message"); - test_assert(15, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); - test_assert(16, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); - - /* - * Testing fetch timeout. - */ - msg1 = chMBFetch(&mb1, &msg2, 1); - test_assert(17, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - chSysLock(); - msg1 = chMBFetchI(&mb1, &msg2); - chSysUnlock(); - test_assert(18, msg1 == MSG_TIMEOUT, "wrong wake-up message"); - - /* - * Testing final conditions. - */ - test_assert_lock(19, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); - test_assert_lock(20, chMBGetUsedCountI(&mb1) == 0, "still full"); - test_assert_lock(21, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); - - /* - * Testing I-Class. - */ - chSysLock(); - msg1 = chMBPostI(&mb1, 'A'); - test_assert(22, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostI(&mb1, 'B'); - test_assert(23, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostI(&mb1, 'C'); - test_assert(24, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostI(&mb1, 'D'); - test_assert(25, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostI(&mb1, 'E'); - chSysUnlock(); - test_assert(26, msg1 == MSG_OK, "wrong wake-up message"); - test_assert(27, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); - for (i = 0; i < MB_SIZE; i++) { - chSysLock(); - msg1 = chMBFetchI(&mb1, &msg2); - chSysUnlock(); - test_assert(28, msg1 == MSG_OK, "wrong wake-up message"); - test_emit_token(msg2); - } - test_assert_sequence(29, "ABCDE"); - test_assert_lock(30, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); - test_assert_lock(31, chMBGetUsedCountI(&mb1) == 0, "still full"); - test_assert(32, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); - - chSysLock(); - msg1 = chMBPostAheadI(&mb1, 'E'); - test_assert(33, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostAheadI(&mb1, 'D'); - test_assert(34, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostAheadI(&mb1, 'C'); - test_assert(35, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostAheadI(&mb1, 'B'); - test_assert(36, msg1 == MSG_OK, "wrong wake-up message"); - msg1 = chMBPostAheadI(&mb1, 'A'); - chSysUnlock(); - test_assert(37, msg1 == MSG_OK, "wrong wake-up message"); - test_assert(38, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); - for (i = 0; i < MB_SIZE; i++) { - chSysLock(); - msg1 = chMBFetchI(&mb1, &msg2); - chSysUnlock(); - test_assert(39, msg1 == MSG_OK, "wrong wake-up message"); - test_emit_token(msg2); - } - test_assert_sequence(40, "ABCDE"); - test_assert_lock(41, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); - test_assert_lock(42, chMBGetUsedCountI(&mb1) == 0, "still full"); - test_assert(43, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); - - /* - * Testing reset. - */ - chMBReset(&mb1); - - /* - * Re-testing final conditions. - */ - test_assert_lock(44, chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); - test_assert_lock(45, chMBGetUsedCountI(&mb1) == 0, "still full"); - test_assert_lock(46, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); - test_assert_lock(47, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); -} - -ROMCONST struct testcase testmbox1 = { - "Mailboxes, queuing and timeouts", - mbox1_setup, - NULL, - mbox1_execute -}; - -#endif /* CH_CFG_USE_MAILBOXES */ - -/** - * @brief Test sequence for mailboxes. - */ -ROMCONST struct testcase * ROMCONST patternmbox[] = { -#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__) - &testmbox1, -#endif - NULL -}; diff --git a/test/testmbox.h b/test/testmbox.h deleted file mode 100644 index 5b61ec888..000000000 --- a/test/testmbox.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTMBOX_H_ -#define _TESTMBOX_H_ - -extern ROMCONST struct testcase * ROMCONST patternmbox[]; - -#endif /* _TESTMBOX_H_ */ diff --git a/test/testmsg.c b/test/testmsg.c deleted file mode 100644 index b3b2aedcd..000000000 --- a/test/testmsg.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_msg Messages test - * - * File: @ref testmsg.c - * - *

Description

- * This module implements the test sequence for the @ref messages subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref messages - * subsystem code. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_MESSAGES - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_msg_001 - * . - * @file testmsg.c - * @brief Messages test source file - * @file testmsg.h - * @brief Messages header file - */ - -#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) - -/** - * @page test_msg_001 Messages Server loop - * - *

Description

- * A thread is spawned that sends four messages back to the tester thread.
- * The test expect to receive the messages in the correct sequence and to - * not find a fifth message waiting. - */ - -static msg_t thread(void *p) { - - chMsgSend(p, 'A'); - chMsgSend(p, 'B'); - chMsgSend(p, 'C'); - return 0; -} - -static void msg1_execute(void) { - thread_t *tp; - msg_t msg; - - /* - * Testing the whole messages loop. - */ - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1, - thread, chThdGetSelfX()); - tp = chMsgWait(); - msg = chMsgGet(tp); - chMsgRelease(tp, msg); - test_emit_token(msg); - tp = chMsgWait(); - msg = chMsgGet(tp); - chMsgRelease(tp, msg); - test_emit_token(msg); - tp = chMsgWait(); - msg = chMsgGet(tp); - chMsgRelease(tp, msg); - test_emit_token(msg); - test_assert_sequence(1, "ABC"); -} - -ROMCONST struct testcase testmsg1 = { - "Messages, loop", - NULL, - NULL, - msg1_execute -}; - -#endif /* CH_CFG_USE_MESSAGES */ - -/** - * @brief Test sequence for messages. - */ -ROMCONST struct testcase * ROMCONST patternmsg[] = { -#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) - &testmsg1, -#endif - NULL -}; diff --git a/test/testmsg.h b/test/testmsg.h deleted file mode 100644 index 47f072d14..000000000 --- a/test/testmsg.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTMSG_H_ -#define _TESTMSG_H_ - -extern ROMCONST struct testcase * ROMCONST patternmsg[]; - -#endif /* _TESTMSG_H_ */ diff --git a/test/testmtx.c b/test/testmtx.c deleted file mode 100644 index c9ba9e093..000000000 --- a/test/testmtx.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_mtx Mutexes test - * - * File: @ref testmtx.c - * - *

Description

- * This module implements the test sequence for the @ref mutexes and - * @ref condvars subsystems.
- * Tests on those subsystems are particularly critical because the system-wide - * implications of the Priority Inheritance mechanism. - * - *

Objective

- * Objective of the test module is to cover 100% of the subsystems code. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_MUTEXES - * - @p CH_CFG_USE_CONDVARS - * - @p CH_DBG_THREADS_PROFILING - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_mtx_001 - * - @subpage test_mtx_002 - * - @subpage test_mtx_003 - * - @subpage test_mtx_004 - * - @subpage test_mtx_005 - * - @subpage test_mtx_006 - * - @subpage test_mtx_007 - * - @subpage test_mtx_008 - * . - * @file testmtx.c - * @brief Mutexes and CondVars test source file - * @file testmtx.h - * @brief Mutexes and CondVars test header file - */ - -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - -#define ALLOWED_DELAY 5 - -/* - * Note, the static initializers are not really required because the - * variables are explicitly initialized in each test case. It is done in order - * to test the macros. - */ -static MUTEX_DECL(m1); -static MUTEX_DECL(m2); -#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) -static CONDVAR_DECL(c1); -#endif - -/** - * @page test_mtx_001 Priority enqueuing test - * - *

Description

- * Five threads, with increasing priority, are enqueued on a locked mutex then - * the mutex is unlocked.
- * The test expects the threads to perform their operations in increasing - * priority order regardless of the initial order. - */ - -static void mtx1_setup(void) { - - chMtxObjectInit(&m1); -} - -static msg_t thread1(void *p) { - - chMtxLock(&m1); - test_emit_token(*(char *)p); - chMtxUnlock(); - return 0; -} - -static void mtx1_execute(void) { - - tprio_t prio = chThdGetPriorityX(); /* Because priority inheritance.*/ - chMtxLock(&m1); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); - chMtxUnlock(); - test_wait_threads(); - test_assert(1, prio == chThdGetPriorityX(), "wrong priority level"); - test_assert_sequence(2, "ABCDE"); -} - -ROMCONST struct testcase testmtx1 = { - "Mutexes, priority enqueuing test", - mtx1_setup, - NULL, - mtx1_execute -}; - -#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) -/** - * @page test_mtx_002 Priority inheritance, simple case - * - *

Description

- * Three threads are involved in the classic priority inversion scenario, a - * medium priority thread tries to starve an high priority thread by - * blocking a low priority thread into a mutex lock zone.
- * The test expects the threads to reach their goal in increasing priority - * order by rearranging their priorities in order to avoid the priority - * inversion trap. - * - *

Scenario

- * This weird looking diagram should explain what happens in the test case: - * @code - * Time ----> 0 10 20 30 40 50 60 70 80 90 100 - * 0 ......AL++++++++++............2+++++++++++AU0---------------++++++G... - * 1 ..................++++++++++++------------------++++++++++++G......... - * 2 .............................AL..........++++++AUG................... - * ^ ^ - * Legend: - * 0..2 - Priority levels - * +++ - Running - * --- - Ready - * ... - Waiting or Terminated - * xL - Lock operation on mutex 'x' - * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' - * G - Goal - * ^ - Priority transition (boost or return). - * @endcode - */ - -static void mtx2_setup(void) { - - chMtxObjectInit(&m1); -} - -/* Low priority thread */ -static msg_t thread2L(void *p) { - - (void)p; - chMtxLock(&m1); - test_cpu_pulse(40); - chMtxUnlock(); - test_cpu_pulse(10); - test_emit_token('C'); - return 0; -} - -/* Medium priority thread */ -static msg_t thread2M(void *p) { - - (void)p; - chThdSleepMilliseconds(20); - test_cpu_pulse(40); - test_emit_token('B'); - return 0; -} - -/* High priority thread */ -static msg_t thread2H(void *p) { - - (void)p; - chThdSleepMilliseconds(40); - chMtxLock(&m1); - test_cpu_pulse(10); - chMtxUnlock(); - test_emit_token('A'); - return 0; -} - -static void mtx2_execute(void) { - systime_t time; - - test_wait_tick(); - time = chVTGetSystemTime(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2H, 0); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2M, 0); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2L, 0); - test_wait_threads(); - test_assert_sequence(1, "ABC"); - test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY); -} - -ROMCONST struct testcase testmtx2 = { - "Mutexes, priority inheritance, simple case", - mtx2_setup, - NULL, - mtx2_execute -}; - -/** - * @page test_mtx_003 Priority inheritance, complex case - * - *

Description

- * Five threads are involved in the complex priority inversion scenario, - * please refer to the diagram below for the complete scenario.
- * The test expects the threads to perform their operations in increasing - * priority order by rearranging their priorities in order to avoid the - * priority inversion trap. - * - *

Scenario

- * This weird looking diagram should explain what happens in the test case: - * @code - * Time ----> 0 10 20 30 40 50 60 70 80 90 100 110 - * 0 ......BL++++------------2+++++------4+++++BU0---------------------------G..... - * 1 ............AL++++2+++++BL----------4-----++++++BU4+++AU1---------------G..... - * 2 ..................AL----------------------------------------------++++++AUG... - * 3 ..............................+++++++-----------------------++++++G........... - * 4 ....................................AL................++++++AUG............... - * ^ ^ ^ ^ ^ ^ - * Legend: - * 0..4 - Priority levels - * +++ - Running - * --- - Ready - * ... - Waiting or Terminated - * xL - Lock operation on mutex 'x' - * xUn - Unlock operation on mutex 'x' with priority returning to level 'n' - * ^ - Priority transition (boost or return). - * @endcode - */ - -static void mtx3_setup(void) { - - chMtxObjectInit(&m1); /* Mutex B.*/ - chMtxObjectInit(&m2); /* Mutex A.*/ -} - -/* Lowest priority thread */ -static msg_t thread3LL(void *p) { - - (void)p; - chMtxLock(&m1); - test_cpu_pulse(30); - chMtxUnlock(); - test_emit_token('E'); - return 0; -} - -/* Low priority thread */ -static msg_t thread3L(void *p) { - - (void)p; - chThdSleepMilliseconds(10); - chMtxLock(&m2); - test_cpu_pulse(20); - chMtxLock(&m1); - test_cpu_pulse(10); - chMtxUnlock(); - test_cpu_pulse(10); - chMtxUnlock(); - test_emit_token('D'); - return 0; -} - -/* Medium priority thread */ -static msg_t thread3M(void *p) { - - (void)p; - chThdSleepMilliseconds(20); - chMtxLock(&m2); - test_cpu_pulse(10); - chMtxUnlock(); - test_emit_token('C'); - return 0; -} - -/* High priority thread */ -static msg_t thread3H(void *p) { - - (void)p; - chThdSleepMilliseconds(40); - test_cpu_pulse(20); - test_emit_token('B'); - return 0; -} - -/* Highest priority thread */ -static msg_t thread3HH(void *p) { - - (void)p; - chThdSleepMilliseconds(50); - chMtxLock(&m2); - test_cpu_pulse(10); - chMtxUnlock(); - test_emit_token('A'); - return 0; -} - -static void mtx3_execute(void) { - systime_t time; - - test_wait_tick(); - time = chVTGetSystemTime(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0); - test_wait_threads(); - test_assert_sequence(1, "ABCDE"); - test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY); -} - -ROMCONST struct testcase testmtx3 = { - "Mutexes, priority inheritance, complex case", - mtx3_setup, - NULL, - mtx3_execute -}; -#endif /* CH_DBG_THREADS_PROFILING */ - -/** - * @page test_mtx_004 Priority return verification - * - *

Description

- * Two threads are spawned that try to lock the mutexes locked by the tester - * thread with precise timing.
- * The test expects that the priority changes caused by the priority - * inheritance algorithm happen at the right moment and with the right values. - */ - -static void mtx4_setup(void) { - - chMtxObjectInit(&m1); - chMtxObjectInit(&m2); -} - -static msg_t thread4a(void *p) { - - (void)p; - chThdSleepMilliseconds(50); - chMtxLock(&m2); - chMtxUnlock(); - return 0; -} - -static msg_t thread4b(void *p) { - - (void)p; - chThdSleepMilliseconds(150); - chMtxLock(&m1); - chMtxUnlock(); - return 0; -} - -static void mtx4_execute(void) { - tprio_t p, p1, p2; - - p = chThdGetPriorityX(); - p1 = p + 1; - p2 = p + 2; - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A"); - chMtxLock(&m2); - test_assert(1, chThdGetPriorityX() == p, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(2, chThdGetPriorityX() == p1, "wrong priority level"); - chMtxLock(&m1); - test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); - chMtxUnlock(); - test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); - chMtxUnlockAll(); - test_assert(7, chThdGetPriorityX() == p, "wrong priority level"); - test_wait_threads(); - - /* Test repeated in order to cover chMtxUnlockS().*/ - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C"); - chMtxLock(&m2); - test_assert(8, chThdGetPriorityX() == p, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(9, chThdGetPriorityX() == p1, "wrong priority level"); - chMtxLock(&m1); - test_assert(10, chThdGetPriorityX() == p1, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); - chSysLock(); - chMtxUnlockS(); - chSchRescheduleS(); - chSysUnlock(); - test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); - chThdSleepMilliseconds(100); - test_assert(13, chThdGetPriorityX() == p1, "wrong priority level"); - chMtxUnlockAll(); - test_assert(14, chThdGetPriorityX() == p, "wrong priority level"); - test_wait_threads(); -} - -ROMCONST struct testcase testmtx4 = { - "Mutexes, priority return", - mtx4_setup, - NULL, - mtx4_execute -}; - -/** - * @page test_mtx_005 Mutex status - * - *

Description

- * Various tests on the mutex structure status after performing some lock and - * unlock operations.
- * The test expects that the internal mutex status is consistent after each - * operation. - */ - -static void mtx5_setup(void) { - - chMtxObjectInit(&m1); -} - -static void mtx5_execute(void) { - bool b; - tprio_t prio; - - prio = chThdGetPriorityX(); - - b = chMtxTryLock(&m1); - test_assert(1, b, "already locked"); - - b = chMtxTryLock(&m1); - test_assert(2, !b, "not locked"); - - chSysLock(); - chMtxUnlockS(); - chSysUnlock(); - - test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); - test_assert(4, m1.m_owner == NULL, "still owned"); - test_assert(5, chThdGetPriorityX() == prio, "wrong priority level"); - - chMtxLock(&m1); - chMtxUnlockAll(); - test_assert(6, queue_isempty(&m1.m_queue), "queue not empty"); - test_assert(7, m1.m_owner == NULL, "still owned"); -} - -ROMCONST struct testcase testmtx5 = { - "Mutexes, status", - mtx5_setup, - NULL, - mtx5_execute -}; - -#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) -/** - * @page test_mtx_006 Condition Variable signal test - * - *

Description

- * Five threads take a mutex and then enter a conditional variable queue, the - * tester thread then proceeds to signal the conditional variable five times - * atomically.
- * The test expects the threads to reach their goal in increasing priority - * order regardless of the initial order. - */ - -static void mtx6_setup(void) { - - chCondObjectInit(&c1); - chMtxObjectInit(&m1); -} - -static msg_t thread10(void *p) { - - chMtxLock(&m1); - chCondWait(&c1); - test_emit_token(*(char *)p); - chMtxUnlock(); - return 0; -} - -static void mtx6_execute(void) { - - tprio_t prio = chThdGetPriorityX(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); - chSysLock(); - chCondSignalI(&c1); - chCondSignalI(&c1); - chCondSignalI(&c1); - chCondSignalI(&c1); - chCondSignalI(&c1); - chSchRescheduleS(); - chSysUnlock(); - test_wait_threads(); - test_assert_sequence(1, "ABCDE"); -} - -ROMCONST struct testcase testmtx6 = { - "CondVar, signal test", - mtx6_setup, - NULL, - mtx6_execute -}; - -/** - * @page test_mtx_007 Condition Variable broadcast test - * - *

Description

- * Five threads take a mutex and then enter a conditional variable queue, the - * tester thread then proceeds to broadcast the conditional variable.
- * The test expects the threads to reach their goal in increasing priority - * order regardless of the initial order. - */ - -static void mtx7_setup(void) { - - chCondObjectInit(&c1); - chMtxObjectInit(&m1); -} - -static void mtx7_execute(void) { - - tprio_t prio = chThdGetPriorityX(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread10, "B"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread10, "A"); - chCondBroadcast(&c1); - test_wait_threads(); - test_assert_sequence(1, "ABCDE"); -} - -ROMCONST struct testcase testmtx7 = { - "CondVar, broadcast test", - mtx7_setup, - NULL, - mtx7_execute -}; - -/** - * @page test_mtx_008 Condition Variable priority boost test - * - *

Description

- * This test case verifies the priority boost of a thread waiting on a - * conditional variable queue. It tests this very specific situation in order - * to complete the code coverage. - */ - -static void mtx8_setup(void) { - - chCondObjectInit(&c1); - chMtxObjectInit(&m1); - chMtxObjectInit(&m2); -} - -static msg_t thread11(void *p) { - - chMtxLock(&m2); - chMtxLock(&m1); -#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__) - chCondWaitTimeout(&c1, TIME_INFINITE); -#else - chCondWait(&c1); -#endif - test_emit_token(*(char *)p); - chMtxUnlock(); - chMtxUnlock(); - return 0; -} - -static msg_t thread12(void *p) { - - chMtxLock(&m2); - test_emit_token(*(char *)p); - chMtxUnlock(); - return 0; -} - -static void mtx8_execute(void) { - - tprio_t prio = chThdGetPriorityX(); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B"); - chCondSignal(&c1); - chCondSignal(&c1); - test_wait_threads(); - test_assert_sequence(1, "ABC"); -} - -ROMCONST struct testcase testmtx8 = { - "CondVar, boost test", - mtx8_setup, - NULL, - mtx8_execute -}; -#endif /* CH_CFG_USE_CONDVARS */ -#endif /* CH_CFG_USE_MUTEXES */ - -/** - * @brief Test sequence for mutexes. - */ -ROMCONST struct testcase * ROMCONST patternmtx[] = { -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - &testmtx1, -#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) - &testmtx2, - &testmtx3, -#endif - &testmtx4, - &testmtx5, -#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__) - &testmtx6, - &testmtx7, - &testmtx8, -#endif -#endif - NULL -}; diff --git a/test/testmtx.h b/test/testmtx.h deleted file mode 100644 index 653c4ad24..000000000 --- a/test/testmtx.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTMTX_H_ -#define _TESTMTX_H_ - -extern ROMCONST struct testcase * ROMCONST patternmtx[]; - -#endif /* _TESTMTX_H_ */ diff --git a/test/testpools.c b/test/testpools.c deleted file mode 100644 index 3037846ea..000000000 --- a/test/testpools.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_pools Memory Pools test - * - * File: @ref testpools.c - * - *

Description

- * This module implements the test sequence for the @ref pools subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref pools code. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_MEMPOOLS - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_pools_001 - * . - * @file testpools.c - * @brief Memory Pools test source file - * @file testpools.h - * @brief Memory Pools test header file - */ - -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) - -static MEMORYPOOL_DECL(mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); - -/** - * @page test_pools_001 Allocation and enqueuing test - * - *

Description

- * Five memory blocks are added to a memory pool then removed.
- * The test expects to find the pool queue in the proper status after each - * operation. - */ - -static void *null_provider(size_t size) { - - (void)size; - return NULL; -} - -static void pools1_setup(void) { - - chPoolObjectInit(&mp1, THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), NULL); -} - -static void pools1_execute(void) { - int i; - - /* Adding the WAs to the pool.*/ - chPoolLoadArray(&mp1, wa[0], MAX_THREADS); - - /* Emptying the pool.*/ - for (i = 0; i < MAX_THREADS; i++) - test_assert(1, chPoolAlloc(&mp1) != NULL, "list empty"); - - /* Now must be empty.*/ - test_assert(2, chPoolAlloc(&mp1) == NULL, "list not empty"); - - /* Adding the WAs to the pool, one by one this time.*/ - for (i = 0; i < MAX_THREADS; i++) - chPoolFree(&mp1, wa[i]); - - /* Emptying the pool again.*/ - for (i = 0; i < MAX_THREADS; i++) - test_assert(3, chPoolAlloc(&mp1) != NULL, "list empty"); - - /* Now must be empty again.*/ - test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty"); - - /* Covering the case where a provider is unable to return more memory.*/ - chPoolObjectInit(&mp1, 16, null_provider); - test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory"); -} - -ROMCONST struct testcase testpools1 = { - "Memory Pools, queue/dequeue", - pools1_setup, - NULL, - pools1_execute -}; - -#endif /* CH_CFG_USE_MEMPOOLS */ - -/* - * @brief Test sequence for pools. - */ -ROMCONST struct testcase * ROMCONST patternpools[] = { -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) - &testpools1, -#endif - NULL -}; diff --git a/test/testpools.h b/test/testpools.h deleted file mode 100644 index 3fe4ed0f6..000000000 --- a/test/testpools.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTPOOLS_H_ -#define _TESTPOOLS_H_ - -extern ROMCONST struct testcase * ROMCONST patternpools[]; - -#endif /* _TESTPOOLS_H_ */ diff --git a/test/testqueues.c b/test/testqueues.c deleted file mode 100644 index 0d1bcc872..000000000 --- a/test/testqueues.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_queues I/O Queues test - * - * File: @ref testqueues.c - * - *

Description

- * This module implements the test sequence for the @ref io_queues subsystem. - * The tests are performed by inserting and removing data from queues and by - * checking both the queues status and the correct sequence of the extracted - * data. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref io_queues code.
- * Note that the @ref io_queues subsystem depends on the @ref semaphores - * subsystem that has to met its testing objectives as well. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_QUEUES (and dependent options) - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_queues_001 - * - @subpage test_queues_002 - * . - * @file testqueues.c - * @brief I/O Queues test source file - * @file testqueues.h - * @brief I/O Queues test header file - */ - -#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) - -#define TEST_QUEUES_SIZE 4 - -static void notify(io_queue_t *qp) { - (void)qp; -} - -/* - * Note, the static initializers are not really required because the - * variables are explicitly initialized in each test case. It is done in order - * to test the macros. - */ -static INPUTQUEUE_DECL(iq, test.wa.T0, TEST_QUEUES_SIZE, notify, NULL); -static OUTPUTQUEUE_DECL(oq, test.wa.T1, TEST_QUEUES_SIZE, notify, NULL); - -/** - * @page test_queues_001 Input Queues functionality and APIs - * - *

Description

- * This test case tests sysnchronos and asynchronous operations on an - * @p InputQueue object including timeouts. The queue state must remain - * consistent through the whole test. - */ - -static void queues1_setup(void) { - - chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); -} - -static msg_t thread1(void *p) { - - (void)p; - chIQGetTimeout(&iq, MS2ST(200)); - return 0; -} - -static void queues1_execute(void) { - unsigned i; - size_t n; - - /* Initial empty state */ - test_assert_lock(1, chIQIsEmptyI(&iq), "not empty"); - - /* Queue filling */ - chSysLock(); - for (i = 0; i < TEST_QUEUES_SIZE; i++) - chIQPutI(&iq, 'A' + i); - chSysUnlock(); - test_assert_lock(2, chIQIsFullI(&iq), "still has space"); - test_assert_lock(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL"); - - /* Queue emptying */ - for (i = 0; i < TEST_QUEUES_SIZE; i++) - test_emit_token(chIQGet(&iq)); - test_assert_lock(4, chIQIsEmptyI(&iq), "still full"); - test_assert_sequence(5, "ABCD"); - - /* Queue filling again */ - chSysLock(); - for (i = 0; i < TEST_QUEUES_SIZE; i++) - chIQPutI(&iq, 'A' + i); - chSysUnlock(); - - /* Reading the whole thing */ - n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); - test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); - test_assert_lock(7, chIQIsEmptyI(&iq), "still full"); - - /* Queue filling again */ - chSysLock(); - for (i = 0; i < TEST_QUEUES_SIZE; i++) - chIQPutI(&iq, 'A' + i); - chSysUnlock(); - - /* Partial reads */ - n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); - test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); - n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); - test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); - test_assert_lock(10, chIQIsEmptyI(&iq), "still full"); - - /* Testing reset */ - chSysLock(); - chIQPutI(&iq, 0); - chIQResetI(&iq); - chSysUnlock(); - test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL); - test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty"); - test_wait_threads(); - - /* Timeout */ - test_assert(13, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); -} - -ROMCONST struct testcase testqueues1 = { - "Queues, input queues", - queues1_setup, - NULL, - queues1_execute -}; - -/** - * @page test_queues_002 Output Queues functionality and APIs - * - *

Description

- * This test case tests sysnchronos and asynchronous operations on an - * @p OutputQueue object including timeouts. The queue state must remain - * consistent through the whole test. - */ - -static void queues2_setup(void) { - - chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); -} - -static msg_t thread2(void *p) { - - (void)p; - chOQPutTimeout(&oq, 0, MS2ST(200)); - return 0; -} - -static void queues2_execute(void) { - unsigned i; - size_t n; - - /* Initial empty state */ - test_assert_lock(1, chOQIsEmptyI(&oq), "not empty"); - - /* Queue filling */ - for (i = 0; i < TEST_QUEUES_SIZE; i++) - chOQPut(&oq, 'A' + i); - test_assert_lock(2, chOQIsFullI(&oq), "still has space"); - - /* Queue emptying */ - for (i = 0; i < TEST_QUEUES_SIZE; i++) { - char c; - - chSysLock(); - c = chOQGetI(&oq); - chSysUnlock(); - test_emit_token(c); - } - test_assert_lock(3, chOQIsEmptyI(&oq), "still full"); - test_assert_sequence(4, "ABCD"); - test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY"); - - /* Writing the whole thing */ - n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); - test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); - test_assert_lock(7, chOQIsFullI(&oq), "not full"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL); - test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty"); - test_wait_threads(); - - /* Testing reset */ - chSysLock(); - chOQResetI(&oq); - chSysUnlock(); - test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full"); - - /* Partial writes */ - n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); - test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); - n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); - test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); - test_assert_lock(12, chOQIsFullI(&oq), "not full"); - - /* Timeout */ - test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); -} - -ROMCONST struct testcase testqueues2 = { - "Queues, output queues", - queues2_setup, - NULL, - queues2_execute -}; -#endif /* CH_CFG_USE_QUEUES */ - -/** - * @brief Test sequence for queues. - */ -ROMCONST struct testcase * ROMCONST patternqueues[] = { -#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__) - &testqueues1, - &testqueues2, -#endif - NULL -}; diff --git a/test/testqueues.h b/test/testqueues.h deleted file mode 100644 index fdfbc4359..000000000 --- a/test/testqueues.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTQUEUES_H_ -#define _TESTQUEUES_H_ - -extern ROMCONST struct testcase * ROMCONST patternqueues[]; - -#endif /* _TESTQUEUES_H_ */ diff --git a/test/testsem.c b/test/testsem.c deleted file mode 100644 index cb7f13bc2..000000000 --- a/test/testsem.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_sem Semaphores test - * - * File: @ref testsem.c - * - *

Description

- * This module implements the test sequence for the @ref semaphores subsystem. - * - *

Objective

- * Objective of the test module is to cover 100% of the @ref semaphores code. - * - *

Preconditions

- * The module requires the following kernel options: - * - @p CH_CFG_USE_SEMAPHORES - * . - * In case some of the required options are not enabled then some or all tests - * may be skipped. - * - *

Test Cases

- * - @subpage test_sem_001 - * - @subpage test_sem_002 - * - @subpage test_sem_003 - * - @subpage test_sem_004 - * . - * @file testsem.c - * @brief Semaphores test source file - * @file testsem.h - * @brief Semaphores test header file - */ - -#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) - -#define ALLOWED_DELAY MS2ST(5) - -/* - * Note, the static initializers are not really required because the - * variables are explicitly initialized in each test case. It is done in order - * to test the macros. - */ -static SEMAPHORE_DECL(sem1, 0); - -/** - * @page test_sem_001 Enqueuing test - * - *

Description

- * Five threads with randomized priorities are enqueued to a semaphore then - * awakened one at time.
- * The test expects that the threads reach their goal in FIFO order or - * priority order depending on the CH_CFG_USE_SEMAPHORES_PRIORITY configuration - * setting. - */ - -static void sem1_setup(void) { - - chSemObjectInit(&sem1, 0); -} - -static msg_t thread1(void *p) { - - chSemWait(&sem1); - test_emit_token(*(char *)p); - return 0; -} - -static void sem1_execute(void) { - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E"); - chSemSignal(&sem1); - chSemSignal(&sem1); - chSemSignal(&sem1); - chSemSignal(&sem1); - chSemSignal(&sem1); - test_wait_threads(); -#if CH_CFG_USE_SEMAPHORES_PRIORITY - test_assert_sequence(1, "ADCEB"); -#else - test_assert_sequence(1, "ABCDE"); -#endif - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A"); - chSysLock(); - chSemAddCounterI(&sem1, 2); - chSchRescheduleS(); - chSysUnlock(); - test_wait_threads(); - test_assert_lock(2, chSemGetCounterI(&sem1) == 1, "invalid counter"); -} - -ROMCONST struct testcase testsem1 = { - "Semaphores, enqueuing", - sem1_setup, - NULL, - sem1_execute -}; - -/** - * @page test_sem_002 Timeout test - * - *

Description

- * The three possible semaphore waiting modes (do not wait, wait with timeout, - * wait without timeout) are explored.
- * The test expects that the semaphore wait function returns the correct value - * in each of the above scenario and that the semaphore structure status is - * correct after each operation. - */ - -static void sem2_setup(void) { - - chSemObjectInit(&sem1, 0); -} - -static msg_t thread2(void *p) { - - (void)p; - chThdSleepMilliseconds(50); - chSysLock(); - chSemSignalI(&sem1); /* For coverage reasons */ - chSchRescheduleS(); - chSysUnlock(); - return 0; -} - -static void sem2_execute(void) { - int i; - systime_t target_time; - msg_t msg; - - /* - * Testing special case TIME_IMMEDIATE. - */ - msg = chSemWaitTimeout(&sem1, TIME_IMMEDIATE); - test_assert(1, msg == MSG_TIMEOUT, "wrong wake-up message"); - test_assert(2, queue_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, chThdGetPriorityX() - 1, - thread2, 0); - msg = chSemWaitTimeout(&sem1, MS2ST(500)); - test_wait_threads(); - test_assert(4, msg == MSG_OK, "wrong wake-up message"); - test_assert(5, queue_isempty(&sem1.s_queue), "queue not empty"); - test_assert(6, sem1.s_cnt == 0, "counter not zero"); - - /* - * Testing timeout condition. - */ - test_wait_tick(); - target_time = chVTGetSystemTime() + MS2ST(5 * 500); - for (i = 0; i < 5; i++) { - test_emit_token('A' + i); - msg = chSemWaitTimeout(&sem1, MS2ST(500)); - test_assert(7, msg == MSG_TIMEOUT, "wrong wake-up message"); - test_assert(8, queue_isempty(&sem1.s_queue), "queue not empty"); - test_assert(9, sem1.s_cnt == 0, "counter not zero"); - } - test_assert_sequence(10, "ABCDE"); - test_assert_time_window(11, target_time, target_time + ALLOWED_DELAY); -} - -ROMCONST struct testcase testsem2 = { - "Semaphores, timeout", - sem2_setup, - NULL, - sem2_execute -}; - -/** - * @page test_sem_003 Atomic signal-wait test - * - *

Description

- * This test case explicitly addresses the @p chSemWaitSignal() function. A - * thread is created that performs a wait and a signal operations. - * The tester thread is awakened from an atomic wait/signal operation.
- * The test expects that the semaphore wait function returns the correct value - * in each of the above scenario and that the semaphore structure status is - * correct after each operation. - */ - -static void sem3_setup(void) { - - chSemObjectInit(&sem1, 0); -} - -static msg_t thread3(void *p) { - - (void)p; - chSemWait(&sem1); - chSemSignal(&sem1); - return 0; -} - -static void sem3_execute(void) { - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0); - chSemSignalWait(&sem1, &sem1); - test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty"); - test_assert(2, sem1.s_cnt == 0, "counter not zero"); - - chSemSignalWait(&sem1, &sem1); - test_assert(3, queue_isempty(&sem1.s_queue), "queue not empty"); - test_assert(4, sem1.s_cnt == 0, "counter not zero"); -} - -ROMCONST struct testcase testsem3 = { - "Semaphores, atomic signal-wait", - sem3_setup, - NULL, - sem3_execute -}; - -/** - * @page test_sem_004 Binary Wait and Signal - * - *

Description

- * This test case tests the binary semaphores functionality. The test both - * checks the binary semaphore status and the expected status of the underlying - * counting semaphore. - */ -static msg_t thread4(void *p) { - - chBSemSignal((binary_semaphore_t *)p); - return 0; -} - -static void sem4_execute(void) { - binary_semaphore_t bsem; - - /* Creates a taken binary semaphore.*/ - chBSemObjectInit(&bsem, TRUE); - chBSemReset(&bsem, TRUE); - test_assert_lock(1, chBSemGetStateI(&bsem) == TRUE, "not taken"); - - /* Starts a signaler thread at a lower priority.*/ - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, - chThdGetPriorityX()-1, thread4, &bsem); - - /* Waits to be signaled.*/ - chBSemWait(&bsem); - - /* The binary semaphore is expected to be taken.*/ - test_assert_lock(2, chBSemGetStateI(&bsem) == TRUE, "not taken"); - - /* Releasing it, check both the binary semaphore state and the underlying - counter semaphore state..*/ - chBSemSignal(&bsem); - test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "still taken"); - test_assert_lock(4, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); - - /* Checking signaling overflow, the counter must not go beyond 1.*/ - chBSemSignal(&bsem); - test_assert_lock(3, chBSemGetStateI(&bsem) == FALSE, "taken"); - test_assert_lock(5, chSemGetCounterI(&bsem.bs_sem) == 1, "unexpected counter"); -} - -ROMCONST struct testcase testsem4 = { - "Binary Semaphores, functionality", - NULL, - NULL, - sem4_execute -}; -#endif /* CH_CFG_USE_SEMAPHORES */ - -/** - * @brief Test sequence for semaphores. - */ -ROMCONST struct testcase * ROMCONST patternsem[] = { -#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__) - &testsem1, - &testsem2, - &testsem3, - &testsem4, -#endif - NULL -}; diff --git a/test/testsem.h b/test/testsem.h deleted file mode 100644 index 94a8bfca8..000000000 --- a/test/testsem.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTSEM_H_ -#define _TESTSEM_H_ - -extern ROMCONST struct testcase * ROMCONST patternsem[]; - -#endif /* _TESTSEM_H_ */ diff --git a/test/testthd.c b/test/testthd.c deleted file mode 100644 index 522e54b9b..000000000 --- a/test/testthd.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "ch.h" -#include "test.h" - -/** - * @page test_threads Threads and Scheduler test - * - * File: @ref testthd.c - * - *

Description

- * This module implements the test sequence for the @ref scheduler, - * @ref threads and @ref time subsystems.
- * Note that the tests on those subsystems are formally required but most of - * their functionality is already demonstrated because the test suite itself - * depends on them, anyway double check is good. - * - *

Objective

- * Objective of the test module is to cover 100% of the subsystems code. - * - *

Preconditions

- * None. - * - *

Test Cases

- * - @subpage test_threads_001 - * - @subpage test_threads_002 - * - @subpage test_threads_003 - * - @subpage test_threads_004 - * . - * @file testthd.c - * @brief Threads and Scheduler test source file - * @file testthd.h - * @brief Threads and Scheduler test header file - */ - -/** - * @page test_threads_001 Ready List functionality #1 - * - *

Description

- * Five threads, with increasing priority, are enqueued in the ready list - * and atomically executed.
- * The test expects the threads to perform their operations in increasing - * priority order regardless of the initial order. - */ - -static msg_t thread(void *p) { - - test_emit_token(*(char *)p); - return 0; -} - -static void thd1_execute(void) { - - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); - threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); - test_wait_threads(); - test_assert_sequence(1, "ABCDE"); -} - -ROMCONST struct testcase testthd1 = { - "Threads, enqueuing test #1", - NULL, - NULL, - thd1_execute -}; - -/** - * @page test_threads_002 Ready List functionality #2 - * - *

Description

- * Five threads, with pseudo-random priority, are enqueued in the ready list - * and atomically executed.
- * The test expects the threads to perform their operations in increasing - * priority order regardless of the initial order. - */ - -static void thd2_execute(void) { - - threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); - threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); - threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A"); - threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); - /* Done this way for coverage of chThdCreateI() and chThdStart().*/ - chSysLock(); - threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); - chSysUnlock(); - chThdStart(threads[2]); - test_wait_threads(); - test_assert_sequence(1, "ABCDE"); -} - -ROMCONST struct testcase testthd2 = { - "Threads, enqueuing test #2", - NULL, - NULL, - thd2_execute -}; - -/** - * @page test_threads_003 Threads priority change test - * - *

Description

- * A series of priority changes are performed on the current thread in order - * to verify that the priority change happens as expected.
- * If the @p CH_CFG_USE_MUTEXES option is enabled then the priority changes are - * also tested under priority inheritance boosted priority state. - */ - -static void thd3_execute(void) { - tprio_t prio, p1; - - prio = chThdGetPriorityX(); - p1 = chThdSetPriority(prio + 1); - test_assert(1, p1 == prio, - "unexpected returned priority level"); - test_assert(2, chThdGetPriorityX() == prio + 1, - "unexpected priority level"); - p1 = chThdSetPriority(p1); - test_assert(3, p1 == prio + 1, - "unexpected returned priority level"); - test_assert(4, chThdGetPriorityX() == prio, - "unexpected priority level"); - -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - /* Simulates a priority boost situation (p_prio > p_realprio).*/ - chSysLock(); - chThdGetSelfX()->p_prio += 2; - chSysUnlock(); - test_assert(5, chThdGetPriorityX() == prio + 2, - "unexpected priority level"); - - /* Tries to raise but below the boost level. */ - p1 = chThdSetPriority(prio + 1); - test_assert(6, p1 == prio, - "unexpected returned priority level"); - test_assert(7, chThdGetSelfX()->p_prio == prio + 2, - "unexpected priority level"); - test_assert(8, chThdGetSelfX()->p_realprio == prio + 1, - "unexpected returned real priority level"); - - /* Tries to raise above the boost level. */ - p1 = chThdSetPriority(prio + 3); - test_assert(9, p1 == prio + 1, - "unexpected returned priority level"); - test_assert(10, chThdGetSelfX()->p_prio == prio + 3, - "unexpected priority level"); - test_assert(11, chThdGetSelfX()->p_realprio == prio + 3, - "unexpected real priority level"); - - chSysLock(); - chThdGetSelfX()->p_prio = prio; - chThdGetSelfX()->p_realprio = prio; - chSysUnlock(); -#endif -} - -ROMCONST struct testcase testthd3 = { - "Threads, priority change", - NULL, - NULL, - thd3_execute -}; - -/** - * @page test_threads_004 Threads delays test - * - *

Description

- * Delay APIs and associated macros are tested, the invoking thread is verified - * to wake up at the exact expected time. - */ - -static void thd4_execute(void) { - systime_t time; - - test_wait_tick(); - - /* Timeouts in microseconds.*/ - time = chVTGetSystemTime(); - chThdSleepMicroseconds(100000); - test_assert_time_window(1, time + US2ST(100000), time + US2ST(100000) + 1); - - /* Timeouts in milliseconds.*/ - time = chVTGetSystemTime(); - chThdSleepMilliseconds(100); - test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + 1); - - /* Timeouts in seconds.*/ - time = chVTGetSystemTime(); - chThdSleepSeconds(1); - test_assert_time_window(3, time + S2ST(1), time + S2ST(1) + 1); - - /* Absolute timelines.*/ - time = chVTGetSystemTime() + MS2ST(100); - chThdSleepUntil(time); - test_assert_time_window(4, time, time + 1); -} - -ROMCONST struct testcase testthd4 = { - "Threads, delays", - NULL, - NULL, - thd4_execute -}; - -/** - * @brief Test sequence for threads. - */ -ROMCONST struct testcase * ROMCONST patternthd[] = { - &testthd1, - &testthd2, - &testthd3, - &testthd4, - NULL -}; diff --git a/test/testthd.h b/test/testthd.h deleted file mode 100644 index f1e3a9475..000000000 --- a/test/testthd.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef _TESTRDY_H_ -#define _TESTRDY_H_ - -extern ROMCONST struct testcase * ROMCONST patternthd[]; - -#endif /* _TESTRDY_H_ */ -- cgit v1.2.3 From 1033792b73022cbf5a7ef741313ae18592306251 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 11 Feb 2014 13:16:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6705 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/coverage/Makefile | 14 +++++++------- test/rt/test.mk | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/rt/coverage/Makefile b/test/rt/coverage/Makefile index d19014202..8a1b3064d 100644 --- a/test/rt/coverage/Makefile +++ b/test/rt/coverage/Makefile @@ -36,7 +36,7 @@ DLIBDIR = # List all default libraries here DLIBS = -lws2_32 -# Must be a directory in ${CHIBIOS}/os/hal/platforms +# Must be a directory in $(CHIBIOS)/os/hal/platforms HOST_TYPE = Win32 # @@ -62,11 +62,11 @@ UADEFS = # Imported source files CHIBIOS = ../.. include $(CHIBIOS)/boards/simulator/board.mk -include ${CHIBIOS}/os/hal/hal.mk -include ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/platform.mk -include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk -include ${CHIBIOS}/os/kernel/kernel.mk -include ${CHIBIOS}/test/test.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/hal/platforms/$(HOST_TYPE)/platform.mk +include $(CHIBIOS)/os/ports/GCC/SIMIA32/port.mk +include $(CHIBIOS)/os/kernel/kernel.mk +include $(CHIBIOS)/test/rt/test.mk # List C source files here SRC = ${PORTSRC} \ @@ -75,7 +75,7 @@ SRC = ${PORTSRC} \ ${HALSRC} \ ${PLATFORMSRC} \ $(BOARDSRC) \ - ${CHIBIOS}/os/hal/platforms/$(HOST_TYPE)/console.c \ + $(CHIBIOS)/os/hal/platforms/$(HOST_TYPE)/console.c \ main.c # List ASM source files here diff --git a/test/rt/test.mk b/test/rt/test.mk index 3f740288c..d2dcf355d 100644 --- a/test/rt/test.mk +++ b/test/rt/test.mk @@ -1,16 +1,16 @@ # List of all the ChibiOS/RT test files. -TESTSRC = ${CHIBIOS}/test/test.c \ - ${CHIBIOS}/test/testthd.c \ - ${CHIBIOS}/test/testsem.c \ - ${CHIBIOS}/test/testmtx.c \ - ${CHIBIOS}/test/testmsg.c \ - ${CHIBIOS}/test/testmbox.c \ - ${CHIBIOS}/test/testevt.c \ - ${CHIBIOS}/test/testheap.c \ - ${CHIBIOS}/test/testpools.c \ - ${CHIBIOS}/test/testdyn.c \ - ${CHIBIOS}/test/testqueues.c \ - ${CHIBIOS}/test/testbmk.c +TESTSRC = ${CHIBIOS}/test/rt/test.c \ + ${CHIBIOS}/test/rt/testthd.c \ + ${CHIBIOS}/test/rt/testsem.c \ + ${CHIBIOS}/test/rt/testmtx.c \ + ${CHIBIOS}/test/rt/testmsg.c \ + ${CHIBIOS}/test/rt/testmbox.c \ + ${CHIBIOS}/test/rt/testevt.c \ + ${CHIBIOS}/test/rt/testheap.c \ + ${CHIBIOS}/test/rt/testpools.c \ + ${CHIBIOS}/test/rt/testdyn.c \ + ${CHIBIOS}/test/rt/testqueues.c \ + ${CHIBIOS}/test/rt/testbmk.c # Required include directories -TESTINC = ${CHIBIOS}/test +TESTINC = ${CHIBIOS}/test/rt -- cgit v1.2.3 From 6c90d27a46cfeb8970eec2cf9d41729202d0e40b Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 12 Feb 2014 09:43:27 +0000 Subject: Preparation to recursive mutexes, now unlock primitives have the mutex as parameter. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6706 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/testbmk.c | 8 ++++---- test/rt/testmtx.c | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/rt/testbmk.c b/test/rt/testbmk.c index 2a3b7c1b5..4f648fa14 100644 --- a/test/rt/testbmk.c +++ b/test/rt/testbmk.c @@ -601,13 +601,13 @@ static void bmk12_execute(void) { test_start_timer(1000); do { chMtxLock(&mtx1); - chMtxUnlock(); + chMtxUnlock(&mtx1); chMtxLock(&mtx1); - chMtxUnlock(); + chMtxUnlock(&mtx1); chMtxLock(&mtx1); - chMtxUnlock(); + chMtxUnlock(&mtx1); chMtxLock(&mtx1); - chMtxUnlock(); + chMtxUnlock(&mtx1); n++; #if defined(SIMULATOR) ChkIntSources(); diff --git a/test/rt/testmtx.c b/test/rt/testmtx.c index c9ba9e093..f2a3c5f5a 100644 --- a/test/rt/testmtx.c +++ b/test/rt/testmtx.c @@ -90,7 +90,7 @@ static msg_t thread1(void *p) { chMtxLock(&m1); test_emit_token(*(char *)p); - chMtxUnlock(); + chMtxUnlock(&m1); return 0; } @@ -103,7 +103,7 @@ static void mtx1_execute(void) { threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C"); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B"); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A"); - chMtxUnlock(); + chMtxUnlock(&m1); test_wait_threads(); test_assert(1, prio == chThdGetPriorityX(), "wrong priority level"); test_assert_sequence(2, "ABCDE"); @@ -349,7 +349,7 @@ static msg_t thread4a(void *p) { (void)p; chThdSleepMilliseconds(50); chMtxLock(&m2); - chMtxUnlock(); + chMtxUnlock(&m2); return 0; } @@ -358,7 +358,7 @@ static msg_t thread4b(void *p) { (void)p; chThdSleepMilliseconds(150); chMtxLock(&m1); - chMtxUnlock(); + chMtxUnlock(&m1); return 0; } @@ -378,7 +378,7 @@ static void mtx4_execute(void) { test_assert(3, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(4, chThdGetPriorityX() == p2, "wrong priority level"); - chMtxUnlock(); + chMtxUnlock(&m1); test_assert(5, chThdGetPriorityX() == p1, "wrong priority level"); chThdSleepMilliseconds(100); test_assert(6, chThdGetPriorityX() == p1, "wrong priority level"); @@ -398,7 +398,7 @@ static void mtx4_execute(void) { chThdSleepMilliseconds(100); test_assert(11, chThdGetPriorityX() == p2, "wrong priority level"); chSysLock(); - chMtxUnlockS(); + chMtxUnlockS(&m1); chSchRescheduleS(); chSysUnlock(); test_assert(12, chThdGetPriorityX() == p1, "wrong priority level"); @@ -444,7 +444,7 @@ static void mtx5_execute(void) { test_assert(2, !b, "not locked"); chSysLock(); - chMtxUnlockS(); + chMtxUnlockS(&m1); chSysUnlock(); test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); @@ -487,7 +487,7 @@ static msg_t thread10(void *p) { chMtxLock(&m1); chCondWait(&c1); test_emit_token(*(char *)p); - chMtxUnlock(); + chMtxUnlock(&m1); return 0; } @@ -580,8 +580,8 @@ static msg_t thread11(void *p) { chCondWait(&c1); #endif test_emit_token(*(char *)p); - chMtxUnlock(); - chMtxUnlock(); + chMtxUnlock(&m1); + chMtxUnlock(&m2); return 0; } @@ -589,7 +589,7 @@ static msg_t thread12(void *p) { chMtxLock(&m2); test_emit_token(*(char *)p); - chMtxUnlock(); + chMtxUnlock(&m2); return 0; } -- cgit v1.2.3 From 7a3da58ae2c6defd58e77bb4a5d3ba7034c642cc Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 12 Feb 2014 13:14:11 +0000 Subject: Recursive mutexes, test code not done yet. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6707 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/testmtx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/rt/testmtx.c b/test/rt/testmtx.c index f2a3c5f5a..ccf7b9497 100644 --- a/test/rt/testmtx.c +++ b/test/rt/testmtx.c @@ -432,10 +432,10 @@ static void mtx5_setup(void) { } static void mtx5_execute(void) { - bool b; - tprio_t prio; - prio = chThdGetPriorityX(); +#if !CH_CFG_USE_MUTEXES_RECURSIVE + bool b; + tprio_t prio = chThdGetPriorityX(); b = chMtxTryLock(&m1); test_assert(1, b, "already locked"); @@ -450,6 +450,7 @@ static void mtx5_execute(void) { test_assert(3, queue_isempty(&m1.m_queue), "queue not empty"); test_assert(4, m1.m_owner == NULL, "still owned"); test_assert(5, chThdGetPriorityX() == prio, "wrong priority level"); +#endif /* !CH_CFG_USE_MUTEXES_RECURSIVE */ chMtxLock(&m1); chMtxUnlockAll(); -- cgit v1.2.3 From b1da190527164b3c6e9a5fadabe66113105168ba Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 4 Mar 2014 12:55:37 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6751 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/coverage/halconf.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/rt/coverage/halconf.h b/test/rt/coverage/halconf.h index 516a705a2..14a2e7f6b 100644 --- a/test/rt/coverage/halconf.h +++ b/test/rt/coverage/halconf.h @@ -79,6 +79,13 @@ #define HAL_USE_I2C FALSE #endif +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + /** * @brief Enables the ICU subsystem. */ -- cgit v1.2.3