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

This commit is contained in:
Giovanni Di Sirio 2016-03-22 10:55:31 +00:00
parent d82ac0a69a
commit 79bd7cc8ea
25 changed files with 816 additions and 996 deletions

View File

@ -46,6 +46,9 @@ THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE);]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to threading.</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to threading.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "osapi.h" <value><![CDATA[#include "osapi.h"
@ -620,6 +623,9 @@ test_assert_sequence("ABC", "events order violation");]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to queues</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to queues</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include <string.h> <value><![CDATA[#include <string.h>
@ -1006,6 +1012,9 @@ test_assert(err == OS_QUEUE_EMPTY, "unexpected error code");]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to timers</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to timers</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include <string.h> <value><![CDATA[#include <string.h>
@ -1446,6 +1455,9 @@ test_assert(err == OS_SUCCESS, "timer stop failed");]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to binary semaphores.</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to binary semaphores.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "osapi.h" <value><![CDATA[#include "osapi.h"
@ -1871,6 +1883,9 @@ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to counter semaphores.</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to counter semaphores.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "osapi.h" <value><![CDATA[#include "osapi.h"
@ -2258,6 +2273,9 @@ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]></value>
<description> <description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to mutex semaphores.</value> <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to mutex semaphores.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "osapi.h" <value><![CDATA[#include "osapi.h"

View File

@ -1,18 +1,4 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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.
*/
/** /**
* @mainpage Test Suite Specification * @mainpage Test Suite Specification
@ -33,15 +19,14 @@
/** /**
* @file test_root.c * @file test_root.c
* @brief Test Suite root structures code. * @brief Test Suite root structures code.
*
* @addtogroup SPC5_TEST_ROOT
* @{
*/ */
#include "hal.h" #include "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
#if !defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* Module exported variables. */ /* Module exported variables. */
/*===========================================================================*/ /*===========================================================================*/
@ -63,9 +48,9 @@ const testcase_t * const *test_suite[] = {
/* Shared code. */ /* Shared code. */
/*===========================================================================*/ /*===========================================================================*/
THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE);
THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE);
THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE);
THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE);
/** @} */ #endif /* !defined(__DOXYGEN__) */

View File

@ -1,25 +1,8 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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_root.h * @file test_root.h
* @brief Test Suite root structures header. * @brief Test Suite root structures header.
*
* @addtogroup SPC5_TEST_ROOT
* @{
*/ */
#ifndef _SPC5_TEST_ROOT_H_ #ifndef _SPC5_TEST_ROOT_H_
@ -32,6 +15,8 @@
#include "test_sequence_005.h" #include "test_sequence_005.h"
#include "test_sequence_006.h" #include "test_sequence_006.h"
#if !defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
@ -49,16 +34,16 @@ extern "C" {
/* Shared definitions. */ /* Shared definitions. */
/*===========================================================================*/ /*===========================================================================*/
#define TEST_SUITE_NAME "NASA OSAL over ChibiOS/RT Test Suite" #define TEST_SUITE_NAME "NASA OSAL over ChibiOS/RT Test Suite"
#define TASKS_BASE_PRIORITY 200 #define TASKS_BASE_PRIORITY 200
#define TASKS_STACK_SIZE 256 #define TASKS_STACK_SIZE 256
extern THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); extern THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE);
extern THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); extern THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE);
extern THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); extern THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE);
extern THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); extern THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE);
#endif /* _SPC5_TEST_ROOT_H_ */ #endif /* !defined(__DOXYGEN__) */
/** @} */ #endif /* _SPC5_TEST_ROOT_H_ */

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_001 Tasks Functionality * @page test_sequence_001 [1] Tasks Functionality
* *
* File: @ref test_sequence_001.c * File: @ref test_sequence_001.c
* *
@ -39,41 +25,41 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include "osapi.h" #include "osapi.h"
static void test_task1(void) { static void test_task1(void) {
test_emit_token('A'); test_emit_token('A');
} }
static void test_task2(void) { static void test_task2(void) {
test_emit_token('B'); test_emit_token('B');
} }
static void test_task3(void) { static void test_task3(void) {
test_emit_token('C'); test_emit_token('C');
} }
static void test_task4(void) { static void test_task4(void) {
test_emit_token('D'); test_emit_token('D');
} }
static void delete_handler(void) { static void delete_handler(void) {
test_emit_token('C'); test_emit_token('C');
} }
static void test_task_delete(void) { static void test_task_delete(void) {
test_emit_token('A'); test_emit_token('A');
(void) OS_TaskInstallDeleteHandler(delete_handler); (void) OS_TaskInstallDeleteHandler(delete_handler);
while (!OS_TaskDeleteCheck()) { while (!OS_TaskDeleteCheck()) {
(void) OS_TaskDelay(1); (void) OS_TaskDelay(1);
} }
test_emit_token('B'); test_emit_token('B');
} }
/**************************************************************************** /****************************************************************************
@ -81,33 +67,33 @@ static void test_task_delete(void) {
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_001_001 OS_TaskCreate() errors * @page test_001_001 [1.1] OS_TaskCreate() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_TaskCreate() is tested. * Parameters checking in OS_TaskCreate() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_TaskCreate() is invoked with task_id set to NULL, an error is * - [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an
* expected.
* - OS_TaskCreate() is invoked with task_name set to NULL, an error is
* expected.
* - OS_TaskCreate() is invoked with stack_pointer set to NULL, an
* error is expected. * error is expected.
* - OS_TaskCreate() is invoked with a very long task name, an error is * - [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an
* expected.
* - OS_TaskCreate() is invoked with priority below and above allowed
* range, an error is expected.
* - OS_TaskCreate() is invoked with a stack size below minimum, an
* error is expected. * error is expected.
* - OS_TaskCreate() is invoked twice with duplicated name and then * - [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL,
* duplicated stack, an error is expected in both cases. * an error is expected.
* - [1.1.4] OS_TaskCreate() is invoked with a very long task name, an
* error is expected.
* - [1.1.5] OS_TaskCreate() is invoked with priority below and above
* allowed range, an error is expected.
* - [1.1.6] OS_TaskCreate() is invoked with a stack size below
* minimum, an error is expected.
* - [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and
* then duplicated stack, an error is expected in both cases.
* . * .
*/ */
static void test_001_001_execute(void) { static void test_001_001_execute(void) {
/* OS_TaskCreate() is invoked with task_id set to NULL, an error is /* [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -123,8 +109,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked with task_name set to NULL, an error is /* [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an
expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -141,8 +127,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked with stack_pointer set to NULL, an /* [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL,
error is expected.*/ an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -159,8 +145,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked with a very long task name, an error is /* [1.1.4] OS_TaskCreate() is invoked with a very long task name, an
expected.*/ error is expected.*/
test_set_step(4); test_set_step(4);
{ {
int32 err; int32 err;
@ -177,8 +163,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked with priority below and above allowed /* [1.1.5] OS_TaskCreate() is invoked with priority below and above
range, an error is expected.*/ allowed range, an error is expected.*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -205,8 +191,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked with a stack size below minimum, an /* [1.1.6] OS_TaskCreate() is invoked with a stack size below
error is expected.*/ minimum, an error is expected.*/
test_set_step(6); test_set_step(6);
{ {
int32 err; int32 err;
@ -223,8 +209,8 @@ static void test_001_001_execute(void) {
test_assert_sequence("", "task executed"); test_assert_sequence("", "task executed");
} }
/* OS_TaskCreate() is invoked twice with duplicated name and then /* [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and
duplicated stack, an error is expected in both cases.*/ then duplicated stack, an error is expected in both cases.*/
test_set_step(7); test_set_step(7);
{ {
int32 err; int32 err;
@ -284,7 +270,7 @@ static const testcase_t test_001_001 = {
}; };
/** /**
* @page test_001_002 OS_TaskCreate() priority ordering * @page test_001_002 [1.2] OS_TaskCreate() priority ordering
* *
* <h2>Description</h2> * <h2>Description</h2>
* Four tasks are created at different priorities and in different * Four tasks are created at different priorities and in different
@ -292,21 +278,22 @@ static const testcase_t test_001_001 = {
* regardless the creation order. * regardless the creation order.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Four tasks are created in priority order from low to high. * - [1.2.1] Four tasks are created in priority order from low to high.
* - Tasks are made runnable atomically and their execution order * - [1.2.2] Tasks are made runnable atomically and their execution
* tested. * order tested.
* - Four tasks are created in priority order from high to low. * - [1.2.3] Four tasks are created in priority order from high to low.
* - Tasks are made runnable atomically and their execution order * - [1.2.4] Tasks are made runnable atomically and their execution
* tested. * order tested.
* - Four tasks are created in an not ordered way. * - [1.2.5] Four tasks are created in an not ordered way.
* - Tasks are made runnable atomically and their execution order * - [1.2.6] Tasks are made runnable atomically and their execution
* tested. * order tested.
* . * .
*/ */
static void test_001_002_execute(void) { static void test_001_002_execute(void) {
/* Four tasks are created in priority order from low to high.*/ /* [1.2.1] Four tasks are created in priority order from low to
high.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -349,15 +336,16 @@ static void test_001_002_execute(void) {
test_assert(err == OS_SUCCESS, "task 1 creation failed"); test_assert(err == OS_SUCCESS, "task 1 creation failed");
} }
/* Tasks are made runnable atomically and their execution order /* [1.2.2] Tasks are made runnable atomically and their execution
tested.*/ order tested.*/
test_set_step(2); test_set_step(2);
{ {
OS_TaskDelay(5); OS_TaskDelay(5);
test_assert_sequence("ABCD", "task order violation"); test_assert_sequence("ABCD", "task order violation");
} }
/* Four tasks are created in priority order from high to low.*/ /* [1.2.3] Four tasks are created in priority order from high to
low.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -400,15 +388,15 @@ static void test_001_002_execute(void) {
test_assert(err == OS_SUCCESS, "task 4 creation failed"); test_assert(err == OS_SUCCESS, "task 4 creation failed");
} }
/* Tasks are made runnable atomically and their execution order /* [1.2.4] Tasks are made runnable atomically and their execution
tested.*/ order tested.*/
test_set_step(4); test_set_step(4);
{ {
OS_TaskDelay(5); OS_TaskDelay(5);
test_assert_sequence("ABCD", "task order violation"); test_assert_sequence("ABCD", "task order violation");
} }
/* Four tasks are created in an not ordered way.*/ /* [1.2.5] Four tasks are created in an not ordered way.*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -451,8 +439,8 @@ static void test_001_002_execute(void) {
test_assert(err == OS_SUCCESS, "task 3 creation failed"); test_assert(err == OS_SUCCESS, "task 3 creation failed");
} }
/* Tasks are made runnable atomically and their execution order /* [1.2.6] Tasks are made runnable atomically and their execution
tested.*/ order tested.*/
test_set_step(6); test_set_step(6);
{ {
OS_TaskDelay(5); OS_TaskDelay(5);
@ -468,21 +456,21 @@ static const testcase_t test_001_002 = {
}; };
/** /**
* @page test_001_003 OS_TaskDelete() errors * @page test_001_003 [1.3] OS_TaskDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_TaskDelete() is tested. * Parameters checking in OS_TaskDelete() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_TaskDelete() is invoked with task_id set to -1, an error is * - [1.3.1] OS_TaskDelete() is invoked with task_id set to -1, an
* expected. * error is expected.
* . * .
*/ */
static void test_001_003_execute(void) { static void test_001_003_execute(void) {
/* OS_TaskDelete() is invoked with task_id set to -1, an error is /* [1.3.1] OS_TaskDelete() is invoked with task_id set to -1, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -500,23 +488,23 @@ static const testcase_t test_001_003 = {
}; };
/** /**
* @page test_001_004 OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality * @page test_001_004 [1.4] OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for * OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for
* functionality. * functionality.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Creating a task executing an infinite loop. * - [1.4.1] Creating a task executing an infinite loop.
* - Letting the task run for a while then deleting it. A check is * - [1.4.2] Letting the task run for a while then deleting it. A check
* performed on the correct execution of the delete handler. * is performed on the correct execution of the delete handler.
* . * .
*/ */
static void test_001_004_execute(void) { static void test_001_004_execute(void) {
uint32 tid; uint32 tid;
/* Creating a task executing an infinite loop.*/ /* [1.4.1] Creating a task executing an infinite loop.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -531,8 +519,8 @@ static void test_001_004_execute(void) {
test_assert(err == OS_SUCCESS, "deletable task creation failed"); test_assert(err == OS_SUCCESS, "deletable task creation failed");
} }
/* Letting the task run for a while then deleting it. A check is /* [1.4.2] Letting the task run for a while then deleting it. A check
performed on the correct execution of the delete handler.*/ is performed on the correct execution of the delete handler.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_001[]; extern const testcase_t * const test_sequence_001[];

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_002 Queues Functionality * @page test_sequence_002 [2] Queues Functionality
* *
* File: @ref test_sequence_002.c * File: @ref test_sequence_002.c
* *
@ -39,25 +25,25 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include <string.h> #include <string.h>
#include "osapi.h" #include "osapi.h"
uint32 qid, tid; uint32 qid, tid;
#define WRITER_NUM_MESSAGES 16 #define WRITER_NUM_MESSAGES 16
#define MESSAGE_SIZE 20 #define MESSAGE_SIZE 20
static void test_task_writer(void) { static void test_task_writer(void) {
unsigned i; unsigned i;
int32 err; int32 err;
for (i = 0; i < WRITER_NUM_MESSAGES; i++) { for (i = 0; i < WRITER_NUM_MESSAGES; i++) {
err = OS_QueuePut(qid, "Hello World", 12, 0); err = OS_QueuePut(qid, "Hello World", 12, 0);
if (err != OS_SUCCESS) { if (err != OS_SUCCESS) {
test_emit_token('*'); test_emit_token('*');
} }
} }
} }
/**************************************************************************** /****************************************************************************
@ -65,30 +51,31 @@ static void test_task_writer(void) {
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_002_001 OS_QueueCreate() and OS_QueueDelete() errors * @page test_002_001 [2.1] OS_QueueCreate() and OS_QueueDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_QueueCreate() and OS_QueueDelete() is * Parameters checking in OS_QueueCreate() and OS_QueueDelete() is
* tested. * tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_QueueCreate() is invoked with queue_id set to NULL, an error is * - [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an
* expected. * error is expected.
* - OS_QueueCreate() is invoked with task_name set to NULL, an error * - [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an
* is expected. * error is expected.
* - OS_QueueCreate() is invoked with a very long task name, an error * - [2.1.3] OS_QueueCreate() is invoked with a very long task name, an
* is expected. * error is expected.
* - OS_QueueDelete() is invoked with queue_id set to -1, an error is * - [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an
* expected. * error is expected.
* - OS_QueueCreate() is invoked twice with duplicated name, an error * - [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an
* is expected, then the queue is deleted using OS_QueueDelete(). * error is expected, then the queue is deleted using
* OS_QueueDelete().
* . * .
*/ */
static void test_002_001_execute(void) { static void test_002_001_execute(void) {
/* OS_QueueCreate() is invoked with queue_id set to NULL, an error is /* [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -101,8 +88,8 @@ static void test_002_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_QueueCreate() is invoked with task_name set to NULL, an error /* [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an
is expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -116,8 +103,8 @@ static void test_002_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_QueueCreate() is invoked with a very long task name, an error /* [2.1.3] OS_QueueCreate() is invoked with a very long task name, an
is expected.*/ error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -131,8 +118,8 @@ static void test_002_001_execute(void) {
test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
} }
/* OS_QueueDelete() is invoked with queue_id set to -1, an error is /* [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an
expected.*/ error is expected.*/
test_set_step(4); test_set_step(4);
{ {
int32 err; int32 err;
@ -141,8 +128,9 @@ static void test_002_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong queue id not detected"); test_assert(err == OS_ERR_INVALID_ID, "wrong queue id not detected");
} }
/* OS_QueueCreate() is invoked twice with duplicated name, an error /* [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an
is expected, then the queue is deleted using OS_QueueDelete().*/ error is expected, then the queue is deleted using
OS_QueueDelete().*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -167,25 +155,25 @@ static const testcase_t test_002_001 = {
}; };
/** /**
* @page test_002_002 OS_QueueGetIdByName() errors * @page test_002_002 [2.2] OS_QueueGetIdByName() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_QueueGetIdByName() is tested. * Parameters checking in OS_QueueGetIdByName() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_QueueGetIdByName() is invoked with queue_id set to NULL, an * - [2.2.1] OS_QueueGetIdByName() is invoked with queue_id set to
* error is expected. * NULL, an error is expected.
* - OS_QueueGetIdByName() is invoked with queue_name set to NULL, an * - [2.2.2] OS_QueueGetIdByName() is invoked with queue_name set to
* error is expected. * NULL, an error is expected.
* - OS_QueueGetIdByName() is invoked with a very long task name, an * - [2.2.3] OS_QueueGetIdByName() is invoked with a very long task
* error is expected. * name, an error is expected.
* . * .
*/ */
static void test_002_002_execute(void) { static void test_002_002_execute(void) {
/* OS_QueueGetIdByName() is invoked with queue_id set to NULL, an /* [2.2.1] OS_QueueGetIdByName() is invoked with queue_id set to
error is expected.*/ NULL, an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -194,8 +182,8 @@ static void test_002_002_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_QueueGetIdByName() is invoked with queue_name set to NULL, an /* [2.2.2] OS_QueueGetIdByName() is invoked with queue_name set to
error is expected.*/ NULL, an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -204,8 +192,8 @@ static void test_002_002_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_QueueGetIdByName() is invoked with a very long task name, an /* [2.2.3] OS_QueueGetIdByName() is invoked with a very long task
error is expected.*/ name, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -223,17 +211,17 @@ static const testcase_t test_002_002 = {
}; };
/** /**
* @page test_002_003 OS_QueuePut() and OS_QueueGet() functionality * @page test_002_003 [2.3] OS_QueuePut() and OS_QueueGet() functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* A task writes on a queue, the messages are retrieved on the other * A task writes on a queue, the messages are retrieved on the other
* side in blocking mode. * side in blocking mode.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Creataing a queue with depth 4 and message size 20. * - [2.3.1] Creataing a queue with depth 4 and message size 20.
* - Creating the writer task. * - [2.3.2] Creating the writer task.
* - Reading messages from the writer task. * - [2.3.3] Reading messages from the writer task.
* - Waiting for task termination then checking for errors. * - [2.3.4] Waiting for task termination then checking for errors.
* . * .
*/ */
@ -256,7 +244,7 @@ static void test_002_003_execute(void) {
uint32 tid; uint32 tid;
unsigned i; unsigned i;
/* Creataing a queue with depth 4 and message size 20.*/ /* [2.3.1] Creataing a queue with depth 4 and message size 20.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -265,7 +253,7 @@ static void test_002_003_execute(void) {
test_assert(err == OS_SUCCESS, "queue creation failed"); test_assert(err == OS_SUCCESS, "queue creation failed");
} }
/* Creating the writer task.*/ /* [2.3.2] Creating the writer task.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -280,7 +268,7 @@ static void test_002_003_execute(void) {
test_assert(err == OS_SUCCESS, "writer task creation failed"); test_assert(err == OS_SUCCESS, "writer task creation failed");
} }
/* Reading messages from the writer task.*/ /* [2.3.3] Reading messages from the writer task.*/
test_set_step(3); test_set_step(3);
{ {
for (i = 0; i < WRITER_NUM_MESSAGES; i++) { for (i = 0; i < WRITER_NUM_MESSAGES; i++) {
@ -295,7 +283,7 @@ static void test_002_003_execute(void) {
} }
} }
/* Waiting for task termination then checking for errors.*/ /* [2.3.4] Waiting for task termination then checking for errors.*/
test_set_step(4); test_set_step(4);
{ {
(void) OS_TaskWait(tid); (void) OS_TaskWait(tid);
@ -312,15 +300,16 @@ static const testcase_t test_002_003 = {
}; };
/** /**
* @page test_002_004 OS_QueueGet() with timeout functionality * @page test_002_004 [2.4] OS_QueueGet() with timeout functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* OS_QueueGet() timeout functionality is tested. * OS_QueueGet() timeout functionality is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Retrieving the queue by name. * - [2.4.1] Retrieving the queue by name.
* - Get operation with a one second timeout, an error is expected. * - [2.4.2] Get operation with a one second timeout, an error is
* - Get operation in non-blocking mode, an error is expected. * expected.
* - [2.4.3] Get operation in non-blocking mode, an error is expected.
* . * .
*/ */
@ -340,7 +329,7 @@ static void test_002_004_execute(void) {
uint32 copied; uint32 copied;
char data[MESSAGE_SIZE]; char data[MESSAGE_SIZE];
/* Retrieving the queue by name.*/ /* [2.4.1] Retrieving the queue by name.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -349,7 +338,8 @@ static void test_002_004_execute(void) {
test_assert(err == OS_SUCCESS, "queue not found"); test_assert(err == OS_SUCCESS, "queue not found");
} }
/* Get operation with a one second timeout, an error is expected.*/ /* [2.4.2] Get operation with a one second timeout, an error is
expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -358,7 +348,8 @@ static void test_002_004_execute(void) {
test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code"); test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code");
} }
/* Get operation in non-blocking mode, an error is expected.*/ /* [2.4.3] Get operation in non-blocking mode, an error is
expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_002[]; extern const testcase_t * const test_sequence_002[];

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_003 Timers Functionality * @page test_sequence_003 [3] Timers Functionality
* *
* File: @ref test_sequence_003.c * File: @ref test_sequence_003.c
* *
@ -40,18 +26,18 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include <string.h> #include <string.h>
#include "osapi.h" #include "osapi.h"
uint32 tmid; uint32 tmid;
uint32 cnt; uint32 cnt;
static void tmr_callback(uint32 timer_id) { static void tmr_callback(uint32 timer_id) {
(void)timer_id; (void)timer_id;
cnt++; cnt++;
} }
/**************************************************************************** /****************************************************************************
@ -59,34 +45,35 @@ static void tmr_callback(uint32 timer_id) {
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_003_001 OS_TimerCreate() and OS_TimerDelete() errors * @page test_003_001 [3.1] OS_TimerCreate() and OS_TimerDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_TimerCreate() and OS_TimerDelete() is * Parameters checking in OS_TimerCreate() and OS_TimerDelete() is
* tested. * tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_TimerCreate() is invoked with timer_id set to NULL, an error is * - [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an
* expected.
* - OS_TimerCreate() is invoked with timer_name set to NULL, an error
* is expected.
* - OS_TimerCreate() is invoked with accuracy set to NULL, an error is
* expected.
* - OS_TimerCreate() is invoked with callback_ptr set to NULL, an
* error is expected. * error is expected.
* - OS_TimerCreate() is invoked with a very long timer name, an error * - [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL,
* is expected. * an error is expected.
* - OS_TimerDelete() is invoked with timer_id set to -1, an error is * - [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an
* expected. * error is expected.
* - OS_TimerCreate() is invoked twice with duplicated name, an error * - [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL,
* is expected, then the queue is deleted using OS_TimerDelete(). * an error is expected.
* - [3.1.5] OS_TimerCreate() is invoked with a very long timer name,
* an error is expected.
* - [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an
* error is expected.
* - [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an
* error is expected, then the queue is deleted using
* OS_TimerDelete().
* . * .
*/ */
static void test_003_001_execute(void) { static void test_003_001_execute(void) {
/* OS_TimerCreate() is invoked with timer_id set to NULL, an error is /* [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -99,8 +86,8 @@ static void test_003_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_TimerCreate() is invoked with timer_name set to NULL, an error /* [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL,
is expected.*/ an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -114,8 +101,8 @@ static void test_003_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_TimerCreate() is invoked with accuracy set to NULL, an error is /* [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an
expected.*/ error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -128,8 +115,8 @@ static void test_003_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_TimerCreate() is invoked with callback_ptr set to NULL, an /* [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL,
error is expected.*/ an error is expected.*/
test_set_step(4); test_set_step(4);
{ {
int32 err; int32 err;
@ -143,8 +130,8 @@ static void test_003_001_execute(void) {
test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected"); test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected");
} }
/* OS_TimerCreate() is invoked with a very long timer name, an error /* [3.1.5] OS_TimerCreate() is invoked with a very long timer name,
is expected.*/ an error is expected.*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -158,8 +145,8 @@ static void test_003_001_execute(void) {
test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
} }
/* OS_TimerDelete() is invoked with timer_id set to -1, an error is /* [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an
expected.*/ error is expected.*/
test_set_step(6); test_set_step(6);
{ {
int32 err; int32 err;
@ -168,8 +155,9 @@ static void test_003_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected"); test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected");
} }
/* OS_TimerCreate() is invoked twice with duplicated name, an error /* [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an
is expected, then the queue is deleted using OS_TimerDelete().*/ error is expected, then the queue is deleted using
OS_TimerDelete().*/
test_set_step(7); test_set_step(7);
{ {
int32 err; int32 err;
@ -195,21 +183,21 @@ static const testcase_t test_003_001 = {
}; };
/** /**
* @page test_003_002 OS_TimerSet() errors * @page test_003_002 [3.2] OS_TimerSet() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_TimerSet() is tested. * Parameters checking in OS_TimerSet() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_TimerSet() is invoked with timer_id set to -1, an error is * - [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error
* expected. * is expected.
* . * .
*/ */
static void test_003_002_execute(void) { static void test_003_002_execute(void) {
/* OS_TimerSet() is invoked with timer_id set to -1, an error is /* [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error
expected.*/ is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -227,25 +215,25 @@ static const testcase_t test_003_002 = {
}; };
/** /**
* @page test_003_003 OS_TimerGetIdByName() errors * @page test_003_003 [3.3] OS_TimerGetIdByName() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_TimerGetIdByName() is tested. * Parameters checking in OS_TimerGetIdByName() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_TimerGetIdByName() is invoked with timer_id set to NULL, an * - [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to
* error is expected. * NULL, an error is expected.
* - OS_TimerGetIdByName() is invoked with timer name set to NULL, an * - [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to
* error is expected. * NULL, an error is expected.
* - OS_TimerGetIdByName() is invoked with a very long task name, an * - [3.3.3] OS_TimerGetIdByName() is invoked with a very long task
* error is expected. * name, an error is expected.
* . * .
*/ */
static void test_003_003_execute(void) { static void test_003_003_execute(void) {
/* OS_TimerGetIdByName() is invoked with timer_id set to NULL, an /* [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to
error is expected.*/ NULL, an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -254,8 +242,8 @@ static void test_003_003_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_TimerGetIdByName() is invoked with timer name set to NULL, an /* [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to
error is expected.*/ NULL, an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -264,8 +252,8 @@ static void test_003_003_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_TimerGetIdByName() is invoked with a very long task name, an /* [3.3.3] OS_TimerGetIdByName() is invoked with a very long task
error is expected.*/ name, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -283,15 +271,15 @@ static const testcase_t test_003_003 = {
}; };
/** /**
* @page test_003_004 OS_TimerSet() one-shot functionality * @page test_003_004 [3.4] OS_TimerSet() one-shot functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* A timer is tested in one-shot mode. * A timer is tested in one-shot mode.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Retrieving the timer by name. * - [3.4.1] Retrieving the timer by name.
* - Setting up the timer for a 70mS one-shot tick. * - [3.4.2] Setting up the timer for a 70mS one-shot tick.
* - Waiting one second then counting the occurred ticks. * - [3.4.3] Waiting one second then counting the occurred ticks.
* . * .
*/ */
@ -312,7 +300,7 @@ static void test_003_004_teardown(void) {
static void test_003_004_execute(void) { static void test_003_004_execute(void) {
uint32 local_tmid; uint32 local_tmid;
/* Retrieving the timer by name.*/ /* [3.4.1] Retrieving the timer by name.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -321,7 +309,7 @@ static void test_003_004_execute(void) {
test_assert(err == OS_SUCCESS, "timer not found"); test_assert(err == OS_SUCCESS, "timer not found");
} }
/* Setting up the timer for a 70mS one-shot tick.*/ /* [3.4.2] Setting up the timer for a 70mS one-shot tick.*/
test_set_step(2); test_set_step(2);
{ {
uint32 err; uint32 err;
@ -330,7 +318,7 @@ static void test_003_004_execute(void) {
test_assert(err == OS_SUCCESS, "timer setup failed"); test_assert(err == OS_SUCCESS, "timer setup failed");
} }
/* Waiting one second then counting the occurred ticks.*/ /* [3.4.3] Waiting one second then counting the occurred ticks.*/
test_set_step(3); test_set_step(3);
{ {
(void) OS_TaskDelay(1000); (void) OS_TaskDelay(1000);
@ -346,16 +334,16 @@ static const testcase_t test_003_004 = {
}; };
/** /**
* @page test_003_005 OS_TimerSet() periodic functionality * @page test_003_005 [3.5] OS_TimerSet() periodic functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* A timer is tested in periodic mode. * A timer is tested in periodic mode.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Retrieving the timer by name. * - [3.5.1] Retrieving the timer by name.
* - Setting up the timer for a 70mS periodic tick. * - [3.5.2] Setting up the timer for a 70mS periodic tick.
* - Waiting one second then counting the occurred ticks. * - [3.5.3] Waiting one second then counting the occurred ticks.
* - Stopping the timer. * - [3.5.4] Stopping the timer.
* . * .
*/ */
@ -377,7 +365,7 @@ static void test_003_005_teardown(void) {
static void test_003_005_execute(void) { static void test_003_005_execute(void) {
uint32 local_tmid; uint32 local_tmid;
/* Retrieving the timer by name.*/ /* [3.5.1] Retrieving the timer by name.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -386,7 +374,7 @@ static void test_003_005_execute(void) {
test_assert(err == OS_SUCCESS, "timer not found"); test_assert(err == OS_SUCCESS, "timer not found");
} }
/* Setting up the timer for a 70mS periodic tick.*/ /* [3.5.2] Setting up the timer for a 70mS periodic tick.*/
test_set_step(2); test_set_step(2);
{ {
uint32 err; uint32 err;
@ -395,14 +383,14 @@ static void test_003_005_execute(void) {
test_assert(err == OS_SUCCESS, "timer setup failed"); test_assert(err == OS_SUCCESS, "timer setup failed");
} }
/* Waiting one second then counting the occurred ticks.*/ /* [3.5.3] Waiting one second then counting the occurred ticks.*/
test_set_step(3); test_set_step(3);
{ {
(void) OS_TaskDelay(1000); (void) OS_TaskDelay(1000);
test_assert(cnt == 14, "wrong ticks"); test_assert(cnt == 14, "wrong ticks");
} }
/* Stopping the timer.*/ /* [3.5.4] Stopping the timer.*/
test_set_step(4); test_set_step(4);
{ {
uint32 err; uint32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_003[]; extern const testcase_t * const test_sequence_003[];

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_004 Binary Semaphores Functionality * @page test_sequence_004 [4] Binary Semaphores Functionality
* *
* File: @ref test_sequence_004.c * File: @ref test_sequence_004.c
* *
@ -42,8 +28,8 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include "osapi.h" #include "osapi.h"
uint32 bsid; uint32 bsid;
/**************************************************************************** /****************************************************************************
@ -51,32 +37,33 @@ uint32 bsid;
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_004_001 OS_BinSemCreate() and OS_BinSemDelete() errors * @page test_004_001 [4.1] OS_BinSemCreate() and OS_BinSemDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is * Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is
* tested. * tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemCreate() is invoked with sem_id set to NULL, an error is * - [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an
* expected.
* - OS_BinSemCreate() is invoked with sem_name set to NULL, an error
* is expected.
* - OS_BinSemCreate() is invoked with an invalid sem_initial_value, an
* error is expected. * error is expected.
* - OS_BinSemCreate() is invoked with a very long timer name, an error * - [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an
* is expected. * error is expected.
* - OS_BinSemDelete() is invoked with timer_id set to -1, an error is * - [4.1.3] OS_BinSemCreate() is invoked with an invalid
* expected. * sem_initial_value, an error is expected.
* - OS_BinSemCreate() is invoked twice with duplicated name, an error * - [4.1.4] OS_BinSemCreate() is invoked with a very long timer name,
* is expected, then the queue is deleted using OS_BinSemDelete(). * an error is expected.
* - [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an
* error is expected.
* - [4.1.6] OS_BinSemCreate() is invoked twice with duplicated name,
* an error is expected, then the queue is deleted using
* OS_BinSemDelete().
* . * .
*/ */
static void test_004_001_execute(void) { static void test_004_001_execute(void) {
/* OS_BinSemCreate() is invoked with sem_id set to NULL, an error is /* [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -88,8 +75,8 @@ static void test_004_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_BinSemCreate() is invoked with sem_name set to NULL, an error /* [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an
is expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -101,8 +88,8 @@ static void test_004_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_BinSemCreate() is invoked with an invalid sem_initial_value, an /* [4.1.3] OS_BinSemCreate() is invoked with an invalid
error is expected.*/ sem_initial_value, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -114,8 +101,8 @@ static void test_004_001_execute(void) {
test_assert(err == OS_INVALID_INT_NUM, "counter error not detected"); test_assert(err == OS_INVALID_INT_NUM, "counter error not detected");
} }
/* OS_BinSemCreate() is invoked with a very long timer name, an error /* [4.1.4] OS_BinSemCreate() is invoked with a very long timer name,
is expected.*/ an error is expected.*/
test_set_step(4); test_set_step(4);
{ {
#if 0 /* Semaphore name currently not implemented.*/ #if 0 /* Semaphore name currently not implemented.*/
@ -129,8 +116,8 @@ static void test_004_001_execute(void) {
#endif #endif
} }
/* OS_BinSemDelete() is invoked with timer_id set to -1, an error is /* [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an
expected.*/ error is expected.*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -139,8 +126,9 @@ static void test_004_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
} }
/* OS_BinSemCreate() is invoked twice with duplicated name, an error /* [4.1.6] OS_BinSemCreate() is invoked twice with duplicated name,
is expected, then the queue is deleted using OS_BinSemDelete().*/ an error is expected, then the queue is deleted using
OS_BinSemDelete().*/
test_set_step(6); test_set_step(6);
{ {
int32 err; int32 err;
@ -167,21 +155,21 @@ static const testcase_t test_004_001 = {
}; };
/** /**
* @page test_004_002 OS_BinSemFlush() errors * @page test_004_002 [4.2] OS_BinSemFlush() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemFlush() is tested. * Parameters checking in OS_BinSemFlush() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemFlush() is invoked with sem_id set to -1, an error is * - [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an
* expected. * error is expected.
* . * .
*/ */
static void test_004_002_execute(void) { static void test_004_002_execute(void) {
/* OS_BinSemFlush() is invoked with sem_id set to -1, an error is /* [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -199,21 +187,21 @@ static const testcase_t test_004_002 = {
}; };
/** /**
* @page test_004_003 OS_BinSemGive() errors * @page test_004_003 [4.3] OS_BinSemGive() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemGive() is tested. * Parameters checking in OS_BinSemGive() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemGive() is invoked with sem_id set to -1, an error is * - [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error
* expected. * is expected.
* . * .
*/ */
static void test_004_003_execute(void) { static void test_004_003_execute(void) {
/* OS_BinSemGive() is invoked with sem_id set to -1, an error is /* [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error
expected.*/ is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -231,21 +219,21 @@ static const testcase_t test_004_003 = {
}; };
/** /**
* @page test_004_004 OS_BinSemTake() errors * @page test_004_004 [4.4] OS_BinSemTake() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemTake() is tested. * Parameters checking in OS_BinSemTake() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemTake() is invoked with sem_id set to -1, an error is * - [4.4.1] OS_BinSemTake() is invoked with sem_id set to -1, an error
* expected. * is expected.
* . * .
*/ */
static void test_004_004_execute(void) { static void test_004_004_execute(void) {
/* OS_BinSemTake() is invoked with sem_id set to -1, an error is /* [4.4.1] OS_BinSemTake() is invoked with sem_id set to -1, an error
expected.*/ is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -263,16 +251,16 @@ static const testcase_t test_004_004 = {
}; };
/** /**
* @page test_004_005 OS_BinSemTimedWait() errors * @page test_004_005 [4.5] OS_BinSemTimedWait() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemTimedWait() is tested. * Parameters checking in OS_BinSemTimedWait() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemTimedWait() is invoked with sem_id set to -1, an error is * - [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an
* expected. * error is expected.
* - OS_BinSemTimedWait() is invoked with msecs set to 0, an error is * - [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an
* expected. * error is expected.
* . * .
*/ */
@ -289,8 +277,8 @@ static void test_004_005_teardown(void) {
static void test_004_005_execute(void) { static void test_004_005_execute(void) {
/* OS_BinSemTimedWait() is invoked with sem_id set to -1, an error is /* [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -299,8 +287,8 @@ static void test_004_005_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
} }
/* OS_BinSemTimedWait() is invoked with msecs set to 0, an error is /* [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an
expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -318,25 +306,25 @@ static const testcase_t test_004_005 = {
}; };
/** /**
* @page test_004_006 OS_BinSemGetIdByName() errors * @page test_004_006 [4.6] OS_BinSemGetIdByName() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_BinSemGetIdByName() is tested. * Parameters checking in OS_BinSemGetIdByName() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemGetIdByName() is invoked with sem_id set to NULL, an * - [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL,
* error is expected.
* - OS_BinSemGetIdByName() is invoked with semaphore name set to NULL,
* an error is expected. * an error is expected.
* - OS_BinSemGetIdByName() is invoked with a very long task name, an * - [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set
* error is expected. * to NULL, an error is expected.
* - [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task
* name, an error is expected.
* . * .
*/ */
static void test_004_006_execute(void) { static void test_004_006_execute(void) {
/* OS_BinSemGetIdByName() is invoked with sem_id set to NULL, an /* [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL,
error is expected.*/ an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -345,8 +333,8 @@ static void test_004_006_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_BinSemGetIdByName() is invoked with semaphore name set to NULL, /* [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set
an error is expected.*/ to NULL, an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -355,8 +343,8 @@ static void test_004_006_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_BinSemGetIdByName() is invoked with a very long task name, an /* [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task
error is expected.*/ name, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -374,14 +362,14 @@ static const testcase_t test_004_006 = {
}; };
/** /**
* @page test_004_007 OS_BinSemTimedWait() timeout functionality * @page test_004_007 [4.7] OS_BinSemTimedWait() timeout functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* OS_BinSemCreate() timeout functionality is tested. * OS_BinSemCreate() timeout functionality is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_BinSemTimedWait() is invoked with timeout set to one second, an * - [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one
* error is expected. * second, an error is expected.
* . * .
*/ */
@ -398,8 +386,8 @@ static void test_004_007_teardown(void) {
static void test_004_007_execute(void) { static void test_004_007_execute(void) {
/* OS_BinSemTimedWait() is invoked with timeout set to one second, an /* [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one
error is expected.*/ second, an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_004[]; extern const testcase_t * const test_sequence_004[];

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_005 Counter Semaphores Functionality * @page test_sequence_005 [5] Counter Semaphores Functionality
* *
* File: @ref test_sequence_005.c * File: @ref test_sequence_005.c
* *
@ -41,8 +27,8 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include "osapi.h" #include "osapi.h"
uint32 csid; uint32 csid;
/**************************************************************************** /****************************************************************************
@ -50,33 +36,33 @@ uint32 csid;
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_005_001 OS_CountSemCreate() and OS_CountSemDelete() errors * @page test_005_001 [5.1] OS_CountSemCreate() and OS_CountSemDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_CountSemCreate() and OS_CountSemDelete() * Parameters checking in OS_CountSemCreate() and OS_CountSemDelete()
* is tested. * is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemCreate() is invoked with sem_id set to NULL, an error * - [5.1.1] OS_CountSemCreate() is invoked with sem_id set to NULL, an
* is expected.
* - OS_CountSemCreate() is invoked with sem_name set to NULL, an error
* is expected.
* - OS_CountSemCreate() is invoked with an invalid sem_initial_value,
* an error is expected.
* - OS_CountSemCreate() is invoked with a very long timer name, an
* error is expected. * error is expected.
* - OS_CountSemDelete() is invoked with timer_id set to -1, an error * - [5.1.2] OS_CountSemCreate() is invoked with sem_name set to NULL,
* is expected. * an error is expected.
* - OS_CountSemCreate() is invoked twice with duplicated name, an * - [5.1.3] OS_CountSemCreate() is invoked with an invalid
* error is expected, then the queue is deleted using * sem_initial_value, an error is expected.
* - [5.1.4] OS_CountSemCreate() is invoked with a very long timer
* name, an error is expected.
* - [5.1.5] OS_CountSemDelete() is invoked with timer_id set to -1, an
* error is expected.
* - [5.1.6] OS_CountSemCreate() is invoked twice with duplicated name,
* an error is expected, then the queue is deleted using
* OS_CountSemDelete(). * OS_CountSemDelete().
* . * .
*/ */
static void test_005_001_execute(void) { static void test_005_001_execute(void) {
/* OS_CountSemCreate() is invoked with sem_id set to NULL, an error /* [5.1.1] OS_CountSemCreate() is invoked with sem_id set to NULL, an
is expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -88,8 +74,8 @@ static void test_005_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_CountSemCreate() is invoked with sem_name set to NULL, an error /* [5.1.2] OS_CountSemCreate() is invoked with sem_name set to NULL,
is expected.*/ an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -101,8 +87,8 @@ static void test_005_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_CountSemCreate() is invoked with an invalid sem_initial_value, /* [5.1.3] OS_CountSemCreate() is invoked with an invalid
an error is expected.*/ sem_initial_value, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -114,8 +100,8 @@ static void test_005_001_execute(void) {
test_assert(err == OS_INVALID_INT_NUM, "counter error not detected"); test_assert(err == OS_INVALID_INT_NUM, "counter error not detected");
} }
/* OS_CountSemCreate() is invoked with a very long timer name, an /* [5.1.4] OS_CountSemCreate() is invoked with a very long timer
error is expected.*/ name, an error is expected.*/
test_set_step(4); test_set_step(4);
{ {
#if 0 /* Semaphore name currently not implemented.*/ #if 0 /* Semaphore name currently not implemented.*/
@ -129,8 +115,8 @@ static void test_005_001_execute(void) {
#endif #endif
} }
/* OS_CountSemDelete() is invoked with timer_id set to -1, an error /* [5.1.5] OS_CountSemDelete() is invoked with timer_id set to -1, an
is expected.*/ error is expected.*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -139,8 +125,8 @@ static void test_005_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
} }
/* OS_CountSemCreate() is invoked twice with duplicated name, an /* [5.1.6] OS_CountSemCreate() is invoked twice with duplicated name,
error is expected, then the queue is deleted using an error is expected, then the queue is deleted using
OS_CountSemDelete().*/ OS_CountSemDelete().*/
test_set_step(6); test_set_step(6);
{ {
@ -168,21 +154,21 @@ static const testcase_t test_005_001 = {
}; };
/** /**
* @page test_005_002 OS_CountSemGive() errors * @page test_005_002 [5.2] OS_CountSemGive() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_CountSemGive() is tested. * Parameters checking in OS_CountSemGive() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemGive() is invoked with sem_id set to -1, an error is * - [5.2.1] OS_CountSemGive() is invoked with sem_id set to -1, an
* expected. * error is expected.
* . * .
*/ */
static void test_005_002_execute(void) { static void test_005_002_execute(void) {
/* OS_CountSemGive() is invoked with sem_id set to -1, an error is /* [5.2.1] OS_CountSemGive() is invoked with sem_id set to -1, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -200,21 +186,21 @@ static const testcase_t test_005_002 = {
}; };
/** /**
* @page test_005_003 OS_CountSemTake() errors * @page test_005_003 [5.3] OS_CountSemTake() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_CountSemTake() is tested. * Parameters checking in OS_CountSemTake() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemTake() is invoked with sem_id set to -1, an error is * - [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an
* expected. * error is expected.
* . * .
*/ */
static void test_005_003_execute(void) { static void test_005_003_execute(void) {
/* OS_CountSemTake() is invoked with sem_id set to -1, an error is /* [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -232,16 +218,16 @@ static const testcase_t test_005_003 = {
}; };
/** /**
* @page test_005_004 OS_CountSemTimedWait() errors * @page test_005_004 [5.4] OS_CountSemTimedWait() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_CountSemTimedWait() is tested. * Parameters checking in OS_CountSemTimedWait() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemTimedWait() is invoked with sem_id set to -1, an error * - [5.4.1] OS_CountSemTimedWait() is invoked with sem_id set to -1,
* is expected. * an error is expected.
* - OS_CountSemTimedWait() is invoked with msecs set to 0, an error is * - [5.4.2] OS_CountSemTimedWait() is invoked with msecs set to 0, an
* expected. * error is expected.
* . * .
*/ */
@ -258,8 +244,8 @@ static void test_005_004_teardown(void) {
static void test_005_004_execute(void) { static void test_005_004_execute(void) {
/* OS_CountSemTimedWait() is invoked with sem_id set to -1, an error /* [5.4.1] OS_CountSemTimedWait() is invoked with sem_id set to -1,
is expected.*/ an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -268,8 +254,8 @@ static void test_005_004_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
} }
/* OS_CountSemTimedWait() is invoked with msecs set to 0, an error is /* [5.4.2] OS_CountSemTimedWait() is invoked with msecs set to 0, an
expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -287,25 +273,25 @@ static const testcase_t test_005_004 = {
}; };
/** /**
* @page test_005_005 OS_CountSemGetIdByName() errors * @page test_005_005 [5.5] OS_CountSemGetIdByName() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_CountSemGetIdByName() is tested. * Parameters checking in OS_CountSemGetIdByName() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an * - [5.5.1] OS_CountSemGetIdByName() is invoked with sem_id set to
* error is expected.
* - OS_CountSemGetIdByName() is invoked with semaphore name set to
* NULL, an error is expected. * NULL, an error is expected.
* - OS_CountSemGetIdByName() is invoked with a very long task name, an * - [5.5.2] OS_CountSemGetIdByName() is invoked with semaphore name
* error is expected. * set to NULL, an error is expected.
* - [5.5.3] OS_CountSemGetIdByName() is invoked with a very long task
* name, an error is expected.
* . * .
*/ */
static void test_005_005_execute(void) { static void test_005_005_execute(void) {
/* OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an /* [5.5.1] OS_CountSemGetIdByName() is invoked with sem_id set to
error is expected.*/ NULL, an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -314,8 +300,8 @@ static void test_005_005_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_CountSemGetIdByName() is invoked with semaphore name set to /* [5.5.2] OS_CountSemGetIdByName() is invoked with semaphore name
NULL, an error is expected.*/ set to NULL, an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -324,8 +310,8 @@ static void test_005_005_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_CountSemGetIdByName() is invoked with a very long task name, an /* [5.5.3] OS_CountSemGetIdByName() is invoked with a very long task
error is expected.*/ name, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;
@ -343,14 +329,14 @@ static const testcase_t test_005_005 = {
}; };
/** /**
* @page test_005_006 OS_CountSemTimedWait() timeout functionality * @page test_005_006 [5.6] OS_CountSemTimedWait() timeout functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* OS_CountSemCreate() timeout functionality is tested. * OS_CountSemCreate() timeout functionality is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_CountSemTimedWait() is invoked with timeout set to one second, * - [5.6.1] OS_CountSemTimedWait() is invoked with timeout set to one
* an error is expected. * second, an error is expected.
* . * .
*/ */
@ -367,8 +353,8 @@ static void test_005_006_teardown(void) {
static void test_005_006_execute(void) { static void test_005_006_execute(void) {
/* OS_CountSemTimedWait() is invoked with timeout set to one second, /* [5.6.1] OS_CountSemTimedWait() is invoked with timeout set to one
an error is expected.*/ second, an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_005[]; extern const testcase_t * const test_sequence_005[];

View File

@ -1,25 +1,11 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 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 "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_006 Mutex Semaphores Functionality * @page test_sequence_006 [6] Mutex Semaphores Functionality
* *
* File: @ref test_sequence_006.c * File: @ref test_sequence_006.c
* *
@ -39,8 +25,8 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include "osapi.h" #include "osapi.h"
uint32 msid; uint32 msid;
/**************************************************************************** /****************************************************************************
@ -48,30 +34,31 @@ uint32 msid;
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_006_001 OS_MutSemCreate() and OS_MutSemDelete() errors * @page test_006_001 [6.1] OS_MutSemCreate() and OS_MutSemDelete() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is * Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is
* tested. * tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_MutSemCreate() is invoked with sem_id set to NULL, an error is * - [6.1.1] OS_MutSemCreate() is invoked with sem_id set to NULL, an
* expected. * error is expected.
* - OS_MutSemCreate() is invoked with sem_name set to NULL, an error * - [6.1.2] OS_MutSemCreate() is invoked with sem_name set to NULL, an
* is expected. * error is expected.
* - OS_MutSemCreate() is invoked with a very long timer name, an error * - [6.1.3] OS_MutSemCreate() is invoked with a very long timer name,
* is expected. * an error is expected.
* - OS_MutSemDelete() is invoked with timer_id set to -1, an error is * - [6.1.4] OS_MutSemDelete() is invoked with timer_id set to -1, an
* expected. * error is expected.
* - OS_MutSemCreate() is invoked twice with duplicated name, an error * - [6.1.5] OS_MutSemCreate() is invoked twice with duplicated name,
* is expected, then the queue is deleted using OS_MutSemDelete(). * an error is expected, then the queue is deleted using
* OS_MutSemDelete().
* . * .
*/ */
static void test_006_001_execute(void) { static void test_006_001_execute(void) {
/* OS_MutSemCreate() is invoked with sem_id set to NULL, an error is /* [6.1.1] OS_MutSemCreate() is invoked with sem_id set to NULL, an
expected.*/ error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -82,8 +69,8 @@ static void test_006_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_MutSemCreate() is invoked with sem_name set to NULL, an error /* [6.1.2] OS_MutSemCreate() is invoked with sem_name set to NULL, an
is expected.*/ error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -94,8 +81,8 @@ static void test_006_001_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_MutSemCreate() is invoked with a very long timer name, an error /* [6.1.3] OS_MutSemCreate() is invoked with a very long timer name,
is expected.*/ an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
#if 0 /* Semaphore name currently not implemented.*/ #if 0 /* Semaphore name currently not implemented.*/
@ -108,8 +95,8 @@ static void test_006_001_execute(void) {
#endif #endif
} }
/* OS_MutSemDelete() is invoked with timer_id set to -1, an error is /* [6.1.4] OS_MutSemDelete() is invoked with timer_id set to -1, an
expected.*/ error is expected.*/
test_set_step(4); test_set_step(4);
{ {
int32 err; int32 err;
@ -118,8 +105,9 @@ static void test_006_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
} }
/* OS_MutSemCreate() is invoked twice with duplicated name, an error /* [6.1.5] OS_MutSemCreate() is invoked twice with duplicated name,
is expected, then the queue is deleted using OS_MutSemDelete().*/ an error is expected, then the queue is deleted using
OS_MutSemDelete().*/
test_set_step(5); test_set_step(5);
{ {
int32 err; int32 err;
@ -146,21 +134,21 @@ static const testcase_t test_006_001 = {
}; };
/** /**
* @page test_006_002 OS_MutSemGive() errors * @page test_006_002 [6.2] OS_MutSemGive() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_MutSemGive() is tested. * Parameters checking in OS_MutSemGive() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_MutSemGive() is invoked with sem_id set to -1, an error is * - [6.2.1] OS_MutSemGive() is invoked with sem_id set to -1, an error
* expected. * is expected.
* . * .
*/ */
static void test_006_002_execute(void) { static void test_006_002_execute(void) {
/* OS_MutSemGive() is invoked with sem_id set to -1, an error is /* [6.2.1] OS_MutSemGive() is invoked with sem_id set to -1, an error
expected.*/ is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -178,21 +166,21 @@ static const testcase_t test_006_002 = {
}; };
/** /**
* @page test_006_003 OS_MutSemTake() errors * @page test_006_003 [6.3] OS_MutSemTake() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_MutSemTake() is tested. * Parameters checking in OS_MutSemTake() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_MutSemTake() is invoked with sem_id set to -1, an error is * - [6.3.1] OS_MutSemTake() is invoked with sem_id set to -1, an error
* expected. * is expected.
* . * .
*/ */
static void test_006_003_execute(void) { static void test_006_003_execute(void) {
/* OS_MutSemTake() is invoked with sem_id set to -1, an error is /* [6.3.1] OS_MutSemTake() is invoked with sem_id set to -1, an error
expected.*/ is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -210,25 +198,25 @@ static const testcase_t test_006_003 = {
}; };
/** /**
* @page test_006_004 OS_MutSemGetIdByName() errors * @page test_006_004 [6.4] OS_MutSemGetIdByName() errors
* *
* <h2>Description</h2> * <h2>Description</h2>
* Parameters checking in OS_MutSemGetIdByName() is tested. * Parameters checking in OS_MutSemGetIdByName() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an * - [6.4.1] OS_MutSemGetIdByName() is invoked with sem_id set to NULL,
* error is expected.
* - OS_MutSemGetIdByName() is invoked with semaphore name set to NULL,
* an error is expected. * an error is expected.
* - OS_MutSemGetIdByName() is invoked with a very long task name, an * - [6.4.2] OS_MutSemGetIdByName() is invoked with semaphore name set
* error is expected. * to NULL, an error is expected.
* - [6.4.3] OS_MutSemGetIdByName() is invoked with a very long task
* name, an error is expected.
* . * .
*/ */
static void test_006_004_execute(void) { static void test_006_004_execute(void) {
/* OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an /* [6.4.1] OS_MutSemGetIdByName() is invoked with sem_id set to NULL,
error is expected.*/ an error is expected.*/
test_set_step(1); test_set_step(1);
{ {
int32 err; int32 err;
@ -237,8 +225,8 @@ static void test_006_004_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, /* [6.4.2] OS_MutSemGetIdByName() is invoked with semaphore name set
an error is expected.*/ to NULL, an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
int32 err; int32 err;
@ -247,8 +235,8 @@ static void test_006_004_execute(void) {
test_assert(err == OS_INVALID_POINTER, "NULL not detected"); test_assert(err == OS_INVALID_POINTER, "NULL not detected");
} }
/* OS_MutSemGetIdByName() is invoked with a very long task name, an /* [6.4.3] OS_MutSemGetIdByName() is invoked with a very long task
error is expected.*/ name, an error is expected.*/
test_set_step(3); test_set_step(3);
{ {
int32 err; int32 err;

View File

@ -1,17 +1,3 @@
/* /* Copyright statement.*/
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
extern const testcase_t * const test_sequence_006[]; extern const testcase_t * const test_sequence_006[];

View File

@ -87,6 +87,9 @@ THD_FUNCTION(test_support, arg) {
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to threading.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "ch.h"]]></value> <value><![CDATA[#include "ch.h"]]></value>
</shared_code> </shared_code>
@ -239,6 +242,9 @@ test_assert_time_window(time + 100,
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to counter semaphores.</value>
</description> </description>
<condition>
<value>CH_CFG_USE_SEMAPHORES</value>
</condition>
<shared_code> <shared_code>
<value><![CDATA[#include "ch.h" <value><![CDATA[#include "ch.h"
@ -253,7 +259,7 @@ static semaphore_t sem1;]]></value>
<value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value> <value>Wait, Signal and Reset primitives are tested. The testing thread does not trigger a state change.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_SEMAPHORES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -316,7 +322,7 @@ test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");]]></value
<value>Wait, Signal and Reset primitives are tested. The testing thread triggers a state change.</value> <value>Wait, Signal and Reset primitives are tested. The testing thread triggers a state change.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_SEMAPHORES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -370,7 +376,7 @@ test_assert(MSG_RESET == msg, "wrong returned message");]]></value>
<value>Timeout on semaphores is tested.</value> <value>Timeout on semaphores is tested.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_SEMAPHORES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -433,6 +439,9 @@ test_assert(MSG_TIMEOUT == msg, "wrong timeout message");]]></value>
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to threads suspend/resume and event flags.</value>
</description> </description>
<condition>
<value />
</condition>
<shared_code> <shared_code>
<value><![CDATA[static thread_reference_t tr1;]]></value> <value><![CDATA[static thread_reference_t tr1;]]></value>
</shared_code> </shared_code>
@ -579,6 +588,9 @@ test_assert((eventmask_t)0 == events, "wrong events mask");]]></value>
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to mailboxes.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to mailboxes.</value>
</description> </description>
<condition>
<value>CH_CFG_USE_MAILBOXES</value>
</condition>
<shared_code> <shared_code>
<value><![CDATA[#define ALLOWED_DELAY MS2ST(5) <value><![CDATA[#define ALLOWED_DELAY MS2ST(5)
#define MB_SIZE 4 #define MB_SIZE 4
@ -595,7 +607,7 @@ static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);]]></value>
<value>The mailbox normal API is tested without triggering blocking conditions.</value> <value>The mailbox normal API is tested without triggering blocking conditions.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_MAILBOXES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -719,7 +731,7 @@ test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></va
<value>The mailbox I-Class API is tested without triggering blocking conditions.</value> <value>The mailbox I-Class API is tested without triggering blocking conditions.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_MAILBOXES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -851,7 +863,7 @@ test_assert(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");]]></va
<value>The mailbox API is tested for timeouts.</value> <value>The mailbox API is tested for timeouts.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_MAILBOXES</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -943,6 +955,9 @@ test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to memory pools.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to memory pools.</value>
</description> </description>
<condition>
<value>CH_CFG_USE_MEMPOOLS</value>
</condition>
<shared_code> <shared_code>
<value><![CDATA[#define MEMORY_POOL_SIZE 4 <value><![CDATA[#define MEMORY_POOL_SIZE 4
@ -961,13 +976,13 @@ static void *null_provider(size_t size, unsigned align) {
<cases> <cases>
<case> <case>
<brief> <brief>
<value>Loading and empting a memory pool.</value> <value>Loading and emptying a memory pool.</value>
</brief> </brief>
<description> <description>
<value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value> <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_MEMPOOLS</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -1066,13 +1081,13 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
</case> </case>
<case> <case>
<brief> <brief>
<value>Loading and empting a guarded memory pool without waiting.</value> <value>Loading and emptying a guarded memory pool without waiting.</value>
</brief> </brief>
<description> <description>
<value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value> <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description> </description>
<condition> <condition>
<value>(CH_CFG_USE_MEMPOOLS &amp;&amp; CH_CFG_USE_SEMAPHORES)</value> <value>CH_CFG_USE_SEMAPHORES</value>
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -1165,7 +1180,7 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
<value>The timeout features for the Guarded Memory Pools is tested.</value> <value>The timeout features for the Guarded Memory Pools is tested.</value>
</description> </description>
<condition> <condition>
<value>(CH_CFG_USE_MEMPOOLS &amp;&amp; CH_CFG_USE_SEMAPHORES)</value> <value>CH_CFG_USE_SEMAPHORES</value>
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -1204,6 +1219,9 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
<description> <description>
<value>This sequence tests the ChibiOS/NIL functionalities related to memory heaps.</value> <value>This sequence tests the ChibiOS/NIL functionalities related to memory heaps.</value>
</description> </description>
<condition>
<value>CH_CFG_USE_HEAP</value>
</condition>
<shared_code> <shared_code>
<value><![CDATA[#define ALLOC_SIZE 16 <value><![CDATA[#define ALLOC_SIZE 16
#define HEAP_SIZE (ALLOC_SIZE * 8) #define HEAP_SIZE (ALLOC_SIZE * 8)
@ -1220,7 +1238,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);]]></value>
<value>Series of allocations/deallocations are performed in carefully designed sequences in order to stimulate all the possible code paths inside the allocator. The test expects to find the heap back to the initial status after each sequence.</value> <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> </description>
<condition> <condition>
<value>CH_CFG_USE_HEAP</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>
@ -1398,7 +1416,7 @@ test_assert(n == sz, "size changed");]]></value>
<value>The default heap is pre-allocated in the system. We test base functionality.</value> <value>The default heap is pre-allocated in the system. We test base functionality.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_HEAP</value> <value />
</condition> </condition>
<various_code> <various_code>
<setup_code> <setup_code>

View File

@ -33,15 +33,14 @@
/** /**
* @file test_root.c * @file test_root.c
* @brief Test Suite root structures code. * @brief Test Suite root structures code.
*
* @addtogroup SPC5_TEST_ROOT
* @{
*/ */
#include "hal.h" #include "hal.h"
#include "ch_test.h" #include "ch_test.h"
#include "test_root.h" #include "test_root.h"
#if !defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* Module exported variables. */ /* Module exported variables. */
/*===========================================================================*/ /*===========================================================================*/
@ -97,4 +96,4 @@ THD_FUNCTION(test_support, arg) {
} }
} }
/** @} */ #endif /* !defined(__DOXYGEN__) */

View File

@ -17,9 +17,6 @@
/** /**
* @file test_root.h * @file test_root.h
* @brief Test Suite root structures header. * @brief Test Suite root structures header.
*
* @addtogroup SPC5_TEST_ROOT
* @{
*/ */
#ifndef _SPC5_TEST_ROOT_H_ #ifndef _SPC5_TEST_ROOT_H_
@ -32,6 +29,8 @@
#include "test_sequence_005.h" #include "test_sequence_005.h"
#include "test_sequence_006.h" #include "test_sequence_006.h"
#if !defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
@ -57,6 +56,6 @@ extern THD_WORKING_AREA(wa_test_support, 128);
THD_FUNCTION(test_support, arg); THD_FUNCTION(test_support, arg);
#endif /* _SPC5_TEST_ROOT_H_ */ #endif /* !defined(__DOXYGEN__) */
/** @} */ #endif /* _SPC5_TEST_ROOT_H_ */

View File

@ -19,7 +19,7 @@
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_001 Threads Functionality * @page test_sequence_001 [1] Threads Functionality
* *
* File: @ref test_sequence_001.c * File: @ref test_sequence_001.c
* *
@ -44,21 +44,21 @@
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_001_001 System Tick Counter functionality * @page test_001_001 [1.1] System Tick Counter functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* The functionality of the API @p chVTGetSystemTimeX() is tested. * The functionality of the API @p chVTGetSystemTimeX() is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - A System Tick Counter increment is expected, the test simply hangs * - [1.1.1] A System Tick Counter increment is expected, the test
* if it does not happen. * simply hangs if it does not happen.
* . * .
*/ */
static void test_001_001_execute(void) { static void test_001_001_execute(void) {
/* A System Tick Counter increment is expected, the test simply hangs /* [1.1.1] A System Tick Counter increment is expected, the test
if it does not happen.*/ simply hangs if it does not happen.*/
test_set_step(1); test_set_step(1);
{ {
systime_t time = chVTGetSystemTimeX(); systime_t time = chVTGetSystemTimeX();
@ -75,30 +75,34 @@ static const testcase_t test_001_001 = {
}; };
/** /**
* @page test_001_002 Thread Sleep functionality * @page test_001_002 [1.2] Thread Sleep functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* The functionality of @p chThdSleep() and derivatives is tested. * The functionality of @p chThdSleep() and derivatives is tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The current system time is read then a sleep is performed for 100 * - [1.2.1] The current system time is read then a sleep is performed
* system ticks and on exit the system time is verified again. * for 100 system ticks and on exit the system time is verified
* - The current system time is read then a sleep is performed for * again.
* 100000 microseconds and on exit the system time is verified again. * - [1.2.2] The current system time is read then a sleep is performed
* - The current system time is read then a sleep is performed for 100 * for 100000 microseconds and on exit the system time is verified
* milliseconds and on exit the system time is verified again. * again.
* - The current system time is read then a sleep is performed for 1 * - [1.2.3] The current system time is read then a sleep is performed
* second and on exit the system time is verified again. * for 100 milliseconds and on exit the system time is verified
* - Function chThdSleepUntil() is tested with a timeline of "now" + * again.
* 100 ticks. * - [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) { static void test_001_002_execute(void) {
systime_t time; systime_t time;
/* The current system time is read then a sleep is performed for 100 /* [1.2.1] The current system time is read then a sleep is performed
system ticks and on exit the system time is verified again.*/ for 100 system ticks and on exit the system time is verified
again.*/
test_set_step(1); test_set_step(1);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -108,8 +112,8 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* The current system time is read then a sleep is performed for /* [1.2.2] The current system time is read then a sleep is performed
100000 microseconds and on exit the system time is verified for 100000 microseconds and on exit the system time is verified
again.*/ again.*/
test_set_step(2); test_set_step(2);
{ {
@ -120,8 +124,9 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* The current system time is read then a sleep is performed for 100 /* [1.2.3] The current system time is read then a sleep is performed
milliseconds and on exit the system time is verified again.*/ for 100 milliseconds and on exit the system time is verified
again.*/
test_set_step(3); test_set_step(3);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -131,8 +136,8 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* The current system time is read then a sleep is performed for 1 /* [1.2.4] The current system time is read then a sleep is performed
second and on exit the system time is verified again.*/ for 1 second and on exit the system time is verified again.*/
test_set_step(4); test_set_step(4);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -142,8 +147,8 @@ static void test_001_002_execute(void) {
"out of time window"); "out of time window");
} }
/* Function chThdSleepUntil() is tested with a timeline of "now" + /* [1.2.5] Function chThdSleepUntil() is tested with a timeline of
100 ticks.*/ "now" + 100 ticks.*/
test_set_step(5); test_set_step(5);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();

View File

@ -19,7 +19,7 @@
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_002 Semaphores * @page test_sequence_002 [2] Semaphores
* *
* File: @ref test_sequence_002.c * File: @ref test_sequence_002.c
* *
@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to * This sequence tests the ChibiOS/NIL functionalities related to
* counter semaphores. * counter semaphores.
* *
* <h2>Conditions</h2>
* This sequence is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Cases</h2> * <h2>Test Cases</h2>
* - @subpage test_002_001 * - @subpage test_002_001
* - @subpage test_002_002 * - @subpage test_002_002
@ -34,6 +40,8 @@
* . * .
*/ */
#if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/**************************************************************************** /****************************************************************************
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
@ -46,27 +54,20 @@ static semaphore_t sem1;
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/** /**
* @page test_002_001 Semaphore primitives, no state change * @page test_002_001 [2.1] Semaphore primitives, no state change
* *
* <h2>Description</h2> * <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread * Wait, Signal and Reset primitives are tested. The testing thread
* does not trigger a state change. * does not trigger a state change.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and * - [2.1.1] The function chSemWait() is invoked, after return the
* the returned message are tested. * counter and the returned message are tested.
* - The function chSemSignal() is invoked, after return the counter is * - [2.1.2] The function chSemSignal() is invoked, after return the
* tested. * counter is tested.
* - The function chSemReset() is invoked, after return the counter is * - [2.1.3] The function chSemReset() is invoked, after return the
* tested. * counter is tested.
* . * .
*/ */
@ -80,8 +81,8 @@ static void test_002_001_teardown(void) {
static void test_002_001_execute(void) { static void test_002_001_execute(void) {
/* The function chSemWait() is invoked, after return the counter and /* [2.1.1] The function chSemWait() is invoked, after return the
the returned message are tested.*/ counter and the returned message are tested.*/
test_set_step(1); test_set_step(1);
{ {
msg_t msg; msg_t msg;
@ -91,16 +92,16 @@ static void test_002_001_execute(void) {
test_assert(MSG_OK == msg, "wrong returned message"); test_assert(MSG_OK == msg, "wrong returned message");
} }
/* The function chSemSignal() is invoked, after return the counter is /* [2.1.2] The function chSemSignal() is invoked, after return the
tested.*/ counter is tested.*/
test_set_step(2); test_set_step(2);
{ {
chSemSignal(&sem1); chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value"); test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
} }
/* The function chSemReset() is invoked, after return the counter is /* [2.1.3] The function chSemReset() is invoked, after return the
tested.*/ counter is tested.*/
test_set_step(3); test_set_step(3);
{ {
chSemReset(&sem1, 2); chSemReset(&sem1, 2);
@ -114,29 +115,21 @@ static const testcase_t test_002_001 = {
test_002_001_teardown, test_002_001_teardown,
test_002_001_execute test_002_001_execute
}; };
#endif /* CH_CFG_USE_SEMAPHORES */
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/** /**
* @page test_002_002 Semaphore primitives, with state change * @page test_002_002 [2.2] Semaphore primitives, with state change
* *
* <h2>Description</h2> * <h2>Description</h2>
* Wait, Signal and Reset primitives are tested. The testing thread * Wait, Signal and Reset primitives are tested. The testing thread
* triggers a state change. * triggers a state change.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The function chSemWait() is invoked, after return the counter and * - [2.2.1] The function chSemWait() is invoked, after return the
* the returned message are tested. The semaphore is signaled by * counter and the returned message are tested. The semaphore is
* another thread. * signaled by another thread.
* - The function chSemWait() is invoked, after return the counter and * - [2.2.2] The function chSemWait() is invoked, after return the
* the returned message are tested. The semaphore is reset by another * counter and the returned message are tested. The semaphore is
* thread. * reset by another thread.
* . * .
*/ */
@ -150,9 +143,9 @@ static void test_002_002_teardown(void) {
static void test_002_002_execute(void) { static void test_002_002_execute(void) {
/* The function chSemWait() is invoked, after return the counter and /* [2.2.1] The function chSemWait() is invoked, after return the
the returned message are tested. The semaphore is signaled by counter and the returned message are tested. The semaphore is
another thread.*/ signaled by another thread.*/
test_set_step(1); test_set_step(1);
{ {
msg_t msg; msg_t msg;
@ -162,9 +155,9 @@ static void test_002_002_execute(void) {
test_assert(MSG_OK == msg, "wrong returned message"); test_assert(MSG_OK == msg, "wrong returned message");
} }
/* The function chSemWait() is invoked, after return the counter and /* [2.2.2] The function chSemWait() is invoked, after return the
the returned message are tested. The semaphore is reset by another counter and the returned message are tested. The semaphore is
thread.*/ reset by another thread.*/
test_set_step(2); test_set_step(2);
{ {
msg_t msg; msg_t msg;
@ -181,27 +174,20 @@ static const testcase_t test_002_002 = {
test_002_002_teardown, test_002_002_teardown,
test_002_002_execute test_002_002_execute
}; };
#endif /* CH_CFG_USE_SEMAPHORES */
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
/** /**
* @page test_002_003 Semaphores timeout * @page test_002_003 [2.3] Semaphores timeout
* *
* <h2>Description</h2> * <h2>Description</h2>
* Timeout on semaphores is tested. * Timeout on semaphores is tested.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_SEMAPHORES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The function chSemWaitTimeout() is invoked a first time, after * - [2.3.1] The function chSemWaitTimeout() is invoked a first time,
* after return the system time, the counter and the returned message
* are tested.
* - [2.3.2] The function chSemWaitTimeout() is invoked again, after
* return the system time, the counter and the returned message are * return the system time, the counter and the returned message are
* tested. * 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; systime_t time;
msg_t msg; msg_t msg;
/* The function chSemWaitTimeout() is invoked a first time, after /* [2.3.1] The function chSemWaitTimeout() is invoked a first time,
return the system time, the counter and the returned message are after return the system time, the counter and the returned message
tested.*/ are tested.*/
test_set_step(1); test_set_step(1);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -231,8 +217,9 @@ static void test_002_003_execute(void) {
test_assert(MSG_TIMEOUT == msg, "wrong timeout message"); test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
} }
/* The function chSemWaitTimeout() is invoked again, after return the /* [2.3.2] The function chSemWaitTimeout() is invoked again, after
system time, the counter and the returned message are tested.*/ return the system time, the counter and the returned message are
tested.*/
test_set_step(2); test_set_step(2);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -251,7 +238,6 @@ static const testcase_t test_002_003 = {
test_002_003_teardown, test_002_003_teardown,
test_002_003_execute test_002_003_execute
}; };
#endif /* CH_CFG_USE_SEMAPHORES */
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
@ -261,14 +247,10 @@ static const testcase_t test_002_003 = {
* @brief Semaphores. * @brief Semaphores.
*/ */
const testcase_t * const test_sequence_002[] = { const testcase_t * const test_sequence_002[] = {
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_001, &test_002_001,
#endif
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_002, &test_002_002,
#endif
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
&test_002_003, &test_002_003,
#endif
NULL NULL
}; };
#endif /* CH_CFG_USE_SEMAPHORES */

View File

@ -19,7 +19,7 @@
#include "test_root.h" #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 * File: @ref test_sequence_003.c
* *
@ -44,19 +44,19 @@ static thread_reference_t tr1;
****************************************************************************/ ****************************************************************************/
/** /**
* @page test_003_001 Suspend and Resume functionality * @page test_003_001 [3.1] Suspend and Resume functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* The functionality of chThdSuspendTimeoutS() and chThdResumeI() is * The functionality of chThdSuspendTimeoutS() and chThdResumeI() is
* tested. * tested.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - The function chThdSuspendTimeoutS() is invoked, the thread is * - [3.1.1] The function chThdSuspendTimeoutS() is invoked, the thread
* remotely resumed with message @p MSG_OK. On return the message and * 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 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; systime_t time;
msg_t msg; msg_t msg;
/* The function chThdSuspendTimeoutS() is invoked, the thread is /* [3.1.1] The function chThdSuspendTimeoutS() is invoked, the thread
remotely resumed with message @p MSG_OK. On return the message and is remotely resumed with message @p MSG_OK. On return the message
the state of the reference are tested.*/ and the state of the reference are tested.*/
test_set_step(1); test_set_step(1);
{ {
chSysLock(); chSysLock();
@ -80,9 +80,9 @@ static void test_003_001_execute(void) {
test_assert(MSG_OK == msg,"wrong returned message"); test_assert(MSG_OK == msg,"wrong returned message");
} }
/* The function chThdSuspendTimeoutS() is invoked, the thread is not /* [3.1.2] The function chThdSuspendTimeoutS() is invoked, the thread
resumed so a timeout must occur. On return the message and the is not resumed so a timeout must occur. On return the message and
state of the reference are tested.*/ the state of the reference are tested.*/
test_set_step(2); test_set_step(2);
{ {
chSysLock(); chSysLock();
@ -104,9 +104,9 @@ static const testcase_t test_003_001 = {
test_003_001_execute test_003_001_execute
}; };
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) #if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
/** /**
* @page test_003_002 Events Flags functionality * @page test_003_002 [3.2] Events Flags functionality
* *
* <h2>Description</h2> * <h2>Description</h2>
* Event flags functionality is tested. * Event flags functionality is tested.
@ -118,15 +118,15 @@ static const testcase_t test_003_001 = {
* . * .
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - A set of event flags are set on the current thread then the * - [3.2.1] A set of event flags are set on the current thread then
* function chEvtWaitAnyTimeout() is invoked, the function is * the function chEvtWaitAnyTimeout() is invoked, the function is
* supposed to return immediately because the event flags are already * supposed to return immediately because the event flags are already
* pending, after return the events mask is tested. * 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 * chEvtWaitAnyTimeout() is invoked, after return the events mask is
* tested. The thread is signaled by another thread. * tested. The thread is signaled by another thread.
* - The function chEvtWaitAnyTimeout() is invoked, no event can wakeup * - [3.2.3] The function chEvtWaitAnyTimeout() is invoked, no event
* the thread, the function must return because timeout. * can wakeup the thread, the function must return because timeout.
* . * .
*/ */
@ -134,8 +134,8 @@ static void test_003_002_execute(void) {
systime_t time; systime_t time;
eventmask_t events; eventmask_t events;
/* A set of event flags are set on the current thread then the /* [3.2.1] A set of event flags are set on the current thread then
function chEvtWaitAnyTimeout() is invoked, the function is the function chEvtWaitAnyTimeout() is invoked, the function is
supposed to return immediately because the event flags are already supposed to return immediately because the event flags are already
pending, after return the events mask is tested.*/ pending, after return the events mask is tested.*/
test_set_step(1); test_set_step(1);
@ -147,7 +147,7 @@ static void test_003_002_execute(void) {
test_assert((eventmask_t)0x55 == events, "wrong events mask"); 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 chEvtWaitAnyTimeout() is invoked, after return the events mask is
tested. The thread is signaled by another thread.*/ tested. The thread is signaled by another thread.*/
test_set_step(2); test_set_step(2);
@ -159,8 +159,8 @@ static void test_003_002_execute(void) {
test_assert((eventmask_t)0x55 == events, "wrong events mask"); test_assert((eventmask_t)0x55 == events, "wrong events mask");
} }
/* The function chEvtWaitAnyTimeout() is invoked, no event can wakeup /* [3.2.3] The function chEvtWaitAnyTimeout() is invoked, no event
the thread, the function must return because timeout.*/ can wakeup the thread, the function must return because timeout.*/
test_set_step(3); test_set_step(3);
{ {
time = chVTGetSystemTimeX(); time = chVTGetSystemTimeX();
@ -189,7 +189,7 @@ static const testcase_t test_003_002 = {
*/ */
const testcase_t * const test_sequence_003[] = { const testcase_t * const test_sequence_003[] = {
&test_003_001, &test_003_001,
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) #if (CH_CFG_USE_EVENTS) || defined(__DOXYGEN__)
&test_003_002, &test_003_002,
#endif #endif
NULL NULL

View File

@ -19,7 +19,7 @@
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_004 Mailboxes * @page test_sequence_004 [4] Mailboxes
* *
* File: @ref test_sequence_004.c * File: @ref test_sequence_004.c
* *
@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to * This sequence tests the ChibiOS/NIL functionalities related to
* mailboxes. * 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> * <h2>Test Cases</h2>
* - @subpage test_004_001 * - @subpage test_004_001
* - @subpage test_004_002 * - @subpage test_004_002
@ -34,6 +40,8 @@
* . * .
*/ */
#if (CH_CFG_USE_MAILBOXES) || defined(__DOXYGEN__)
/**************************************************************************** /****************************************************************************
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
@ -48,31 +56,27 @@ static MAILBOX_DECL(mb1, mb_buffer, MB_SIZE);
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/** /**
* @page test_004_001 Mailbox normal API, non-blocking tests * @page test_004_001 [4.1] Mailbox normal API, non-blocking tests
* *
* <h2>Description</h2> * <h2>Description</h2>
* The mailbox normal API is tested without triggering blocking * The mailbox normal API is tested without triggering blocking
* conditions. * conditions.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MAILBOXES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Testing the mailbox size. * - [4.1.1] Testing the mailbox size.
* - Resetting the mailbox, conditions are checked, no errors expected. * - [4.1.2] Resetting the mailbox, conditions are checked, no errors
* - Filling the mailbox using chMBPost() and chMBPostAhead() once, no * expected.
* errors expected. * - [4.1.3] Filling the mailbox using chMBPost() and chMBPostAhead()
* - Testing intermediate conditions. Data pointers must be aligned, * once, no errors expected.
* semaphore counters are checked. * - [4.1.4] Testing intermediate conditions. Data pointers must be
* - Emptying the mailbox using chMBFetch(), no errors expected. * aligned, semaphore counters are checked.
* - Posting and then fetching one more message, no errors expected. * - [4.1.5] Emptying the mailbox using chMBFetch(), no errors
* - Testing final conditions. Data pointers must be aligned to buffer * expected.
* start, semaphore counters are checked. * - [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; msg_t msg1, msg2;
unsigned i; unsigned i;
/* Testing the mailbox size.*/ /* [4.1.1] Testing the mailbox size.*/
test_set_step(1); test_set_step(1);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size"); 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.*/ expected.*/
test_set_step(2); 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"); test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
} }
/* Filling the mailbox using chMBPost() and chMBPostAhead() once, no /* [4.1.3] Filling the mailbox using chMBPost() and chMBPostAhead()
errors expected.*/ once, no errors expected.*/
test_set_step(3); test_set_step(3);
{ {
for (i = 0; i < MB_SIZE - 1; i++) { 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"); test_assert(msg1 == MSG_OK, "wrong wake-up message");
} }
/* Testing intermediate conditions. Data pointers must be aligned, /* [4.1.4] Testing intermediate conditions. Data pointers must be
semaphore counters are checked.*/ aligned, semaphore counters are checked.*/
test_set_step(4); test_set_step(4);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty"); 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"); 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); test_set_step(5);
{ {
for (i = 0; i < MB_SIZE; i++) { 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"); 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); test_set_step(6);
{ {
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); 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"); test_assert(msg1 == MSG_OK, "wrong wake-up message");
} }
/* Testing final conditions. Data pointers must be aligned to buffer /* [4.1.7] Testing final conditions. Data pointers must be aligned to
start, semaphore counters are checked.*/ buffer start, semaphore counters are checked.*/
test_set_step(7); test_set_step(7);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); 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_teardown,
test_004_001_execute test_004_001_execute
}; };
#endif /* CH_CFG_USE_MAILBOXES */
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/** /**
* @page test_004_002 Mailbox I-Class API, non-blocking tests * @page test_004_002 [4.2] Mailbox I-Class API, non-blocking tests
* *
* <h2>Description</h2> * <h2>Description</h2>
* The mailbox I-Class API is tested without triggering blocking * The mailbox I-Class API is tested without triggering blocking
* conditions. * conditions.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MAILBOXES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Testing the mailbox size. * - [4.2.1] Testing the mailbox size.
* - Resetting the mailbox, conditions are checked, no errors expected. * - [4.2.2] Resetting the mailbox, conditions are checked, no errors
* - Filling the mailbox using chMBPostI() and chMBPostAheadI() once, * expected.
* no errors expected. * - [4.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
* - Testing intermediate conditions. Data pointers must be aligned, * once, no errors expected.
* semaphore counters are checked. * - [4.2.4] Testing intermediate conditions. Data pointers must be
* - Emptying the mailbox using chMBFetchI(), no errors expected. * aligned, semaphore counters are checked.
* - Posting and then fetching one more message, no errors expected. * - [4.2.5] Emptying the mailbox using chMBFetchI(), no errors
* - Testing final conditions. Data pointers must be aligned to buffer * expected.
* start, semaphore counters are checked. * - [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; msg_t msg1, msg2;
unsigned i; unsigned i;
/* Testing the mailbox size.*/ /* [4.2.1] Testing the mailbox size.*/
test_set_step(1); test_set_step(1);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "wrong size"); 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.*/ expected.*/
test_set_step(2); 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"); test_assert_lock(mb1.buffer == mb1.rdptr, "read pointer not aligned to base");
} }
/* Filling the mailbox using chMBPostI() and chMBPostAheadI() once, /* [4.2.3] Filling the mailbox using chMBPostI() and chMBPostAheadI()
no errors expected.*/ once, no errors expected.*/
test_set_step(3); test_set_step(3);
{ {
for (i = 0; i < MB_SIZE - 1; i++) { 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"); test_assert(msg1 == MSG_OK, "wrong wake-up message");
} }
/* Testing intermediate conditions. Data pointers must be aligned, /* [4.2.4] Testing intermediate conditions. Data pointers must be
semaphore counters are checked.*/ aligned, semaphore counters are checked.*/
test_set_step(4); test_set_step(4);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == 0, "still empty"); 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"); 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); test_set_step(5);
{ {
for (i = 0; i < MB_SIZE; i++) { 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"); 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); test_set_step(6);
{ {
msg1 = chMBPost(&mb1, 'B' + i, TIME_INFINITE); 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"); test_assert(msg1 == MSG_OK, "wrong wake-up message");
} }
/* Testing final conditions. Data pointers must be aligned to buffer /* [4.2.7] Testing final conditions. Data pointers must be aligned to
start, semaphore counters are checked.*/ buffer start, semaphore counters are checked.*/
test_set_step(7); test_set_step(7);
{ {
test_assert_lock(chMBGetFreeCountI(&mb1) == MB_SIZE, "not empty"); 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_teardown,
test_004_002_execute test_004_002_execute
}; };
#endif /* CH_CFG_USE_MAILBOXES */
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
/** /**
* @page test_004_003 Mailbox timeouts * @page test_004_003 [4.3] Mailbox timeouts
* *
* <h2>Description</h2> * <h2>Description</h2>
* The mailbox API is tested for timeouts. * The mailbox API is tested for timeouts.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MAILBOXES
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Filling the mailbox. * - [4.3.1] Filling the mailbox.
* - Testing chMBPost(), chMBPostI(), chMBPostAhead() and * - [4.3.2] Testing chMBPost(), chMBPostI(), chMBPostAhead() and
* chMBPostAheadI() timeout. * chMBPostAheadI() timeout.
* - Resetting the mailbox. * - [4.3.3] Resetting the mailbox.
* - Testing chMBFetch() and chMBFetchI() timeout. * - [4.3.4] Testing chMBFetch() and chMBFetchI() timeout.
* . * .
*/ */
@ -324,7 +319,7 @@ static void test_004_003_execute(void) {
msg_t msg1, msg2; msg_t msg1, msg2;
unsigned i; unsigned i;
/* Filling the mailbox.*/ /* [4.3.1] Filling the mailbox.*/
test_set_step(1); test_set_step(1);
{ {
for (i = 0; i < MB_SIZE; i++) { 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.*/ chMBPostAheadI() timeout.*/
test_set_step(2); test_set_step(2);
{ {
@ -351,13 +346,13 @@ static void test_004_003_execute(void) {
test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message"); test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");
} }
/* Resetting the mailbox.*/ /* [4.3.3] Resetting the mailbox.*/
test_set_step(3); test_set_step(3);
{ {
chMBReset(&mb1); chMBReset(&mb1);
} }
/* Testing chMBFetch() and chMBFetchI() timeout.*/ /* [4.3.4] Testing chMBFetch() and chMBFetchI() timeout.*/
test_set_step(4); test_set_step(4);
{ {
msg1 = chMBFetch(&mb1, &msg2, 1); msg1 = chMBFetch(&mb1, &msg2, 1);
@ -375,7 +370,6 @@ static const testcase_t test_004_003 = {
test_004_003_teardown, test_004_003_teardown,
test_004_003_execute test_004_003_execute
}; };
#endif /* CH_CFG_USE_MAILBOXES */
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
@ -385,14 +379,10 @@ static const testcase_t test_004_003 = {
* @brief Mailboxes. * @brief Mailboxes.
*/ */
const testcase_t * const test_sequence_004[] = { const testcase_t * const test_sequence_004[] = {
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_001, &test_004_001,
#endif
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_002, &test_004_002,
#endif
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
&test_004_003, &test_004_003,
#endif
NULL NULL
}; };
#endif /* CH_CFG_USE_MAILBOXES */

View File

@ -19,7 +19,7 @@
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_005 Memory Pools * @page test_sequence_005 [5] Memory Pools
* *
* File: @ref test_sequence_005.c * File: @ref test_sequence_005.c
* *
@ -27,6 +27,12 @@
* This sequence tests the ChibiOS/NIL functionalities related to * This sequence tests the ChibiOS/NIL functionalities related to
* memory pools. * 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> * <h2>Test Cases</h2>
* - @subpage test_005_001 * - @subpage test_005_001
* - @subpage test_005_002 * - @subpage test_005_002
@ -34,6 +40,8 @@
* . * .
*/ */
#if (CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
/**************************************************************************** /****************************************************************************
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
@ -56,29 +64,22 @@ static void *null_provider(size_t size, unsigned align) {
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
/** /**
* @page test_005_001 Loading and empting a memory pool * @page test_005_001 [5.1] Loading and emptying a memory pool
* *
* <h2>Description</h2> * <h2>Description</h2>
* The memory pool functionality is tested by loading and empting it, * The memory pool functionality is tested by loading and emptying it,
* all conditions are tested. * all conditions are tested.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_MEMPOOLS
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Adding the objects to the pool using chPoolLoadArray(). * - [5.1.1] Adding the objects to the pool using chPoolLoadArray().
* - Emptying the pool using chPoolAlloc(). * - [5.1.2] Emptying the pool using chPoolAlloc().
* - Now must be empty. * - [5.1.3] Now must be empty.
* - Adding the objects to the pool using chPoolFree(). * - [5.1.4] Adding the objects to the pool using chPoolFree().
* - Emptying the pool using chPoolAlloc() again. * - [5.1.5] Emptying the pool using chPoolAlloc() again.
* - Now must be empty again. * - [5.1.6] Now must be empty again.
* - Covering the case where a provider is unable to return more * - [5.1.7] Covering the case where a provider is unable to return
* memory. * more memory.
* . * .
*/ */
@ -89,47 +90,47 @@ static void test_005_001_setup(void) {
static void test_005_001_execute(void) { static void test_005_001_execute(void) {
unsigned i; 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); test_set_step(1);
{ {
chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE); chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);
} }
/* Emptying the pool using chPoolAlloc().*/ /* [5.1.2] Emptying the pool using chPoolAlloc().*/
test_set_step(2); test_set_step(2);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty"); test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
} }
/* Now must be empty.*/ /* [5.1.3] Now must be empty.*/
test_set_step(3); test_set_step(3);
{ {
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty"); 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); test_set_step(4);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
chPoolFree(&mp1, &objects[i]); chPoolFree(&mp1, &objects[i]);
} }
/* Emptying the pool using chPoolAlloc() again.*/ /* [5.1.5] Emptying the pool using chPoolAlloc() again.*/
test_set_step(5); test_set_step(5);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chPoolAlloc(&mp1) != NULL, "list empty"); 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_set_step(6);
{ {
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty"); test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
} }
/* Covering the case where a provider is unable to return more /* [5.1.7] Covering the case where a provider is unable to return
memory.*/ more memory.*/
test_set_step(7); test_set_step(7);
{ {
chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider); 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 = { static const testcase_t test_005_001 = {
"Loading and empting a memory pool", "Loading and emptying a memory pool",
test_005_001_setup, test_005_001_setup,
NULL, NULL,
test_005_001_execute test_005_001_execute
}; };
#endif /* CH_CFG_USE_MEMPOOLS */
#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__) #if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/** /**
* @page test_005_002 Loading and empting a guarded memory pool without waiting * @page test_005_002 [5.2] Loading and emptying a guarded memory pool without waiting
* *
* <h2>Description</h2> * <h2>Description</h2>
* The memory pool functionality is tested by loading and empting it, * The memory pool functionality is tested by loading and emptying it,
* all conditions are tested. * all conditions are tested.
* *
* <h2>Conditions</h2> * <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition * This test is only executed if the following preprocessor condition
* evaluates to true: * evaluates to true:
* - (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) * - CH_CFG_USE_SEMAPHORES
* . * .
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Adding the objects to the pool using chGuardedPoolLoadArray(). * - [5.2.1] Adding the objects to the pool using
* - Emptying the pool using chGuardedPoolAllocTimeout(). * chGuardedPoolLoadArray().
* - Now must be empty. * - [5.2.2] Emptying the pool using chGuardedPoolAllocTimeout().
* - Adding the objects to the pool using chGuardedPoolFree(). * - [5.2.3] Now must be empty.
* - Emptying the pool using chGuardedPoolAllocTimeout() again. * - [5.2.4] Adding the objects to the pool using chGuardedPoolFree().
* - Now must be empty again. * - [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) { static void test_005_002_execute(void) {
unsigned i; 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); test_set_step(1);
{ {
chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE); chGuardedPoolLoadArray(&gmp1, objects, MEMORY_POOL_SIZE);
} }
/* Emptying the pool using chGuardedPoolAllocTimeout().*/ /* [5.2.2] Emptying the pool using chGuardedPoolAllocTimeout().*/
test_set_step(2); test_set_step(2);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty"); 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_set_step(3);
{ {
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty"); 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); test_set_step(4);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
chGuardedPoolFree(&gmp1, &objects[i]); chGuardedPoolFree(&gmp1, &objects[i]);
} }
/* Emptying the pool using chGuardedPoolAllocTimeout() again.*/ /* [5.2.5] Emptying the pool using chGuardedPoolAllocTimeout()
again.*/
test_set_step(5); test_set_step(5);
{ {
for (i = 0; i < MEMORY_POOL_SIZE; i++) for (i = 0; i < MEMORY_POOL_SIZE; i++)
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) != NULL, "list empty"); 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_set_step(6);
{ {
test_assert(chGuardedPoolAllocTimeout(&gmp1, TIME_IMMEDIATE) == NULL, "list not empty"); 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 = { 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, test_005_002_setup,
NULL, NULL,
test_005_002_execute test_005_002_execute
}; };
#endif /* (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) */ #endif /* CH_CFG_USE_SEMAPHORES */
#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__) #if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
/** /**
* @page test_005_003 Guarded Memory Pools timeout * @page test_005_003 [5.3] Guarded Memory Pools timeout
* *
* <h2>Description</h2> * <h2>Description</h2>
* The timeout features for the Guarded Memory Pools is tested. * The timeout features for the Guarded Memory Pools is tested.
@ -234,12 +238,12 @@ static const testcase_t test_005_002 = {
* <h2>Conditions</h2> * <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition * This test is only executed if the following preprocessor condition
* evaluates to true: * evaluates to true:
* - (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) * - CH_CFG_USE_SEMAPHORES
* . * .
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Trying to allocate with 100mS timeout, must fail because the pool * - [5.3.1] Trying to allocate with 100mS timeout, must fail because
* is empty. * the pool is empty.
* . * .
*/ */
@ -249,8 +253,8 @@ static void test_005_003_setup(void) {
static void test_005_003_execute(void) { static void test_005_003_execute(void) {
/* Trying to allocate with 100mS timeout, must fail because the pool /* [5.3.1] Trying to allocate with 100mS timeout, must fail because
is empty.*/ the pool is empty.*/
test_set_step(1); test_set_step(1);
{ {
test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty"); test_assert(chGuardedPoolAllocTimeout(&gmp1, MS2ST(100)) == NULL, "list not empty");
@ -263,7 +267,7 @@ static const testcase_t test_005_003 = {
NULL, NULL,
test_005_003_execute test_005_003_execute
}; };
#endif /* (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) */ #endif /* CH_CFG_USE_SEMAPHORES */
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
@ -273,14 +277,14 @@ static const testcase_t test_005_003 = {
* @brief Memory Pools. * @brief Memory Pools.
*/ */
const testcase_t * const test_sequence_005[] = { const testcase_t * const test_sequence_005[] = {
#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
&test_005_001, &test_005_001,
#endif #if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_005_002, &test_005_002,
#endif #endif
#if (CH_CFG_USE_MEMPOOLS && CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__) #if (CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
&test_005_003, &test_005_003,
#endif #endif
NULL NULL
}; };
#endif /* CH_CFG_USE_MEMPOOLS */

View File

@ -19,7 +19,7 @@
#include "test_root.h" #include "test_root.h"
/** /**
* @page test_sequence_006 Memory Heaps * @page test_sequence_006 [6] Memory Heaps
* *
* File: @ref test_sequence_006.c * File: @ref test_sequence_006.c
* *
@ -27,12 +27,20 @@
* This sequence tests the ChibiOS/NIL functionalities related to * This sequence tests the ChibiOS/NIL functionalities related to
* memory heaps. * 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> * <h2>Test Cases</h2>
* - @subpage test_006_001 * - @subpage test_006_001
* - @subpage test_006_002 * - @subpage test_006_002
* . * .
*/ */
#if (CH_CFG_USE_HEAP) || defined(__DOXYGEN__)
/**************************************************************************** /****************************************************************************
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
@ -47,9 +55,8 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/** /**
* @page test_006_001 Allocation and fragmentation * @page test_006_001 [6.1] Allocation and fragmentation
* *
* <h2>Description</h2> * <h2>Description</h2>
* Series of allocations/deallocations are performed in carefully * 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 * inside the allocator. The test expects to find the heap back to the
* initial status after each sequence. * initial status after each sequence.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_HEAP
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Testing initial conditions, the heap must not be fragmented and * - [6.1.1] Testing initial conditions, the heap must not be
* one free block present. * fragmented and one free block present.
* - Trying to allocate an block bigger than available space, an error * - [6.1.2] Trying to allocate an block bigger than available space,
* is expected. * an error is expected.
* - Single block allocation using chHeapAlloc() then the block is * - [6.1.3] Single block allocation using chHeapAlloc() then the block
* freed using chHeapFree(), must not fail. * is freed using chHeapFree(), must not fail.
* - Using chHeapStatus() to assess the heap state. There must be at * - [6.1.4] Using chHeapStatus() to assess the heap state. There must
* least one free block of sufficient size. * be at least one free block of sufficient size.
* - Allocating then freeing in the same order. * - [6.1.5] Allocating then freeing in the same order.
* - Allocating then freeing in reverse order. * - [6.1.6] Allocating then freeing in reverse order.
* - Small fragments handling. Checking the behavior when allocating * - [6.1.7] Small fragments handling. Checking the behavior when
* blocks with size not multiple of alignment unit. * allocating blocks with size not multiple of alignment unit.
* - Skipping a fragment, the first fragment in the list is too small * - [6.1.8] Skipping a fragment, the first fragment in the list is too
* so the allocator must pick the second one. * small so the allocator must pick the second one.
* - Allocating the whole available space. * - [6.1.9] Allocating the whole available space.
* - Testing final conditions. The heap geometry must be the same than * - [6.1.10] Testing final conditions. The heap geometry must be the
* the one registered at beginning. * same than the one registered at beginning.
* . * .
*/ */
@ -92,23 +93,23 @@ static void test_006_001_execute(void) {
void *p1, *p2, *p3; void *p1, *p2, *p3;
size_t n, sz; size_t n, sz;
/* Testing initial conditions, the heap must not be fragmented and /* [6.1.1] Testing initial conditions, the heap must not be
one free block present.*/ fragmented and one free block present.*/
test_set_step(1); test_set_step(1);
{ {
test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented"); test_assert(chHeapStatus(&test_heap, &sz, NULL) == 1, "heap fragmented");
} }
/* Trying to allocate an block bigger than available space, an error /* [6.1.2] Trying to allocate an block bigger than available space,
is expected.*/ an error is expected.*/
test_set_step(2); test_set_step(2);
{ {
p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2); p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
test_assert(p1 == NULL, "allocation not failed"); test_assert(p1 == NULL, "allocation not failed");
} }
/* Single block allocation using chHeapAlloc() then the block is /* [6.1.3] Single block allocation using chHeapAlloc() then the block
freed using chHeapFree(), must not fail.*/ is freed using chHeapFree(), must not fail.*/
test_set_step(3); test_set_step(3);
{ {
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE); p1 = chHeapAlloc(&test_heap, ALLOC_SIZE);
@ -116,8 +117,8 @@ static void test_006_001_execute(void) {
chHeapFree(p1); chHeapFree(p1);
} }
/* Using chHeapStatus() to assess the heap state. There must be at /* [6.1.4] Using chHeapStatus() to assess the heap state. There must
least one free block of sufficient size.*/ be at least one free block of sufficient size.*/
test_set_step(4); test_set_step(4);
{ {
size_t total_size, largest_size; 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"); 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); test_set_step(5);
{ {
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE); 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"); 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); test_set_step(6);
{ {
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE); 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"); test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
} }
/* Small fragments handling. Checking the behavior when allocating /* [6.1.7] Small fragments handling. Checking the behavior when
blocks with size not multiple of alignment unit.*/ allocating blocks with size not multiple of alignment unit.*/
test_set_step(7); test_set_step(7);
{ {
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE + 1); 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"); test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
} }
/* Skipping a fragment, the first fragment in the list is too small /* [6.1.8] Skipping a fragment, the first fragment in the list is too
so the allocator must pick the second one.*/ small so the allocator must pick the second one.*/
test_set_step(8); test_set_step(8);
{ {
p1 = chHeapAlloc(&test_heap, ALLOC_SIZE); 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"); 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); test_set_step(9);
{ {
(void)chHeapStatus(&test_heap, &n, NULL); (void)chHeapStatus(&test_heap, &n, NULL);
@ -194,8 +195,8 @@ static void test_006_001_execute(void) {
chHeapFree(p1); chHeapFree(p1);
} }
/* Testing final conditions. The heap geometry must be the same than /* [6.1.10] Testing final conditions. The heap geometry must be the
the one registered at beginning.*/ same than the one registered at beginning.*/
test_set_step(10); test_set_step(10);
{ {
test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented"); test_assert(chHeapStatus(&test_heap, &n, NULL) == 1, "heap fragmented");
@ -209,26 +210,18 @@ static const testcase_t test_006_001 = {
NULL, NULL,
test_006_001_execute test_006_001_execute
}; };
#endif /* CH_CFG_USE_HEAP */
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
/** /**
* @page test_006_002 Default Heap * @page test_006_002 [6.2] Default Heap
* *
* <h2>Description</h2> * <h2>Description</h2>
* The default heap is pre-allocated in the system. We test base * The default heap is pre-allocated in the system. We test base
* functionality. * functionality.
* *
* <h2>Conditions</h2>
* This test is only executed if the following preprocessor condition
* evaluates to true:
* - CH_CFG_USE_HEAP
* .
*
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - Single block allocation using chHeapAlloc() then the block is * - [6.2.1] Single block allocation using chHeapAlloc() then the block
* freed using chHeapFree(), must not fail. * is freed using chHeapFree(), must not fail.
* - Testing allocation failure. * - [6.2.2] Testing allocation failure.
* . * .
*/ */
@ -236,8 +229,8 @@ static void test_006_002_execute(void) {
void *p1; void *p1;
size_t total_size, largest_size; size_t total_size, largest_size;
/* Single block allocation using chHeapAlloc() then the block is /* [6.2.1] Single block allocation using chHeapAlloc() then the block
freed using chHeapFree(), must not fail.*/ is freed using chHeapFree(), must not fail.*/
test_set_step(1); test_set_step(1);
{ {
(void)chHeapStatus(NULL, &total_size, &largest_size); (void)chHeapStatus(NULL, &total_size, &largest_size);
@ -246,7 +239,7 @@ static void test_006_002_execute(void) {
chHeapFree(p1); chHeapFree(p1);
} }
/* Testing allocation failure.*/ /* [6.2.2] Testing allocation failure.*/
test_set_step(2); test_set_step(2);
{ {
p1 = chHeapAlloc(NULL, (size_t)-256); p1 = chHeapAlloc(NULL, (size_t)-256);
@ -260,7 +253,6 @@ static const testcase_t test_006_002 = {
NULL, NULL,
test_006_002_execute test_006_002_execute
}; };
#endif /* CH_CFG_USE_HEAP */
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
@ -270,11 +262,9 @@ static const testcase_t test_006_002 = {
* @brief Memory Heaps. * @brief Memory Heaps.
*/ */
const testcase_t * const test_sequence_006[] = { const testcase_t * const test_sequence_006[] = {
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
&test_006_001, &test_006_001,
#endif
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
&test_006_002, &test_006_002,
#endif
NULL NULL
}; };
#endif /* CH_CFG_USE_HEAP */

View File

@ -1343,10 +1343,10 @@ static void *null_provider(size_t size, unsigned align) {
<cases> <cases>
<case> <case>
<brief> <brief>
<value>Loading and empting a memory pool.</value> <value>Loading and emptying a memory pool.</value>
</brief> </brief>
<description> <description>
<value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value> <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description> </description>
<condition> <condition>
<value /> <value />
@ -1448,10 +1448,10 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
</case> </case>
<case> <case>
<brief> <brief>
<value>Loading and empting a guarded memory pool without waiting.</value> <value>Loading and emptying a guarded memory pool without waiting.</value>
</brief> </brief>
<description> <description>
<value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value> <value>The memory pool functionality is tested by loading and emptying it, all conditions are tested.</value>
</description> </description>
<condition> <condition>
<value>CH_CFG_USE_SEMAPHORES</value> <value>CH_CFG_USE_SEMAPHORES</value>