aboutsummaryrefslogtreecommitdiffstats
path: root/test/rt
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-29 10:34:51 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-29 10:34:51 +0000
commit342e9200a730a4231d9d5bf0050e7c2141b3ccdd (patch)
treebe626d93b683f51d537960cfe4fda282c4b7c882 /test/rt
parent8447e50604d8676df61e9ccd9b62954c9eb4e3ab (diff)
downloadChibiOS-342e9200a730a4231d9d5bf0050e7c2141b3ccdd.tar.gz
ChibiOS-342e9200a730a4231d9d5bf0050e7c2141b3ccdd.tar.bz2
ChibiOS-342e9200a730a4231d9d5bf0050e7c2141b3ccdd.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9177 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/rt')
-rw-r--r--test/rt/configuration.xml235
1 files changed, 119 insertions, 116 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);]]></value>
</global_definitions>
@@ -132,9 +135,7 @@ void test_wait_threads(void) {
<value />
</condition>
<shared_code>
- <value><![CDATA[#include "ch.h"
-
-/* Timer callback for testing system functions in ISR context.*/
+ <value><![CDATA[/* Timer callback for testing system functions in ISR context.*/
static void vtcb(void *p) {
syssts_t sts;
@@ -415,9 +416,7 @@ while (time == chVTGetSystemTimeX()) {
<value />
</condition>
<shared_code>
- <value><![CDATA[#include "ch.h"
-
-static THD_FUNCTION(thread, p) {
+ <value><![CDATA[static THD_FUNCTION(thread, p) {
test_emit_token(*(char *)p);
}]]></value>
@@ -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");]]></value>
+test_assert_sequence("ABCDE", "invalid sequence");]]></value>
</code>
</step>
<step>
@@ -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");]]></value>
+test_assert_sequence("ABCDE", "invalid sequence");]]></value>
</code>
</step>
<step>
@@ -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");]]></value>
+test_assert_sequence("ABCDE", "invalid sequence");]]></value>
</code>
</step>
</steps>
@@ -627,9 +626,9 @@ test_assert_sequence("ABCDE");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[prio = chThdGetPriorityX();
-p1 = chThdSetPriority(prio + 1);
-test_assert(p1 == prio, "unexpected returned priority level");
+ <value><![CDATA[prio = chThdGetPriorityX();
+p1 = chThdSetPriority(prio + 1);
+test_assert(p1 == prio, "unexpected returned priority level");
test_assert(chThdGetPriorityX() == prio + 1, "unexpected priority level");]]></value>
</code>
</step>
@@ -641,8 +640,8 @@ test_assert(chThdGetPriorityX() == prio + 1, "unexpected priority level");]]></v
<value />
</tags>
<code>
- <value><![CDATA[p1 = chThdSetPriority(p1);
-test_assert(p1 == prio + 1, "unexpected returned priority level");
+ <value><![CDATA[p1 = chThdSetPriority(p1);
+test_assert(p1 == prio + 1, "unexpected returned priority level");
test_assert(chThdGetPriorityX() == prio, "unexpected priority level");]]></value>
</code>
</step>
@@ -678,7 +677,8 @@ test_assert(chThdGetPriorityX() == prio, "unexpected priority level");]]></value
<value />
</tags>
<code>
- <value><![CDATA[chThdGetSelfX()->prio += 2;
+ <value><![CDATA[prio = chThdGetPriorityX();
+chThdGetSelfX()->prio += 2;
test_assert(chThdGetPriorityX() == prio + 2, "unexpected priority level");]]></value>
</code>
</step>
@@ -690,9 +690,9 @@ test_assert(chThdGetPriorityX() == prio + 2, "unexpected priority level");]]></v
<value />
</tags>
<code>
- <value><![CDATA[p1 = chThdSetPriority(prio + 1);
-test_assert(p1 == prio, "unexpected returned priority level");
-test_assert(chThdGetSelfX()->prio == prio + 2, "unexpected priority level");
+ <value><![CDATA[p1 = chThdSetPriority(prio + 1);
+test_assert(p1 == prio, "unexpected returned priority level");
+test_assert(chThdGetSelfX()->prio == prio + 2, "unexpected priority level");
test_assert(chThdGetSelfX()->realprio == prio + 1, "unexpected returned real priority level");]]></value>
</code>
</step>
@@ -704,9 +704,9 @@ test_assert(chThdGetSelfX()->realprio == prio + 1, "unexpected returned real pri
<value />
</tags>
<code>
- <value><![CDATA[p1 = chThdSetPriority(prio + 3);
-test_assert(p1 == prio + 1, "unexpected returned priority level");
-test_assert(chThdGetSelfX()->prio == prio + 3, "unexpected priority level");
+ <value><![CDATA[p1 = chThdSetPriority(prio + 3);
+test_assert(p1 == prio + 1, "unexpected returned priority level");
+test_assert(chThdGetSelfX()->prio == prio + 3, "unexpected priority level");
test_assert(chThdGetSelfX()->realprio == prio + 3, "unexpected real priority level");]]></value>
</code>
</step>
@@ -718,9 +718,9 @@ test_assert(chThdGetSelfX()->realprio == prio + 3, "unexpected real priority lev
<value />
</tags>
<code>
- <value><![CDATA[chSysLock();
-chThdGetSelfX()->prio = prio;
-chThdGetSelfX()->realprio = prio;
+ <value><![CDATA[chSysLock();
+chThdGetSelfX()->prio = prio;
+chThdGetSelfX()->realprio = prio;
chSysUnlock();]]></value>
</code>
</step>
@@ -733,79 +733,81 @@ chSysUnlock();]]></value>
<value>Internal Tests</value>
</type>
<brief>
- <value>Semaphores.</value>
+ <value>Suspend/Resume.</value>
</brief>
<description>
- <value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
+ <value>This sequence tests the ChibiOS/RT functionalities related to threads suspend/resume.</value>
</description>
<condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
+ <value />
</condition>
<shared_code>
- <value><![CDATA[#include "ch.h"
-
-static semaphore_t sem1;]]></value>
+ <value><![CDATA[static thread_reference_t tr1;
+
+static THD_FUNCTION(thread1, p) {
+
+ chThdResumeI(&tr1, MSG_OK);
+ test_emit_token(*(char *)p);
+}]]></value>
</shared_code>
<cases>
<case>
<brief>
- <value>Semaphore primitives, no state change.</value>
+ <value>Suspend and Resume functionality.</value>
</brief>
<description>
- <value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
+ <value>The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
- <value><![CDATA[chSemObjectInit(&sem1, 1);]]></value>
+ <value><![CDATA[tr1 = NULL;]]></value>
</setup_code>
<teardown_code>
- <value><![CDATA[chSemReset(&sem1, 0);]]></value>
+ <value />
</teardown_code>
<local_variables>
- <value />
+ <value><![CDATA[systime_t time;
+msg_t msg;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
- <value>The function chSemWait() is invoked, after return the counter and the returned message are tested.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg_t msg;
-
-msg = chSemWait(&sem1);
-test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
-test_assert(MSG_OK == msg, "wrong returned message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>The function chSemSignal() is invoked, after return the counter is tested.</value>
+ <value>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.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[chSemSignal(&sem1);
-test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");]]></value>
+ <value><![CDATA[threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, "A");
+chSysLock();
+msg = chThdSuspendTimeoutS(&tr1, TIME_INFINITE);
+chSysUnlock();
+test_assert(NULL == tr1, "not NULL");
+test_assert(MSG_OK == msg,"wrong returned message");
+test_wait_threads();]]></value>
</code>
</step>
<step>
<description>
- <value>The function chSemReset() is invoked, after return the counter is tested.</value>
+ <value>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.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[chSemReset(&sem1, 2);
-test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value>
+ <value><![CDATA[chSysLock();
+time = chVTGetSystemTimeX();
+msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
+chSysUnlock();
+test_assert_time_window(time + MS2ST(1000),
+ time + MS2ST(1000) + 1,
+ "out of time window");
+test_assert(NULL == tr1, "not NULL");
+test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
</code>
</step>
</steps>
@@ -817,144 +819,145 @@ test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value
<value>Internal Tests</value>
</type>
<brief>
- <value>Suspend/Resume and Event Flags.</value>
+ <value>Semaphores.</value>
</brief>
<description>
- <value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value>
+ <value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
</description>
<condition>
- <value />
+ <value>CH_CFG_USE_SEMAPHORES</value>
</condition>
<shared_code>
- <value><![CDATA[static thread_reference_t tr1;]]></value>
+ <value><![CDATA[#include "ch.h"
+
+static semaphore_t sem1;
+
+static THD_FUNCTION(thread1, p) {
+
+ chSemWait(&sem1);
+ test_emit_token(*(char *)p);
+}]]></value>
</shared_code>
<cases>
<case>
<brief>
- <value>Suspend and Resume functionality.</value>
+ <value>Semaphore primitives, no state change.</value>
</brief>
<description>
- <value>The functionality of chThdSuspendTimeoutS() and chThdResumeI() is tested.</value>
+ <value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
- <value><![CDATA[tr1 = NULL;]]></value>
+ <value><![CDATA[chSemObjectInit(&sem1, 1);]]></value>
</setup_code>
<teardown_code>
- <value />
+ <value><![CDATA[chSemReset(&sem1, 0);]]></value>
</teardown_code>
<local_variables>
- <value><![CDATA[systime_t time;
-msg_t msg;]]></value>
+ <value />
</local_variables>
</various_code>
<steps>
<step>
<description>
- <value>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.</value>
+ <value>The function chSemWait() is invoked, after return the counter and the returned message are tested.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[chSysLock();
-msg = chThdSuspendTimeoutS(&gtr1, TIME_INFINITE);
-chSysUnlock();
-test_assert(NULL == gtr1, "not NULL");
-test_assert(MSG_OK == msg,"wrong returned message");]]></value>
+ <value><![CDATA[msg_t msg;
+
+msg = chSemWait(&sem1);
+test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
+test_assert(MSG_OK == msg, "wrong returned message");]]></value>
</code>
</step>
<step>
<description>
- <value>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.</value>
+ <value>The function chSemSignal() is invoked, after return the counter is tested.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[chSysLock();
-time = chVTGetSystemTimeX();
-msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
-chSysUnlock();
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
- "out of time window");
-test_assert(NULL == tr1, "not NULL");
-test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
+ <value><![CDATA[chSemSignal(&sem1);
+test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The function chSemReset() is invoked, after return the counter is tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chSemReset(&sem1, 2);
+test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
- <value>Events Flags functionality.</value>
+ <value>Semaphore enqueuing test.</value>
</brief>
<description>
- <value>Event flags functionality is tested.</value>
+ <value>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.</value>
</description>
<condition>
- <value>CH_CFG_USE_EVENTS</value>
+ <value />
</condition>
<various_code>
<setup_code>
- <value />
+ <value><![CDATA[chSemObjectInit(&sem1, 0);]]></value>
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
- <value><![CDATA[systime_t time;
-eventmask_t events;]]></value>
+ <value />
</local_variables>
</various_code>
<steps>
<step>
<description>
- <value>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.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[time = chVTGetSystemTimeX();
-chEvtSignal(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");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>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.</value>
+ <value>Five threads are created with mixed priority levels (not increasing nor decreasing). Threads enqueue on a semaphore initialized to zero.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[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");]]></value>
+ <value><![CDATA[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");]]></value>
</code>
</step>
<step>
<description>
- <value>The function chEvtWaitAnyTimeout() is invoked, no event can wakeup the thread, the function must return because timeout.</value>
+ <value>The semaphore is signaled 5 times. The thread activation sequence is tested.</value>
</description>
<tags>
<value />
</tags>
<code>
- <value><![CDATA[time = chVTGetSystemTimeX();
-events = chEvtWaitAnyTimeout(0, MS2ST(1000));
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
- "out of time window");
-test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
+ <value><![CDATA[chSemSignal(&sem1);
+chSemSignal(&sem1);
+chSemSignal(&sem1);
+chSemSignal(&sem1);
+chSemSignal(&sem1);
+test_wait_threads();
+#if CH_CFG_USE_SEMAPHORES_PRIORITY
+ test_assert_sequence("ADCEB", "invalid sequence");
+#else
+ test_assert_sequence("ABCDE", "invalid sequence");
+#endif]]></value>
</code>
</step>
</steps>