aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-30 15:18:47 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-30 15:18:47 +0000
commit19cf7f0541f9c883b7d9512611faa5725c12ec8f (patch)
tree30c3a53e28de2a8910b4a9c3b6a37f307768b3e0 /test
parent4907ec2164700045939b6ee4331133018e1092a2 (diff)
downloadChibiOS-19cf7f0541f9c883b7d9512611faa5725c12ec8f.tar.gz
ChibiOS-19cf7f0541f9c883b7d9512611faa5725c12ec8f.tar.bz2
ChibiOS-19cf7f0541f9c883b7d9512611faa5725c12ec8f.zip
CV coverage.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9186 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r--test/rt/configuration.xml175
-rw-r--r--test/rt/source/test/test_sequence_005.c140
2 files changed, 286 insertions, 29 deletions
diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml
index 6189cdab1..f155ab19e 100644
--- a/test/rt/configuration.xml
+++ b/test/rt/configuration.xml
@@ -1884,13 +1884,13 @@ test_assert(queue_isempty(&m1.queue), "queue not empty");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[b = chMtxTryLock(&m1);
-test_assert(b, "already locked");
-b = chMtxTryLock(&m1);
-test_assert(!b, "not locked");
-
-chMtxUnlockAll();
-test_assert(m1.owner == NULL, "still owned");
+ <value><![CDATA[b = chMtxTryLock(&m1);
+test_assert(b, "already locked");
+b = chMtxTryLock(&m1);
+test_assert(!b, "not locked");
+
+chMtxUnlockAll();
+test_assert(m1.owner == NULL, "still owned");
test_assert(queue_isempty(&m1.queue), "queue not empty");]]></value>
</code>
</step>
@@ -2009,18 +2009,18 @@ test_assert(queue_isempty(&m1.queue), "queue not empty");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[b = chMtxTryLock(&m1);
-test_assert(b, "already locked");
-chSysLock();
-b = chMtxTryLockS(&m1);
-chSysUnlock();
-test_assert(b, "already locked");
-test_assert(m1.cnt == 2, "invalid recursion counter");
-chSysLock();
-chMtxUnlockAllS();
-chSysUnlock();
-test_assert(m1.owner == NULL, "still owned");
-test_assert(queue_isempty(&m1.queue), "queue not empty");
+ <value><![CDATA[b = chMtxTryLock(&m1);
+test_assert(b, "already locked");
+chSysLock();
+b = chMtxTryLockS(&m1);
+chSysUnlock();
+test_assert(b, "already locked");
+test_assert(m1.cnt == 2, "invalid recursion counter");
+chSysLock();
+chMtxUnlockAllS();
+chSysUnlock();
+test_assert(m1.owner == NULL, "still owned");
+test_assert(queue_isempty(&m1.queue), "queue not empty");
test_assert(m1.cnt == 0, "invalid recursion counter");]]></value>
</code>
</step>
@@ -2032,16 +2032,16 @@ test_assert(m1.cnt == 0, "invalid recursion counter");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[chMtxLock(&m1);
-test_assert(m1.owner != NULL, "not owned");
-chSysLock();
-chMtxLockS(&m1);
-chSysUnlock();
-test_assert(m1.owner != NULL, "not owned");
-test_assert(m1.cnt == 2, "invalid recursion counter");
-chMtxUnlockAll();
-test_assert(m1.owner == NULL, "still owned");
-test_assert(queue_isempty(&m1.queue), "queue not empty");
+ <value><![CDATA[chMtxLock(&m1);
+test_assert(m1.owner != NULL, "not owned");
+chSysLock();
+chMtxLockS(&m1);
+chSysUnlock();
+test_assert(m1.owner != NULL, "not owned");
+test_assert(m1.cnt == 2, "invalid recursion counter");
+chMtxUnlockAll();
+test_assert(m1.owner == NULL, "still owned");
+test_assert(queue_isempty(&m1.queue), "queue not empty");
test_assert(m1.cnt == 0, "invalid recursion counter");]]></value>
</code>
</step>
@@ -2058,6 +2058,123 @@ test_assert(m1.cnt == 0, "invalid recursion counter");]]></value>
</step>
</steps>
</case>
+ <case>
+ <brief>
+ <value>Condition Variable signal test.</value>
+ </brief>
+ <description>
+ <value>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.&lt;br&gt;&#xD;
+The test expects the threads to reach their goal in increasing priority order regardless of the initial order.</value>
+ </description>
+ <condition>
+ <value>CH_CFG_USE_CONDVARS</value>
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[chCondObjectInit(&c1);
+chMtxObjectInit(&m1);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Starting the five threads with increasing priority, the threads will queue on the condition variable.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[tprio_t prio = chThdGetPriorityX();
+threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread6, "E");
+threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "D");
+threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread6, "C");
+threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread6, "B");
+threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread6, "A");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Atomically signaling the condition variable five times then waiting for the threads to terminate in priority order, the order is tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chSysLock();
+chCondSignalI(&c1);
+chCondSignalI(&c1);
+chCondSignalI(&c1);
+chCondSignalI(&c1);
+chCondSignalI(&c1);
+chSchRescheduleS();
+chSysUnlock();
+test_wait_threads();
+test_assert_sequence("ABCDE", "invalid sequence");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>Condition Variable broadcast test.</value>
+ </brief>
+ <description>
+ <value>Five threads take a mutex and then enter a conditional variable queue, the tester thread then proceeds to broadcast the conditional variable.&lt;br&gt;&#xD;
+The test expects the threads to reach their goal in increasing priority order regardless of the initial order.</value>
+ </description>
+ <condition>
+ <value>CH_CFG_USE_CONDVARS</value>
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[chCondObjectInit(&c1);
+chMtxObjectInit(&m1);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Starting the five threads with increasing priority, the threads will queue on the condition variable.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[tprio_t prio = chThdGetPriorityX();
+threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread8, "E");
+threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread8, "D");
+threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread8, "C");
+threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread8, "B");
+threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread8, "A");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Broarcasting on the condition variable then waiting for the threads to terminate in priority order, the order is tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[chCondBroadcast(&c1);
+test_wait_threads();
+test_assert_sequence("ABCDE", "invalid sequence");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
</cases>
</sequence>
<sequence>
diff --git a/test/rt/source/test/test_sequence_005.c b/test/rt/source/test/test_sequence_005.c
index bd4cb825d..d5eb89546 100644
--- a/test/rt/source/test/test_sequence_005.c
+++ b/test/rt/source/test/test_sequence_005.c
@@ -40,6 +40,8 @@
* - @subpage test_005_004
* - @subpage test_005_005
* - @subpage test_005_006
+ * - @subpage test_005_007
+ * - @subpage test_005_008
* .
*/
@@ -765,6 +767,138 @@ static const testcase_t test_005_006 = {
};
#endif /* CH_CFG_USE_MUTEXES_RECURSIVE */
+#if (CH_CFG_USE_CONDVARS) || defined(__DOXYGEN__)
+/**
+ * @page test_005_007 [5.7] Condition Variable signal test
+ *
+ * <h2>Description</h2>
+ * 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.<br> The test expects the threads to
+ * reach their goal in increasing priority order regardless of the
+ * initial order.
+ *
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_CONDVARS
+ * .
+ *
+ * <h2>Test Steps</h2>
+ * - [5.7.1] Starting the five threads with increasing priority, the
+ * threads will queue on the condition variable.
+ * - [5.7.2] Atomically signaling the condition variable five times
+ * then waiting for the threads to terminate in priority order, the
+ * order is tested.
+ * .
+ */
+
+static void test_005_007_setup(void) {
+ chCondObjectInit(&c1);
+ chMtxObjectInit(&m1);
+}
+
+static void test_005_007_execute(void) {
+
+ /* [5.7.1] Starting the five threads with increasing priority, the
+ threads will queue on the condition variable.*/
+ test_set_step(1);
+ {
+ tprio_t prio = chThdGetPriorityX();
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread6, "E");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "D");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread6, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread6, "B");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread6, "A");
+ }
+
+ /* [5.7.2] Atomically signaling the condition variable five times
+ then waiting for the threads to terminate in priority order, the
+ order is tested.*/
+ test_set_step(2);
+ {
+ chSysLock();
+ chCondSignalI(&c1);
+ chCondSignalI(&c1);
+ chCondSignalI(&c1);
+ chCondSignalI(&c1);
+ chCondSignalI(&c1);
+ chSchRescheduleS();
+ chSysUnlock();
+ test_wait_threads();
+ test_assert_sequence("ABCDE", "invalid sequence");
+ }
+}
+
+static const testcase_t test_005_007 = {
+ "Condition Variable signal test",
+ test_005_007_setup,
+ NULL,
+ test_005_007_execute
+};
+#endif /* CH_CFG_USE_CONDVARS */
+
+#if (CH_CFG_USE_CONDVARS) || defined(__DOXYGEN__)
+/**
+ * @page test_005_008 [5.8] Condition Variable broadcast test
+ *
+ * <h2>Description</h2>
+ * Five threads take a mutex and then enter a conditional variable
+ * queue, the tester thread then proceeds to broadcast the conditional
+ * variable.<br> The test expects the threads to reach their goal in
+ * increasing priority order regardless of the initial order.
+ *
+ * <h2>Conditions</h2>
+ * This test is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_CONDVARS
+ * .
+ *
+ * <h2>Test Steps</h2>
+ * - [5.8.1] Starting the five threads with increasing priority, the
+ * threads will queue on the condition variable.
+ * - [5.8.2] Broarcasting on the condition variable then waiting for
+ * the threads to terminate in priority order, the order is tested.
+ * .
+ */
+
+static void test_005_008_setup(void) {
+ chCondObjectInit(&c1);
+ chMtxObjectInit(&m1);
+}
+
+static void test_005_008_execute(void) {
+
+ /* [5.8.1] Starting the five threads with increasing priority, the
+ threads will queue on the condition variable.*/
+ test_set_step(1);
+ {
+ tprio_t prio = chThdGetPriorityX();
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread8, "E");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread8, "D");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread8, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread8, "B");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread8, "A");
+ }
+
+ /* [5.8.2] Broarcasting on the condition variable then waiting for
+ the threads to terminate in priority order, the order is tested.*/
+ test_set_step(2);
+ {
+ chCondBroadcast(&c1);
+ test_wait_threads();
+ test_assert_sequence("ABCDE", "invalid sequence");
+ }
+}
+
+static const testcase_t test_005_008 = {
+ "Condition Variable broadcast test",
+ test_005_008_setup,
+ NULL,
+ test_005_008_execute
+};
+#endif /* CH_CFG_USE_CONDVARS */
+
/****************************************************************************
* Exported data.
****************************************************************************/
@@ -783,6 +917,12 @@ const testcase_t * const test_sequence_005[] = {
#if (CH_CFG_USE_MUTEXES_RECURSIVE) || defined(__DOXYGEN__)
&test_005_006,
#endif
+#if (CH_CFG_USE_CONDVARS) || defined(__DOXYGEN__)
+ &test_005_007,
+#endif
+#if (CH_CFG_USE_CONDVARS) || defined(__DOXYGEN__)
+ &test_005_008,
+#endif
NULL
};