git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9188 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
Giovanni Di Sirio 2016-03-31 10:10:43 +00:00
parent eebd4b6a02
commit 039a6c7349
5 changed files with 237 additions and 17 deletions

View File

@ -89,7 +89,7 @@
- RT: Removed I/O Queues and Streams interface, now those exists (much
improved) inside the HAL.
- HAL: Improvements to the I/O queues now timeouts are absolute for
iqReadTimeout() and oqWriteTimeout functions.
iqReadTimeout() and oqWriteTimeout() functions.
- RT: Added a NASA-OSAL API emulator over the RT kernel.
- RT: Added RT-STM32L476-DISCOVERY demo.
- HAL: Added more STM32L4xx testhal demos.

View File

@ -758,7 +758,10 @@ chSysUnlock();]]></value>
static THD_FUNCTION(thread1, p) {
chSysLock();
chThdResumeI(&tr1, MSG_OK);
chSchRescheduleS();
chSysUnlock();
test_emit_token(*(char *)p);
}]]></value>
</shared_code>
@ -1202,7 +1205,7 @@ test_assert(sem1.cnt == 0, "counter not zero");]]></value>
<value />
</setup_code>
<teardown_code>
<value />
<value><![CDATA[test_wait_threads();]]></value>
</teardown_code>
<local_variables>
<value><![CDATA[binary_semaphore_t bsem;
@ -1465,6 +1468,13 @@ static THD_FUNCTION(thread8, p) {
test_emit_token(*(char *)p);
chMtxUnlock(&m1);
chMtxUnlock(&m2);
}
static THD_FUNCTION(thread9, p) {
chMtxLock(&m2);
test_emit_token(*(char *)p);
chMtxUnlock(&m2);
}
#endif /* CH_CFG_USE_CONDVARS */]]></value>
</shared_code>
@ -2134,8 +2144,7 @@ The test expects the threads to reach their goal in increasing priority order re
<various_code>
<setup_code>
<value><![CDATA[chCondObjectInit(&c1);
chMtxObjectInit(&m1);
chMtxObjectInit(&m2);]]></value>
chMtxObjectInit(&m1);]]></value>
</setup_code>
<teardown_code>
<value />
@ -2154,11 +2163,11 @@ chMtxObjectInit(&m2);]]></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>
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>
@ -2176,6 +2185,110 @@ test_assert_sequence("ABCDE", "invalid sequence");]]></value>
</step>
</steps>
</case>
<case>
<brief>
<value>Condition Variable priority boost test.</value>
</brief>
<description>
<value>This test case verifies the priority boost of a thread waiting on a conditional variable queue. It tests this very specific situation in order to improve code coverage. The created threads perform the following operations: TA{lock(M2), lock(M1), wait(C1), unlock(M1), unlock(M2)}, TB{lock(M2), wait(C1), unlock(M2)}. TC{lock(M1), unlock(M1)}.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[chCondObjectInit(&c1);
chMtxObjectInit(&m1);
chMtxObjectInit(&m2);]]></value>
</setup_code>
<teardown_code>
<value />
</teardown_code>
<local_variables>
<value><![CDATA[tprio_t prio;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>Reading current base priority.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[prio = chThdGetPriorityX();]]></value>
</code>
</step>
<step>
<description>
<value>Thread A is created at priority P(+1), it locks M2, locks M1 and goes to wait on C1.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread8, "A");]]></value>
</code>
</step>
<step>
<description>
<value>Thread C is created at priority P(+2), it enqueues on M1 and boosts TA priority at P(+2).</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "C");]]></value>
</code>
</step>
<step>
<description>
<value>Thread B is created at priority P(+3), it enqueues on M2 and boosts TA priority at P(+3).</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread9, "B");]]></value>
</code>
</step>
<step>
<description>
<value>Signaling C1: TA wakes up, unlocks M1 and priority goes to P(+2). TB locks M1, unlocks M1 and completes. TA unlocks M2 and priority goes to P(+1). TC waits on C1. TA completes.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chCondSignal(&c1);]]></value>
</code>
</step>
<step>
<description>
<value>Signaling C1: TC wakes up, unlocks M1 and completes.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[chCondSignal(&c1);]]></value>
</code>
</step>
<step>
<description>
<value>Checking the order of operations.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[test_wait_threads();
test_assert_sequence("ABC", "invalid sequence");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
<sequence>
@ -2252,7 +2365,7 @@ for (i = 0; i < 4; i++) {
msg = chMsgGet(tp);
chMsgRelease(tp, msg);
test_emit_token(msg);
}
}
test_wait_threads();
test_assert_sequence("ABCD", "invalid sequence");]]></value>
</code>

View File

@ -40,7 +40,10 @@ static thread_reference_t tr1;
static THD_FUNCTION(thread1, p) {
chSysLock();
chThdResumeI(&tr1, MSG_OK);
chSchRescheduleS();
chSysUnlock();
test_emit_token(*(char *)p);
}

View File

@ -418,6 +418,10 @@ static const testcase_t test_004_005 = {
* .
*/
static void test_004_006_teardown(void) {
test_wait_threads();
}
static void test_004_006_execute(void) {
binary_semaphore_t bsem;
msg_t msg;
@ -477,7 +481,7 @@ static void test_004_006_execute(void) {
static const testcase_t test_004_006 = {
"Testing Binary Semaphores special case",
NULL,
NULL,
test_004_006_teardown,
test_004_006_execute
};

View File

@ -42,6 +42,7 @@
* - @subpage test_005_006
* - @subpage test_005_007
* - @subpage test_005_008
* - @subpage test_005_009
* .
*/
@ -214,6 +215,13 @@ static THD_FUNCTION(thread8, p) {
chMtxUnlock(&m1);
chMtxUnlock(&m2);
}
static THD_FUNCTION(thread9, p) {
chMtxLock(&m2);
test_emit_token(*(char *)p);
chMtxUnlock(&m2);
}
#endif /* CH_CFG_USE_CONDVARS */
/****************************************************************************
@ -869,7 +877,6 @@ static const testcase_t test_005_007 = {
static void test_005_008_setup(void) {
chCondObjectInit(&c1);
chMtxObjectInit(&m1);
chMtxObjectInit(&m2);
}
static void test_005_008_execute(void) {
@ -879,11 +886,11 @@ static void test_005_008_execute(void) {
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");
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.8.2] Broarcasting on the condition variable then waiting for
@ -904,6 +911,98 @@ static const testcase_t test_005_008 = {
};
#endif /* CH_CFG_USE_CONDVARS */
/**
* @page test_005_009 [5.9] Condition Variable priority boost test
*
* <h2>Description</h2>
* This test case verifies the priority boost of a thread waiting on a
* conditional variable queue. It tests this very specific situation in
* order to improve code coverage. The created threads perform the
* following operations: TA{lock(M2), lock(M1), wait(C1), unlock(M1),
* unlock(M2)}, TB{lock(M2), wait(C1), unlock(M2)}. TC{lock(M1),
* unlock(M1)}.
*
* <h2>Test Steps</h2>
* - [5.9.1] Reading current base priority.
* - [5.9.2] Thread A is created at priority P(+1), it locks M2, locks
* M1 and goes to wait on C1.
* - [5.9.3] Thread C is created at priority P(+2), it enqueues on M1
* and boosts TA priority at P(+2).
* - [5.9.4] Thread B is created at priority P(+3), it enqueues on M2
* and boosts TA priority at P(+3).
* - [5.9.5] Signaling C1: TA wakes up, unlocks M1 and priority goes to
* P(+2). TB locks M1, unlocks M1 and completes. TA unlocks M2 and
* priority goes to P(+1). TC waits on C1. TA completes.
* - [5.9.6] Signaling C1: TC wakes up, unlocks M1 and completes.
* - [5.9.7] Checking the order of operations.
* .
*/
static void test_005_009_setup(void) {
chCondObjectInit(&c1);
chMtxObjectInit(&m1);
chMtxObjectInit(&m2);
}
static void test_005_009_execute(void) {
tprio_t prio;
/* [5.9.1] Reading current base priority.*/
test_set_step(1);
{
prio = chThdGetPriorityX();
}
/* [5.9.2] Thread A is created at priority P(+1), it locks M2, locks
M1 and goes to wait on C1.*/
test_set_step(2);
{
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread8, "A");
}
/* [5.9.3] Thread C is created at priority P(+2), it enqueues on M1
and boosts TA priority at P(+2).*/
test_set_step(3);
{
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread6, "C");
}
/* [5.9.4] Thread B is created at priority P(+3), it enqueues on M2
and boosts TA priority at P(+3).*/
test_set_step(4);
{
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread9, "B");
}
/* [5.9.5] Signaling C1: TA wakes up, unlocks M1 and priority goes to
P(+2). TB locks M1, unlocks M1 and completes. TA unlocks M2 and
priority goes to P(+1). TC waits on C1. TA completes.*/
test_set_step(5);
{
chCondSignal(&c1);
}
/* [5.9.6] Signaling C1: TC wakes up, unlocks M1 and completes.*/
test_set_step(6);
{
chCondSignal(&c1);
}
/* [5.9.7] Checking the order of operations.*/
test_set_step(7);
{
test_wait_threads();
test_assert_sequence("ABC", "invalid sequence");
}
}
static const testcase_t test_005_009 = {
"Condition Variable priority boost test",
test_005_009_setup,
NULL,
test_005_009_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
@ -928,6 +1027,7 @@ const testcase_t * const test_sequence_005[] = {
#if (CH_CFG_USE_CONDVARS) || defined(__DOXYGEN__)
&test_005_008,
#endif
&test_005_009,
NULL
};