aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-19 09:16:38 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-19 09:16:38 +0000
commit0e3a108a64d9d2ac6d820f90b35a47c2d6cad2cc (patch)
tree2979ec33586a799a130e0db8e1228d68a78670eb /test
parent59d34439eb700f96bd6daa33b11b0092931b17b4 (diff)
downloadChibiOS-0e3a108a64d9d2ac6d820f90b35a47c2d6cad2cc.tar.gz
ChibiOS-0e3a108a64d9d2ac6d820f90b35a47c2d6cad2cc.tar.bz2
ChibiOS-0e3a108a64d9d2ac6d820f90b35a47c2d6cad2cc.zip
NIL test suite updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10864 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r--test/lib/test.mk5
-rw-r--r--test/nil/configuration.xml958
-rw-r--r--test/nil/nil_test.mk9
-rw-r--r--test/nil/source/test/nil_test_root.c (renamed from test/nil/source/test/test_root.c)45
-rw-r--r--test/nil/source/test/nil_test_root.h (renamed from test/nil/source/test/test_root.h)23
-rw-r--r--test/nil/source/test/nil_test_sequence_001.c (renamed from test/nil/source/test/test_sequence_001.c)45
-rw-r--r--test/nil/source/test/nil_test_sequence_001.h (renamed from test/nil/source/test/test_sequence_001.h)10
-rw-r--r--test/nil/source/test/nil_test_sequence_002.c (renamed from test/nil/source/test/test_sequence_002.c)67
-rw-r--r--test/nil/source/test/nil_test_sequence_002.h (renamed from test/nil/source/test/test_sequence_002.h)10
-rw-r--r--test/nil/source/test/nil_test_sequence_003.c (renamed from test/nil/source/test/test_sequence_003.c)93
-rw-r--r--test/nil/source/test/nil_test_sequence_003.h (renamed from test/nil/source/test/test_sequence_003.h)10
-rw-r--r--test/nil/source/test/nil_test_sequence_004.c (renamed from test/nil/source/test/test_sequence_004.c)65
-rw-r--r--test/nil/source/test/nil_test_sequence_004.h (renamed from test/nil/source/test/test_sequence_004.h)10
-rw-r--r--test/nil/source/test/test_sequence_005.c408
-rw-r--r--test/nil/source/test/test_sequence_005.h27
-rw-r--r--test/nil/source/test/test_sequence_006.c296
-rw-r--r--test/nil/source/test/test_sequence_006.h27
-rw-r--r--test/nil/source/test/test_sequence_007.c273
-rw-r--r--test/nil/source/test/test_sequence_007.h27
-rw-r--r--test/nil/test.mk14
20 files changed, 242 insertions, 2180 deletions
diff --git a/test/lib/test.mk b/test/lib/test.mk
new file mode 100644
index 000000000..4f1dc479b
--- /dev/null
+++ b/test/lib/test.mk
@@ -0,0 +1,5 @@
+# List of all the test runtime files.
+TESTSRC += ${CHIBIOS}/test/lib/ch_test.c
+
+# Required include directories
+TESTINC += ${CHIBIOS}/test/lib \ No newline at end of file
diff --git a/test/nil/configuration.xml b/test/nil/configuration.xml
index c808728ae..c18e8f181 100644
--- a/test/nil/configuration.xml
+++ b/test/nil/configuration.xml
@@ -100,6 +100,9 @@ THD_FUNCTION(test_support, arg) {
}]]></value>
</global_code>
</global_data_and_code>
+ <code_prefix>
+ <value>nil_</value>
+ </code_prefix>
<sequences>
<sequence>
<type index="0">
@@ -337,8 +340,8 @@ while (time == chVTGetSystemTimeX()) {
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleep(100);
-test_assert_time_window(time + 100,
- time + 100 + 1,
+test_assert_time_window(chTimeAddX(time, 100),
+ chTimeAddX(time, 100 + 1),
"out of time window");]]></value>
</code>
</step>
@@ -352,8 +355,8 @@ test_assert_time_window(time + 100,
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepMicroseconds(100000);
-test_assert_time_window(time + US2ST(100000),
- time + US2ST(100000) + 1,
+test_assert_time_window(chTimeAddX(time, TIME_US2I(100000)),
+ chTimeAddX(time, TIME_US2I(100000) + 1),
"out of time window");]]></value>
</code>
</step>
@@ -367,8 +370,8 @@ test_assert_time_window(time + US2ST(100000),
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepMilliseconds(100);
-test_assert_time_window(time + MS2ST(100),
- time + MS2ST(100) + 1,
+test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)),
+ chTimeAddX(time, TIME_MS2I(100) + 1),
"out of time window");]]></value>
</code>
</step>
@@ -382,8 +385,8 @@ test_assert_time_window(time + MS2ST(100),
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdSleepSeconds(1);
-test_assert_time_window(time + S2ST(1),
- time + S2ST(1) + 1,
+test_assert_time_window(chTimeAddX(time, TIME_S2I(1)),
+ chTimeAddX(time, TIME_S2I(1) + 1),
"out of time window");]]></value>
</code>
</step>
@@ -396,9 +399,9 @@ test_assert_time_window(time + S2ST(1),
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
-chThdSleepUntil(time + 100);
-test_assert_time_window(time + 100,
- time + 100 + 1,
+chThdSleepUntil(chTimeAddX(time, 100));
+test_assert_time_window(chTimeAddX(time, 100),
+ chTimeAddX(time, 100 + 1),
"out of time window");]]></value>
</code>
</step>
@@ -574,9 +577,9 @@ msg_t msg;]]></value>
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
-msg = chSemWaitTimeout(&sem1, MS2ST(1000));
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
+test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
@@ -591,9 +594,9 @@ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
-msg = chSemWaitTimeout(&sem1, MS2ST(1000));
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
+test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
@@ -668,10 +671,10 @@ test_assert(MSG_OK == msg,"wrong returned message");]]></value>
<code>
<value><![CDATA[chSysLock();
time = chVTGetSystemTimeX();
-msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
+msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000));
chSysUnlock();
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert(NULL == tr1, "not NULL");
test_assert(MSG_TIMEOUT == msg, "wrong returned message");]]></value>
@@ -712,7 +715,7 @@ eventmask_t events;]]></value>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
-events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
</code>
@@ -727,7 +730,7 @@ test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
-events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
</code>
@@ -741,9 +744,9 @@ test_assert((eventmask_t)0x55 == events, "wrong events mask");]]></value>
</tags>
<code>
<value><![CDATA[time = chVTGetSystemTimeX();
-events = chEvtWaitAnyTimeout(0, MS2ST(1000));
-test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+events = chEvtWaitAnyTimeout(0, TIME_MS2I(1000));
+test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
</code>
@@ -752,911 +755,6 @@ 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>
- <condition>
- <value>CH_CFG_USE_MAILBOXES</value>
- </condition>
- <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 normal API, non-blocking tests.</value>
- </brief>
- <description>
- <value>The mailbox normal API is tested without triggering blocking conditions.</value>
- </description>
- <condition>
- <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, msg2;
-unsigned i;]]></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>Resetting the mailbox, conditions are checked, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chMBReset(&mb1);
-test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
-test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
-test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing the behavior of API when the mailbox is in reset state then return in active state.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, (msg_t)0, TIME_INFINITE);
-test_assert(msg1 == MSG_RESET, "not in reset state");
-msg1 = chMBPostAheadTimeout(&mb1, (msg_t)0, TIME_INFINITE);
-test_assert(msg1 == MSG_RESET, "not in reset state");
-msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
-test_assert(msg1 == MSG_RESET, "not in reset state");
-chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling the mailbox using chMBPostTimeout() and chMBPostAheadTimeout() once, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE - 1; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
-}
-msg1 = chMBPostAheadTimeout(&mb1, 'A', TIME_INFINITE);
-test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing intermediate conditions. Data pointers must be aligned, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
-test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the mailbox using chMBFetchTimeout(), no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
-}
-test_assert_sequence("ABCD", "wrong get sequence");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Posting and then fetching one more message, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
-test_assert(msg1 == MSG_OK, "wrong wake-up message");
-msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
-test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. Data pointers must be aligned to buffer start, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
-test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
-test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Mailbox I-Class API, non-blocking tests.</value>
- </brief>
- <description>
- <value>The mailbox I-Class API is tested without triggering blocking conditions.</value>
- </description>
- <condition>
- <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, msg2;
-unsigned i;]]></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>Resetting the mailbox, conditions are checked, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chSysLock();
-chMBResetI(&mb1);
-chSysUnlock();
-test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
-test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
-test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
-chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Filling the mailbox using chMBPostI() and chMBPostAheadI() once, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE - 1; i++) {
- chSysLock();
- msg1 = chMBPostI(&mb1, 'B' + i);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
-}
-chSysLock();
-msg1 = chMBPostAheadI(&mb1, 'A');
-chSysUnlock();
-test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing intermediate conditions. Data pointers must be aligned, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
-test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the mailbox using chMBFetchI(), no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- chSysLock();
- msg1 = chMBFetchI(&mb1, &msg2);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
-}
-test_assert_sequence("ABCD", "wrong get sequence");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Posting and then fetching one more message, no errors expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
-test_assert(msg1 == MSG_OK, "wrong wake-up message");
-msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
-test_assert(msg1 == MSG_OK, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. Data pointers must be aligned to buffer start, semaphore counters are checked.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
-test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
-test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
-test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Mailbox timeouts.</value>
- </brief>
- <description>
- <value>The mailbox API is tested for timeouts.</value>
- </description>
- <condition>
- <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, msg2;
-unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Filling the mailbox.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
-}]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing chMBPostTimeout(), chMBPostI(), chMBPostAheadTimeout() and chMBPostAheadI() timeout.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBPostTimeout(&mb1, 'X', 1);
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
-chSysLock();
-msg1 = chMBPostI(&mb1, 'X');
-chSysUnlock();
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
-msg1 = chMBPostAheadTimeout(&mb1, 'X', 1);
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
-chSysLock();
-msg1 = chMBPostAheadI(&mb1, 'X');
-chSysUnlock();
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Resetting the mailbox.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chMBReset(&mb1);;
-chMBResumeX(&mb1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing chMBFetchTimeout() and chMBFetchI() timeout.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[msg1 = chMBFetchTimeout(&mb1, &msg2, 1);
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
-chSysLock();
-msg1 = chMBFetchI(&mb1, &msg2);
-chSysUnlock();
-test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Memory Pools.</value>
- </brief>
- <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
-
-static uint32_t objects[MEMORY_POOL_SIZE];
-static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), PORT_NATURAL_ALIGN, NULL);
-
-#if CH_CFG_USE_SEMAPHORES
-static GUARDEDMEMORYPOOL_DECL(gmp1, sizeof (uint32_t), PORT_NATURAL_ALIGN);
-#endif
-
-static void *null_provider(size_t size, unsigned align) {
-
- (void)size;
- (void)align;
-
- return NULL;
-}]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Loading and emptying a memory pool.</value>
- </brief>
- <description>
- <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Adding the objects to the pool using chPoolLoadArray().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chPoolAlloc().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Adding the objects to the pool using chPoolFree().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- chPoolFree(&mp1, &objects[i]);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chPoolAlloc() again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Covering the case where a provider is unable to return more memory.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
-test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Loading and emptying a guarded memory pool without waiting.</value>
- </brief>
- <description>
- <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[unsigned i;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Adding the objects to the pool using chGuardedPoolLoadArray().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chGuardedPoolAllocTimeout().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Adding the objects to the pool using chGuardedPoolFree().</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- chGuardedPoolFree(&gmp1, &objects[i]);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Emptying the pool using chGuardedPoolAllocTimeout() again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Now must be empty again.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Guarded Memory Pools timeout.</value>
- </brief>
- <description>
- <value>The timeout features for the Guarded Memory Pools is tested.</value>
- </description>
- <condition>
- <value>CH_CFG_USE_SEMAPHORES</value>
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value />
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Trying to allocate with 100mS timeout, must fail because the pool is empty.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
- <sequence>
- <type index="0">
- <value>Internal Tests</value>
- </type>
- <brief>
- <value>Memory Heaps.</value>
- </brief>
- <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)
-
-static memory_heap_t test_heap;
-static CH_HEAP_AREA(myheap, HEAP_SIZE);]]></value>
- </shared_code>
- <cases>
- <case>
- <brief>
- <value>Allocation and fragmentation.</value>
- </brief>
- <description>
- <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 />
- </condition>
- <various_code>
- <setup_code>
- <value><![CDATA[chHeapObjectInit(&test_heap, myheap, sizeof(myheap));]]></value>
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[void *p1, *p2, *p3;
-size_t n, sz;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Testing initial conditions, the heap must not be fragmented and one free block present.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Trying to allocate an block bigger than available space, an error is expected.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
-test_assert(p1 == NULL, "allocation not failed");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Single block allocation using chHeapAlloc() then the block is freed using chHeapFree(), must not fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-test_assert(p1 != NULL, "allocation failed");
-chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Using chHeapStatus() to assess the heap state. There must be at least one free block of sufficient size.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[size_t total_size, largest_size;
-
-n = chHeapStatus(&test_heap, &total_size, &largest_size);
-test_assert(n == 1, "missing free block");
-test_assert(total_size >= ALLOC_SIZE, "unexpected heap state");
-test_assert(total_size == largest_size, "unexpected heap state");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating then freeing in the same order.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-chHeapFree(p1); /* Does not merge.*/
-chHeapFree(p2); /* Merges backward.*/
-chHeapFree(p3); /* Merges both sides.*/
-test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating then freeing in reverse order.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-chHeapFree(p3); /* Merges forward.*/
-chHeapFree(p2); /* Merges forward.*/
-chHeapFree(p1); /* Merges forward.*/
-test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Small fragments handling. Checking the behavior when allocating blocks with size not multiple of alignment unit.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE + 1);
-p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-chHeapFree(p1);
-test_assert(chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
-p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-/* Note, the first situation happens when the alignment size is smaller
- than the header size, the second in the other cases.*/
-test_assert((chHeapStatus(&test_heap, &n, NULL) == 1) ||
- (chHeapStatus(&test_heap, &n, NULL) == 2), "heap fragmented");
-chHeapFree(p2);
-chHeapFree(p1);
-test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Skipping a fragment, the first fragment in the list is too small so the allocator must pick the second one.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-chHeapFree(p1);
-test_assert( chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
-p1 = chHeapAlloc(&test_heap, ALLOC_SIZE * 2); /* Skips first fragment.*/
-chHeapFree(p1);
-chHeapFree(p2);
-test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Allocating the whole available space.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[(void)chHeapStatus(&test_heap, &n, NULL);
-p1 = chHeapAlloc(&test_heap, n);
-test_assert(p1 != NULL, "allocation failed");
-test_assert(chHeapStatus(&test_heap, NULL, NULL) == 0, "not empty");
-chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing final conditions. The heap geometry must be the same than the one registered at beginning.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
-test_assert(n == sz, "size changed");]]></value>
- </code>
- </step>
- </steps>
- </case>
- <case>
- <brief>
- <value>Default Heap.</value>
- </brief>
- <description>
- <value>The default heap is pre-allocated in the system. We test base functionality.</value>
- </description>
- <condition>
- <value />
- </condition>
- <various_code>
- <setup_code>
- <value />
- </setup_code>
- <teardown_code>
- <value />
- </teardown_code>
- <local_variables>
- <value><![CDATA[void *p1;
-size_t total_size, largest_size;]]></value>
- </local_variables>
- </various_code>
- <steps>
- <step>
- <description>
- <value>Single block allocation using chHeapAlloc() then the block is freed using chHeapFree(), must not fail.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[(void)chHeapStatus(NULL, &total_size, &largest_size);
-p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
-test_assert(p1 != NULL, "allocation failed");
-chHeapFree(p1);]]></value>
- </code>
- </step>
- <step>
- <description>
- <value>Testing allocation failure.</value>
- </description>
- <tags>
- <value />
- </tags>
- <code>
- <value><![CDATA[p1 = chHeapAlloc(NULL, (size_t)-256);
-test_assert(p1 == NULL, "allocation not failed");]]></value>
- </code>
- </step>
- </steps>
- </case>
- </cases>
- </sequence>
</sequences>
</instance>
</instances>
diff --git a/test/nil/nil_test.mk b/test/nil/nil_test.mk
new file mode 100644
index 000000000..c49541d73
--- /dev/null
+++ b/test/nil/nil_test.mk
@@ -0,0 +1,9 @@
+# List of all the ChibiOS/NIL test files.
+TESTSRC += ${CHIBIOS}/test/nil/source/test/nil_test_root.c \
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_001.c \
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_002.c \
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_003.c \
+ ${CHIBIOS}/test/nil/source/test/nil_test_sequence_004.c
+
+# Required include directories
+TESTINC += ${CHIBIOS}/test/nil/source/test
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/nil_test_root.c
index 6006e4e2d..4974bad56 100644
--- a/test/nil/source/test/test_root.c
+++ b/test/nil/source/test/nil_test_root.c
@@ -21,24 +21,20 @@
* through successive improvements.
*
* <h2>Test Sequences</h2>
- * - @subpage test_sequence_001
- * - @subpage test_sequence_002
- * - @subpage test_sequence_003
- * - @subpage test_sequence_004
- * - @subpage test_sequence_005
- * - @subpage test_sequence_006
- * - @subpage test_sequence_007
+ * - @subpage nil_test_sequence_001
+ * - @subpage nil_test_sequence_002
+ * - @subpage nil_test_sequence_003
+ * - @subpage nil_test_sequence_004
* .
*/
/**
- * @file test_root.c
+ * @file nil_test_root.c
* @brief Test Suite root structures code.
*/
#include "hal.h"
-#include "ch_test.h"
-#include "test_root.h"
+#include "nil_test_root.h"
#if !defined(__DOXYGEN__)
@@ -47,27 +43,26 @@
/*===========================================================================*/
/**
- * @brief Array of all the test sequences.
+ * @brief Array of test sequences.
*/
-const testcase_t * const *test_suite[] = {
- test_sequence_001,
- test_sequence_002,
+const testsequence_t * const nil_test_suite_array[] = {
+ &nil_test_sequence_001,
+ &nil_test_sequence_002,
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
- test_sequence_003,
-#endif
- test_sequence_004,
-#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
- test_sequence_005,
-#endif
-#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
- test_sequence_006,
-#endif
-#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
- test_sequence_007,
+ &nil_test_sequence_003,
#endif
+ &nil_test_sequence_004,
NULL
};
+/**
+ * @brief Test suite root structure.
+ */
+const testsuite_t nil_test_suite = {
+ "Test Specification for ChibiOS/NIL.",
+ nil_test_suite_array
+};
+
/*===========================================================================*/
/* Shared code. */
/*===========================================================================*/
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/nil_test_root.h
index 39c680871..1f523d5e4 100644
--- a/test/nil/source/test/test_root.h
+++ b/test/nil/source/test/nil_test_root.h
@@ -15,20 +15,19 @@
*/
/**
- * @file test_root.h
+ * @file nil_test_root.h
* @brief Test Suite root structures header.
*/
-#ifndef TEST_ROOT_H
-#define TEST_ROOT_H
+#ifndef NIL_TEST_ROOT_H
+#define NIL_TEST_ROOT_H
-#include "test_sequence_001.h"
-#include "test_sequence_002.h"
-#include "test_sequence_003.h"
-#include "test_sequence_004.h"
-#include "test_sequence_005.h"
-#include "test_sequence_006.h"
-#include "test_sequence_007.h"
+#include "ch_test.h"
+
+#include "nil_test_sequence_001.h"
+#include "nil_test_sequence_002.h"
+#include "nil_test_sequence_003.h"
+#include "nil_test_sequence_004.h"
#if !defined(__DOXYGEN__)
@@ -36,7 +35,7 @@
/* External declarations. */
/*===========================================================================*/
-extern const testcase_t * const *test_suite[];
+extern const testsuite_t nil_test_suite;
#ifdef __cplusplus
extern "C" {
@@ -62,4 +61,4 @@ THD_FUNCTION(test_support, arg);
#endif /* !defined(__DOXYGEN__) */
-#endif /* TEST_ROOT_H */
+#endif /* NIL_TEST_ROOT_H */
diff --git a/test/nil/source/test/test_sequence_001.c b/test/nil/source/test/nil_test_sequence_001.c
index f20e3a3fd..1040700ef 100644
--- a/test/nil/source/test/test_sequence_001.c
+++ b/test/nil/source/test/nil_test_sequence_001.c
@@ -15,24 +15,23 @@
*/
#include "hal.h"
-#include "ch_test.h"
-#include "test_root.h"
+#include "nil_test_root.h"
/**
- * @file test_sequence_001.c
+ * @file nil_test_sequence_001.c
* @brief Test Sequence 001 code.
*
- * @page test_sequence_001 [1] Information
+ * @page nil_test_sequence_001 [1] Information
*
- * File: @ref test_sequence_001.c
+ * File: @ref nil_test_sequence_001.c
*
* <h2>Description</h2>
* This sequence reports configuration and version information about
* the NIL kernel.
*
* <h2>Test Cases</h2>
- * - @subpage test_001_001
- * - @subpage test_001_002
+ * - @subpage nil_test_001_001
+ * - @subpage nil_test_001_002
* .
*/
@@ -47,7 +46,7 @@
****************************************************************************/
/**
- * @page test_001_001 [1.1] Kernel Info
+ * @page nil_test_001_001 [1.1] Kernel Info
*
* <h2>Description</h2>
* The version numbers are reported.
@@ -57,7 +56,7 @@
* .
*/
-static void test_001_001_execute(void) {
+static void nil_test_001_001_execute(void) {
/* [1.1.1] Prints the version string.*/
test_set_step(1);
@@ -80,15 +79,15 @@ static void test_001_001_execute(void) {
}
}
-static const testcase_t test_001_001 = {
+static const testcase_t nil_test_001_001 = {
"Kernel Info",
NULL,
NULL,
- test_001_001_execute
+ nil_test_001_001_execute
};
/**
- * @page test_001_002 [1.2] Kernel Settings
+ * @page nil_test_001_002 [1.2] Kernel Settings
*
* <h2>Description</h2>
* The static kernel settings are reported.
@@ -98,7 +97,7 @@ static const testcase_t test_001_001 = {
* .
*/
-static void test_001_002_execute(void) {
+static void nil_test_001_002_execute(void) {
/* [1.2.1] Prints the configuration options settings.*/
test_set_step(1);
@@ -154,11 +153,11 @@ static void test_001_002_execute(void) {
}
}
-static const testcase_t test_001_002 = {
+static const testcase_t nil_test_001_002 = {
"Kernel Settings",
NULL,
NULL,
- test_001_002_execute
+ nil_test_001_002_execute
};
/****************************************************************************
@@ -166,10 +165,18 @@ static const testcase_t test_001_002 = {
****************************************************************************/
/**
- * @brief Information.
+ * @brief Array of test cases.
*/
-const testcase_t * const test_sequence_001[] = {
- &test_001_001,
- &test_001_002,
+const testcase_t * const nil_test_sequence_001_array[] = {
+ &nil_test_001_001,
+ &nil_test_001_002,
NULL
};
+
+/**
+ * @brief Information.
+ */
+const testsequence_t nil_test_sequence_001 = {
+ NULL,
+ nil_test_sequence_001_array
+};
diff --git a/test/nil/source/test/test_sequence_001.h b/test/nil/source/test/nil_test_sequence_001.h
index 9684d47f6..5d1781747 100644
--- a/test/nil/source/test/test_sequence_001.h
+++ b/test/nil/source/test/nil_test_sequence_001.h
@@ -15,13 +15,13 @@
*/
/**
- * @file test_sequence_001.h
+ * @file nil_test_sequence_001.h
* @brief Test Sequence 001 header.
*/
-#ifndef TEST_SEQUENCE_001_H
-#define TEST_SEQUENCE_001_H
+#ifndef NIL_TEST_SEQUENCE_001_H
+#define NIL_TEST_SEQUENCE_001_H
-extern const testcase_t * const test_sequence_001[];
+extern const testsequence_t nil_test_sequence_001;
-#endif /* TEST_SEQUENCE_001_H */
+#endif /* NIL_TEST_SEQUENCE_001_H */
diff --git a/test/nil/source/test/test_sequence_002.c b/test/nil/source/test/nil_test_sequence_002.c
index db5aff647..26d511714 100644
--- a/test/nil/source/test/test_sequence_002.c
+++ b/test/nil/source/test/nil_test_sequence_002.c
@@ -15,24 +15,23 @@
*/
#include "hal.h"
-#include "ch_test.h"
-#include "test_root.h"
+#include "nil_test_root.h"
/**
- * @file test_sequence_002.c
+ * @file nil_test_sequence_002.c
* @brief Test Sequence 002 code.
*
- * @page test_sequence_002 [2] Threads Functionality
+ * @page nil_test_sequence_002 [2] Threads Functionality
*
- * File: @ref test_sequence_002.c
+ * File: @ref nil_test_sequence_002.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* threading.
*
* <h2>Test Cases</h2>
- * - @subpage test_002_001
- * - @subpage test_002_002
+ * - @subpage nil_test_002_001
+ * - @subpage nil_test_002_002
* .
*/
@@ -47,7 +46,7 @@
****************************************************************************/
/**
- * @page test_002_001 [2.1] System Tick Counter functionality
+ * @page nil_test_002_001 [2.1] System Tick Counter functionality
*
* <h2>Description</h2>
* The functionality of the API @p chVTGetSystemTimeX() is tested.
@@ -58,7 +57,7 @@
* .
*/
-static void test_002_001_execute(void) {
+static void nil_test_002_001_execute(void) {
/* [2.1.1] A System Tick Counter increment is expected, the test
simply hangs if it does not happen.*/
@@ -70,15 +69,15 @@ static void test_002_001_execute(void) {
}
}
-static const testcase_t test_002_001 = {
+static const testcase_t nil_test_002_001 = {
"System Tick Counter functionality",
NULL,
NULL,
- test_002_001_execute
+ nil_test_002_001_execute
};
/**
- * @page test_002_002 [2.2] Thread Sleep functionality
+ * @page nil_test_002_002 [2.2] Thread Sleep functionality
*
* <h2>Description</h2>
* The functionality of @p chThdSleep() and derivatives is tested.
@@ -100,7 +99,7 @@ static const testcase_t test_002_001 = {
* .
*/
-static void test_002_002_execute(void) {
+static void nil_test_002_002_execute(void) {
systime_t time;
/* [2.2.1] The current system time is read then a sleep is performed
@@ -110,8 +109,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleep(100);
- test_assert_time_window(time + 100,
- time + 100 + 1,
+ test_assert_time_window(chTimeAddX(time, 100),
+ chTimeAddX(time, 100 + 1),
"out of time window");
}
@@ -122,8 +121,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepMicroseconds(100000);
- test_assert_time_window(time + US2ST(100000),
- time + US2ST(100000) + 1,
+ test_assert_time_window(chTimeAddX(time, TIME_US2I(100000)),
+ chTimeAddX(time, TIME_US2I(100000) + 1),
"out of time window");
}
@@ -134,8 +133,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepMilliseconds(100);
- test_assert_time_window(time + MS2ST(100),
- time + MS2ST(100) + 1,
+ test_assert_time_window(chTimeAddX(time, TIME_MS2I(100)),
+ chTimeAddX(time, TIME_MS2I(100) + 1),
"out of time window");
}
@@ -145,8 +144,8 @@ static void test_002_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdSleepSeconds(1);
- test_assert_time_window(time + S2ST(1),
- time + S2ST(1) + 1,
+ test_assert_time_window(chTimeAddX(time, TIME_S2I(1)),
+ chTimeAddX(time, TIME_S2I(1) + 1),
"out of time window");
}
@@ -155,18 +154,18 @@ static void test_002_002_execute(void) {
test_set_step(5);
{
time = chVTGetSystemTimeX();
- chThdSleepUntil(time + 100);
- test_assert_time_window(time + 100,
- time + 100 + 1,
+ chThdSleepUntil(chTimeAddX(time, 100));
+ test_assert_time_window(chTimeAddX(time, 100),
+ chTimeAddX(time, 100 + 1),
"out of time window");
}
}
-static const testcase_t test_002_002 = {
+static const testcase_t nil_test_002_002 = {
"Thread Sleep functionality",
NULL,
NULL,
- test_002_002_execute
+ nil_test_002_002_execute
};
/****************************************************************************
@@ -174,10 +173,18 @@ static const testcase_t test_002_002 = {
****************************************************************************/
/**
- * @brief Threads Functionality.
+ * @brief Array of test cases.
*/
-const testcase_t * const test_sequence_002[] = {
- &test_002_001,
- &test_002_002,
+const testcase_t * const nil_test_sequence_002_array[] = {
+ &nil_test_002_001,
+ &nil_test_002_002,
NULL
};
+
+/**
+ * @brief Threads Functionality.
+ */
+const testsequence_t nil_test_sequence_002 = {
+ NULL,
+ nil_test_sequence_002_array
+};
diff --git a/test/nil/source/test/test_sequence_002.h b/test/nil/source/test/nil_test_sequence_002.h
index 190f9ca46..4b62bd4d6 100644
--- a/test/nil/source/test/test_sequence_002.h
+++ b/test/nil/source/test/nil_test_sequence_002.h
@@ -15,13 +15,13 @@
*/
/**
- * @file test_sequence_002.h
+ * @file nil_test_sequence_002.h
* @brief Test Sequence 002 header.
*/
-#ifndef TEST_SEQUENCE_002_H
-#define TEST_SEQUENCE_002_H
+#ifndef NIL_TEST_SEQUENCE_002_H
+#define NIL_TEST_SEQUENCE_002_H
-extern const testcase_t * const test_sequence_002[];
+extern const testsequence_t nil_test_sequence_002;
-#endif /* TEST_SEQUENCE_002_H */
+#endif /* NIL_TEST_SEQUENCE_002_H */
diff --git a/test/nil/source/test/test_sequence_003.c b/test/nil/source/test/nil_test_sequence_003.c
index 48159347d..6fe29ef46 100644
--- a/test/nil/source/test/test_sequence_003.c
+++ b/test/nil/source/test/nil_test_sequence_003.c
@@ -15,16 +15,15 @@
*/
#include "hal.h"
-#include "ch_test.h"
-#include "test_root.h"
+#include "nil_test_root.h"
/**
- * @file test_sequence_003.c
+ * @file nil_test_sequence_003.c
* @brief Test Sequence 003 code.
*
- * @page test_sequence_003 [3] Semaphores
+ * @page nil_test_sequence_003 [3] Semaphores
*
- * File: @ref test_sequence_003.c
+ * File: @ref nil_test_sequence_003.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
@@ -37,9 +36,9 @@
* .
*
* <h2>Test Cases</h2>
- * - @subpage test_003_001
- * - @subpage test_003_002
- * - @subpage test_003_003
+ * - @subpage nil_test_003_001
+ * - @subpage nil_test_003_002
+ * - @subpage nil_test_003_003
* .
*/
@@ -58,7 +57,7 @@ static semaphore_t sem1;
****************************************************************************/
/**
- * @page test_003_001 [3.1] Semaphore primitives, no state change
+ * @page nil_test_003_001 [3.1] Semaphore primitives, no state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
@@ -74,15 +73,15 @@ static semaphore_t sem1;
* .
*/
-static void test_003_001_setup(void) {
+static void nil_test_003_001_setup(void) {
chSemObjectInit(&sem1, 1);
}
-static void test_003_001_teardown(void) {
+static void nil_test_003_001_teardown(void) {
chSemReset(&sem1, 0);
}
-static void test_003_001_execute(void) {
+static void nil_test_003_001_execute(void) {
/* [3.1.1] The function chSemWait() is invoked, after return the
counter and the returned message are tested.*/
@@ -112,15 +111,15 @@ static void test_003_001_execute(void) {
}
}
-static const testcase_t test_003_001 = {
+static const testcase_t nil_test_003_001 = {
"Semaphore primitives, no state change",
- test_003_001_setup,
- test_003_001_teardown,
- test_003_001_execute
+ nil_test_003_001_setup,
+ nil_test_003_001_teardown,
+ nil_test_003_001_execute
};
/**
- * @page test_003_002 [3.2] Semaphore primitives, with state change
+ * @page nil_test_003_002 [3.2] Semaphore primitives, with state change
*
* <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread
@@ -136,15 +135,15 @@ static const testcase_t test_003_001 = {
* .
*/
-static void test_003_002_setup(void) {
+static void nil_test_003_002_setup(void) {
chSemObjectInit(&gsem1, 0);
}
-static void test_003_002_teardown(void) {
+static void nil_test_003_002_teardown(void) {
chSemReset(&gsem1, 0);
}
-static void test_003_002_execute(void) {
+static void nil_test_003_002_execute(void) {
/* [3.2.1] The function chSemWait() is invoked, after return the
counter and the returned message are tested. The semaphore is
@@ -171,15 +170,15 @@ static void test_003_002_execute(void) {
}
}
-static const testcase_t test_003_002 = {
+static const testcase_t nil_test_003_002 = {
"Semaphore primitives, with state change",
- test_003_002_setup,
- test_003_002_teardown,
- test_003_002_execute
+ nil_test_003_002_setup,
+ nil_test_003_002_teardown,
+ nil_test_003_002_execute
};
/**
- * @page test_003_003 [3.3] Semaphores timeout
+ * @page nil_test_003_003 [3.3] Semaphores timeout
*
* <h2>Description</h2>
* Timeout on semaphores is tested.
@@ -194,15 +193,15 @@ static const testcase_t test_003_002 = {
* .
*/
-static void test_003_003_setup(void) {
+static void nil_test_003_003_setup(void) {
chSemObjectInit(&sem1, 0);
}
-static void test_003_003_teardown(void) {
+static void nil_test_003_003_teardown(void) {
chSemReset(&sem1, 0);
}
-static void test_003_003_execute(void) {
+static void nil_test_003_003_execute(void) {
systime_t time;
msg_t msg;
@@ -212,9 +211,9 @@ static void test_003_003_execute(void) {
test_set_step(1);
{
time = chVTGetSystemTimeX();
- msg = chSemWaitTimeout(&sem1, MS2ST(1000));
- test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+ msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
+ test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
@@ -226,20 +225,20 @@ static void test_003_003_execute(void) {
test_set_step(2);
{
time = chVTGetSystemTimeX();
- msg = chSemWaitTimeout(&sem1, MS2ST(1000));
- test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+ msg = chSemWaitTimeout(&sem1, TIME_MS2I(1000));
+ test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
}
-static const testcase_t test_003_003 = {
+static const testcase_t nil_test_003_003 = {
"Semaphores timeout",
- test_003_003_setup,
- test_003_003_teardown,
- test_003_003_execute
+ nil_test_003_003_setup,
+ nil_test_003_003_teardown,
+ nil_test_003_003_execute
};
/****************************************************************************
@@ -247,13 +246,21 @@ static const testcase_t test_003_003 = {
****************************************************************************/
/**
- * @brief Semaphores.
+ * @brief Array of test cases.
*/
-const testcase_t * const test_sequence_003[] = {
- &test_003_001,
- &test_003_002,
- &test_003_003,
+const testcase_t * const nil_test_sequence_003_array[] = {
+ &nil_test_003_001,
+ &nil_test_003_002,
+ &nil_test_003_003,
NULL
};
+/**
+ * @brief Semaphores.
+ */
+const testsequence_t nil_test_sequence_003 = {
+ NULL,
+ nil_test_sequence_003_array
+};
+
#endif /* CH_CFG_USE_SEMAPHORES */
diff --git a/test/nil/source/test/test_sequence_003.h b/test/nil/source/test/nil_test_sequence_003.h
index 2de592a2f..10adaeaf5 100644
--- a/test/nil/source/test/test_sequence_003.h
+++ b/test/nil/source/test/nil_test_sequence_003.h
@@ -15,13 +15,13 @@
*/
/**
- * @file test_sequence_003.h
+ * @file nil_test_sequence_003.h
* @brief Test Sequence 003 header.
*/
-#ifndef TEST_SEQUENCE_003_H
-#define TEST_SEQUENCE_003_H
+#ifndef NIL_TEST_SEQUENCE_003_H
+#define NIL_TEST_SEQUENCE_003_H
-extern const testcase_t * const test_sequence_003[];
+extern const testsequence_t nil_test_sequence_003;
-#endif /* TEST_SEQUENCE_003_H */
+#endif /* NIL_TEST_SEQUENCE_003_H */
diff --git a/test/nil/source/test/test_sequence_004.c b/test/nil/source/test/nil_test_sequence_004.c
index 0b9c8bc96..719a114e1 100644
--- a/test/nil/source/test/test_sequence_004.c
+++ b/test/nil/source/test/nil_test_sequence_004.c
@@ -15,24 +15,23 @@
*/
#include "hal.h"
-#include "ch_test.h"
-#include "test_root.h"
+#include "nil_test_root.h"
/**
- * @file test_sequence_004.c
+ * @file nil_test_sequence_004.c
* @brief Test Sequence 004 code.
*
- * @page test_sequence_004 [4] Suspend/Resume and Event Flags
+ * @page nil_test_sequence_004 [4] Suspend/Resume and Event Flags
*
- * File: @ref test_sequence_004.c
+ * File: @ref nil_test_sequence_004.c
*
* <h2>Description</h2>
* This sequence tests the ChibiOS/NIL functionalities related to
* threads suspend/resume and event flags.
*
* <h2>Test Cases</h2>
- * - @subpage test_004_001
- * - @subpage test_004_002
+ * - @subpage nil_test_004_001
+ * - @subpage nil_test_004_002
* .
*/
@@ -47,7 +46,7 @@ static thread_reference_t tr1;
****************************************************************************/
/**
- * @page test_004_001 [4.1] Suspend and Resume functionality
+ * @page nil_test_004_001 [4.1] Suspend and Resume functionality
*
* <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
@@ -63,11 +62,11 @@ static thread_reference_t tr1;
* .
*/
-static void test_004_001_setup(void) {
+static void nil_test_004_001_setup(void) {
tr1 = NULL;
}
-static void test_004_001_execute(void) {
+static void nil_test_004_001_execute(void) {
systime_t time;
msg_t msg;
@@ -90,26 +89,26 @@ static void test_004_001_execute(void) {
{
chSysLock();
time = chVTGetSystemTimeX();
- msg = chThdSuspendTimeoutS(&tr1, MS2ST(1000));
+ msg = chThdSuspendTimeoutS(&tr1, TIME_MS2I(1000));
chSysUnlock();
- test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+ test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert(NULL == tr1, "not NULL");
test_assert(MSG_TIMEOUT == msg, "wrong returned message");
}
}
-static const testcase_t test_004_001 = {
+static const testcase_t nil_test_004_001 = {
"Suspend and Resume functionality",
- test_004_001_setup,
+ nil_test_004_001_setup,
NULL,
- test_004_001_execute
+ nil_test_004_001_execute
};
#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
/**
- * @page test_004_002 [4.2] Events Flags functionality
+ * @page nil_test_004_002 [4.2] Events Flags functionality
*
* <h2>Description</h2>
* Event flags functionality is tested.
@@ -133,7 +132,7 @@ static const testcase_t test_004_001 = {
* .
*/
-static void test_004_002_execute(void) {
+static void nil_test_004_002_execute(void) {
systime_t time;
eventmask_t events;
@@ -145,7 +144,7 @@ static void test_004_002_execute(void) {
{
time = chVTGetSystemTimeX();
chEvtSignal(chThdGetSelfX(), 0x55);
- events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+ events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
@@ -157,7 +156,7 @@ static void test_004_002_execute(void) {
{
time = chVTGetSystemTimeX();
chThdGetSelfX()->epmask = 0;
- events = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+ events = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(1000));
test_assert((eventmask_t)0 != events, "timed out");
test_assert((eventmask_t)0x55 == events, "wrong events mask");
}
@@ -167,19 +166,19 @@ static void test_004_002_execute(void) {
test_set_step(3);
{
time = chVTGetSystemTimeX();
- events = chEvtWaitAnyTimeout(0, MS2ST(1000));
- test_assert_time_window(time + MS2ST(1000),
- time + MS2ST(1000) + 1,
+ events = chEvtWaitAnyTimeout(0, TIME_MS2I(1000));
+ test_assert_time_window(chTimeAddX(time, TIME_MS2I(1000)),
+ chTimeAddX(time, TIME_MS2I(1000) + 1),
"out of time window");
test_assert((eventmask_t)0 == events, "wrong events mask");
}
}
-static const testcase_t test_004_002 = {
+static const testcase_t nil_test_004_002 = {
"Events Flags functionality",
NULL,
NULL,
- test_004_002_execute
+ nil_test_004_002_execute
};
#endif /* CH_CFG_USE_EVENTS */
@@ -188,12 +187,20 @@ static const testcase_t test_004_002 = {
****************************************************************************/
/**
- * @brief Suspend/Resume and Event Flags.
+ * @brief Array of test cases.
*/
-const testcase_t * const test_sequence_004[] = {
- &test_004_001,
+const testcase_t * const nil_test_sequence_004_array[] = {
+ &nil_test_004_001,
#if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
- &test_004_002,
+ &nil_test_004_002,
#endif
NULL
};
+
+/**
+ * @brief Suspend/Resume and Event Flags.
+ */
+const testsequence_t nil_test_sequence_004 = {
+ NULL,
+ nil_test_sequence_004_array
+};
diff --git a/test/nil/source/test/test_sequence_004.h b/test/nil/source/test/nil_test_sequence_004.h
index 19d8c1bd7..88a1080ab 100644
--- a/test/nil/source/test/test_sequence_004.h
+++ b/test/nil/source/test/nil_test_sequence_004.h
@@ -15,13 +15,13 @@
*/
/**
- * @file test_sequence_004.h
+ * @file nil_test_sequence_004.h
* @brief Test Sequence 004 header.
*/
-#ifndef TEST_SEQUENCE_004_H
-#define TEST_SEQUENCE_004_H
+#ifndef NIL_TEST_SEQUENCE_004_H
+#define NIL_TEST_SEQUENCE_004_H
-extern const testcase_t * const test_sequence_004[];
+extern const testsequence_t nil_test_sequence_004;
-#endif /* TEST_SEQUENCE_004_H */
+#endif /* NIL_TEST_SEQUENCE_004_H */
diff --git a/test/nil/source/test/test_sequence_005.c b/test/nil/source/test/test_sequence_005.c
deleted file mode 100644
index fbca897f9..000000000
--- a/test/nil/source/test/test_sequence_005.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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"
-
-/**
- * @file test_sequence_005.c
- * @brief Test Sequence 005 code.
- *
- * @page test_sequence_005 [5] Mailboxes
- *
- * File: @ref test_sequence_005.c
- *
- * <h2>Description</h2>
- * 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_005_001
- * - @subpage test_005_002
- * - @subpage test_005_003
- * .
- */
-
-#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
-
-/****************************************************************************
- * 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.
- ****************************************************************************/
-
-/**
- * @page test_005_001 [5.1] Mailbox normal API, non-blocking tests
- *
- * <h2>Description</h2>
- * The mailbox normal API is tested without triggering blocking
- * conditions.
- *
- * <h2>Test Steps</h2>
- * - [5.1.1] Testing the mailbox size.
- * - [5.1.2] Resetting the mailbox, conditions are checked, no errors
- * expected.
- * - [5.1.3] Testing the behavior of API when the mailbox is in reset
- * state then return in active state.
- * - [5.1.4] Filling the mailbox using chMBPostTimeout() and
- * chMBPostAheadTimeout() once, no errors expected.
- * - [5.1.5] Testing intermediate conditions. Data pointers must be
- * aligned, semaphore counters are checked.
- * - [5.1.6] Emptying the mailbox using chMBFetchTimeout(), no errors
- * expected.
- * - [5.1.7] Posting and then fetching one more message, no errors
- * expected.
- * - [5.1.8] Testing final conditions. Data pointers must be aligned to
- * buffer start, semaphore counters are checked.
- * .
- */
-
-static void test_005_001_setup(void) {
- chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
-}
-
-static void test_005_001_teardown(void) {
- chMBReset(&mb1);
-}
-
-static void test_005_001_execute(void) {
- msg_t msg1, msg2;
- unsigned i;
-
- /* [5.1.1] Testing the mailbox size.*/
- test_set_step(1);
- {
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
- }
-
- /* [5.1.2] Resetting the mailbox, conditions are checked, no errors
- expected.*/
- test_set_step(2);
- {
- chMBReset(&mb1);
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
- }
-
- /* [5.1.3] Testing the behavior of API when the mailbox is in reset
- state then return in active state.*/
- test_set_step(3);
- {
- msg1 = chMBPostTimeout(&mb1, (msg_t)0, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- msg1 = chMBPostAheadTimeout(&mb1, (msg_t)0, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_RESET, "not in reset state");
- chMBResumeX(&mb1);
- }
-
- /* [5.1.4] Filling the mailbox using chMBPostTimeout() and
- chMBPostAheadTimeout() once, no errors expected.*/
- test_set_step(4);
- {
- for (i = 0; i < MB_SIZE - 1; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
- msg1 = chMBPostAheadTimeout(&mb1, 'A', TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
-
- /* [5.1.5] Testing intermediate conditions. Data pointers must be
- aligned, semaphore counters are checked.*/
- test_set_step(5);
- {
- test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
- test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
- }
-
- /* [5.1.6] Emptying the mailbox using chMBFetchTimeout(), no errors
- expected.*/
- test_set_step(6);
- {
- for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
- }
- test_assert_sequence("ABCD", "wrong get sequence");
- }
-
- /* [5.1.7] Posting and then fetching one more message, no errors
- expected.*/
- test_set_step(7);
- {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
-
- /* [5.1.8] Testing final conditions. Data pointers must be aligned to
- buffer start, semaphore counters are checked.*/
- test_set_step(8);
- {
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
- }
-}
-
-static const testcase_t test_005_001 = {
- "Mailbox normal API, non-blocking tests",
- test_005_001_setup,
- test_005_001_teardown,
- test_005_001_execute
-};
-
-/**
- * @page test_005_002 [5.2] Mailbox I-Class API, non-blocking tests
- *
- * <h2>Description</h2>
- * The mailbox I-Class API is tested without triggering blocking
- * conditions.
- *
- * <h2>Test Steps</h2>
- * - [5.2.1] Testing the mailbox size.
- * - [5.2.2] Resetting the mailbox, conditions are checked, no errors
- * expected.
- * - [5.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
- * once, no errors expected.
- * - [5.2.4] Testing intermediate conditions. Data pointers must be
- * aligned, semaphore counters are checked.
- * - [5.2.5] Emptying the mailbox using chMBFetchI(), no errors
- * expected.
- * - [5.2.6] Posting and then fetching one more message, no errors
- * expected.
- * - [5.2.7] Testing final conditions. Data pointers must be aligned to
- * buffer start, semaphore counters are checked.
- * .
- */
-
-static void test_005_002_setup(void) {
- chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
-}
-
-static void test_005_002_teardown(void) {
- chMBReset(&mb1);
-}
-
-static void test_005_002_execute(void) {
- msg_t msg1, msg2;
- unsigned i;
-
- /* [5.2.1] Testing the mailbox size.*/
- test_set_step(1);
- {
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size");
- }
-
- /* [5.2.2] Resetting the mailbox, conditions are checked, no errors
- expected.*/
- test_set_step(2);
- {
- chSysLock();
- chMBResetI(&mb1);
- chSysUnlock();
- test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert_lock(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
- chMBResumeX(&mb1);
- }
-
- /* [5.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++) {
- chSysLock();
- msg1 = chMBPostI(&mb1, 'B' + i);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
- chSysLock();
- msg1 = chMBPostAheadI(&mb1, 'A');
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
-
- /* [5.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");
- test_assert_lock(chMBGetUsedCountI(&mb1) == MB_SIZE, "not full");
- test_assert_lock(mb1.rdptr == mb1.wrptr, "pointers not aligned");
- }
-
- /* [5.2.5] Emptying the mailbox using chMBFetchI(), no errors
- expected.*/
- test_set_step(5);
- {
- for (i = 0; i < MB_SIZE; i++) {
- chSysLock();
- msg1 = chMBFetchI(&mb1, &msg2);
- chSysUnlock();
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- test_emit_token(msg2);
- }
- test_assert_sequence("ABCD", "wrong get sequence");
- }
-
- /* [5.2.6] Posting and then fetching one more message, no errors
- expected.*/
- test_set_step(6);
- {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- msg1 = chMBFetchTimeout(&mb1, &msg2, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
-
- /* [5.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");
- test_assert_lock(chMBGetUsedCountI(&mb1) == 0, "still full");
- test_assert(mb1.buffer == mb1.wrptr, "write pointer not aligned to base");
- test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
- }
-}
-
-static const testcase_t test_005_002 = {
- "Mailbox I-Class API, non-blocking tests",
- test_005_002_setup,
- test_005_002_teardown,
- test_005_002_execute
-};
-
-/**
- * @page test_005_003 [5.3] Mailbox timeouts
- *
- * <h2>Description</h2>
- * The mailbox API is tested for timeouts.
- *
- * <h2>Test Steps</h2>
- * - [5.3.1] Filling the mailbox.
- * - [5.3.2] Testing chMBPostTimeout(), chMBPostI(),
- * chMBPostAheadTimeout() and chMBPostAheadI() timeout.
- * - [5.3.3] Resetting the mailbox.
- * - [5.3.4] Testing chMBFetchTimeout() and chMBFetchI() timeout.
- * .
- */
-
-static void test_005_003_setup(void) {
- chMBObjectInit(&mb1, mb_buffer, MB_SIZE);
-}
-
-static void test_005_003_teardown(void) {
- chMBReset(&mb1);
-}
-
-static void test_005_003_execute(void) {
- msg_t msg1, msg2;
- unsigned i;
-
- /* [5.3.1] Filling the mailbox.*/
- test_set_step(1);
- {
- for (i = 0; i < MB_SIZE; i++) {
- msg1 = chMBPostTimeout(&mb1, 'B' + i, TIME_INFINITE);
- test_assert(msg1 == MSG_OK, "wrong wake-up message");
- }
- }
-
- /* [5.3.2] Testing chMBPostTimeout(), chMBPostI(),
- chMBPostAheadTimeout() and chMBPostAheadI() timeout.*/
- test_set_step(2);
- {
- msg1 = chMBPostTimeout(&mb1, 'X', 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBPostI(&mb1, 'X');
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- msg1 = chMBPostAheadTimeout(&mb1, 'X', 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBPostAheadI(&mb1, 'X');
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- }
-
- /* [5.3.3] Resetting the mailbox.*/
- test_set_step(3);
- {
- chMBReset(&mb1);;
- chMBResumeX(&mb1);
- }
-
- /* [5.3.4] Testing chMBFetchTimeout() and chMBFetchI() timeout.*/
- test_set_step(4);
- {
- msg1 = chMBFetchTimeout(&mb1, &msg2, 1);
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- chSysLock();
- msg1 = chMBFetchI(&mb1, &msg2);
- chSysUnlock();
- test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
- }
-}
-
-static const testcase_t test_005_003 = {
- "Mailbox timeouts",
- test_005_003_setup,
- test_005_003_teardown,
- test_005_003_execute
-};
-
-/****************************************************************************
- * Exported data.
- ****************************************************************************/
-
-/**
- * @brief Mailboxes.
- */
-const testcase_t * const test_sequence_005[] = {
- &test_005_001,
- &test_005_002,
- &test_005_003,
- NULL
-};
-
-#endif /* CH_CFG_USE_MAILBOXES */
diff --git a/test/nil/source/test/test_sequence_005.h b/test/nil/source/test/test_sequence_005.h
deleted file mode 100644
index d2df83307..000000000
--- a/test/nil/source/test/test_sequence_005.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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.
-*/
-
-/**
- * @file test_sequence_005.h
- * @brief Test Sequence 005 header.
- */
-
-#ifndef TEST_SEQUENCE_005_H
-#define TEST_SEQUENCE_005_H
-
-extern const testcase_t * const test_sequence_005[];
-
-#endif /* TEST_SEQUENCE_005_H */
diff --git a/test/nil/source/test/test_sequence_006.c b/test/nil/source/test/test_sequence_006.c
deleted file mode 100644
index 123b6d5e7..000000000
--- a/test/nil/source/test/test_sequence_006.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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"
-
-/**
- * @file test_sequence_006.c
- * @brief Test Sequence 006 code.
- *
- * @page test_sequence_006 [6] Memory Pools
- *
- * File: @ref test_sequence_006.c
- *
- * <h2>Description</h2>
- * 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_006_001
- * - @subpage test_006_002
- * - @subpage test_006_003
- * .
- */
-
-#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
-
-/****************************************************************************
- * Shared code.
- ****************************************************************************/
-
-#define MEMORY_POOL_SIZE 4
-
-static uint32_t objects[MEMORY_POOL_SIZE];
-static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), PORT_NATURAL_ALIGN, NULL);
-
-#if CH_CFG_USE_SEMAPHORES
-static GUARDEDMEMORYPOOL_DECL(gmp1, sizeof (uint32_t), PORT_NATURAL_ALIGN);
-#endif
-
-static void *null_provider(size_t size, unsigned align) {
-
- (void)size;
- (void)align;
-
- return NULL;
-}
-
-/****************************************************************************
- * Test cases.
- ****************************************************************************/
-
-/**
- * @page test_006_001 [6.1] Loading and emptying a memory pool
- *
- * <h2>Description</h2>
- * The memory pool functionality is tested by loading and emptying it,
- * all conditions are tested.
- *
- * <h2>Test Steps</h2>
- * - [6.1.1] Adding the objects to the pool using chPoolLoadArray().
- * - [6.1.2] Emptying the pool using chPoolAlloc().
- * - [6.1.3] Now must be empty.
- * - [6.1.4] Adding the objects to the pool using chPoolFree().
- * - [6.1.5] Emptying the pool using chPoolAlloc() again.
- * - [6.1.6] Now must be empty again.
- * - [6.1.7] Covering the case where a provider is unable to return
- * more memory.
- * .
- */
-
-static void test_006_001_setup(void) {
- chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);
-}
-
-static void test_006_001_execute(void) {
- unsigned i;
-
- /* [6.1.1] Adding the objects to the pool using chPoolLoadArray().*/
- test_set_step(1);
- {
- chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);
- }
-
- /* [6.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");
- }
-
- /* [6.1.3] Now must be empty.*/
- test_set_step(3);
- {
- test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
- }
-
- /* [6.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]);
- }
-
- /* [6.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");
- }
-
- /* [6.1.6] Now must be empty again.*/
- test_set_step(6);
- {
- test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
- }
-
- /* [6.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);
- test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");
- }
-}
-
-static const testcase_t test_006_001 = {
- "Loading and emptying a memory pool",
- test_006_001_setup,
- NULL,
- test_006_001_execute
-};
-
-#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
-/**
- * @page test_006_002 [6.2] Loading and emptying a guarded memory pool without waiting
- *
- * <h2>Description</h2>
- * 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_SEMAPHORES
- * .
- *
- * <h2>Test Steps</h2>
- * - [6.2.1] Adding the objects to the pool using
- * chGuardedPoolLoadArray().
- * - [6.2.2] Emptying the pool using chGuardedPoolAllocTimeout().
- * - [6.2.3] Now must be empty.
- * - [6.2.4] Adding the objects to the pool using chGuardedPoolFree().
- * - [6.2.5] Emptying the pool using chGuardedPoolAllocTimeout() again.
- * - [6.2.6] Now must be empty again.
- * .
- */
-
-static void test_006_002_setup(void) {
- chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
-}
-
-static void test_006_002_execute(void) {
- unsigned i;
-
- /* [6.2.1] Adding the objects to the pool using
- chGuardedPoolLoadArray().*/
- test_set_step(1);
- {
- chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);
- }
-
- /* [6.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");
- }
-
- /* [6.2.3] Now must be empty.*/
- test_set_step(3);
- {
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
- }
-
- /* [6.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]);
- }
-
- /* [6.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");
- }
-
- /* [6.2.6] Now must be empty again.*/
- test_set_step(6);
- {
- test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty");
- }
-}
-
-static const testcase_t test_006_002 = {
- "Loading and emptying a guarded memory pool without waiting",
- test_006_002_setup,
- NULL,
- test_006_002_execute
-};
-#endif /* CH_CFG_USE_SEMAPHORES */
-
-#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
-/**
- * @page test_006_003 [6.3] Guarded Memory Pools timeout
- *
- * <h2>Description</h2>
- * The timeout features for the Guarded Memory Pools 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>
- * - [6.3.1] Trying to allocate with 100mS timeout, must fail because
- * the pool is empty.
- * .
- */
-
-static void test_006_003_setup(void) {
- chGuardedPoolObjectInit(&gmp1, sizeof (uint32_t));
-}
-
-static void test_006_003_execute(void) {
-
- /* [6.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");
- }
-}
-
-static const testcase_t test_006_003 = {
- "Guarded Memory Pools timeout",
- test_006_003_setup,
- NULL,
- test_006_003_execute
-};
-#endif /* CH_CFG_USE_SEMAPHORES */
-
-/****************************************************************************
- * Exported data.
- ****************************************************************************/
-
-/**
- * @brief Memory Pools.
- */
-const testcase_t * const test_sequence_006[] = {
- &test_006_001,
-#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
- &test_006_002,
-#endif
-#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
- &test_006_003,
-#endif
- NULL
-};
-
-#endif /* CH_CFG_USE_MEMPOOLS */
diff --git a/test/nil/source/test/test_sequence_006.h b/test/nil/source/test/test_sequence_006.h
deleted file mode 100644
index 959689dc1..000000000
--- a/test/nil/source/test/test_sequence_006.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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.
-*/
-
-/**
- * @file test_sequence_006.h
- * @brief Test Sequence 006 header.
- */
-
-#ifndef TEST_SEQUENCE_006_H
-#define TEST_SEQUENCE_006_H
-
-extern const testcase_t * const test_sequence_006[];
-
-#endif /* TEST_SEQUENCE_006_H */
diff --git a/test/nil/source/test/test_sequence_007.c b/test/nil/source/test/test_sequence_007.c
deleted file mode 100644
index 4e5908ab0..000000000
--- a/test/nil/source/test/test_sequence_007.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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"
-
-/**
- * @file test_sequence_007.c
- * @brief Test Sequence 007 code.
- *
- * @page test_sequence_007 [7] Memory Heaps
- *
- * File: @ref test_sequence_007.c
- *
- * <h2>Description</h2>
- * 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_007_001
- * - @subpage test_007_002
- * .
- */
-
-#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
-
-/****************************************************************************
- * Shared code.
- ****************************************************************************/
-
-#define ALLOC_SIZE 16
-#define HEAP_SIZE (ALLOC_SIZE * 8)
-
-static memory_heap_t test_heap;
-static CH_HEAP_AREA(myheap, HEAP_SIZE);
-
-/****************************************************************************
- * Test cases.
- ****************************************************************************/
-
-/**
- * @page test_007_001 [7.1] Allocation and fragmentation
- *
- * <h2>Description</h2>
- * 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.
- *
- * <h2>Test Steps</h2>
- * - [7.1.1] Testing initial conditions, the heap must not be
- * fragmented and one free block present.
- * - [7.1.2] Trying to allocate an block bigger than available space,
- * an error is expected.
- * - [7.1.3] Single block allocation using chHeapAlloc() then the block
- * is freed using chHeapFree(), must not fail.
- * - [7.1.4] Using chHeapStatus() to assess the heap state. There must
- * be at least one free block of sufficient size.
- * - [7.1.5] Allocating then freeing in the same order.
- * - [7.1.6] Allocating then freeing in reverse order.
- * - [7.1.7] Small fragments handling. Checking the behavior when
- * allocating blocks with size not multiple of alignment unit.
- * - [7.1.8] Skipping a fragment, the first fragment in the list is too
- * small so the allocator must pick the second one.
- * - [7.1.9] Allocating the whole available space.
- * - [7.1.10] Testing final conditions. The heap geometry must be the
- * same than the one registered at beginning.
- * .
- */
-
-static void test_007_001_setup(void) {
- chHeapObjectInit(&test_heap, myheap, sizeof(myheap));
-}
-
-static void test_007_001_execute(void) {
- void *p1, *p2, *p3;
- size_t n, sz;
-
- /* [7.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");
- }
-
- /* [7.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");
- }
-
- /* [7.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);
- test_assert(p1 != NULL, "allocation failed");
- chHeapFree(p1);
- }
-
- /* [7.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;
-
- n = chHeapStatus(&test_heap, &total_size, &largest_size);
- test_assert(n == 1, "missing free block");
- test_assert(total_size >= ALLOC_SIZE, "unexpected heap state");
- test_assert(total_size == largest_size, "unexpected heap state");
- }
-
- /* [7.1.5] Allocating then freeing in the same order.*/
- test_set_step(5);
- {
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1); /* Does not merge.*/
- chHeapFree(p2); /* Merges backward.*/
- chHeapFree(p3); /* Merges both sides.*/
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
- }
-
- /* [7.1.6] Allocating then freeing in reverse order.*/
- test_set_step(6);
- {
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- p3 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p3); /* Merges forward.*/
- chHeapFree(p2); /* Merges forward.*/
- chHeapFree(p1); /* Merges forward.*/
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
- }
-
- /* [7.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);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- /* Note, the first situation happens when the alignment size is smaller
- than the header size, the second in the other cases.*/
- test_assert((chHeapStatus(&test_heap, &n, NULL) == 1) ||
- (chHeapStatus(&test_heap, &n, NULL) == 2), "heap fragmented");
- chHeapFree(p2);
- chHeapFree(p1);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
- }
-
- /* [7.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);
- p2 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- chHeapFree(p1);
- test_assert( chHeapStatus(&test_heap, &n, NULL) == 2, "invalid state");
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE * 2); /* Skips first fragment.*/
- chHeapFree(p1);
- chHeapFree(p2);
- test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
- }
-
- /* [7.1.9] Allocating the whole available space.*/
- test_set_step(9);
- {
- (void)chHeapStatus(&test_heap, &n, NULL);
- p1 = chHeapAlloc(&test_heap, n);
- test_assert(p1 != NULL, "allocation failed");
- test_assert(chHeapStatus(&test_heap, NULL, NULL) == 0, "not empty");
- chHeapFree(p1);
- }
-
- /* [7.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");
- test_assert(n == sz, "size changed");
- }
-}
-
-static const testcase_t test_007_001 = {
- "Allocation and fragmentation",
- test_007_001_setup,
- NULL,
- test_007_001_execute
-};
-
-/**
- * @page test_007_002 [7.2] Default Heap
- *
- * <h2>Description</h2>
- * The default heap is pre-allocated in the system. We test base
- * functionality.
- *
- * <h2>Test Steps</h2>
- * - [7.2.1] Single block allocation using chHeapAlloc() then the block
- * is freed using chHeapFree(), must not fail.
- * - [7.2.2] Testing allocation failure.
- * .
- */
-
-static void test_007_002_execute(void) {
- void *p1;
- size_t total_size, largest_size;
-
- /* [7.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);
- p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
- test_assert(p1 != NULL, "allocation failed");
- chHeapFree(p1);
- }
-
- /* [7.2.2] Testing allocation failure.*/
- test_set_step(2);
- {
- p1 = chHeapAlloc(NULL, (size_t)-256);
- test_assert(p1 == NULL, "allocation not failed");
- }
-}
-
-static const testcase_t test_007_002 = {
- "Default Heap",
- NULL,
- NULL,
- test_007_002_execute
-};
-
-/****************************************************************************
- * Exported data.
- ****************************************************************************/
-
-/**
- * @brief Memory Heaps.
- */
-const testcase_t * const test_sequence_007[] = {
- &test_007_001,
- &test_007_002,
- NULL
-};
-
-#endif /* CH_CFG_USE_HEAP */
diff --git a/test/nil/source/test/test_sequence_007.h b/test/nil/source/test/test_sequence_007.h
deleted file mode 100644
index b0b926223..000000000
--- a/test/nil/source/test/test_sequence_007.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2017 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.
-*/
-
-/**
- * @file test_sequence_007.h
- * @brief Test Sequence 007 header.
- */
-
-#ifndef TEST_SEQUENCE_007_H
-#define TEST_SEQUENCE_007_H
-
-extern const testcase_t * const test_sequence_007[];
-
-#endif /* TEST_SEQUENCE_007_H */
diff --git a/test/nil/test.mk b/test/nil/test.mk
deleted file mode 100644
index ac60ee95a..000000000
--- a/test/nil/test.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# List of all the ChibiOS/NIL test files.
-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_004.c \
- ${CHIBIOS}/test/nil/source/test/test_sequence_005.c \
- ${CHIBIOS}/test/nil/source/test/test_sequence_006.c\
- ${CHIBIOS}/test/nil/source/test/test_sequence_007.c
-
-# Required include directories
-TESTINC = ${CHIBIOS}/test/lib \
- ${CHIBIOS}/test/nil/source/test