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

This commit is contained in:
Giovanni Di Sirio 2016-03-12 11:11:37 +00:00
parent d962e4e163
commit 991de13cad
7 changed files with 581 additions and 8 deletions

View File

@ -2067,7 +2067,7 @@ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
<steps>
<step>
<description>
<value>OS_BinSemTake() is invoked with sem_id set to -1, an error is expected.</value>
<value>OS_CountSemTake() is invoked with sem_id set to -1, an error is expected.</value>
</description>
<tags>
<value />
@ -2075,7 +2075,7 @@ test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
<code>
<value><![CDATA[int32 err;
err = OS_BinSemTake((uint32)-1);
err = OS_CountSemTake((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
</code>
</step>
@ -2141,7 +2141,7 @@ test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected");]]></value>
<value>OS_CountSemGetIdByName() errors</value>
</brief>
<description>
<value>Parameters checking in OS_BinSemGetIdByName() is tested.</value>
<value>Parameters checking in OS_CountSemGetIdByName() is tested.</value>
</description>
<condition>
<value />
@ -2245,6 +2245,277 @@ test_assert(err == OS_SEM_TIMEOUT, "unexpected error code");]]></value>
</case>
</cases>
</sequence>
<sequence>
<type index="0">
<value>Internal Tests</value>
</type>
<brief>
<value>Mutex Semaphores Functionality</value>
</brief>
<description>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to mutex semaphores.</value>
</description>
<shared_code>
<value><![CDATA[#include "osapi.h"
uint32 msid;]]></value>
</shared_code>
<cases>
<case>
<brief>
<value>OS_MutSemCreate() and OS_MutSemDelete() errors</value>
</brief>
<description>
<value>Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() 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_MutSemCreate() is invoked with sem_id set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemCreate(NULL, /* Error.*/
"failing semaphore",
0);
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemCreate() is invoked with sem_name set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemCreate(&msid,
NULL, /* Error.*/
0);
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemCreate() 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_MutSemCreate(&msid,
"very very long semaphore name", /* Error.*/
0);
test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
#endif]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemDelete() is invoked with timer_id set to -1, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemDelete((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_MutSemDelete().</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[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");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_MutSemGive() errors</value>
</brief>
<description>
<value>Parameters checking in OS_MutSemGive() 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_MutSemGive() is invoked with sem_id set to -1, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemGive((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_MutSemTake() errors</value>
</brief>
<description>
<value>Parameters checking in OS_MutSemTake() 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_MutSemTake() is invoked with sem_id set to -1, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemTake((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_MutSemGetIdByName() errors</value>
</brief>
<description>
<value>Parameters checking in OS_MutSemGetIdByName() 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_MutSemGetIdByName() is invoked with sem_id set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemGetIdByName(NULL, "semaphore");
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemGetIdByName(&msid, NULL);
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_MutSemGetIdByName() is invoked with a very long task name, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_MutSemGetIdByName(&msid, "very very long semaphore name");
test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
</sequences>
</instance>
</instances>

View File

@ -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
};

View File

@ -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. */

View File

@ -206,20 +206,20 @@ static const testcase_t test_005_002 = {
* Parameters checking in OS_CountSemTake() is tested.
*
* <h2>Test Steps</h2>
* - 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
*
* <h2>Description</h2>
* Parameters checking in OS_BinSemGetIdByName() is tested.
* Parameters checking in OS_CountSemGetIdByName() is tested.
*
* <h2>Test Steps</h2>
* - OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an

View File

@ -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
*
* <h2>Description</h2>
* This sequence tests the NASA OSAL over ChibiOS/RT functionalities
* related to mutex semaphores.
*
* <h2>Test Cases</h2>
* - @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
*
* <h2>Description</h2>
* Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is
* tested.
*
* <h2>Test Steps</h2>
* - 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
*
* <h2>Description</h2>
* Parameters checking in OS_MutSemGive() is tested.
*
* <h2>Test Steps</h2>
* - 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
*
* <h2>Description</h2>
* Parameters checking in OS_MutSemTake() is tested.
*
* <h2>Test Steps</h2>
* - 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
*
* <h2>Description</h2>
* Parameters checking in OS_MutSemGetIdByName() is tested.
*
* <h2>Test Steps</h2>
* - 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
};

View File

@ -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[];

View File

@ -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 \