aboutsummaryrefslogtreecommitdiffstats
path: root/test/nil
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-22 10:55:31 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-22 10:55:31 +0000
commit79bd7cc8ea69d9229d229e69fd5db558ddcb1553 (patch)
tree47aa9a671a40579dedf416504a32ee47d8ed316c /test/nil
parentd82ac0a69a90df8a74e44e2090e68ae86e930bc1 (diff)
downloadChibiOS-79bd7cc8ea69d9229d229e69fd5db558ddcb1553.tar.gz
ChibiOS-79bd7cc8ea69d9229d229e69fd5db558ddcb1553.tar.bz2
ChibiOS-79bd7cc8ea69d9229d229e69fd5db558ddcb1553.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9147 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/nil')
-rw-r--r--test/nil/configuration.xml48
-rw-r--r--test/nil/source/test/test_root.c7
-rw-r--r--test/nil/source/test/test_root.h9
-rw-r--r--test/nil/source/test/test_sequence_001.c59
-rw-r--r--test/nil/source/test/test_sequence_002.c114
-rw-r--r--test/nil/source/test/test_sequence_003.c52
-rw-r--r--test/nil/source/test/test_sequence_004.c154
-rw-r--r--test/nil/source/test/test_sequence_005.c120
-rw-r--r--test/nil/source/test/test_sequence_006.c116
9 files changed, 333 insertions, 346 deletions
diff --git a/test/nil/configuration.xml b/test/nil/configuration.xml
index 1181fb341..c759ff4f9 100644
--- a/test/nil/configuration.xml
+++ b/test/nil/configuration.xml
@@ -87,6 +87,9 @@ THD_FUNCTION(test_support, arg) {
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value>
</description>
+ <condition>
+ <value />
+ </condition>
<shared_code>
<value><![CDATA[#include "ch.h"]]></value>
</shared_code>
@@ -239,6 +242,9 @@ test_assert_time_window(time + 100,
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
</description>
+ <condition>
+ <value>CH_CFG_USE_SEMAPHORES</value>
+ </condition>
<shared_code>
<value><![CDATA[#include "ch.h"
@@ -253,7 +259,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>CH_CFG_USE_SEMAPHORES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -316,7 +322,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>CH_CFG_USE_SEMAPHORES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -370,7 +376,7 @@ test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
<value>Timeout on semaphores is tested.</value>
</description>
<condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -433,6 +439,9 @@ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value>
</description>
+ <condition>
+ <value />
+ </condition>
<shared_code>
<value><![CDATA[static thread_reference_t tr1;]]></value>
</shared_code>
@@ -579,6 +588,9 @@ test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to mailboxes.</value>
</description>
+ <condition>
+ <value>CH_CFG_USE_MAILBOXES</value>
+ </condition>
<shared_code>
<value><![CDATA[#define ALLOWED_DELAY MS2ST(5)
#define MB_SIZE 4
@@ -595,7 +607,7 @@ static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);]]></value>
<value>The mailbox normal API is tested without triggering blocking conditions.</value>
</description>
<condition>
- <value>CH_CFG_USE_MAILBOXES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -719,7 +731,7 @@ test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></va
<value>The mailbox I-Class API is tested without triggering blocking conditions.</value>
</description>
<condition>
- <value>CH_CFG_USE_MAILBOXES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -851,7 +863,7 @@ test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></va
<value>The mailbox API is tested for timeouts.</value>
</description>
<condition>
- <value>CH_CFG_USE_MAILBOXES</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -943,6 +955,9 @@ test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to memory pools.</value>
</description>
+ <condition>
+ <value>CH_CFG_USE_MEMPOOLS</value>
+ </condition>
<shared_code>
<value><![CDATA[#define MEMORY_POOL_SIZE 4
@@ -961,13 +976,13 @@ static void *null_provider(size_t size, unsigned align) {
<cases>
<case>
<brief>
- <value>Loading and empting a memory pool.</value>
+ <value>Loading and emptying a memory pool.</value>
</brief>
<description>
- <value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value>
+ <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description>
<condition>
- <value>CH_CFG_USE_MEMPOOLS</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -1066,13 +1081,13 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
</case>
<case>
<brief>
- <value>Loading and empting a guarded memory pool without waiting.</value>
+ <value>Loading and emptying a guarded memory pool without waiting.</value>
</brief>
<description>
- <value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value>
+ <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description>
<condition>
- <value>(CH_CFG_USE_MEMPOOLS &amp;&amp; CH_CFG_USE_SEMAPHORES)</value>
+ <value>CH_CFG_USE_SEMAPHORES</value>
</condition>
<various_code>
<setup_code>
@@ -1165,7 +1180,7 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
<value>The timeout features for the Guarded Memory Pools is tested.</value>
</description>
<condition>
- <value>(CH_CFG_USE_MEMPOOLS &amp;&amp; CH_CFG_USE_SEMAPHORES)</value>
+ <value>CH_CFG_USE_SEMAPHORES</value>
</condition>
<various_code>
<setup_code>
@@ -1204,6 +1219,9 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
<description>
<value>This sequence tests the ChibiOS/NIL functionalities related to memory heaps.</value>
</description>
+ <condition>
+ <value>CH_CFG_USE_HEAP</value>
+ </condition>
<shared_code>
<value><![CDATA[#define ALLOC_SIZE 16
#define HEAP_SIZE (ALLOC_SIZE * 8)
@@ -1220,7 +1238,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);]]></value>
<value>Series of allocations/deallocations are performed in carefully designed sequences in order to stimulate all the possible code paths inside the allocator. The test expects to find the heap back to the initial status after each sequence.</value>
</description>
<condition>
- <value>CH_CFG_USE_HEAP</value>
+ <value />
</condition>
<various_code>
<setup_code>
@@ -1398,7 +1416,7 @@ test_assert(n == sz, "size changed");]]></value>
<value>The default heap is pre-allocated in the system. We test base functionality.</value>
</description>
<condition>
- <value>CH_CFG_USE_HEAP</value>
+ <value />
</condition>
<various_code>
<setup_code>
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/test_root.c
index 72a98172e..23d4884c9 100644
--- a/test/nil/source/test/test_root.c
+++ b/test/nil/source/test/test_root.c
@@ -33,15 +33,14 @@
/**
* @file test_root.c
* @brief Test Suite root structures code.
- *
- * @addtogroup SPC5_TEST_ROOT
- * @{
*/
#include "hal.h"
#include "ch_test.h"
#include "test_root.h"
+#if !defined(__DOXYGEN__)
+
/*===========================================================================*/
/* Module exported variables. */
/*===========================================================================*/
@@ -97,4 +96,4 @@ THD_FUNCTION(test_support, arg) {
}
}
-/** @} */
+#endif /* !defined(__DOXYGEN__) */
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/test_root.h
index 242091b3d..d52950e64 100644
--- a/test/nil/source/test/test_root.h
+++ b/test/nil/source/test/test_root.h
@@ -17,9 +17,6 @@
/**
* @file test_root.h
* @brief Test Suite root structures header.
- *
- * @addtogroup SPC5_TEST_ROOT
- * @{
*/
#ifndef _SPC5_TEST_ROOT_H_
@@ -32,6 +29,8 @@
#include "test_sequence_005.h"
#include "test_sequence_006.h"
+#if !defined(__DOXYGEN__)
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -57,6 +56,6 @@ extern THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg);
-#endif /* _SPC5_TEST_ROOT_H_ */
+#endif /* !defined(__DOXYGEN__) */
-/** @} */
+#endif /* _SPC5_TEST_ROOT_H_ */
diff --git a/test/nil/source/test/test_sequence_001.c b/test/nil/source/test/test_sequence_001.c
index 8073ac10f..a3446b096 100644
--- a/test/nil/source/test/test_sequence_001.c
+++ b/test/nil/source/test/test_sequence_001.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_001 Threads Functionality
+ * @page test_sequence_001 [1] Threads Functionality
*
* File: @ref test_sequence_001.c
*
@@ -44,21 +44,21 @@
****************************************************************************/
/**
- * @page test_001_001 System Tick Counter functionality
+ * @page test_001_001 [1.1] System Tick Counter functionality
*
* <h2>Description</h2>
* The functionality of the API @p chVTGetSystemTimeX() is tested.
*
* <h2>Test Steps</h2>
- * - A System Tick Counter increment is expected, the test simply hangs
- * if it does not happen.
+ * - [1.1.1] A System Tick Counter increment is expected, the test
+ * simply hangs if it does not happen.
* .
*/
static void test_001_001_execute(void) {
- /* A System Tick Counter increment is expected, the test simply hangs
- if it does not happen.*/
+ /* [1.1.1] A System Tick Counter increment is expected, the test
+ simply hangs if it does not happen.*/
test_set_step(1);
{
systime_t time = chVTGetSystemTimeX();
@@ -75,30 +75,34 @@ static const testcase_t test_001_001 = {
};
/**
- * @page test_001_002 Thread Sleep functionality
+ * @page test_001_002 [1.2] Thread Sleep functionality
*
* <h2>Description</h2>
* The functionality of @p chThdSleep() and derivatives is tested.
*
* <h2>Test Steps</h2>
- * - The current system time is read then a sleep is performed for 100
- * system ticks and on exit the system time is verified again.
- * - The current system time is read then a sleep is performed for
- * 100000 microseconds and on exit the system time is verified again.
- * - The current system time is read then a sleep is performed for 100
- * milliseconds and on exit the system time is verified again.
- * - The current system time is read then a sleep is performed for 1
- * second and on exit the system time is verified again.
- * - Function chThdSleepUntil() is tested with a timeline of "now" +
- * 100 ticks.
+ * - [1.2.1] The current system time is read then a sleep is performed
+ * for 100 system ticks and on exit the system time is verified
+ * again.
+ * - [1.2.2] The current system time is read then a sleep is performed
+ * for 100000 microseconds and on exit the system time is verified
+ * again.
+ * - [1.2.3] The current system time is read then a sleep is performed
+ * for 100 milliseconds and on exit the system time is verified
+ * again.
+ * - [1.2.4] The current system time is read then a sleep is performed
+ * for 1 second and on exit the system time is verified again.
+ * - [1.2.5] Function chThdSleepUntil() is tested with a timeline of
+ * "now" + 100 ticks.
* .
*/
static void test_001_002_execute(void) {
systime_t time;
- /* The current system time is read then a sleep is performed for 100
- system ticks and on exit the system time is verified again.*/
+ /* [1.2.1] The current system time is read then a sleep is performed
+ for 100 system ticks and on exit the system time is verified
+ again.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
@@ -108,8 +112,8 @@ static void test_001_002_execute(void) {
"out of time window");
}
- /* The current system time is read then a sleep is performed for
- 100000 microseconds and on exit the system time is verified
+ /* [1.2.2] The current system time is read then a sleep is performed
+ for 100000 microseconds and on exit the system time is verified
again.*/
test_set_step(2);
{
@@ -120,8 +124,9 @@ static void test_001_002_execute(void) {
"out of time window");
}
- /* The current system time is read then a sleep is performed for 100
- milliseconds and on exit the system time is verified again.*/
+ /* [1.2.3] The current system time is read then a sleep is performed
+ for 100 milliseconds and on exit the system time is verified
+ again.*/
test_set_step(3);
{
time = chVTGetSystemTimeX();
@@ -131,8 +136,8 @@ static void test_001_002_execute(void) {
"out of time window");
}
- /* The current system time is read then a sleep is performed for 1
- second and on exit the system time is verified again.*/
+ /* [1.2.4] The current system time is read then a sleep is performed
+ for 1 second and on exit the system time is verified again.*/
test_set_step(4);
{
time = chVTGetSystemTimeX();
@@ -142,8 +147,8 @@ static void test_001_002_execute(void) {
"out of time window");
}
- /* Function chThdSleepUntil() is tested with a timeline of "now" +
- 100 ticks.*/
+ /* [1.2.5] Function chThdSleepUntil() is tested with a timeline of
+ "now" + 100 ticks.*/
test_set_step(5);
{
time = chVTGetSystemTimeX();
diff --git a/test/nil/source/test/test_sequence_002.c b/test/nil/source/test/test_sequence_002.c
index 0656d04f0..9c32486bd 100644
--- a/test/nil/source/test/test_sequence_002.c
+++ b/test/nil/source/test/test_sequence_002.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_002 Semaphores
+ * @page test_sequence_002 [2] Semaphores
*
* File: @ref test_sequence_002.c
*
@@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to
* counter semaphores.
*
+ * <h2>Conditions</h2>
+ * This sequence is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_SEMAPHORES
+ * .
+ *
* <h2>Test Cases</h2>
* - @subpage test_002_001
* - @subpage test_002_002
@@ -34,6 +40,8 @@
* .
*/
+#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
+
/****************************************************************************
* Shared code.
****************************************************************************/
@@ -46,27 +54,20 @@ static semaphore_t sem1;
* Test cases.
****************************************************************************/
-#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/**
- * @page test_002_001 Semaphore primitives, no state change
+ * @page test_002_001 [2.1] Semaphore primitives, no state change
*
* <h2>Description</h2>
* 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.
- * - The function chSemSignal() is invoked, after return the counter is
- * tested.
- * - The function chSemReset() is invoked, after return the counter is
- * tested.
+ * - [2.1.1] The function chSemWait() is invoked, after return the
+ * counter and the returned message are tested.
+ * - [2.1.2] The function chSemSignal() is invoked, after return the
+ * counter is tested.
+ * - [2.1.3] The function chSemReset() is invoked, after return the
+ * counter is tested.
* .
*/
@@ -80,8 +81,8 @@ static void test_002_001_teardown(void) {
static void test_002_001_execute(void) {
- /* The function chSemWait() is invoked, after return the counter and
- the returned message are tested.*/
+ /* [2.1.1] The function chSemWait() is invoked, after return the
+ counter and the returned message are tested.*/
test_set_step(1);
{
msg_t msg;
@@ -91,16 +92,16 @@ static void test_002_001_execute(void) {
test_assert(MSG_OK == msg, "wrong returned message");
}
- /* The function chSemSignal() is invoked, after return the counter is
- tested.*/
+ /* [2.1.2] The function chSemSignal() is invoked, after return the
+ counter is tested.*/
test_set_step(2);
{
chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
}
- /* The function chSemReset() is invoked, after return the counter is
- tested.*/
+ /* [2.1.3] The function chSemReset() is invoked, after return the
+ counter is tested.*/
test_set_step(3);
{
chSemReset(&sem1, 2);
@@ -114,29 +115,21 @@ 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
+ * @page test_002_002 [2.2] Semaphore primitives, with state change
*
* <h2>Description</h2>
* 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
- * another thread.
- * - The function chSemWait() is invoked, after return the counter and
- * the returned message are tested. The semaphore is reset by another
- * thread.
+ * - [2.2.1] The function chSemWait() is invoked, after return the
+ * counter and the returned message are tested. The semaphore is
+ * signaled by another thread.
+ * - [2.2.2] The function chSemWait() is invoked, after return the
+ * counter and the returned message are tested. The semaphore is
+ * reset by another thread.
* .
*/
@@ -150,9 +143,9 @@ static void test_002_002_teardown(void) {
static void test_002_002_execute(void) {
- /* The function chSemWait() is invoked, after return the counter and
- the returned message are tested. The semaphore is signaled by
- another thread.*/
+ /* [2.2.1] The function chSemWait() is invoked, after return the
+ counter and the returned message are tested. The semaphore is
+ signaled by another thread.*/
test_set_step(1);
{
msg_t msg;
@@ -162,9 +155,9 @@ static void test_002_002_execute(void) {
test_assert(MSG_OK == msg, "wrong returned message");
}
- /* The function chSemWait() is invoked, after return the counter and
- the returned message are tested. The semaphore is reset by another
- thread.*/
+ /* [2.2.2] The function chSemWait() is invoked, after return the
+ counter and the returned message are tested. The semaphore is
+ reset by another thread.*/
test_set_step(2);
{
msg_t msg;
@@ -181,27 +174,20 @@ 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
+ * @page test_002_003 [2.3] 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
+ * - [2.3.1] The function chSemWaitTimeout() is invoked a first time,
+ * after return the system time, the counter and the returned message
+ * are tested.
+ * - [2.3.2] The function chSemWaitTimeout() is invoked again, after
* return the system time, the counter and the returned message are
* tested.
- * - The function chSemWaitTimeout() is invoked again, after return the
- * system time, the counter and the returned message are tested.
* .
*/
@@ -217,9 +203,9 @@ static void test_002_003_execute(void) {
systime_t time;
msg_t msg;
- /* The function chSemWaitTimeout() is invoked a first time, after
- return the system time, the counter and the returned message are
- tested.*/
+ /* [2.3.1] The function chSemWaitTimeout() is invoked a first time,
+ after return the system time, the counter and the returned message
+ are tested.*/
test_set_step(1);
{
time = chVTGetSystemTimeX();
@@ -231,8 +217,9 @@ static void test_002_003_execute(void) {
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
- /* The function chSemWaitTimeout() is invoked again, after return the
- system time, the counter and the returned message are tested.*/
+ /* [2.3.2] The function chSemWaitTimeout() is invoked again, after
+ return the system time, the counter and the returned message are
+ tested.*/
test_set_step(2);
{
time = chVTGetSystemTimeX();
@@ -251,7 +238,6 @@ static const testcase_t test_002_003 = {
test_002_003_teardown,
test_002_003_execute
};
-#endif /* CH_CFG_USE_SEMAPHORES */
/****************************************************************************
* Exported data.
@@ -261,14 +247,10 @@ 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
};
+
+#endif /* CH_CFG_USE_SEMAPHORES */
diff --git a/test/nil/source/test/test_sequence_003.c b/test/nil/source/test/test_sequence_003.c
index b527dec06..5be49525b 100644
--- a/test/nil/source/test/test_sequence_003.c
+++ b/test/nil/source/test/test_sequence_003.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_003 Suspend/Resume and Event Flags
+ * @page test_sequence_003 [3] Suspend/Resume and Event Flags
*
* File: @ref test_sequence_003.c
*
@@ -44,19 +44,19 @@ static thread_reference_t tr1;
****************************************************************************/
/**
- * @page test_003_001 Suspend and Resume functionality
+ * @page test_003_001 [3.1] Suspend and Resume functionality
*
* <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
* tested.
*
* <h2>Test Steps</h2>
- * - The function chThdSuspendTimeoutS() is invoked, the thread is
- * remotely resumed with message @p MSG_OK. On return the message and
+ * - [3.1.1] 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.
+ * - [3.1.2] 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.
- * - 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.
* .
*/
@@ -68,9 +68,9 @@ static void test_003_001_execute(void) {
systime_t time;
msg_t msg;
- /* 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.*/
+ /* [3.1.1] 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.*/
test_set_step(1);
{
chSysLock();
@@ -80,9 +80,9 @@ static void test_003_001_execute(void) {
test_assert(MSG_OK == msg,"wrong returned message");
}
- /* 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.*/
+ /* [3.1.2] 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.*/
test_set_step(2);
{
chSysLock();
@@ -104,9 +104,9 @@ static const testcase_t test_003_001 = {
test_003_001_execute
};
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
/**
- * @page test_003_002 Events Flags functionality
+ * @page test_003_002 [3.2] Events Flags functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
@@ -118,15 +118,15 @@ static const testcase_t test_003_001 = {
* .
*
* <h2>Test Steps</h2>
- * - A set of event flags are set on the current thread then the
- * function chEvtWaitAnyTimeout() is invoked, the function is
+ * - [3.2.1] 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.
- * - The pending event flags mask is cleared then the function
+ * - [3.2.2] 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.
- * - The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
- * the thread, the function must return because timeout.
+ * - [3.2.3] The function chEvtWaitAnyTimeout() is invoked, no event
+ * can wakeup the thread, the function must return because timeout.
* .
*/
@@ -134,8 +134,8 @@ static void test_003_002_execute(void) {
systime_t time;
eventmask_t events;
- /* A set of event flags are set on the current thread then the
- function chEvtWaitAnyTimeout() is invoked, the function is
+ /* [3.2.1] 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.*/
test_set_step(1);
@@ -147,7 +147,7 @@ static void test_003_002_execute(void) {
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
- /* The pending event flags mask is cleared then the function
+ /* [3.2.2] 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.*/
test_set_step(2);
@@ -159,8 +159,8 @@ static void test_003_002_execute(void) {
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
- /* The function chEvtWaitAnyTimeout() is invoked, no event can wakeup
- the thread, the function must return because timeout.*/
+ /* [3.2.3] The function chEvtWaitAnyTimeout() is invoked, no event
+ can wakeup the thread, the function must return because timeout.*/
test_set_step(3);
{
time = chVTGetSystemTimeX();
@@ -189,7 +189,7 @@ static const testcase_t test_003_002 = {
*/
const testcase_t * const test_sequence_003[] = {
&test_003_001,
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
&test_003_002,
#endif
NULL
diff --git a/test/nil/source/test/test_sequence_004.c b/test/nil/source/test/test_sequence_004.c
index 2035849bd..a4b3765f5 100644
--- a/test/nil/source/test/test_sequence_004.c
+++ b/test/nil/source/test/test_sequence_004.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_004 Mailboxes
+ * @page test_sequence_004 [4] Mailboxes
*
* File: @ref test_sequence_004.c
*
@@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to
* mailboxes.
*
+ * <h2>Conditions</h2>
+ * This sequence is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_MAILBOXES
+ * .
+ *
* <h2>Test Cases</h2>
* - @subpage test_004_001
* - @subpage test_004_002
@@ -34,6 +40,8 @@
* .
*/
+#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
+
/****************************************************************************
* Shared code.
****************************************************************************/
@@ -48,31 +56,27 @@ static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
* Test cases.
****************************************************************************/
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/**
- * @page test_004_001 Mailbox normal API, non-blocking tests
+ * @page test_004_001 [4.1] Mailbox normal API, non-blocking tests
*
* <h2>Description</h2>
* The mailbox normal 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.
- * - Resetting the mailbox, conditions are checked, no errors expected.
- * - Filling the mailbox using chMBPost() and chMBPostAhead() once, no
- * errors expected.
- * - Testing intermediate conditions. Data pointers must be aligned,
- * semaphore counters are checked.
- * - Emptying the mailbox using chMBFetch(), no errors expected.
- * - Posting and then fetching one more message, no errors expected.
- * - Testing final conditions. Data pointers must be aligned to buffer
- * start, semaphore counters are checked.
+ * - [4.1.1] Testing the mailbox size.
+ * - [4.1.2] Resetting the mailbox, conditions are checked, no errors
+ * expected.
+ * - [4.1.3] Filling the mailbox using chMBPost() and chMBPostAhead()
+ * once, no errors expected.
+ * - [4.1.4] Testing intermediate conditions. Data pointers must be
+ * aligned, semaphore counters are checked.
+ * - [4.1.5] Emptying the mailbox using chMBFetch(), no errors
+ * expected.
+ * - [4.1.6] Posting and then fetching one more message, no errors
+ * expected.
+ * - [4.1.7] Testing final conditions. Data pointers must be aligned to
+ * buffer start, semaphore counters are checked.
* .
*/
@@ -88,13 +92,13 @@ static void test_004_001_execute(void) {
msg_t msg1, msg2;
unsigned i;
- /* Testing the mailbox size.*/
+ /* [4.1.1] Testing the mailbox size.*/
test_set_step(1);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
}
- /* Resetting the mailbox, conditions are checked, no errors
+ /* [4.1.2] Resetting the mailbox, conditions are checked, no errors
expected.*/
test_set_step(2);
{
@@ -105,8 +109,8 @@ static void test_004_001_execute(void) {
test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
}
- /* Filling the mailbox using chMBPost() and chMBPostAhead() once, no
- errors expected.*/
+ /* [4.1.3] Filling the mailbox using chMBPost() and chMBPostAhead()
+ once, no errors expected.*/
test_set_step(3);
{
for (i = 0; i < MB_SIZE - 1; i++) {
@@ -117,8 +121,8 @@ static void test_004_001_execute(void) {
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
- /* Testing intermediate conditions. Data pointers must be aligned,
- semaphore counters are checked.*/
+ /* [4.1.4] Testing intermediate conditions. Data pointers must be
+ aligned, semaphore counters are checked.*/
test_set_step(4);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
@@ -126,7 +130,8 @@ static void test_004_001_execute(void) {
test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
}
- /* Emptying the mailbox using chMBFetch(), no errors expected.*/
+ /* [4.1.5] Emptying the mailbox using chMBFetch(), no errors
+ expected.*/
test_set_step(5);
{
for (i = 0; i < MB_SIZE; i++) {
@@ -137,7 +142,8 @@ static void test_004_001_execute(void) {
test_assert_sequence("ABCD", "wrong get sequence");
}
- /* Posting and then fetching one more message, no errors expected.*/
+ /* [4.1.6] Posting and then fetching one more message, no errors
+ expected.*/
test_set_step(6);
{
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
@@ -146,8 +152,8 @@ static void test_004_001_execute(void) {
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
- /* Testing final conditions. Data pointers must be aligned to buffer
- start, semaphore counters are checked.*/
+ /* [4.1.7] Testing final conditions. Data pointers must be aligned to
+ buffer start, semaphore counters are checked.*/
test_set_step(7);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
@@ -163,33 +169,28 @@ static const testcase_t test_004_001 = {
test_004_001_teardown,
test_004_001_execute
};
-#endif /* CH_CFG_USE_MAILBOXES */
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/**
- * @page test_004_002 Mailbox I-Class API, non-blocking tests
+ * @page test_004_002 [4.2] Mailbox I-Class API, non-blocking tests
*
* <h2>Description</h2>
* The mailbox I-Class 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.
- * - Resetting the mailbox, conditions are checked, no errors expected.
- * - Filling the mailbox using chMBPostI() and chMBPostAheadI() once,
- * no errors expected.
- * - Testing intermediate conditions. Data pointers must be aligned,
- * semaphore counters are checked.
- * - Emptying the mailbox using chMBFetchI(), no errors expected.
- * - Posting and then fetching one more message, no errors expected.
- * - Testing final conditions. Data pointers must be aligned to buffer
- * start, semaphore counters are checked.
+ * - [4.2.1] Testing the mailbox size.
+ * - [4.2.2] Resetting the mailbox, conditions are checked, no errors
+ * expected.
+ * - [4.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
+ * once, no errors expected.
+ * - [4.2.4] Testing intermediate conditions. Data pointers must be
+ * aligned, semaphore counters are checked.
+ * - [4.2.5] Emptying the mailbox using chMBFetchI(), no errors
+ * expected.
+ * - [4.2.6] Posting and then fetching one more message, no errors
+ * expected.
+ * - [4.2.7] Testing final conditions. Data pointers must be aligned to
+ * buffer start, semaphore counters are checked.
* .
*/
@@ -205,13 +206,13 @@ static void test_004_002_execute(void) {
msg_t msg1, msg2;
unsigned i;
- /* Testing the mailbox size.*/
+ /* [4.2.1] Testing the mailbox size.*/
test_set_step(1);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
}
- /* Resetting the mailbox, conditions are checked, no errors
+ /* [4.2.2] Resetting the mailbox, conditions are checked, no errors
expected.*/
test_set_step(2);
{
@@ -224,8 +225,8 @@ static void test_004_002_execute(void) {
test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
}
- /* Filling the mailbox using chMBPostI() and chMBPostAheadI() once,
- no errors expected.*/
+ /* [4.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
+ once, no errors expected.*/
test_set_step(3);
{
for (i = 0; i < MB_SIZE - 1; i++) {
@@ -240,8 +241,8 @@ static void test_004_002_execute(void) {
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
- /* Testing intermediate conditions. Data pointers must be aligned,
- semaphore counters are checked.*/
+ /* [4.2.4] Testing intermediate conditions. Data pointers must be
+ aligned, semaphore counters are checked.*/
test_set_step(4);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
@@ -249,7 +250,8 @@ static void test_004_002_execute(void) {
test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
}
- /* Emptying the mailbox using chMBFetchI(), no errors expected.*/
+ /* [4.2.5] Emptying the mailbox using chMBFetchI(), no errors
+ expected.*/
test_set_step(5);
{
for (i = 0; i < MB_SIZE; i++) {
@@ -262,7 +264,8 @@ static void test_004_002_execute(void) {
test_assert_sequence("ABCD", "wrong get sequence");
}
- /* Posting and then fetching one more message, no errors expected.*/
+ /* [4.2.6] Posting and then fetching one more message, no errors
+ expected.*/
test_set_step(6);
{
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE);
@@ -271,8 +274,8 @@ static void test_004_002_execute(void) {
test_assert(msg1 == MSG_OK, "wrong wake-up message");
}
- /* Testing final conditions. Data pointers must be aligned to buffer
- start, semaphore counters are checked.*/
+ /* [4.2.7] Testing final conditions. Data pointers must be aligned to
+ buffer start, semaphore counters are checked.*/
test_set_step(7);
{
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
@@ -288,27 +291,19 @@ static const testcase_t test_004_002 = {
test_004_002_teardown,
test_004_002_execute
};
-#endif /* CH_CFG_USE_MAILBOXES */
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/**
- * @page test_004_003 Mailbox timeouts
+ * @page test_004_003 [4.3] Mailbox timeouts
*
* <h2>Description</h2>
* The mailbox API is tested for timeouts.
*
- * <h2>Conditions</h2>
- * This test is only executed if the following preprocessor condition
- * evaluates to true:
- * - CH_CFG_USE_MAILBOXES
- * .
- *
* <h2>Test Steps</h2>
- * - Filling the mailbox.
- * - Testing chMBPost(), chMBPostI(), chMBPostAhead() and
+ * - [4.3.1] Filling the mailbox.
+ * - [4.3.2] Testing chMBPost(), chMBPostI(), chMBPostAhead() and
* chMBPostAheadI() timeout.
- * - Resetting the mailbox.
- * - Testing chMBFetch() and chMBFetchI() timeout.
+ * - [4.3.3] Resetting the mailbox.
+ * - [4.3.4] Testing chMBFetch() and chMBFetchI() timeout.
* .
*/
@@ -324,7 +319,7 @@ static void test_004_003_execute(void) {
msg_t msg1, msg2;
unsigned i;
- /* Filling the mailbox.*/
+ /* [4.3.1] Filling the mailbox.*/
test_set_step(1);
{
for (i = 0; i < MB_SIZE; i++) {
@@ -333,7 +328,7 @@ static void test_004_003_execute(void) {
}
}
- /* Testing chMBPost(), chMBPostI(), chMBPostAhead() and
+ /* [4.3.2] Testing chMBPost(), chMBPostI(), chMBPostAhead() and
chMBPostAheadI() timeout.*/
test_set_step(2);
{
@@ -351,13 +346,13 @@ static void test_004_003_execute(void) {
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
}
- /* Resetting the mailbox.*/
+ /* [4.3.3] Resetting the mailbox.*/
test_set_step(3);
{
chMBReset(&mb1);
}
- /* Testing chMBFetch() and chMBFetchI() timeout.*/
+ /* [4.3.4] Testing chMBFetch() and chMBFetchI() timeout.*/
test_set_step(4);
{
msg1 = chMBFetch(&mb1, &msg2, 1);
@@ -375,7 +370,6 @@ static const testcase_t test_004_003 = {
test_004_003_teardown,
test_004_003_execute
};
-#endif /* CH_CFG_USE_MAILBOXES */
/****************************************************************************
* Exported data.
@@ -385,14 +379,10 @@ static const testcase_t test_004_003 = {
* @brief Mailboxes.
*/
const testcase_t * const test_sequence_004[] = {
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_001,
-#endif
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_002,
-#endif
-#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_003,
-#endif
NULL
};
+
+#endif /* CH_CFG_USE_MAILBOXES */
diff --git a/test/nil/source/test/test_sequence_005.c b/test/nil/source/test/test_sequence_005.c
index e75a36252..f37622787 100644
--- a/test/nil/source/test/test_sequence_005.c
+++ b/test/nil/source/test/test_sequence_005.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_005 Memory Pools
+ * @page test_sequence_005 [5] Memory Pools
*
* File: @ref test_sequence_005.c
*
@@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to
* memory pools.
*
+ * <h2>Conditions</h2>
+ * This sequence is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_MEMPOOLS
+ * .
+ *
* <h2>Test Cases</h2>
* - @subpage test_005_001
* - @subpage test_005_002
@@ -34,6 +40,8 @@
* .
*/
+#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
+
/****************************************************************************
* Shared code.
****************************************************************************/
@@ -56,29 +64,22 @@ static void *null_provider(size_t size, unsigned align) {
* Test cases.
****************************************************************************/
-#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
/**
- * @page test_005_001 Loading and empting a memory pool
+ * @page test_005_001 [5.1] Loading and emptying a memory pool
*
* <h2>Description</h2>
- * The memory pool functionality is tested by loading and empting it,
+ * The memory pool functionality is tested by loading and emptying it,
* all conditions are tested.
*
- * <h2>Conditions</h2>
- * This test is only executed if the following preprocessor condition
- * evaluates to true:
- * - CH_CFG_USE_MEMPOOLS
- * .
- *
* <h2>Test Steps</h2>
- * - Adding the objects to the pool using chPoolLoadArray().
- * - Emptying the pool using chPoolAlloc().
- * - Now must be empty.
- * - Adding the objects to the pool using chPoolFree().
- * - Emptying the pool using chPoolAlloc() again.
- * - Now must be empty again.
- * - Covering the case where a provider is unable to return more
- * memory.
+ * - [5.1.1] Adding the objects to the pool using chPoolLoadArray().
+ * - [5.1.2] Emptying the pool using chPoolAlloc().
+ * - [5.1.3] Now must be empty.
+ * - [5.1.4] Adding the objects to the pool using chPoolFree().
+ * - [5.1.5] Emptying the pool using chPoolAlloc() again.
+ * - [5.1.6] Now must be empty again.
+ * - [5.1.7] Covering the case where a provider is unable to return
+ * more memory.
* .
*/
@@ -89,47 +90,47 @@ static void test_005_001_setup(void) {
static void test_005_001_execute(void) {
unsigned i;
- /* Adding the objects to the pool using chPoolLoadArray().*/
+ /* [5.1.1] Adding the objects to the pool using chPoolLoadArray().*/
test_set_step(1);
{
chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);
}
- /* Emptying the pool using chPoolAlloc().*/
+ /* [5.1.2] Emptying the pool using chPoolAlloc().*/
test_set_step(2);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
}
- /* Now must be empty.*/
+ /* [5.1.3] Now must be empty.*/
test_set_step(3);
{
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
}
- /* Adding the objects to the pool using chPoolFree().*/
+ /* [5.1.4] Adding the objects to the pool using chPoolFree().*/
test_set_step(4);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
chPoolFree(&mp1, &objects[i]);
}
- /* Emptying the pool using chPoolAlloc() again.*/
+ /* [5.1.5] Emptying the pool using chPoolAlloc() again.*/
test_set_step(5);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
}
- /* Now must be empty again.*/
+ /* [5.1.6] Now must be empty again.*/
test_set_step(6);
{
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
}
- /* Covering the case where a provider is unable to return more
- memory.*/
+ /* [5.1.7] Covering the case where a provider is unable to return
+ more memory.*/
test_set_step(7);
{
chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
@@ -138,34 +139,34 @@ static void test_005_001_execute(void) {
}
static const testcase_t test_005_001 = {
- "Loading and empting a memory pool",
+ "Loading and emptying a memory pool",
test_005_001_setup,
NULL,
test_005_001_execute
};
-#endif /* CH_CFG_USE_MEMPOOLS */
-#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/**
- * @page test_005_002 Loading and empting a guarded memory pool without waiting
+ * @page test_005_002 [5.2] Loading and emptying a guarded memory pool without waiting
*
* <h2>Description</h2>
- * The memory pool functionality is tested by loading and empting it,
+ * The memory pool functionality is tested by loading and emptying it,
* all conditions are tested.
*
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
- * - (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES)
+ * - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2>
- * - Adding the objects to the pool using chGuardedPoolLoadArray().
- * - Emptying the pool using chGuardedPoolAllocTimeout().
- * - Now must be empty.
- * - Adding the objects to the pool using chGuardedPoolFree().
- * - Emptying the pool using chGuardedPoolAllocTimeout() again.
- * - Now must be empty again.
+ * - [5.2.1] Adding the objects to the pool using
+ * chGuardedPoolLoadArray().
+ * - [5.2.2] Emptying the pool using chGuardedPoolAllocTimeout().
+ * - [5.2.3] Now must be empty.
+ * - [5.2.4] Adding the objects to the pool using chGuardedPoolFree().
+ * - [5.2.5] Emptying the pool using chGuardedPoolAllocTimeout() again.
+ * - [5.2.6] Now must be empty again.
* .
*/
@@ -176,40 +177,43 @@ static void test_005_002_setup(void) {
static void test_005_002_execute(void) {
unsigned i;
- /* Adding the objects to the pool using chGuardedPoolLoadArray().*/
+ /* [5.2.1] Adding the objects to the pool using
+ chGuardedPoolLoadArray().*/
test_set_step(1);
{
chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);
}
- /* Emptying the pool using chGuardedPoolAllocTimeout().*/
+ /* [5.2.2] Emptying the pool using chGuardedPoolAllocTimeout().*/
test_set_step(2);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
}
- /* Now must be empty.*/
+ /* [5.2.3] Now must be empty.*/
test_set_step(3);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
}
- /* Adding the objects to the pool using chGuardedPoolFree().*/
+ /* [5.2.4] Adding the objects to the pool using
+ chGuardedPoolFree().*/
test_set_step(4);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
chGuardedPoolFree(&gmp1, &objects[i]);
}
- /* Emptying the pool using chGuardedPoolAllocTimeout() again.*/
+ /* [5.2.5] Emptying the pool using chGuardedPoolAllocTimeout()
+ again.*/
test_set_step(5);
{
for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");
}
- /* Now must be empty again.*/
+ /* [5.2.6] Now must be empty again.*/
test_set_step(6);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
@@ -217,16 +221,16 @@ static void test_005_002_execute(void) {
}
static const testcase_t test_005_002 = {
- "Loading and empting a guarded memory pool without waiting",
+ "Loading and emptying a guarded memory pool without waiting",
test_005_002_setup,
NULL,
test_005_002_execute
};
-#endif /* (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) */
+#endif /* CH_CFG_USE_SEMAPHORES */
-#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/**
- * @page test_005_003 Guarded Memory Pools timeout
+ * @page test_005_003 [5.3] Guarded Memory Pools timeout
*
* <h2>Description</h2>
* The timeout features for the Guarded Memory Pools is tested.
@@ -234,12 +238,12 @@ static const testcase_t test_005_002 = {
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
- * - (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES)
+ * - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2>
- * - Trying to allocate with 100mS timeout, must fail because the pool
- * is empty.
+ * - [5.3.1] Trying to allocate with 100mS timeout, must fail because
+ * the pool is empty.
* .
*/
@@ -249,8 +253,8 @@ static void test_005_003_setup(void) {
static void test_005_003_execute(void) {
- /* Trying to allocate with 100mS timeout, must fail because the pool
- is empty.*/
+ /* [5.3.1] Trying to allocate with 100mS timeout, must fail because
+ the pool is empty.*/
test_set_step(1);
{
test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty");
@@ -263,7 +267,7 @@ static const testcase_t test_005_003 = {
NULL,
test_005_003_execute
};
-#endif /* (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) */
+#endif /* CH_CFG_USE_SEMAPHORES */
/****************************************************************************
* Exported data.
@@ -273,14 +277,14 @@ static const testcase_t test_005_003 = {
* @brief Memory Pools.
*/
const testcase_t * const test_sequence_005[] = {
-#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
&test_005_001,
-#endif
-#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_005_002,
#endif
-#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_005_003,
#endif
NULL
};
+
+#endif /* CH_CFG_USE_MEMPOOLS */
diff --git a/test/nil/source/test/test_sequence_006.c b/test/nil/source/test/test_sequence_006.c
index 0261f1026..07addd7e2 100644
--- a/test/nil/source/test/test_sequence_006.c
+++ b/test/nil/source/test/test_sequence_006.c
@@ -19,7 +19,7 @@
#include "test_root.h"
/**
- * @page test_sequence_006 Memory Heaps
+ * @page test_sequence_006 [6] Memory Heaps
*
* File: @ref test_sequence_006.c
*
@@ -27,12 +27,20 @@
* This sequence tests the ChibiOS/NIL functionalities related to
* memory heaps.
*
+ * <h2>Conditions</h2>
+ * This sequence is only executed if the following preprocessor condition
+ * evaluates to true:
+ * - CH_CFG_USE_HEAP
+ * .
+ *
* <h2>Test Cases</h2>
* - @subpage test_006_001
* - @subpage test_006_002
* .
*/
+#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
+
/****************************************************************************
* Shared code.
****************************************************************************/
@@ -47,9 +55,8 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);
* Test cases.
****************************************************************************/
-#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/**
- * @page test_006_001 Allocation and fragmentation
+ * @page test_006_001 [6.1] Allocation and fragmentation
*
* <h2>Description</h2>
* Series of allocations/deallocations are performed in carefully
@@ -57,30 +64,24 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);
* inside the allocator. The test expects to find the heap back to the
* initial status after each sequence.
*
- * <h2>Conditions</h2>
- * This test is only executed if the following preprocessor condition
- * evaluates to true:
- * - CH_CFG_USE_HEAP
- * .
- *
* <h2>Test Steps</h2>
- * - Testing initial conditions, the heap must not be fragmented and
- * one free block present.
- * - Trying to allocate an block bigger than available space, an error
- * is expected.
- * - Single block allocation using chHeapAlloc() then the block is
- * freed using chHeapFree(), must not fail.
- * - Using chHeapStatus() to assess the heap state. There must be at
- * least one free block of sufficient size.
- * - Allocating then freeing in the same order.
- * - Allocating then freeing in reverse order.
- * - Small fragments handling. Checking the behavior when allocating
- * blocks with size not multiple of alignment unit.
- * - Skipping a fragment, the first fragment in the list is too small
- * so the allocator must pick the second one.
- * - Allocating the whole available space.
- * - Testing final conditions. The heap geometry must be the same than
- * the one registered at beginning.
+ * - [6.1.1] Testing initial conditions, the heap must not be
+ * fragmented and one free block present.
+ * - [6.1.2] Trying to allocate an block bigger than available space,
+ * an error is expected.
+ * - [6.1.3] Single block allocation using chHeapAlloc() then the block
+ * is freed using chHeapFree(), must not fail.
+ * - [6.1.4] Using chHeapStatus() to assess the heap state. There must
+ * be at least one free block of sufficient size.
+ * - [6.1.5] Allocating then freeing in the same order.
+ * - [6.1.6] Allocating then freeing in reverse order.
+ * - [6.1.7] Small fragments handling. Checking the behavior when
+ * allocating blocks with size not multiple of alignment unit.
+ * - [6.1.8] Skipping a fragment, the first fragment in the list is too
+ * small so the allocator must pick the second one.
+ * - [6.1.9] Allocating the whole available space.
+ * - [6.1.10] Testing final conditions. The heap geometry must be the
+ * same than the one registered at beginning.
* .
*/
@@ -92,23 +93,23 @@ static void test_006_001_execute(void) {
void *p1, *p2, *p3;
size_t n, sz;
- /* Testing initial conditions, the heap must not be fragmented and
- one free block present.*/
+ /* [6.1.1] Testing initial conditions, the heap must not be
+ fragmented and one free block present.*/
test_set_step(1);
{
test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented");
}
- /* Trying to allocate an block bigger than available space, an error
- is expected.*/
+ /* [6.1.2] Trying to allocate an block bigger than available space,
+ an error is expected.*/
test_set_step(2);
{
p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
test_assert(p1 == NULL, "allocation not failed");
}
- /* Single block allocation using chHeapAlloc() then the block is
- freed using chHeapFree(), must not fail.*/
+ /* [6.1.3] Single block allocation using chHeapAlloc() then the block
+ is freed using chHeapFree(), must not fail.*/
test_set_step(3);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
@@ -116,8 +117,8 @@ static void test_006_001_execute(void) {
chHeapFree(p1);
}
- /* Using chHeapStatus() to assess the heap state. There must be at
- least one free block of sufficient size.*/
+ /* [6.1.4] Using chHeapStatus() to assess the heap state. There must
+ be at least one free block of sufficient size.*/
test_set_step(4);
{
size_t total_size, largest_size;
@@ -128,7 +129,7 @@ static void test_006_001_execute(void) {
test_assert(total_size == largest_size, "unexpected heap state");
}
- /* Allocating then freeing in the same order.*/
+ /* [6.1.5] Allocating then freeing in the same order.*/
test_set_step(5);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
@@ -140,7 +141,7 @@ static void test_006_001_execute(void) {
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
- /* Allocating then freeing in reverse order.*/
+ /* [6.1.6] Allocating then freeing in reverse order.*/
test_set_step(6);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
@@ -152,8 +153,8 @@ static void test_006_001_execute(void) {
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
- /* Small fragments handling. Checking the behavior when allocating
- blocks with size not multiple of alignment unit.*/
+ /* [6.1.7] Small fragments handling. Checking the behavior when
+ allocating blocks with size not multiple of alignment unit.*/
test_set_step(7);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE + 1);
@@ -170,8 +171,8 @@ static void test_006_001_execute(void) {
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
- /* Skipping a fragment, the first fragment in the list is too small
- so the allocator must pick the second one.*/
+ /* [6.1.8] Skipping a fragment, the first fragment in the list is too
+ small so the allocator must pick the second one.*/
test_set_step(8);
{
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
@@ -184,7 +185,7 @@ static void test_006_001_execute(void) {
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
}
- /* Allocating the whole available space.*/
+ /* [6.1.9] Allocating the whole available space.*/
test_set_step(9);
{
(void)chHeapStatus(&test_heap, &n, NULL);
@@ -194,8 +195,8 @@ static void test_006_001_execute(void) {
chHeapFree(p1);
}
- /* Testing final conditions. The heap geometry must be the same than
- the one registered at beginning.*/
+ /* [6.1.10] Testing final conditions. The heap geometry must be the
+ same than the one registered at beginning.*/
test_set_step(10);
{
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
@@ -209,26 +210,18 @@ static const testcase_t test_006_001 = {
NULL,
test_006_001_execute
};
-#endif /* CH_CFG_USE_HEAP */
-#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/**
- * @page test_006_002 Default Heap
+ * @page test_006_002 [6.2] Default Heap
*
* <h2>Description</h2>
* The default heap is pre-allocated in the system. We test base
* functionality.
*
- * <h2>Conditions</h2>
- * This test is only executed if the following preprocessor condition
- * evaluates to true:
- * - CH_CFG_USE_HEAP
- * .
- *
* <h2>Test Steps</h2>
- * - Single block allocation using chHeapAlloc() then the block is
- * freed using chHeapFree(), must not fail.
- * - Testing allocation failure.
+ * - [6.2.1] Single block allocation using chHeapAlloc() then the block
+ * is freed using chHeapFree(), must not fail.
+ * - [6.2.2] Testing allocation failure.
* .
*/
@@ -236,8 +229,8 @@ static void test_006_002_execute(void) {
void *p1;
size_t total_size, largest_size;
- /* Single block allocation using chHeapAlloc() then the block is
- freed using chHeapFree(), must not fail.*/
+ /* [6.2.1] Single block allocation using chHeapAlloc() then the block
+ is freed using chHeapFree(), must not fail.*/
test_set_step(1);
{
(void)chHeapStatus(NULL, &total_size, &largest_size);
@@ -246,7 +239,7 @@ static void test_006_002_execute(void) {
chHeapFree(p1);
}
- /* Testing allocation failure.*/
+ /* [6.2.2] Testing allocation failure.*/
test_set_step(2);
{
p1 = chHeapAlloc(NULL, (size_t)-256);
@@ -260,7 +253,6 @@ static const testcase_t test_006_002 = {
NULL,
test_006_002_execute
};
-#endif /* CH_CFG_USE_HEAP */
/****************************************************************************
* Exported data.
@@ -270,11 +262,9 @@ static const testcase_t test_006_002 = {
* @brief Memory Heaps.
*/
const testcase_t * const test_sequence_006[] = {
-#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
&test_006_001,
-#endif
-#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
&test_006_002,
-#endif
NULL
};
+
+#endif /* CH_CFG_USE_HEAP */