From ade53fbc15fcf754ccb29e90f19cb2f921a90288 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 10 Mar 2016 14:57:26 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9065 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nasa_osal/configuration.xml | 264 +++++++++++++++++-------- test/nasa_osal/source/test/test_sequence_002.c | 134 ++++++------- test/nasa_osal/source/test/test_sequence_003.c | 84 +++++++- 3 files changed, 336 insertions(+), 146 deletions(-) (limited to 'test') diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index df5342bff..eef897b28 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -757,37 +757,29 @@ test_assert(err == OS_SUCCESS, "queue deletion failed");]]> - OS_QueuePut() and OS_QueueGet() functionality + OS_QueueGetIdByName() errors - A task writes on a queue, the messages are retrieved on the other side in blocking mode. + Parameters checking in OS_QueueGetIdByName() is tested. - + - + - + - Creataing a queue with depth 4 and message size 20 + OS_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected. @@ -795,13 +787,13 @@ unsigned i;]]> +err = OS_QueueGetIdByName(NULL, "queue"); +test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]> - Creating the writer task. + OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected. @@ -809,76 +801,59 @@ test_assert(err == OS_SUCCESS, "queue creation failed");]]> +err = OS_QueueGetIdByName(&qid, NULL); +test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]> - Reading messages from the writer task. + OS_QueueGetIdByName() is invoked with a very long task name, an error is expected. - - - - - - Waiting for task termination then checking for errors. - - - - - - +err = OS_QueueGetIdByName(&qid, "very very long queue name"); +test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]> - OS_QueueGetIdByName() errors + OS_QueuePut() and OS_QueueGet() functionality - Parameters checking in OS_QueueGetIdByName() is tested. + A task writes on a queue, the messages are retrieved on the other side in blocking mode. - + - + - + - OS_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected. + Creataing a queue with depth 4 and message size 20 @@ -886,13 +861,13 @@ test_assert_sequence("", "queue write errors occurred");]]> +err = OS_QueueCreate(&qid, "test queue", 4, MESSAGE_SIZE, 0); +test_assert(err == OS_SUCCESS, "queue creation failed");]]> - OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected. + Creating the writer task. @@ -900,29 +875,54 @@ test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]> +err = OS_TaskCreate(&tid, + "writer task", + test_task_writer, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); +test_assert(err == OS_SUCCESS, "writer task creation failed");]]> - OS_QueueGetIdByName() is invoked with a very long task name, an error is expected. + Reading messages from the writer task. - + err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(200)); + test_assert(err == OS_SUCCESS, "timed out"); + test_assert(strncmp(data, "Hello World", sizeof (data)) == 0, + "wrong message"); +}]]> + + + + + Waiting for task termination then checking for errors. + + + + + + - OS_QueueGet() with timeout + OS_QueueGet() with timeout functionality OS_QueueGetIdByName is tested. @@ -949,7 +949,7 @@ char data[MESSAGE_SIZE];]]> - Retrieving the queue name. + Retrieving the queue by name. @@ -1006,13 +1006,16 @@ test_assert(err == OS_QUEUE_EMPTY, "unexpected error code");]]> -#include "osapi.h" - +#include "osapi.h" + uint32 tmid; - -static void tmr_callback(uint32 timer_id) { - +uint32 cnt; + +static void tmr_callback(uint32 timer_id) { + (void)timer_id; + + cnt++; }]]> @@ -1109,7 +1112,7 @@ err = OS_TimerCreate(&tmid, "failing timer", &accuracy, NULL); /* Error.*/ -test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]> +test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected");]]> @@ -1284,7 +1287,11 @@ test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]> - + }]]> - + - + + + + Retrieving the timer by name. + + + + + + + + + + + Setting up the timer for a 70mS one-shot tick. + + + + + + + + + + + Waiting one second then counting the occurred ticks. + + + + + + + + + @@ -1309,18 +1357,78 @@ test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]> - + - - + - + + + + Retrieving the timer by name. + + + + + + + + + + + Setting up the timer for a 70mS periodic tick. + + + + + + + + + + + Waiting one second then counting the occurred ticks. + + + + + + + + + + + Stopping the timer. + + + + + + + + + diff --git a/test/nasa_osal/source/test/test_sequence_002.c b/test/nasa_osal/source/test/test_sequence_002.c index 7600c5f99..1b10a193a 100644 --- a/test/nasa_osal/source/test/test_sequence_002.c +++ b/test/nasa_osal/source/test/test_sequence_002.c @@ -167,7 +167,63 @@ static const testcase_t test_002_001 = { }; /** - * @page test_002_002 OS_QueuePut() and OS_QueueGet() functionality + * @page test_002_002 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_002_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_002 = { + "OS_QueueGetIdByName() errors", + NULL, + NULL, + test_002_002_execute +}; + +/** + * @page test_002_003 OS_QueuePut() and OS_QueueGet() functionality * *

Description

* A task writes on a queue, the messages are retrieved on the other @@ -181,12 +237,12 @@ static const testcase_t test_002_001 = { * . */ -static void test_002_002_setup(void) { +static void test_002_003_setup(void) { qid = 0; tid = 0; } -static void test_002_002_teardown(void) { +static void test_002_003_teardown(void) { if (qid != 0) { (void) OS_QueueDelete(qid); } @@ -196,7 +252,7 @@ static void test_002_002_teardown(void) { } } -static void test_002_002_execute(void) { +static void test_002_003_execute(void) { uint32 tid; unsigned i; @@ -248,77 +304,21 @@ static void test_002_002_execute(void) { } } -static const testcase_t test_002_002 = { - "OS_QueuePut() and OS_QueueGet() functionality", - test_002_002_setup, - test_002_002_teardown, - 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, + "OS_QueuePut() and OS_QueueGet() functionality", + test_002_003_setup, + test_002_003_teardown, test_002_003_execute }; /** - * @page test_002_004 OS_QueueGet() with timeout + * @page test_002_004 OS_QueueGet() with timeout functionality * *

Description

* OS_QueueGetIdByName is tested. * *

Test Steps

- * - Retrieving the queue name. + * - Retrieving the queue by name. * - Get operation with a one second timeout, an error is expected. * - Get operation in non-blocking mode, an error is expected. * . @@ -340,7 +340,7 @@ static void test_002_004_execute(void) { uint32 copied; char data[MESSAGE_SIZE]; - /* Retrieving the queue name.*/ + /* Retrieving the queue by name.*/ test_set_step(1); { int32 err; @@ -369,7 +369,7 @@ static void test_002_004_execute(void) { } static const testcase_t test_002_004 = { - "OS_QueueGet() with timeout", + "OS_QueueGet() with timeout functionality", test_002_004_setup, test_002_004_teardown, test_002_004_execute diff --git a/test/nasa_osal/source/test/test_sequence_003.c b/test/nasa_osal/source/test/test_sequence_003.c index 87338fc05..2d2fc0a69 100644 --- a/test/nasa_osal/source/test/test_sequence_003.c +++ b/test/nasa_osal/source/test/test_sequence_003.c @@ -45,10 +45,13 @@ #include "osapi.h" uint32 tmid; +uint32 cnt; static void tmr_callback(uint32 timer_id) { (void)timer_id; + + cnt++; } /**************************************************************************** @@ -137,7 +140,7 @@ static void test_003_001_execute(void) { "failing timer", &accuracy, NULL); /* Error.*/ - test_assert(err == OS_INVALID_POINTER, "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 @@ -285,10 +288,18 @@ static const testcase_t test_003_003 = { * A timer is tested in one-shot mode. * *

Test Steps

+ * - Retrieving the timer by name. + * - Setting up the timer for a 70mS one-shot tick. + * - Waiting one second then counting the occurred ticks. + * . */ static void test_003_004_setup(void) { + uint32 accuracy; + + cnt = 0; tmid = 0; + (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); } static void test_003_004_teardown(void) { @@ -298,6 +309,32 @@ static void test_003_004_teardown(void) { } static void test_003_004_execute(void) { + uint32 local_tmid; + + /* Retrieving the timer by name.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerGetIdByName(&local_tmid, "test timer"); + test_assert(err == OS_SUCCESS, "timer not found"); + } + + /* Setting up the timer for a 70mS one-shot tick.*/ + test_set_step(2); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 70000, 0); + test_assert(err == OS_SUCCESS, "timer setup failed"); + } + + /* Waiting one second then counting the occurred ticks.*/ + test_set_step(3); + { + (void) OS_TaskDelay(1000); + test_assert(cnt == 1, "wrong ticks"); + } } static const testcase_t test_003_004 = { @@ -314,19 +351,64 @@ static const testcase_t test_003_004 = { * A timer is tested in periodic mode. * *

Test Steps

+ * - Retrieving the timer by name. + * - Setting up the timer for a 70mS periodic tick. + * - Waiting one second then counting the occurred ticks. + * - Stopping the timer. + * . */ static void test_003_005_setup(void) { + uint32 accuracy; + + cnt = 0; tmid = 0; + (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); } static void test_003_005_teardown(void) { if (tmid != 0) { + (void) OS_TimerSet(tmid, 0, 0); (void) OS_TimerDelete(tmid); } } static void test_003_005_execute(void) { + uint32 local_tmid; + + /* Retrieving the timer by name.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerGetIdByName(&local_tmid, "test timer"); + test_assert(err == OS_SUCCESS, "timer not found"); + } + + /* Setting up the timer for a 70mS periodic tick.*/ + test_set_step(2); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 70000, 70000); + test_assert(err == OS_SUCCESS, "timer setup failed"); + } + + /* Waiting one second then counting the occurred ticks.*/ + test_set_step(3); + { + (void) OS_TaskDelay(1000); + test_assert(cnt == 14, "wrong ticks"); + } + + /* Stopping the timer.*/ + test_set_step(4); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 0, 0); + test_assert(err == OS_SUCCESS, "timer stop failed"); + } } static const testcase_t test_003_005 = { -- cgit v1.2.3