git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9129 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
49dac4f825
commit
4b6e936c8a
|
@ -854,6 +854,33 @@ struct nil_system {
|
|||
#define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Semaphores macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Data part of a static semaphore initializer.
|
||||
* @details This macro should be used when statically initializing a semaphore
|
||||
* that is part of a bigger structure.
|
||||
*
|
||||
* @param[in] name the name of the semaphore variable
|
||||
* @param[in] n the counter initial value, this value must be
|
||||
* non-negative
|
||||
*/
|
||||
#define _SEMAPHORE_DATA(name, n) {n}
|
||||
|
||||
/**
|
||||
* @brief Static semaphore initializer.
|
||||
* @details Statically initialized semaphores require no explicit
|
||||
* initialization using @p chSemInit().
|
||||
*
|
||||
* @param[in] name the name of the semaphore variable
|
||||
* @param[in] n the counter initial value, this value must be
|
||||
* non-negative
|
||||
*/
|
||||
#define SEMAPHORE_DECL(name, n) semaphore_t name = _SEMAPHORE_DATA(name, n)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Macro Functions
|
||||
* @{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="source"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="components"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
|
|
@ -65,7 +65,7 @@ THD_FUNCTION(test_support, arg) {
|
|||
<value>Internal Tests</value>
|
||||
</type>
|
||||
<brief>
|
||||
<value>Threads Functionality</value>
|
||||
<value>Threads Functionality.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value>
|
||||
|
@ -217,7 +217,7 @@ test_assert_time_window(time + 100,
|
|||
<value>Internal Tests</value>
|
||||
</type>
|
||||
<brief>
|
||||
<value>Semaphores</value>
|
||||
<value>Semaphores.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
|
||||
|
@ -236,7 +236,7 @@ static semaphore_t sem1;]]></value>
|
|||
<value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value />
|
||||
<value>CH_CFG_USE_SEMAPHORES</value>
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
|
@ -299,7 +299,7 @@ test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value
|
|||
<value>Wait, Signal and Reset primitives are tested. The testing thread triggers a state change.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value />
|
||||
<value>CH_CFG_USE_SEMAPHORES</value>
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
|
@ -353,7 +353,7 @@ test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
|
|||
<value>Timeout on semaphores is tested.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value />
|
||||
<value>CH_CFG_USE_SEMAPHORES</value>
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
|
@ -363,7 +363,7 @@ test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
|
|||
<value><![CDATA[chSemReset(&sem1, 0);]]></value>
|
||||
</teardown_code>
|
||||
<local_variables>
|
||||
<value><![CDATA[systime_t time;
|
||||
<value><![CDATA[systime_t time;
|
||||
msg_t msg;]]></value>
|
||||
</local_variables>
|
||||
</various_code>
|
||||
|
@ -376,12 +376,12 @@ msg_t msg;]]></value>
|
|||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
|
||||
test_assert_time_window(time + MS2ST(1000),
|
||||
time + MS2ST(1000) + 1,
|
||||
"out of time window");
|
||||
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
|
||||
test_assert_time_window(time + MS2ST(1000),
|
||||
time + MS2ST(1000) + 1,
|
||||
"out of time window");
|
||||
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
|
||||
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
|
@ -393,12 +393,12 @@ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
|
|||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
|
||||
test_assert_time_window(time + MS2ST(1000),
|
||||
time + MS2ST(1000) + 1,
|
||||
"out of time window");
|
||||
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
msg = chSemWaitTimeout(&sem1, MS2ST(1000));
|
||||
test_assert_time_window(time + MS2ST(1000),
|
||||
time + MS2ST(1000) + 1,
|
||||
"out of time window");
|
||||
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
|
||||
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
|
@ -438,7 +438,7 @@ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
|
|||
<value />
|
||||
</teardown_code>
|
||||
<local_variables>
|
||||
<value><![CDATA[systime_t time;
|
||||
<value><![CDATA[systime_t time;
|
||||
msg_t msg;]]></value>
|
||||
</local_variables>
|
||||
</various_code>
|
||||
|
@ -451,10 +451,10 @@ msg_t msg;]]></value>
|
|||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[chSysLock();
|
||||
msg = chThdSuspendTimeoutS(>r1, TIME_INFINITE);
|
||||
chSysUnlock();
|
||||
test_assert(NULL == gtr1, "not NULL");
|
||||
<value><![CDATA[chSysLock();
|
||||
msg = chThdSuspendTimeoutS(>r1, TIME_INFINITE);
|
||||
chSysUnlock();
|
||||
test_assert(NULL == gtr1, "not NULL");
|
||||
test_assert(MSG_OK == msg,"wrong returned message");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
|
@ -466,14 +466,14 @@ test_assert(MSG_OK == msg,"wrong returned message");]]></value>
|
|||
<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");
|
||||
<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>
|
||||
|
@ -487,7 +487,7 @@ test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
|
|||
<value>Event flags functionality is tested.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value />
|
||||
<value>CH_CFG_USE_EVENTS</value>
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
|
@ -497,7 +497,7 @@ test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
|
|||
<value />
|
||||
</teardown_code>
|
||||
<local_variables>
|
||||
<value><![CDATA[systime_t time;
|
||||
<value><![CDATA[systime_t time;
|
||||
eventmask_t events;]]></value>
|
||||
</local_variables>
|
||||
</various_code>
|
||||
|
@ -510,10 +510,10 @@ eventmask_t events;]]></value>
|
|||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
chEvtSignal(chThdGetSelfX(), 0x55);
|
||||
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
|
||||
test_assert((eventmask_t)0 != events, "timed out");
|
||||
<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>
|
||||
|
@ -525,10 +525,10 @@ test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
|
|||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[time = chVTGetSystemTimeX();
|
||||
chThdGetSelfX()->epmask = 0;
|
||||
events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
|
||||
test_assert((eventmask_t)0 != events, "timed out");
|
||||
<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>
|
||||
</code>
|
||||
</step>
|
||||
|
@ -540,11 +540,11 @@ test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
|
|||
<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");
|
||||
<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>
|
||||
</code>
|
||||
</step>
|
||||
|
@ -552,6 +552,79 @@ test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
|
|||
</case>
|
||||
</cases>
|
||||
</sequence>
|
||||
<sequence>
|
||||
<type index="0">
|
||||
<value>Internal Tests</value>
|
||||
</type>
|
||||
<brief>
|
||||
<value>Mailboxes.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>This sequence tests the ChibiOS/NIL functionalities related to mailboxes.</value>
|
||||
</description>
|
||||
<shared_code>
|
||||
<value><![CDATA[#define ALLOWED_DELAY MS2ST(5)
|
||||
#define MB_SIZE 4
|
||||
|
||||
static msg_t mb_buffer[MB_SIZE];
|
||||
static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);]]></value>
|
||||
</shared_code>
|
||||
<cases>
|
||||
<case>
|
||||
<brief>
|
||||
<value>Mailbox non-blocking tests.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>The mailbox API is tested without triggering blocking conditions.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value>CH_CFG_USE_MAILBOXES</value>
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
<value><![CDATA[chMBObjectInit(&mb1, mb_buffer, MB_SIZE);]]></value>
|
||||
</setup_code>
|
||||
<teardown_code>
|
||||
<value><![CDATA[chMBReset(&mb1);]]></value>
|
||||
</teardown_code>
|
||||
<local_variables>
|
||||
<value><![CDATA[msg_t msg1;]]></value>
|
||||
</local_variables>
|
||||
</various_code>
|
||||
<steps>
|
||||
<step>
|
||||
<description>
|
||||
<value>Testing the mailbox size.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Testing forward and backward queuing, checking for no errors.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[unsigned i;
|
||||
|
||||
for (i = 0; i < MB_SIZE - 1; i++) {
|
||||
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
|
||||
test_assert(msg1 == MSG_OK, "wrong wake-up message");
|
||||
}
|
||||
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
|
||||
test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
</steps>
|
||||
</case>
|
||||
</cases>
|
||||
</sequence>
|
||||
</sequences>
|
||||
</instance>
|
||||
</instances>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* - @subpage test_sequence_001
|
||||
* - @subpage test_sequence_002
|
||||
* - @subpage test_sequence_003
|
||||
* - @subpage test_sequence_004
|
||||
* .
|
||||
*/
|
||||
|
||||
|
@ -50,6 +51,7 @@ const testcase_t * const *test_suite[] = {
|
|||
test_sequence_001,
|
||||
test_sequence_002,
|
||||
test_sequence_003,
|
||||
test_sequence_004,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "test_sequence_001.h"
|
||||
#include "test_sequence_002.h"
|
||||
#include "test_sequence_003.h"
|
||||
#include "test_sequence_004.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
|
|
@ -46,6 +46,7 @@ static semaphore_t sem1;
|
|||
* Test cases.
|
||||
****************************************************************************/
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @page test_002_001 Semaphore primitives, no state change
|
||||
*
|
||||
|
@ -53,6 +54,12 @@ static semaphore_t sem1;
|
|||
* Wait, Signal and Reset primitives are tested. The testing thread
|
||||
* does not trigger a state change.
|
||||
*
|
||||
* <h2>Conditions</h2>
|
||||
* This test is only executed if the following preprocessor condition
|
||||
* evaluates to true:
|
||||
* - CH_CFG_USE_SEMAPHORES
|
||||
* .
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - The function chSemWait() is invoked, after return the counter and
|
||||
* the returned message are tested.
|
||||
|
@ -107,7 +114,9 @@ static const testcase_t test_002_001 = {
|
|||
test_002_001_teardown,
|
||||
test_002_001_execute
|
||||
};
|
||||
#endif /* CH_CFG_USE_SEMAPHORES */
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @page test_002_002 Semaphore primitives, with state change
|
||||
*
|
||||
|
@ -115,6 +124,12 @@ static const testcase_t test_002_001 = {
|
|||
* Wait, Signal and Reset primitives are tested. The testing thread
|
||||
* triggers a state change.
|
||||
*
|
||||
* <h2>Conditions</h2>
|
||||
* This test is only executed if the following preprocessor condition
|
||||
* evaluates to true:
|
||||
* - CH_CFG_USE_SEMAPHORES
|
||||
* .
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - The function chSemWait() is invoked, after return the counter and
|
||||
* the returned message are tested. The semaphore is signaled by
|
||||
|
@ -166,13 +181,21 @@ static const testcase_t test_002_002 = {
|
|||
test_002_002_teardown,
|
||||
test_002_002_execute
|
||||
};
|
||||
#endif /* CH_CFG_USE_SEMAPHORES */
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @page test_002_003 Semaphores timeout
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* Timeout on semaphores is tested.
|
||||
*
|
||||
* <h2>Conditions</h2>
|
||||
* This test is only executed if the following preprocessor condition
|
||||
* evaluates to true:
|
||||
* - CH_CFG_USE_SEMAPHORES
|
||||
* .
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - The function chSemWaitTimeout() is invoked a first time, after
|
||||
* return the system time, the counter and the returned message are
|
||||
|
@ -228,6 +251,7 @@ static const testcase_t test_002_003 = {
|
|||
test_002_003_teardown,
|
||||
test_002_003_execute
|
||||
};
|
||||
#endif /* CH_CFG_USE_SEMAPHORES */
|
||||
|
||||
/****************************************************************************
|
||||
* Exported data.
|
||||
|
@ -237,8 +261,14 @@ static const testcase_t test_002_003 = {
|
|||
* @brief Semaphores.
|
||||
*/
|
||||
const testcase_t * const test_sequence_002[] = {
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
&test_002_001,
|
||||
#endif
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
&test_002_002,
|
||||
#endif
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
&test_002_003,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
|
|
@ -104,12 +104,19 @@ static const testcase_t test_003_001 = {
|
|||
test_003_001_execute
|
||||
};
|
||||
|
||||
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @page test_003_002 Events Flags functionality
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* Event flags functionality is tested.
|
||||
*
|
||||
* <h2>Conditions</h2>
|
||||
* This test is only executed if the following preprocessor condition
|
||||
* evaluates to true:
|
||||
* - CH_CFG_USE_EVENTS
|
||||
* .
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - A set of event flags are set on the current thread then the
|
||||
* function chEvtWaitAnyTimeout() is invoked, the function is
|
||||
|
@ -171,6 +178,7 @@ static const testcase_t test_003_002 = {
|
|||
NULL,
|
||||
test_003_002_execute
|
||||
};
|
||||
#endif /* CH_CFG_USE_EVENTS */
|
||||
|
||||
/****************************************************************************
|
||||
* Exported data.
|
||||
|
@ -181,6 +189,8 @@ static const testcase_t test_003_002 = {
|
|||
*/
|
||||
const testcase_t * const test_sequence_003[] = {
|
||||
&test_003_001,
|
||||
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
|
||||
&test_003_002,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "ch_test.h"
|
||||
#include "test_root.h"
|
||||
|
||||
/**
|
||||
* @page test_sequence_004 Mailboxes
|
||||
*
|
||||
* File: @ref test_sequence_004.c
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* This sequence tests the ChibiOS/NIL functionalities related to
|
||||
* mailboxes.
|
||||
*
|
||||
* <h2>Test Cases</h2>
|
||||
* - @subpage test_004_001
|
||||
* .
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Shared code.
|
||||
****************************************************************************/
|
||||
|
||||
#define ALLOWED_DELAY MS2ST(5)
|
||||
#define MB_SIZE 4
|
||||
|
||||
static msg_t mb_buffer[MB_SIZE];
|
||||
static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
|
||||
|
||||
/****************************************************************************
|
||||
* Test cases.
|
||||
****************************************************************************/
|
||||
|
||||
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @page test_004_001 Mailbox non-blocking tests
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* The mailbox API is tested without triggering blocking conditions.
|
||||
*
|
||||
* <h2>Conditions</h2>
|
||||
* This test is only executed if the following preprocessor condition
|
||||
* evaluates to true:
|
||||
* - CH_CFG_USE_MAILBOXES
|
||||
* .
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - Testing the mailbox size.
|
||||
* - Testing forward and backward queuing, checking for no errors.
|
||||
* .
|
||||
*/
|
||||
|
||||
static void test_004_001_setup(void) {
|
||||
chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
|
||||
}
|
||||
|
||||
static void test_004_001_teardown(void) {
|
||||
chMBReset(&mb1);
|
||||
}
|
||||
|
||||
static void test_004_001_execute(void) {
|
||||
msg_t msg1;
|
||||
|
||||
/* Testing the mailbox size.*/
|
||||
test_set_step(1);
|
||||
{
|
||||
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
|
||||
}
|
||||
|
||||
/* Testing forward and backward queuing, checking for no errors.*/
|
||||
test_set_step(2);
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MB_SIZE - 1; i++) {
|
||||
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
|
||||
test_assert(msg1 == MSG_OK, "wrong wake-up message");
|
||||
}
|
||||
msg1 = chMBPostAhead(&mb1, 'A', TIME_INFINITE);
|
||||
test_assert(msg1 == MSG_OK, "wrong wake-up message");
|
||||
}
|
||||
}
|
||||
|
||||
static const testcase_t test_004_001 = {
|
||||
"Mailbox non-blocking tests",
|
||||
test_004_001_setup,
|
||||
test_004_001_teardown,
|
||||
test_004_001_execute
|
||||
};
|
||||
#endif /* CH_CFG_USE_MAILBOXES */
|
||||
|
||||
/****************************************************************************
|
||||
* Exported data.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Mailboxes.
|
||||
*/
|
||||
const testcase_t * const test_sequence_004[] = {
|
||||
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
|
||||
&test_004_001,
|
||||
#endif
|
||||
NULL
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
extern const testcase_t * const test_sequence_004[];
|
|
@ -3,7 +3,8 @@ TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \
|
|||
${CHIBIOS}/test/nil/source/test/test_root.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_001.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_002.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_003.c
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_003.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_004.c
|
||||
|
||||
# Required include directories
|
||||
TESTINC = ${CHIBIOS}/test/lib \
|
||||
|
|
Loading…
Reference in New Issue