From 15d0007e9687428fe314e1369a9bb4eeb427cfcc Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 3 Apr 2015 12:48:22 +0000 Subject: Mass change, all thread functions now return void. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7849 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/coverage/main.c | 5 ++--- test/rt/test.c | 14 ++++++-------- test/rt/test.h | 4 +++- test/rt/testbmk.c | 16 ++++++---------- test/rt/testbuild/main.c | 5 ++--- test/rt/testdyn.c | 3 +-- test/rt/testevt.c | 6 ++---- test/rt/testmsg.c | 3 +-- test/rt/testmtx.c | 42 ++++++++++++++---------------------------- test/rt/testqueues.c | 10 ++++------ test/rt/testsem.c | 12 ++++-------- test/rt/testthd.c | 3 +-- 12 files changed, 46 insertions(+), 77 deletions(-) (limited to 'test/rt') diff --git a/test/rt/coverage/main.c b/test/rt/coverage/main.c index f1ed0b739..51e253a4b 100644 --- a/test/rt/coverage/main.c +++ b/test/rt/coverage/main.c @@ -27,7 +27,6 @@ * Simulator main. */ int main(int argc, char *argv[]) { - msg_t result; (void)argc; (void)argv; @@ -43,8 +42,8 @@ int main(int argc, char *argv[]) { conInit(); chSysInit(); - result = TestThread(&CD1); - if (result) + TestThread(&CD1); + if (test_global_fail) exit(1); else exit(0); diff --git a/test/rt/test.c b/test/rt/test.c index 14638a3dd..5dc791a0f 100644 --- a/test/rt/test.c +++ b/test/rt/test.c @@ -56,7 +56,8 @@ static ROMCONST struct testcase * ROMCONST *patterns[] = { NULL }; -static bool local_fail, global_fail; +bool test_global_fail; +static bool local_fail; static unsigned failpoint; static char tokens_buffer[MAX_TOKENS]; static char *tokp; @@ -156,8 +157,8 @@ void test_emit_token(char token) { */ bool _test_fail(unsigned point) { + test_global_fail = TRUE; local_fail = TRUE; - global_fail = TRUE; failpoint = point; return TRUE; } @@ -309,9 +310,8 @@ static void print_line(void) { * @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) { +void TestThread(void *p) { int i, j; chp = p; @@ -346,7 +346,7 @@ msg_t TestThread(void *p) { #endif test_println(""); - global_fail = FALSE; + test_global_fail = FALSE; i = 0; while (patterns[i]) { j = 0; @@ -379,12 +379,10 @@ msg_t TestThread(void *p) { print_line(); test_println(""); test_print("Final result: "); - if (global_fail) + if (test_global_fail) test_println("FAILURE"); else test_println("SUCCESS"); - - return (msg_t)global_fail; } /** @} */ diff --git a/test/rt/test.h b/test/rt/test.h index 90f7b977f..da080db2d 100644 --- a/test/rt/test.h +++ b/test/rt/test.h @@ -76,10 +76,12 @@ union test_buffers { }; #endif +extern bool test_global_fail; + #ifdef __cplusplus extern "C" { #endif - msg_t TestThread(void *p); + void TestThread(void *p); void test_printn(uint32_t n); void test_print(const char *msgp); void test_println(const char *msgp); diff --git a/test/rt/testbmk.c b/test/rt/testbmk.c index 7d23f02bf..b4f4af7d6 100644 --- a/test/rt/testbmk.c +++ b/test/rt/testbmk.c @@ -63,13 +63,13 @@ static semaphore_t sem1; static mutex_t mtx1; #endif -static msg_t thread1(void *p) { +static THD_FUNCTION(thread1, p) { - return (msg_t)p; + chThdExit((msg_t)p); } #if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) -static msg_t thread2(void *p) { +static THD_FUNCTION(thread2, p) { thread_t *tp; msg_t msg; @@ -79,7 +79,6 @@ static msg_t thread2(void *p) { msg = chMsgGet(tp); chMsgRelease(tp, msg); } while (msg); - return 0; } #ifdef __GNUC__ @@ -204,7 +203,7 @@ ROMCONST struct testcase testbmk3 = { * iterations after a second of continuous operations. */ -msg_t thread4(void *p) { +static THD_FUNCTION(thread4, p) { msg_t msg; thread_t *self = chThdGetSelfX(); @@ -215,7 +214,6 @@ msg_t thread4(void *p) { msg = self->p_u.rdymsg; } while (msg == MSG_OK); chSysUnlock(); - return 0; } static void bmk4_execute(void) { @@ -344,12 +342,11 @@ ROMCONST struct testcase testbmk6 = { * a second of continuous operations. */ -static msg_t thread3(void *p) { +static THD_FUNCTION(thread3, p) { (void)p; while (!chThdShouldTerminateX()) chSemWait(&sem1); - return 0; } static void bmk7_setup(void) { @@ -405,7 +402,7 @@ ROMCONST struct testcase testbmk7 = { * a second of continuous operations. */ -static msg_t thread8(void *p) { +static THD_FUNCTION(thread8, p) { do { chThdYield(); @@ -417,7 +414,6 @@ static msg_t thread8(void *p) { _sim_check_for_interrupts(); #endif } while(!chThdShouldTerminateX()); - return 0; } static void bmk8_execute(void) { diff --git a/test/rt/testbuild/main.c b/test/rt/testbuild/main.c index 540a8a7d0..5eccafa5a 100644 --- a/test/rt/testbuild/main.c +++ b/test/rt/testbuild/main.c @@ -26,7 +26,6 @@ * Simulator main. */ int main(int argc, char *argv[]) { - msg_t result; (void)argc; (void)argv; @@ -42,8 +41,8 @@ int main(int argc, char *argv[]) { conInit(); chSysInit(); - result = TestThread(&CD1); - if (result) + TestThread(&CD1); + if (test_global_fail) exit(1); else exit(0); diff --git a/test/rt/testdyn.c b/test/rt/testdyn.c index f085e7ae8..8dd6d5bf2 100644 --- a/test/rt/testdyn.c +++ b/test/rt/testdyn.c @@ -68,10 +68,9 @@ static memory_pool_t mp1; * one to fail. */ -static msg_t thread(void *p) { +static THD_FUNCTION(thread, p) { test_emit_token(*(char *)p); - return 0; } #if (CH_CFG_USE_HEAP && !CH_CFG_USE_MALLOC_HEAP) || defined(__DOXYGEN__) diff --git a/test/rt/testevt.c b/test/rt/testevt.c index 5a7aa1b93..cc4a456d5 100644 --- a/test/rt/testevt.c +++ b/test/rt/testevt.c @@ -130,20 +130,18 @@ static void evt2_setup(void) { chEvtGetAndClearEvents(ALL_EVENTS); } -static msg_t thread1(void *p) { +static THD_FUNCTION(thread1, p) { chThdSleepMilliseconds(50); chEvtSignal((thread_t *)p, 1); - return 0; } -static msg_t thread2(void *p) { +static THD_FUNCTION(thread2, p) { (void)p; chEvtBroadcast(&es1); chThdSleepMilliseconds(50); chEvtBroadcast(&es2); - return 0; } static void evt2_execute(void) { diff --git a/test/rt/testmsg.c b/test/rt/testmsg.c index aa04ce744..2a98d0fc6 100644 --- a/test/rt/testmsg.c +++ b/test/rt/testmsg.c @@ -56,12 +56,11 @@ * not find a fifth message waiting. */ -static msg_t thread(void *p) { +static THD_FUNCTION(thread, p) { chMsgSend(p, 'A'); chMsgSend(p, 'B'); chMsgSend(p, 'C'); - return 0; } static void msg1_execute(void) { diff --git a/test/rt/testmtx.c b/test/rt/testmtx.c index f15e82dc7..f34072ad0 100644 --- a/test/rt/testmtx.c +++ b/test/rt/testmtx.c @@ -86,12 +86,11 @@ static void mtx1_setup(void) { chMtxObjectInit(&m1); } -static msg_t thread1(void *p) { +static THD_FUNCTION(thread1, p) { chMtxLock(&m1); test_emit_token(*(char *)p); chMtxUnlock(&m1); - return 0; } static void mtx1_execute(void) { @@ -154,7 +153,7 @@ static void mtx2_setup(void) { } /* Low priority thread */ -static msg_t thread2L(void *p) { +static THD_FUNCTION(thread2L, p) { (void)p; chMtxLock(&m1); @@ -162,21 +161,19 @@ static msg_t thread2L(void *p) { chMtxUnlock(&m1); test_cpu_pulse(10); test_emit_token('C'); - return 0; } /* Medium priority thread */ -static msg_t thread2M(void *p) { +static THD_FUNCTION(thread2M, p) { (void)p; chThdSleepMilliseconds(20); test_cpu_pulse(40); test_emit_token('B'); - return 0; } /* High priority thread */ -static msg_t thread2H(void *p) { +static THD_FUNCTION(thread2H, p) { (void)p; chThdSleepMilliseconds(40); @@ -184,7 +181,6 @@ static msg_t thread2H(void *p) { test_cpu_pulse(10); chMtxUnlock(&m1); test_emit_token('A'); - return 0; } static void mtx2_execute(void) { @@ -245,18 +241,17 @@ static void mtx3_setup(void) { } /* Lowest priority thread */ -static msg_t thread3LL(void *p) { +static THD_FUNCTION(thread3LL, p) { (void)p; chMtxLock(&m1); test_cpu_pulse(30); chMtxUnlock(&m1); test_emit_token('E'); - return 0; } /* Low priority thread */ -static msg_t thread3L(void *p) { +static THD_FUNCTION(thread3L, p) { (void)p; chThdSleepMilliseconds(10); @@ -268,11 +263,10 @@ static msg_t thread3L(void *p) { test_cpu_pulse(10); chMtxUnlock(&m2); test_emit_token('D'); - return 0; } /* Medium priority thread */ -static msg_t thread3M(void *p) { +static THD_FUNCTION(thread3M, p) { (void)p; chThdSleepMilliseconds(20); @@ -280,21 +274,19 @@ static msg_t thread3M(void *p) { test_cpu_pulse(10); chMtxUnlock(&m2); test_emit_token('C'); - return 0; } /* High priority thread */ -static msg_t thread3H(void *p) { +static THD_FUNCTION(thread3H, p) { (void)p; chThdSleepMilliseconds(40); test_cpu_pulse(20); test_emit_token('B'); - return 0; } /* Highest priority thread */ -static msg_t thread3HH(void *p) { +static THD_FUNCTION(thread3HH, p) { (void)p; chThdSleepMilliseconds(50); @@ -302,7 +294,6 @@ static msg_t thread3HH(void *p) { test_cpu_pulse(10); chMtxUnlock(&m2); test_emit_token('A'); - return 0; } static void mtx3_execute(void) { @@ -344,22 +335,20 @@ static void mtx4_setup(void) { chMtxObjectInit(&m2); } -static msg_t thread4a(void *p) { +static THD_FUNCTION(thread4a, p) { (void)p; chThdSleepMilliseconds(50); chMtxLock(&m2); chMtxUnlock(&m2); - return 0; } -static msg_t thread4b(void *p) { +static THD_FUNCTION(thread4b, p) { (void)p; chThdSleepMilliseconds(150); chMtxLock(&m1); chMtxUnlock(&m1); - return 0; } static void mtx4_execute(void) { @@ -483,13 +472,12 @@ static void mtx6_setup(void) { chMtxObjectInit(&m1); } -static msg_t thread10(void *p) { +static THD_FUNCTION(thread10, p) { chMtxLock(&m1); chCondWait(&c1); test_emit_token(*(char *)p); chMtxUnlock(&m1); - return 0; } static void mtx6_execute(void) { @@ -571,7 +559,7 @@ static void mtx8_setup(void) { chMtxObjectInit(&m2); } -static msg_t thread11(void *p) { +static THD_FUNCTION(thread11, p) { chMtxLock(&m2); chMtxLock(&m1); @@ -583,15 +571,13 @@ static msg_t thread11(void *p) { test_emit_token(*(char *)p); chMtxUnlock(&m1); chMtxUnlock(&m2); - return 0; } -static msg_t thread12(void *p) { +static THD_FUNCTION(thread12, p) { chMtxLock(&m2); test_emit_token(*(char *)p); chMtxUnlock(&m2); - return 0; } static void mtx8_execute(void) { diff --git a/test/rt/testqueues.c b/test/rt/testqueues.c index ebd06435e..50981f26c 100644 --- a/test/rt/testqueues.c +++ b/test/rt/testqueues.c @@ -70,7 +70,7 @@ 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 + * This test case tests synchronous and asynchronous operations on an * @p InputQueue object including timeouts. The queue state must remain * consistent through the whole test. */ @@ -80,11 +80,10 @@ static void queues1_setup(void) { chIQObjectInit(&iq, wa[0], TEST_QUEUES_SIZE, notify, NULL); } -static msg_t thread1(void *p) { +static THD_FUNCTION(thread1, p) { (void)p; chIQGetTimeout(&iq, MS2ST(200)); - return 0; } static void queues1_execute(void) { @@ -157,7 +156,7 @@ ROMCONST struct testcase testqueues1 = { * @page test_queues_002 Output Queues functionality and APIs * *

Description

- * This test case tests sysnchronos and asynchronous operations on an + * This test case tests synchronous and asynchronous operations on an * @p OutputQueue object including timeouts. The queue state must remain * consistent through the whole test. */ @@ -167,11 +166,10 @@ static void queues2_setup(void) { chOQObjectInit(&oq, wa[0], TEST_QUEUES_SIZE, notify, NULL); } -static msg_t thread2(void *p) { +static THD_FUNCTION(thread2, p) { (void)p; chOQPutTimeout(&oq, 0, MS2ST(200)); - return 0; } static void queues2_execute(void) { diff --git a/test/rt/testsem.c b/test/rt/testsem.c index 11965695e..c8258b2de 100644 --- a/test/rt/testsem.c +++ b/test/rt/testsem.c @@ -74,11 +74,10 @@ static void sem1_setup(void) { chSemObjectInit(&sem1, 0); } -static msg_t thread1(void *p) { +static THD_FUNCTION(thread1, p) { chSemWait(&sem1); test_emit_token(*(char *)p); - return 0; } static void sem1_execute(void) { @@ -131,7 +130,7 @@ static void sem2_setup(void) { chSemObjectInit(&sem1, 0); } -static msg_t thread2(void *p) { +static THD_FUNCTION(thread2, p) { (void)p; chThdSleepMilliseconds(50); @@ -139,7 +138,6 @@ static msg_t thread2(void *p) { chSemSignalI(&sem1); /* For coverage reasons */ chSchRescheduleS(); chSysUnlock(); - return 0; } static void sem2_execute(void) { @@ -206,12 +204,11 @@ static void sem3_setup(void) { chSemObjectInit(&sem1, 0); } -static msg_t thread3(void *p) { +static THD_FUNCTION(thread3, p) { (void)p; chSemWait(&sem1); chSemSignal(&sem1); - return 0; } static void sem3_execute(void) { @@ -241,10 +238,9 @@ ROMCONST struct testcase testsem3 = { * checks the binary semaphore status and the expected status of the underlying * counting semaphore. */ -static msg_t thread4(void *p) { +static THD_FUNCTION(thread4, p) { chBSemSignal((binary_semaphore_t *)p); - return 0; } static void sem4_execute(void) { diff --git a/test/rt/testthd.c b/test/rt/testthd.c index 0f0c88c86..5b1127aa3 100644 --- a/test/rt/testthd.c +++ b/test/rt/testthd.c @@ -57,10 +57,9 @@ * priority order regardless of the initial order. */ -static msg_t thread(void *p) { +static THD_FUNCTION(thread, p) { test_emit_token(*(char *)p); - return 0; } static void thd1_execute(void) { -- cgit v1.2.3