From 21a8820047ea2ffc0a4a91c973c5990bd2dac6ce Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 10 Mar 2016 10:07:14 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9063 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- .../NASA-OSAL-STM32F746G-DISCOVERY/main.c | 2 +- test/nasa_osal/configuration.xml | 137 ++++++++++++++++++ .../nasa_osal/source/test/test_sequence_002.c | 124 ++++++++++++++++ 3 files changed, 262 insertions(+), 1 deletion(-) diff --git a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c index 9f94a613e..84e33aea6 100644 --- a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c +++ b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c @@ -53,7 +53,7 @@ int main(void) { /* Activates the serial driver 1 using the driver default configuration.*/ sdStart(&SD1, NULL); - /* GPIOI1 is programmed as output (board LED).*/ + /* ARD_D13 is programmed as output (board LED).*/ palClearLine(LINE_ARD_D13); palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL); diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index 69db8c2f8..6924cd1a4 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -854,6 +854,143 @@ test_assert_sequence("", "queue write errors occurred");]]> + + + OS_QueueGetIdByName() errors + + + Parameters checking in OS_QueueGetIdByName() is tested. + + + + + + + + + + + + + + + + + + + OS_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected. + + + + + + + + + + + OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected. + + + + + + + + + + + OS_QueueGetIdByName() is invoked with a very long task name, an error is expected. + + + + + + + + + + + + + OS_QueueGet() with timeout + + + OS_QueueGetIdByName is tested. + + + + + + + + + + + + + + + + + + + Retrieving the queue name. + + + + + + + + + + + Get operation with a one second timeout, an error is expected. + + + + + + + + + + + Get operation in non-blocking mode, an error is expected. + + + + + + + + + + diff --git a/test/nasa_osal/source/test/test_sequence_002.c b/test/nasa_osal/source/test/test_sequence_002.c index 4b9da0522..44a4fe5df 100644 --- a/test/nasa_osal/source/test/test_sequence_002.c +++ b/test/nasa_osal/source/test/test_sequence_002.c @@ -30,6 +30,8 @@ *

Test Cases

* - @subpage test_002_001 * - @subpage test_002_002 + * - @subpage test_002_003 + * - @subpage test_002_004 * . */ @@ -253,6 +255,126 @@ static const testcase_t test_002_002 = { test_002_002_execute }; +/** + * @page test_002_003 OS_QueueGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_QueueGetIdByName() is tested. + * + *

Test Steps

+ * - OS_QueueGetIdByName() is invoked with queue_id set to NULL, an + * error is expected. + * - OS_QueueGetIdByName() is invoked with queue_name set to NULL, an + * error is expected. + * - OS_QueueGetIdByName() is invoked with a very long task name, an + * error is expected. + * . + */ + +static void test_002_003_execute(void) { + + /* OS_QueueGetIdByName() is invoked with queue_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_QueueGetIdByName(NULL, "queue"); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_QueueGetIdByName() is invoked with queue_name set to NULL, an + error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_QueueGetIdByName(&qid, NULL); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_QueueGetIdByName() is invoked with a very long task name, an + error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_QueueGetIdByName(&qid, "very very long queue name"); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } +} + +static const testcase_t test_002_003 = { + "OS_QueueGetIdByName() errors", + NULL, + NULL, + test_002_003_execute +}; + +/** + * @page test_002_004 OS_QueueGet() with timeout + * + *

Description

+ * OS_QueueGetIdByName is tested. + * + *

Test Steps

+ * - Retrieving the queue name. + * - Get operation with a one second timeout, an error is expected. + * - Get operation in non-blocking mode, an error is expected. + * . + */ + +static void test_002_004_setup(void) { + qid = 0; + (void) OS_QueueCreate(&qid, "test queue", 2, MESSAGE_SIZE, 0); +} + +static void test_002_004_teardown(void) { + if (qid != 0) { + OS_QueueDelete(qid); + } +} + +static void test_002_004_execute(void) { + uint32 local_qid; + uint32 copied; + char data[MESSAGE_SIZE]; + + /* Retrieving the queue name.*/ + test_set_step(1); + { + int32 err; + + err = OS_QueueGetIdByName(&local_qid, "test queue"); + test_assert(err == OS_SUCCESS, "queue not found"); + } + + /* Get operation with a one second timeout, an error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(1000)); + test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code"); + } + + /* Get operation in non-blocking mode, an error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_CHECK); + test_assert(err == OS_QUEUE_EMPTY, "unexpected error code"); + } +} + +static const testcase_t test_002_004 = { + "OS_QueueGet() with timeout", + test_002_004_setup, + test_002_004_teardown, + test_002_004_execute +}; + /**************************************************************************** * Exported data. ****************************************************************************/ @@ -263,5 +385,7 @@ static const testcase_t test_002_002 = { const testcase_t * const test_sequence_002[] = { &test_002_001, &test_002_002, + &test_002_003, + &test_002_004, NULL };