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

This commit is contained in:
Giovanni Di Sirio 2016-03-10 10:07:14 +00:00
parent 2dccb17f8f
commit 21a8820047
3 changed files with 262 additions and 1 deletions

View File

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

View File

@ -854,6 +854,143 @@ test_assert_sequence("", "queue write errors occurred");]]></value>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_QueueGetIdByName() errors</value>
</brief>
<description>
<value>Parameters checking in OS_QueueGetIdByName() 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_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGetIdByName(NULL, "queue");
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGetIdByName(&qid, NULL);
test_assert(err == OS_INVALID_POINTER, "NULL not detected");]]></value>
</code>
</step>
<step>
<description>
<value>OS_QueueGetIdByName() is invoked with a very long task name, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGetIdByName(&qid, "very very long queue name");
test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_QueueGet() with timeout</value>
</brief>
<description>
<value>OS_QueueGetIdByName is tested.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[qid = 0;
(void) OS_QueueCreate(&qid, "test queue", 2, MESSAGE_SIZE, 0);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[if (qid != 0) {
OS_QueueDelete(qid);
}]]></value>
</teardown_code>
<local_variables>
<value><![CDATA[uint32 local_qid;
uint32 copied;
char data[MESSAGE_SIZE];]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>Retrieving the queue name.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGetIdByName(&local_qid, "test queue");
test_assert(err == OS_SUCCESS, "queue not found");]]></value>
</code>
</step>
<step>
<description>
<value>Get operation with a one second timeout, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(1000));
test_assert(err == OS_QUEUE_TIMEOUT, "unexpected error code");]]></value>
</code>
</step>
<step>
<description>
<value>Get operation in non-blocking mode, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_CHECK);
test_assert(err == OS_QUEUE_EMPTY, "unexpected error code");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
</sequences>

View File

@ -30,6 +30,8 @@
* <h2>Test Cases</h2>
* - @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
*
* <h2>Description</h2>
* Parameters checking in OS_QueueGetIdByName() is tested.
*
* <h2>Test Steps</h2>
* - 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
*
* <h2>Description</h2>
* OS_QueueGetIdByName is tested.
*
* <h2>Test Steps</h2>
* - 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
};