aboutsummaryrefslogtreecommitdiffstats
path: root/test/nasa_osal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-11 16:20:58 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-11 16:20:58 +0000
commitd962e4e16350563b8c5878b3231c35f308613f1f (patch)
treee382015973a6b7039bc1457a8a64d56e427ed8d9 /test/nasa_osal
parentc27d4ae937cdfd4829ed8290efd8e079181d3bc5 (diff)
downloadChibiOS-d962e4e16350563b8c5878b3231c35f308613f1f.tar.gz
ChibiOS-d962e4e16350563b8c5878b3231c35f308613f1f.tar.bz2
ChibiOS-d962e4e16350563b8c5878b3231c35f308613f1f.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9080 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/nasa_osal')
-rw-r--r--test/nasa_osal/configuration.xml391
-rw-r--r--test/nasa_osal/source/test/test_root.c2
-rw-r--r--test/nasa_osal/source/test/test_root.h1
-rw-r--r--test/nasa_osal/source/test/test_sequence_004.c12
-rw-r--r--test/nasa_osal/source/test/test_sequence_005.c403
-rw-r--r--test/nasa_osal/source/test/test_sequence_005.h17
-rw-r--r--test/nasa_osal/test.mk3
7 files changed, 820 insertions, 9 deletions
diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml
index 323193671..9cc1b47b0 100644
--- a/test/nasa_osal/configuration.xml
+++ b/test/nasa_osal/configuration.xml
@@ -1451,7 +1451,7 @@ uint32 bsid;]]></value>
<cases>
<case>
<brief>
- <value>OS_TimerCreate() and OS_TimerDelete() errors</value>
+ <value>OS_BinSemCreate() and OS_BinSemDelete() errors</value>
</brief>
<description>
<value>Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is tested.</value>
@@ -1557,7 +1557,7 @@ test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");]]></va
</step>
<step>
<description>
- <value>OS_TimerCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_TimerDelete().</value>
+ <value>OS_BinSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_BinSemDelete().</value>
</description>
<tags>
<value />
@@ -1858,6 +1858,393 @@ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]></value>
</case>
</cases>
</sequence>
+ <sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>Counter Semaphores Functionality</value>
+ </brief>
+ <description>
+ <value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to counter semaphores.</value>
+ </description>
+ <shared_code>
+ <value><![CDATA[#include "osapi.h"
+
+uint32 csid;]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>OS_CountSemCreate() and OS_CountSemDelete() errors</value>
+ </brief>
+ <description>
+ <value>Parameters checking in OS_CountSemCreate() and OS_CountSemDelete() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_CountSemCreate() is invoked with sem_id set to NULL, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemCreate(NULL, /* Error.*/
+ "failing semaphore",
+ 0,
+ 0);
+test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemCreate() is invoked with sem_name set to NULL, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemCreate(&csid,
+ NULL, /* Error.*/
+ 0,
+ 0);
+test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemCreate() is invoked with an invalid sem_initial_value, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemCreate(&csid,
+ "failing semaphore",
+ (uint32)-1, /* Error.*/
+ 0);
+test_assert(err == OS_INVALID_INT_NUM, "counter error not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemCreate() is invoked with a very long timer name, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[#if 0 /* Semaphore name currently not implemented.*/
+int32 err;
+
+err = OS_CountSemCreate(&csid,
+ "very very long semaphore name",/* Error.*/
+ 0,
+ 0);
+test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
+#endif]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemDelete() is invoked with timer_id set to -1, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemDelete((uint32)-1);
+test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_CountSemDelete().</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+uint32 csid1; /*, csid2;*/
+
+err = OS_CountSemCreate(&csid1, "my semaphore", 0, 0);
+test_assert(err == OS_SUCCESS, "semaphore creation failed");
+
+#if 0 /* Semaphore name currently not implemented.*/
+err = OS_CountSemCreate(&csid2, "my semaphore", 0, 0);
+test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected");
+#endif
+
+err = OS_CountSemDelete(csid1);
+test_assert(err == OS_SUCCESS, "semaphore deletion failed");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>OS_CountSemGive() errors</value>
+ </brief>
+ <description>
+ <value>Parameters checking in OS_CountSemGive() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_CountSemGive() is invoked with sem_id set to -1, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemGive((uint32)-1);
+test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>OS_CountSemTake() errors</value>
+ </brief>
+ <description>
+ <value>Parameters checking in OS_CountSemTake() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_BinSemTake() is invoked with sem_id set to -1, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_BinSemTake((uint32)-1);
+test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>OS_CountSemTimedWait() errors</value>
+ </brief>
+ <description>
+ <value>Parameters checking in OS_CountSemTimedWait() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[csid = 0;
+(void) OS_CountSemCreate(&csid, "test semaphore", 0, 0);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[if (csid > 0) {
+ (void) OS_CountSemDelete(csid);
+}]]></value>
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_CountSemTimedWait() is invoked with sem_id set to -1, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemTimedWait((uint32)-1, 1000);
+test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemTimedWait() is invoked with msecs set to 0, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemTimedWait(csid, 0);
+test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>OS_CountSemGetIdByName() errors</value>
+ </brief>
+ <description>
+ <value>Parameters checking in OS_BinSemGetIdByName() is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemGetIdByName(NULL, "semaphore");
+test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemGetIdByName(&csid, NULL);
+test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>OS_CountSemGetIdByName() is invoked with a very long task name, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemGetIdByName(&csid, "very very long semaphore name");
+test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>OS_CountSemTimedWait() timeout functionality</value>
+ </brief>
+ <description>
+ <value>OS_CountSemCreate() timeout functionality is tested.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[csid = 0;
+(void) OS_CountSemCreate(&csid, "test semaphore", 0, 0);]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[if (csid > 0) {
+ (void) OS_CountSemDelete(csid);
+}]]></value>
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>OS_CountSemTimedWait() is invoked with timeout set to one second, an error is expected.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+
+err = OS_CountSemTimedWait(csid, 1000);
+test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
+ </sequence>
</sequences>
</instance>
</instances>
diff --git a/test/nasa_osal/source/test/test_root.c b/test/nasa_osal/source/test/test_root.c
index a14b0e244..35419fa35 100644
--- a/test/nasa_osal/source/test/test_root.c
+++ b/test/nasa_osal/source/test/test_root.c
@@ -25,6 +25,7 @@
* - @subpage test_sequence_002
* - @subpage test_sequence_003
* - @subpage test_sequence_004
+ * - @subpage test_sequence_005
* .
*/
@@ -52,6 +53,7 @@ const testcase_t * const *test_suite[] = {
test_sequence_002,
test_sequence_003,
test_sequence_004,
+ test_sequence_005,
NULL
};
diff --git a/test/nasa_osal/source/test/test_root.h b/test/nasa_osal/source/test/test_root.h
index d509debfa..3ce44595f 100644
--- a/test/nasa_osal/source/test/test_root.h
+++ b/test/nasa_osal/source/test/test_root.h
@@ -29,6 +29,7 @@
#include "test_sequence_002.h"
#include "test_sequence_003.h"
#include "test_sequence_004.h"
+#include "test_sequence_005.h"
/*===========================================================================*/
/* External declarations. */
diff --git a/test/nasa_osal/source/test/test_sequence_004.c b/test/nasa_osal/source/test/test_sequence_004.c
index 3f99bafad..908a0861b 100644
--- a/test/nasa_osal/source/test/test_sequence_004.c
+++ b/test/nasa_osal/source/test/test_sequence_004.c
@@ -51,7 +51,7 @@ uint32 bsid;
****************************************************************************/
/**
- * @page test_004_001 OS_TimerCreate() and OS_TimerDelete() errors
+ * @page test_004_001 OS_BinSemCreate() and OS_BinSemDelete() errors
*
* <h2>Description</h2>
* Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is
@@ -68,8 +68,8 @@ uint32 bsid;
* is expected.
* - OS_BinSemDelete() is invoked with timer_id set to -1, an error is
* expected.
- * - OS_TimerCreate() is invoked twice with duplicated name, an error
- * is expected, then the queue is deleted using OS_TimerDelete().
+ * - OS_BinSemCreate() is invoked twice with duplicated name, an error
+ * is expected, then the queue is deleted using OS_BinSemDelete().
* .
*/
@@ -139,8 +139,8 @@ static void test_004_001_execute(void) {
test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
}
- /* OS_TimerCreate() is invoked twice with duplicated name, an error
- is expected, then the queue is deleted using OS_TimerDelete().*/
+ /* OS_BinSemCreate() is invoked twice with duplicated name, an error
+ is expected, then the queue is deleted using OS_BinSemDelete().*/
test_set_step(6);
{
int32 err;
@@ -160,7 +160,7 @@ static void test_004_001_execute(void) {
}
static const testcase_t test_004_001 = {
- "OS_TimerCreate() and OS_TimerDelete() errors",
+ "OS_BinSemCreate() and OS_BinSemDelete() errors",
NULL,
NULL,
test_004_001_execute
diff --git a/test/nasa_osal/source/test/test_sequence_005.c b/test/nasa_osal/source/test/test_sequence_005.c
new file mode 100644
index 000000000..6663cda81
--- /dev/null
+++ b/test/nasa_osal/source/test/test_sequence_005.c
@@ -0,0 +1,403 @@
+/*
+ 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_005 Counter Semaphores Functionality
+ *
+ * File: @ref test_sequence_005.c
+ *
+ * <h2>Description</h2>
+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities
+ * related to counter semaphores.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage test_005_001
+ * - @subpage test_005_002
+ * - @subpage test_005_003
+ * - @subpage test_005_004
+ * - @subpage test_005_005
+ * - @subpage test_005_006
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include "osapi.h"
+
+uint32 csid;
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page test_005_001 OS_CountSemCreate() and OS_CountSemDelete() errors
+ *
+ * <h2>Description</h2>
+ * Parameters checking in OS_CountSemCreate() and OS_CountSemDelete()
+ * is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_CountSemCreate() is invoked with sem_id set to NULL, an error
+ * 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.
+ * - OS_CountSemDelete() is invoked with timer_id set to -1, an error
+ * is expected.
+ * - OS_CountSemCreate() is invoked twice with duplicated name, an
+ * error is expected, then the queue is deleted using
+ * OS_CountSemDelete().
+ * .
+ */
+
+static void test_005_001_execute(void) {
+
+ /* OS_CountSemCreate() is invoked with sem_id set to NULL, an error
+ is expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_CountSemCreate(NULL, /* Error.*/
+ "failing semaphore",
+ 0,
+ 0);
+ test_assert(err == OS_INVALID_POINTER, "NULL not detected");
+ }
+
+ /* OS_CountSemCreate() is invoked with sem_name set to NULL, an error
+ is expected.*/
+ test_set_step(2);
+ {
+ int32 err;
+
+ err = OS_CountSemCreate(&csid,
+ NULL, /* Error.*/
+ 0,
+ 0);
+ test_assert(err == OS_INVALID_POINTER, "NULL not detected");
+ }
+
+ /* OS_CountSemCreate() is invoked with an invalid sem_initial_value,
+ an error is expected.*/
+ test_set_step(3);
+ {
+ int32 err;
+
+ err = OS_CountSemCreate(&csid,
+ "failing semaphore",
+ (uint32)-1, /* Error.*/
+ 0);
+ test_assert(err == OS_INVALID_INT_NUM, "counter error not detected");
+ }
+
+ /* OS_CountSemCreate() is invoked with a very long timer name, an
+ error is expected.*/
+ test_set_step(4);
+ {
+ #if 0 /* Semaphore name currently not implemented.*/
+ int32 err;
+
+ err = OS_CountSemCreate(&csid,
+ "very very long semaphore name",/* Error.*/
+ 0,
+ 0);
+ test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
+ #endif
+ }
+
+ /* OS_CountSemDelete() is invoked with timer_id set to -1, an error
+ is expected.*/
+ test_set_step(5);
+ {
+ int32 err;
+
+ err = OS_CountSemDelete((uint32)-1);
+ test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
+ }
+
+ /* OS_CountSemCreate() is invoked twice with duplicated name, an
+ error is expected, then the queue is deleted using
+ OS_CountSemDelete().*/
+ test_set_step(6);
+ {
+ int32 err;
+ uint32 csid1; /*, csid2;*/
+
+ err = OS_CountSemCreate(&csid1, "my semaphore", 0, 0);
+ test_assert(err == OS_SUCCESS, "semaphore creation failed");
+
+ #if 0 /* Semaphore name currently not implemented.*/
+ err = OS_CountSemCreate(&csid2, "my semaphore", 0, 0);
+ test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected");
+ #endif
+
+ err = OS_CountSemDelete(csid1);
+ test_assert(err == OS_SUCCESS, "semaphore deletion failed");
+ }
+}
+
+static const testcase_t test_005_001 = {
+ "OS_CountSemCreate() and OS_CountSemDelete() errors",
+ NULL,
+ NULL,
+ test_005_001_execute
+};
+
+/**
+ * @page test_005_002 OS_CountSemGive() errors
+ *
+ * <h2>Description</h2>
+ * Parameters checking in OS_CountSemGive() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_CountSemGive() is invoked with sem_id set to -1, an error is
+ * expected.
+ * .
+ */
+
+static void test_005_002_execute(void) {
+
+ /* OS_CountSemGive() is invoked with sem_id set to -1, an error is
+ expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_CountSemGive((uint32)-1);
+ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
+ }
+}
+
+static const testcase_t test_005_002 = {
+ "OS_CountSemGive() errors",
+ NULL,
+ NULL,
+ test_005_002_execute
+};
+
+/**
+ * @page test_005_003 OS_CountSemTake() errors
+ *
+ * <h2>Description</h2>
+ * Parameters checking in OS_CountSemTake() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_BinSemTake() 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
+ expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_BinSemTake((uint32)-1);
+ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
+ }
+}
+
+static const testcase_t test_005_003 = {
+ "OS_CountSemTake() errors",
+ NULL,
+ NULL,
+ test_005_003_execute
+};
+
+/**
+ * @page test_005_004 OS_CountSemTimedWait() errors
+ *
+ * <h2>Description</h2>
+ * Parameters checking in OS_CountSemTimedWait() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_CountSemTimedWait() is invoked with sem_id set to -1, an error
+ * is expected.
+ * - OS_CountSemTimedWait() is invoked with msecs set to 0, an error is
+ * expected.
+ * .
+ */
+
+static void test_005_004_setup(void) {
+ csid = 0;
+ (void) OS_CountSemCreate(&csid, "test semaphore", 0, 0);
+}
+
+static void test_005_004_teardown(void) {
+ if (csid > 0) {
+ (void) OS_CountSemDelete(csid);
+ }
+}
+
+static void test_005_004_execute(void) {
+
+ /* OS_CountSemTimedWait() is invoked with sem_id set to -1, an error
+ is expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_CountSemTimedWait((uint32)-1, 1000);
+ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");
+ }
+
+ /* OS_CountSemTimedWait() is invoked with msecs set to 0, an error is
+ expected.*/
+ test_set_step(2);
+ {
+ int32 err;
+
+ err = OS_CountSemTimedWait(csid, 0);
+ test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected");
+ }
+}
+
+static const testcase_t test_005_004 = {
+ "OS_CountSemTimedWait() errors",
+ test_005_004_setup,
+ test_005_004_teardown,
+ test_005_004_execute
+};
+
+/**
+ * @page test_005_005 OS_CountSemGetIdByName() errors
+ *
+ * <h2>Description</h2>
+ * Parameters checking in OS_BinSemGetIdByName() is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an
+ * error is expected.
+ * - OS_CountSemGetIdByName() is invoked with semaphore name set to
+ * NULL, an error is expected.
+ * - OS_CountSemGetIdByName() is invoked with a very long task name, an
+ * error is expected.
+ * .
+ */
+
+static void test_005_005_execute(void) {
+
+ /* OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an
+ error is expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_CountSemGetIdByName(NULL, "semaphore");
+ test_assert(err == OS_INVALID_POINTER, "NULL not detected");
+ }
+
+ /* OS_CountSemGetIdByName() is invoked with semaphore name set to
+ NULL, an error is expected.*/
+ test_set_step(2);
+ {
+ int32 err;
+
+ err = OS_CountSemGetIdByName(&csid, NULL);
+ test_assert(err == OS_INVALID_POINTER, "NULL not detected");
+ }
+
+ /* OS_CountSemGetIdByName() is invoked with a very long task name, an
+ error is expected.*/
+ test_set_step(3);
+ {
+ int32 err;
+
+ err = OS_CountSemGetIdByName(&csid, "very very long semaphore name");
+ test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
+ }
+}
+
+static const testcase_t test_005_005 = {
+ "OS_CountSemGetIdByName() errors",
+ NULL,
+ NULL,
+ test_005_005_execute
+};
+
+/**
+ * @page test_005_006 OS_CountSemTimedWait() timeout functionality
+ *
+ * <h2>Description</h2>
+ * OS_CountSemCreate() timeout functionality is tested.
+ *
+ * <h2>Test Steps</h2>
+ * - OS_CountSemTimedWait() is invoked with timeout set to one second,
+ * an error is expected.
+ * .
+ */
+
+static void test_005_006_setup(void) {
+ csid = 0;
+ (void) OS_CountSemCreate(&csid, "test semaphore", 0, 0);
+}
+
+static void test_005_006_teardown(void) {
+ if (csid > 0) {
+ (void) OS_CountSemDelete(csid);
+ }
+}
+
+static void test_005_006_execute(void) {
+
+ /* OS_CountSemTimedWait() is invoked with timeout set to one second,
+ an error is expected.*/
+ test_set_step(1);
+ {
+ int32 err;
+
+ err = OS_CountSemTimedWait(csid, 1000);
+ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");
+ }
+}
+
+static const testcase_t test_005_006 = {
+ "OS_CountSemTimedWait() timeout functionality",
+ test_005_006_setup,
+ test_005_006_teardown,
+ test_005_006_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Counter Semaphores Functionality.
+ */
+const testcase_t * const test_sequence_005[] = {
+ &test_005_001,
+ &test_005_002,
+ &test_005_003,
+ &test_005_004,
+ &test_005_005,
+ &test_005_006,
+ NULL
+};
diff --git a/test/nasa_osal/source/test/test_sequence_005.h b/test/nasa_osal/source/test/test_sequence_005.h
new file mode 100644
index 000000000..4cb8e1db0
--- /dev/null
+++ b/test/nasa_osal/source/test/test_sequence_005.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_005[];
diff --git a/test/nasa_osal/test.mk b/test/nasa_osal/test.mk
index 2aa0e3f26..6597edc88 100644
--- a/test/nasa_osal/test.mk
+++ b/test/nasa_osal/test.mk
@@ -4,7 +4,8 @@ TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \
${CHIBIOS}/test/nasa_osal/source/test/test_sequence_001.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_004.c \
+ ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_005.c
# Required include directories
TESTINC = ${CHIBIOS}/test/lib \