From 342e9200a730a4231d9d5bf0050e7c2141b3ccdd Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 29 Mar 2016 10:34:51 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9177 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/rt/configuration.xml | 275 +++++++++++++++++++------------------- 1 file changed, 139 insertions(+), 136 deletions(-) diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml index 338cc36ed..d524fcd08 100644 --- a/test/rt/configuration.xml +++ b/test/rt/configuration.xml @@ -71,6 +71,9 @@ union test_buffers { uint8_t buffer[WA_SIZE * 5]; }; +extern thread_t *threads[MAX_THREADS]; +extern void * ROMCONST wa[5]; + void test_terminate_threads(void); void test_wait_threads(void);]]> @@ -132,9 +135,7 @@ void test_wait_threads(void) { - - @@ -558,7 +557,7 @@ 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("ABCDE");]]> +test_assert_sequence("ABCDE", "invalid sequence");]]> @@ -575,7 +574,7 @@ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E"); test_wait_threads(); -test_assert_sequence("ABCDE");]]> +test_assert_sequence("ABCDE", "invalid sequence");]]> @@ -592,7 +591,7 @@ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B"); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C"); test_wait_threads(); -test_assert_sequence("ABCDE");]]> +test_assert_sequence("ABCDE", "invalid sequence");]]> @@ -627,9 +626,9 @@ test_assert_sequence("ABCDE");]]> - @@ -641,8 +640,8 @@ test_assert(chThdGetPriorityX() == prio + 1, "unexpected priority level");]]> - @@ -678,7 +677,8 @@ test_assert(chThdGetPriorityX() == prio, "unexpected priority level");]]> - prio += 2; + prio += 2; test_assert(chThdGetPriorityX() == prio + 2, "unexpected priority level");]]> @@ -690,9 +690,9 @@ test_assert(chThdGetPriorityX() == prio + 2, "unexpected priority level");]]> - prio == prio + 2, "unexpected priority level"); + prio == prio + 2, "unexpected priority level"); test_assert(chThdGetSelfX()->realprio == prio + 1, "unexpected returned real priority level");]]> @@ -704,9 +704,9 @@ test_assert(chThdGetSelfX()->realprio == prio + 1, "unexpected returned real pri - prio == prio + 3, "unexpected priority level"); + prio == prio + 3, "unexpected priority level"); test_assert(chThdGetSelfX()->realprio == prio + 3, "unexpected real priority level");]]> @@ -718,9 +718,9 @@ test_assert(chThdGetSelfX()->realprio == prio + 3, "unexpected real priority lev - prio = prio; -chThdGetSelfX()->realprio = prio; + prio = prio; +chThdGetSelfX()->realprio = prio; chSysUnlock();]]> @@ -728,6 +728,92 @@ chSysUnlock();]]> + + + Internal Tests + + + Suspend/Resume. + + + This sequence tests the ChibiOS/RT functionalities related to threads suspend/resume. + + + + + + + + + + + Suspend and Resume functionality. + + + The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested. + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + + + Internal Tests @@ -744,7 +830,13 @@ chSysUnlock();]]> +static semaphore_t sem1; + +static THD_FUNCTION(thread1, p) { + + chSemWait(&sem1); + test_emit_token(*(char *)p); +}]]> @@ -810,151 +902,62 @@ test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]> - - - - - Internal Tests - - - Suspend/Resume and Event Flags. - - - This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags. - - - - - - - - - Suspend and Resume functionality. + Semaphore enqueuing test. - The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested. + 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 @p CH_CFG_USE_SEMAPHORES_PRIORITY configuration setting. - + - + - 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. + Five threads are created with mixed priority levels (not increasing nor decreasing). Threads enqueue on a semaphore initialized to zero. - + - 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. + The semaphore is signaled 5 times. The thread activation sequence is tested. - - - - - - - - Events Flags functionality. - - - Event flags functionality is tested. - - - CH_CFG_USE_EVENTS - - - - - - - - - - - - - - - - A set of event flags are set on the current thread then the function chEvtWaitAnyTimeout() 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 chEvtWaitAnyTimeout() is invoked, after return the events mask is tested. The thread is signaled by another thread. - - - - - - 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 chEvtWaitAnyTimeout() is invoked, no event can wakeup the thread, the function must return because timeout. - - - - - - +