aboutsummaryrefslogtreecommitdiffstats
path: root/test/rt
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-31 14:57:58 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-31 14:57:58 +0000
commite783e741f5951c0907ce0debec86cd266899a185 (patch)
tree85c6d12122d2669c8b58d4a8360d846c498a0b2e /test/rt
parent7c20551c988918cdad797a343d2126820cd75e8f (diff)
downloadChibiOS-e783e741f5951c0907ce0debec86cd266899a185.tar.gz
ChibiOS-e783e741f5951c0907ce0debec86cd266899a185.tar.bz2
ChibiOS-e783e741f5951c0907ce0debec86cd266899a185.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9190 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/rt')
-rw-r--r--test/rt/configuration.xml141
-rw-r--r--test/rt/source/test/test_sequence_007.c138
2 files changed, 277 insertions, 2 deletions
diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml
index 607b4e474..a87534371 100644
--- a/test/rt/configuration.xml
+++ b/test/rt/configuration.xml
@@ -2402,7 +2402,7 @@ static THD_FUNCTION(evt_thread3, p) {
chEvtSignal((thread_t *)p, 1);
}
-static THD_FUNCTION(evt_thread4, p) {
+static THD_FUNCTION(evt_thread7, p) {
(void)p;
chEvtBroadcast(&es1);
@@ -2775,6 +2775,145 @@ test_wait_threads();]]></value>
</step>
</steps>
</case>
+ <case>
+ <brief>
+ <value>Events Flags wait timeouts.</value>
+ </brief>
+ <description>
+ <value>Timeout functionality is tested for chEvtWaitOneTimeout(), chEvtWaitAnyTimeout() and chEvtWaitAllTimeout().</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[chEvtGetAndClearEvents(ALL_EVENTS);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[eventmask_t m;]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>The functions are invoked first with TIME_IMMEDIATE timeout, the timeout condition is tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+test_assert(m == 0, "spurious event");
+m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+test_assert(m == 0, "spurious event");
+m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+test_assert(m == 0, "spurious event");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>The functions are invoked first with a 50mS timeout, the timeout condition is tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[m = chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(50));
+test_assert(m == 0, "spurious event");
+m = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(50));
+test_assert(m == 0, "spurious event");
+m = chEvtWaitAllTimeout(ALL_EVENTS, MS2ST(50));
+test_assert(m == 0, "spurious event");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>Broadcasting using chEvtBroadcast().</value>
+ </brief>
+ <description>
+ <value>Functionality of chEvtBroadcast() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[chEvtGetAndClearEvents(ALL_EVENTS);
+chEvtObjectInit(&es1);
+chEvtObjectInit(&es2);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[eventmask_t m;
+event_listener_t el1, el2;
+systime_t target_time;]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Registering on two event sources associating them with flags 1 and 4.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chEvtRegisterMask(&es1, &el1, 1);
+chEvtRegisterMask(&es2, &el2, 4);]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Getting current time and starting a broadcaster thread, the thread broadcast the first Event Source immediately and the other after 50mS.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[target_time = test_wait_tick() + MS2ST(50);
+threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ evt_thread7, "A");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Calling chEvtWaitAll() then verifying that both event flags have been received after 50mS and that the event flags mask has been emptied.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[m = chEvtWaitAll(5);
+test_assert_time_window(target_time, target_time + ALLOWED_DELAY,
+ "out of time window");
+m = chEvtGetAndClearEvents(ALL_EVENTS);
+test_assert(m == 0, "stuck event");
+test_wait_threads();]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Unregistering from the Event Sources.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chEvtUnregister(&es1, &el1);
+chEvtUnregister(&es2, &el2);
+test_assert(!chEvtIsListeningI(&es1), "stuck listener");
+test_assert(!chEvtIsListeningI(&es2), "stuck listener");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
</cases>
</sequence>
<sequence>
diff --git a/test/rt/source/test/test_sequence_007.c b/test/rt/source/test/test_sequence_007.c
index 2a7e014b3..4e0fcc8da 100644
--- a/test/rt/source/test/test_sequence_007.c
+++ b/test/rt/source/test/test_sequence_007.c
@@ -38,6 +38,8 @@
* - @subpage test_007_003
* - @subpage test_007_004
* - @subpage test_007_005
+ * - @subpage test_007_006
+ * - @subpage test_007_007
* .
*/
@@ -61,7 +63,7 @@ static THD_FUNCTION(evt_thread3, p) {
chEvtSignal((thread_t *)p, 1);
}
-static THD_FUNCTION(evt_thread4, p) {
+static THD_FUNCTION(evt_thread7, p) {
(void)p;
chEvtBroadcast(&es1);
@@ -401,6 +403,138 @@ static const testcase_t test_007_005 = {
test_007_005_execute
};
+/**
+ * @page test_007_006 [7.6] Events Flags wait timeouts
+ *
+ * <h2>Description</h2>
+ * Timeout functionality is tested for chEvtWaitOneTimeout(),
+ * chEvtWaitAnyTimeout() and chEvtWaitAllTimeout().
+ *
+ * <h2>Test Steps</h2>
+ * - [7.6.1] The functions are invoked first with TIME_IMMEDIATE
+ * timeout, the timeout condition is tested.
+ * - [7.6.2] The functions are invoked first with a 50mS timeout, the
+ * timeout condition is tested.
+ * .
+ */
+
+static void test_007_006_setup(void) {
+ chEvtGetAndClearEvents(ALL_EVENTS);
+}
+
+static void test_007_006_execute(void) {
+ eventmask_t m;
+
+ /* [7.6.1] The functions are invoked first with TIME_IMMEDIATE
+ timeout, the timeout condition is tested.*/
+ test_set_step(1);
+ {
+ m = chEvtWaitOneTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+ test_assert(m == 0, "spurious event");
+ m = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+ test_assert(m == 0, "spurious event");
+ m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE);
+ test_assert(m == 0, "spurious event");
+ }
+
+ /* [7.6.2] The functions are invoked first with a 50mS timeout, the
+ timeout condition is tested.*/
+ test_set_step(2);
+ {
+ m = chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(50));
+ test_assert(m == 0, "spurious event");
+ m = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(50));
+ test_assert(m == 0, "spurious event");
+ m = chEvtWaitAllTimeout(ALL_EVENTS, MS2ST(50));
+ test_assert(m == 0, "spurious event");
+ }
+}
+
+static const testcase_t test_007_006 = {
+ "Events Flags wait timeouts",
+ test_007_006_setup,
+ NULL,
+ test_007_006_execute
+};
+
+/**
+ * @page test_007_007 [7.7] Broadcasting using chEvtBroadcast()
+ *
+ * <h2>Description</h2>
+ * Functionality of chEvtBroadcast() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - [7.7.1] Registering on two event sources associating them with
+ * flags 1 and 4.
+ * - [7.7.2] Getting current time and starting a broadcaster thread,
+ * the thread broadcast the first Event Source immediately and the
+ * other after 50mS.
+ * - [7.7.3] Calling chEvtWaitAll() then verifying that both event
+ * flags have been received after 50mS and that the event flags mask
+ * has been emptied.
+ * - [7.7.4] Unregistering from the Event Sources.
+ * .
+ */
+
+static void test_007_007_setup(void) {
+ chEvtGetAndClearEvents(ALL_EVENTS);
+ chEvtObjectInit(&es1);
+ chEvtObjectInit(&es2);
+}
+
+static void test_007_007_execute(void) {
+ eventmask_t m;
+ event_listener_t el1, el2;
+ systime_t target_time;
+
+ /* [7.7.1] Registering on two event sources associating them with
+ flags 1 and 4.*/
+ test_set_step(1);
+ {
+ chEvtRegisterMask(&es1, &el1, 1);
+ chEvtRegisterMask(&es2, &el2, 4);
+ }
+
+ /* [7.7.2] Getting current time and starting a broadcaster thread,
+ the thread broadcast the first Event Source immediately and the
+ other after 50mS.*/
+ test_set_step(2);
+ {
+ target_time = test_wait_tick() + MS2ST(50);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ evt_thread7, "A");
+ }
+
+ /* [7.7.3] Calling chEvtWaitAll() then verifying that both event
+ flags have been received after 50mS and that the event flags mask
+ has been emptied.*/
+ test_set_step(3);
+ {
+ m = chEvtWaitAll(5);
+ test_assert_time_window(target_time, target_time + ALLOWED_DELAY,
+ "out of time window");
+ m = chEvtGetAndClearEvents(ALL_EVENTS);
+ test_assert(m == 0, "stuck event");
+ test_wait_threads();
+ }
+
+ /* [7.7.4] Unregistering from the Event Sources.*/
+ test_set_step(4);
+ {
+ chEvtUnregister(&es1, &el1);
+ chEvtUnregister(&es2, &el2);
+ test_assert(!chEvtIsListeningI(&es1), "stuck listener");
+ test_assert(!chEvtIsListeningI(&es2), "stuck listener");
+ }
+}
+
+static const testcase_t test_007_007 = {
+ "Broadcasting using chEvtBroadcast()",
+ test_007_007_setup,
+ NULL,
+ test_007_007_execute
+};
+
/****************************************************************************
* Exported data.
****************************************************************************/
@@ -414,6 +548,8 @@ const testcase_t * const test_sequence_007[] = {
&test_007_003,
&test_007_004,
&test_007_005,
+ &test_007_006,
+ &test_007_007,
NULL
};