From 991de13cad02f1b4121aa172ea3788cc6c900edf Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 12 Mar 2016 11:11:37 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9083 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/nasa_osal/configuration.xml | 277 ++++++++++++++++- test/nasa_osal/source/test/test_root.c | 2 + test/nasa_osal/source/test/test_root.h | 1 + .../nasa_osal/source/test/test_sequence_005.c | 8 +- .../nasa_osal/source/test/test_sequence_006.c | 281 ++++++++++++++++++ .../nasa_osal/source/test/test_sequence_006.h | 17 ++ test/nasa_osal/test.mk | 3 +- 7 files changed, 581 insertions(+), 8 deletions(-) create mode 100644 test/nasa_osal/source/test/test_sequence_006.c create mode 100644 test/nasa_osal/source/test/test_sequence_006.h diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index 9cc1b47b0..2bc6312f4 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -2067,7 +2067,7 @@ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]> - OS_BinSemTake() is invoked with sem_id set to -1, an error is expected. + OS_CountSemTake() is invoked with sem_id set to -1, an error is expected. @@ -2075,7 +2075,7 @@ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]> @@ -2141,7 +2141,7 @@ test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected");]]> OS_CountSemGetIdByName() errors - Parameters checking in OS_BinSemGetIdByName() is tested. + Parameters checking in OS_CountSemGetIdByName() is tested. @@ -2245,6 +2245,277 @@ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]> + + + Internal Tests + + + Mutex Semaphores Functionality + + + This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to mutex semaphores. + + + + + + + + OS_MutSemCreate() and OS_MutSemDelete() errors + + + Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is tested. + + + + + + + + + + + + + + + + + + + OS_MutSemCreate() is invoked with sem_id set to NULL, an error is expected. + + + + + + + + + + + OS_MutSemCreate() is invoked with sem_name set to NULL, an error is expected. + + + + + + + + + + + OS_MutSemCreate() is invoked with a very long timer name, an error is expected. + + + + + + + + + + + OS_MutSemDelete() is invoked with timer_id set to -1, an error is expected. + + + + + + + + + + + OS_MutSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_MutSemDelete(). + + + + + + + + + + + + + OS_MutSemGive() errors + + + Parameters checking in OS_MutSemGive() is tested. + + + + + + + + + + + + + + + + + + + OS_MutSemGive() is invoked with sem_id set to -1, an error is expected. + + + + + + + + + + + + + OS_MutSemTake() errors + + + Parameters checking in OS_MutSemTake() is tested. + + + + + + + + + + + + + + + + + + + OS_MutSemTake() is invoked with sem_id set to -1, an error is expected. + + + + + + + + + + + + + OS_MutSemGetIdByName() errors + + + Parameters checking in OS_MutSemGetIdByName() is tested. + + + + + + + + + + + + + + + + + + + OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an error is expected. + + + + + + + + + + + OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected. + + + + + + + + + + + OS_MutSemGetIdByName() is invoked with a very long task name, an error is expected. + + + + + + + + + + + + diff --git a/test/nasa_osal/source/test/test_root.c b/test/nasa_osal/source/test/test_root.c index 35419fa35..af5ff61d7 100644 --- a/test/nasa_osal/source/test/test_root.c +++ b/test/nasa_osal/source/test/test_root.c @@ -26,6 +26,7 @@ * - @subpage test_sequence_003 * - @subpage test_sequence_004 * - @subpage test_sequence_005 + * - @subpage test_sequence_006 * . */ @@ -54,6 +55,7 @@ const testcase_t * const *test_suite[] = { test_sequence_003, test_sequence_004, test_sequence_005, + test_sequence_006, NULL }; diff --git a/test/nasa_osal/source/test/test_root.h b/test/nasa_osal/source/test/test_root.h index 3ce44595f..53cec7c37 100644 --- a/test/nasa_osal/source/test/test_root.h +++ b/test/nasa_osal/source/test/test_root.h @@ -30,6 +30,7 @@ #include "test_sequence_003.h" #include "test_sequence_004.h" #include "test_sequence_005.h" +#include "test_sequence_006.h" /*===========================================================================*/ /* External declarations. */ diff --git a/test/nasa_osal/source/test/test_sequence_005.c b/test/nasa_osal/source/test/test_sequence_005.c index 6663cda81..3072c1666 100644 --- a/test/nasa_osal/source/test/test_sequence_005.c +++ b/test/nasa_osal/source/test/test_sequence_005.c @@ -206,20 +206,20 @@ static const testcase_t test_005_002 = { * Parameters checking in OS_CountSemTake() is tested. * *

Test Steps

- * - OS_BinSemTake() is invoked with sem_id set to -1, an error is + * - OS_CountSemTake() is invoked with sem_id set to -1, an error is * expected. * . */ static void test_005_003_execute(void) { - /* OS_BinSemTake() is invoked with sem_id set to -1, an error is + /* OS_CountSemTake() is invoked with sem_id set to -1, an error is expected.*/ test_set_step(1); { int32 err; - err = OS_BinSemTake((uint32)-1); + err = OS_CountSemTake((uint32)-1); test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); } } @@ -290,7 +290,7 @@ static const testcase_t test_005_004 = { * @page test_005_005 OS_CountSemGetIdByName() errors * *

Description

- * Parameters checking in OS_BinSemGetIdByName() is tested. + * Parameters checking in OS_CountSemGetIdByName() is tested. * *

Test Steps

* - OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an diff --git a/test/nasa_osal/source/test/test_sequence_006.c b/test/nasa_osal/source/test/test_sequence_006.c new file mode 100644 index 000000000..6e61ffc73 --- /dev/null +++ b/test/nasa_osal/source/test/test_sequence_006.c @@ -0,0 +1,281 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" +#include "ch_test.h" +#include "test_root.h" + +/** + * @page test_sequence_006 Mutex Semaphores Functionality + * + * File: @ref test_sequence_006.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to mutex semaphores. + * + *

Test Cases

+ * - @subpage test_006_001 + * - @subpage test_006_002 + * - @subpage test_006_003 + * - @subpage test_006_004 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include "osapi.h" + +uint32 msid; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page test_006_001 OS_MutSemCreate() and OS_MutSemDelete() errors + * + *

Description

+ * Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is + * tested. + * + *

Test Steps

+ * - OS_MutSemCreate() is invoked with sem_id set to NULL, an error is + * expected. + * - OS_MutSemCreate() is invoked with sem_name set to NULL, an error + * is expected. + * - OS_MutSemCreate() is invoked with a very long timer name, an error + * is expected. + * - OS_MutSemDelete() is invoked with timer_id set to -1, an error is + * expected. + * - OS_MutSemCreate() is invoked twice with duplicated name, an error + * is expected, then the queue is deleted using OS_MutSemDelete(). + * . + */ + +static void test_006_001_execute(void) { + + /* OS_MutSemCreate() is invoked with sem_id set to NULL, an error is + expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_MutSemCreate(NULL, /* Error.*/ + "failing semaphore", + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_MutSemCreate() is invoked with sem_name set to NULL, an error + is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_MutSemCreate(&msid, + NULL, /* Error.*/ + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_MutSemCreate() is invoked with a very long timer name, an error + is expected.*/ + test_set_step(3); + { + #if 0 /* Semaphore name currently not implemented.*/ + int32 err; + + err = OS_MutSemCreate(&msid, + "very very long semaphore name", /* Error.*/ + 0); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + #endif + } + + /* OS_MutSemDelete() is invoked with timer_id set to -1, an error is + expected.*/ + test_set_step(4); + { + int32 err; + + err = OS_MutSemDelete((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); + } + + /* OS_MutSemCreate() is invoked twice with duplicated name, an error + is expected, then the queue is deleted using OS_MutSemDelete().*/ + test_set_step(5); + { + int32 err; + uint32 msid1; /*, msid2;*/ + + err = OS_MutSemCreate(&msid1, "my semaphore", 0); + test_assert(err == OS_SUCCESS, "semaphore creation failed"); + + #if 0 /* Semaphore name currently not implemented.*/ + err = OS_MutSemCreate(&msid2, "my semaphore", 0); + test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); + #endif + + err = OS_MutSemDelete(msid1); + test_assert(err == OS_SUCCESS, "semaphore deletion failed"); + } +} + +static const testcase_t test_006_001 = { + "OS_MutSemCreate() and OS_MutSemDelete() errors", + NULL, + NULL, + test_006_001_execute +}; + +/** + * @page test_006_002 OS_MutSemGive() errors + * + *

Description

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

Test Steps

+ * - OS_MutSemGive() is invoked with sem_id set to -1, an error is + * expected. + * . + */ + +static void test_006_002_execute(void) { + + /* OS_MutSemGive() is invoked with sem_id set to -1, an error is + expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_MutSemGive((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } +} + +static const testcase_t test_006_002 = { + "OS_MutSemGive() errors", + NULL, + NULL, + test_006_002_execute +}; + +/** + * @page test_006_003 OS_MutSemTake() errors + * + *

Description

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

Test Steps

+ * - OS_MutSemTake() is invoked with sem_id set to -1, an error is + * expected. + * . + */ + +static void test_006_003_execute(void) { + + /* OS_MutSemTake() is invoked with sem_id set to -1, an error is + expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_MutSemTake((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } +} + +static const testcase_t test_006_003 = { + "OS_MutSemTake() errors", + NULL, + NULL, + test_006_003_execute +}; + +/** + * @page test_006_004 OS_MutSemGetIdByName() errors + * + *

Description

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

Test Steps

+ * - OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an + * error is expected. + * - OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, + * an error is expected. + * - OS_MutSemGetIdByName() is invoked with a very long task name, an + * error is expected. + * . + */ + +static void test_006_004_execute(void) { + + /* OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_MutSemGetIdByName(NULL, "semaphore"); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, + an error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_MutSemGetIdByName(&msid, NULL); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* OS_MutSemGetIdByName() is invoked with a very long task name, an + error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_MutSemGetIdByName(&msid, "very very long semaphore name"); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } +} + +static const testcase_t test_006_004 = { + "OS_MutSemGetIdByName() errors", + NULL, + NULL, + test_006_004_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Mutex Semaphores Functionality. + */ +const testcase_t * const test_sequence_006[] = { + &test_006_001, + &test_006_002, + &test_006_003, + &test_006_004, + NULL +}; diff --git a/test/nasa_osal/source/test/test_sequence_006.h b/test/nasa_osal/source/test/test_sequence_006.h new file mode 100644 index 000000000..739ecb3f3 --- /dev/null +++ b/test/nasa_osal/source/test/test_sequence_006.h @@ -0,0 +1,17 @@ +/* + ChibiOS - Copyright (C) 2006..2015 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[]; diff --git a/test/nasa_osal/test.mk b/test/nasa_osal/test.mk index 6597edc88..cf9a9cdb7 100644 --- a/test/nasa_osal/test.mk +++ b/test/nasa_osal/test.mk @@ -5,7 +5,8 @@ TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_002.c \ ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_003.c \ ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_004.c \ - ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_005.c + ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_005.c \ + ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_006.c # Required include directories TESTINC = ${CHIBIOS}/test/lib \