From 79bd7cc8ea69d9229d229e69fd5db558ddcb1553 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 22 Mar 2016 10:55:31 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9147 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nil/source/test/test_root.c | 7 +- test/nil/source/test/test_root.h | 9 +- test/nil/source/test/test_sequence_001.c | 59 ++++++------ test/nil/source/test/test_sequence_002.c | 114 ++++++++++------------- test/nil/source/test/test_sequence_003.c | 52 +++++------ test/nil/source/test/test_sequence_004.c | 154 +++++++++++++++---------------- test/nil/source/test/test_sequence_005.c | 120 ++++++++++++------------ test/nil/source/test/test_sequence_006.c | 116 +++++++++++------------ 8 files changed, 300 insertions(+), 331 deletions(-) (limited to 'test/nil/source') 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 * *

Description

* The functionality of the API @p chVTGetSystemTimeX() is tested. * *

Test Steps

- * - 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 * *

Description

* The functionality of @p chThdSleep() and derivatives is tested. * *

Test Steps

- * - 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. * + *

Conditions

+ * This sequence is only executed if the following preprocessor condition + * evaluates to true: + * - CH_CFG_USE_SEMAPHORES + * . + * *

Test Cases

* - @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 * *

Description

* Wait, Signal and Reset primitives are tested. The testing thread * does not trigger a state change. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_SEMAPHORES - * . - * *

Test Steps

- * - 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 * *

Description

* Wait, Signal and Reset primitives are tested. The testing thread * triggers a state change. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_SEMAPHORES - * . - * *

Test Steps

- * - 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 * *

Description

* Timeout on semaphores is tested. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_SEMAPHORES - * . - * *

Test Steps

- * - 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 * *

Description

* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is * tested. * *

Test Steps

- * - 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 * *

Description

* Event flags functionality is tested. @@ -118,15 +118,15 @@ static const testcase_t test_003_001 = { * . * *

Test Steps

- * - 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. * + *

Conditions

+ * This sequence is only executed if the following preprocessor condition + * evaluates to true: + * - CH_CFG_USE_MAILBOXES + * . + * *

Test Cases

* - @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 * *

Description

* The mailbox normal API is tested without triggering blocking * conditions. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_MAILBOXES - * . - * *

Test Steps

- * - 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 * *

Description

* The mailbox I-Class API is tested without triggering blocking * conditions. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_MAILBOXES - * . - * *

Test Steps

- * - 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 * *

Description

* The mailbox API is tested for timeouts. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_MAILBOXES - * . - * *

Test Steps

- * - 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. * + *

Conditions

+ * This sequence is only executed if the following preprocessor condition + * evaluates to true: + * - CH_CFG_USE_MEMPOOLS + * . + * *

Test Cases

* - @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 * *

Description

- * 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. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_MEMPOOLS - * . - * *

Test Steps

- * - 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 * *

Description

- * 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. * *

Conditions

* 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 * . * *

Test Steps

- * - 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 * *

Description

* The timeout features for the Guarded Memory Pools is tested. @@ -234,12 +238,12 @@ static const testcase_t test_005_002 = { *

Conditions

* 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 * . * *

Test Steps

- * - 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. * + *

Conditions

+ * This sequence is only executed if the following preprocessor condition + * evaluates to true: + * - CH_CFG_USE_HEAP + * . + * *

Test Cases

* - @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 * *

Description

* 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. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_HEAP - * . - * *

Test Steps

- * - 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 * *

Description

* The default heap is pre-allocated in the system. We test base * functionality. * - *

Conditions

- * This test is only executed if the following preprocessor condition - * evaluates to true: - * - CH_CFG_USE_HEAP - * . - * *

Test Steps

- * - 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 */ -- cgit v1.2.3