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

This commit is contained in:
Giovanni Di Sirio 2016-03-08 08:38:54 +00:00
parent c3e44eb929
commit 742a1d93c8
6 changed files with 225 additions and 7 deletions

View File

@ -0,0 +1,66 @@
/*
ChibiOS - Copyright (C) 2006..2016 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.
*/
/**
* @file osapi-os-custom.h
* @brief Custom OSAPI extensions header.
*
* @addtogroup osapi-custom
* @{
*/
#ifndef _OSAPI_CUSTOM_H_
#define _OSAPI_CUSTOM_H_
/*===========================================================================*/
/* Module constants. */
/*===========================================================================*/
/*===========================================================================*/
/* Module pre-compile time settings. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
/*===========================================================================*/
/* Module macros. */
/*===========================================================================*/
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
boolean OS_TaskDeleteCheck(void);
#ifdef __cplusplus
}
#endif
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
#endif /* _OSAPI_CUSTOM_H_ */
/** @} */

View File

@ -133,6 +133,7 @@
//#include "osapi-os-net.h"
//#include "osapi-os-loader.h"
#include "osapi-os-timer.h"
#include "osapi-os-custom.h"
#ifdef __cplusplus
}

View File

@ -1777,10 +1777,26 @@ int32 OS_TaskInstallDeleteHandler(void *function_pointer) {
return OS_SUCCESS;
}
/**
* @brief Check for task termination request.
* @note This is a ChibiOS/RT extension, direct task delete is not
* allowed in RT.
*
* @return The termination request flag.
* @retval false if termination has not been requested.
* @retval true if termination has been requested.
*
* @api
*/
boolean OS_TaskDeleteCheck(void) {
return (boolean)chThdShouldTerminateX();
}
/**
* @brief Task delete.
* @note Limitation, it does not actually kill the thread, it just sets a
* flag in the thread that has then to terminate volountarly. The
* flag in the thread that has then to terminate voluntarily. The
* flag can be checked using @p chThdShouldTerminateX().
*
* @param[in] task_id the task id

View File

@ -10,7 +10,7 @@
<instance locked="false" id="org.chibios.spc5.components.chibios_unitary_tests_engine">
<description>
<introduction>
<value>This document has been automatically generated.</value>
<value>Test suite for NASA OSAL implementation over ChibiOS/RT. The purpose of this suite is to perform unit tests on the OSAL module and to converge to 100% code coverage through successive improvements.</value>
</introduction>
</description>
<global_data_and_code>
@ -44,7 +44,7 @@ THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE);]]></value>
<value>This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to threading.</value>
</description>
<shared_code>
<value><![CDATA[#include "osapi.h"
<value><![CDATA[#include "osapi.h"
static void test_thread1(void) {
@ -60,10 +60,18 @@ static void test_thread3(void) {
test_emit_token('C');
}
static void test_thread4(void) {
test_emit_token('D');
}
static void test_thread_delete(void) {
static void test_thread4(void) {
test_emit_token('D');
while (!OS_TaskDeleteCheck()) {
OS_TaskDelay(1);
}
test_emit_token('A');
}]]></value>
</shared_code>
<cases>
@ -490,6 +498,67 @@ test_assert_sequence("ABCD", "task order violation");]]></value>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_TaskDelete() errors</value>
</brief>
<description>
<value>Parameters checking in OS_TaskDelete() 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_TaskDelete() is invoked with task_id set to -1, an error is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[int32 err;
err = OS_TaskDelete((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "wrong task id not detected");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality</value>
</brief>
<description>
<value>OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for functionality.</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 />
</case>
</cases>
</sequence>
</sequences>

View File

@ -16,7 +16,9 @@
/**
* @mainpage Test Suite Specification
* This document has been automatically generated.
* Test suite for NASA OSAL implementation over ChibiOS/RT. The purpose
* of this suite is to perform unit tests on the OSAL module and to
* converge to 100% code coverage through successive improvements.
*
* <h2>Test Sequences</h2>
* - @subpage test_sequence_001

View File

@ -30,6 +30,8 @@
* <h2>Test Cases</h2>
* - @subpage test_001_001
* - @subpage test_001_002
* - @subpage test_001_003
* - @subpage test_001_004
* .
*/
@ -57,6 +59,14 @@ static void test_thread3(void) {
static void test_thread4(void) {
test_emit_token('D');
}
static void test_thread_delete(void) {
while (!OS_TaskDeleteCheck()) {
OS_TaskDelay(1);
}
test_emit_token('A');
}
/****************************************************************************
@ -448,6 +458,58 @@ static const testcase_t test_001_002 = {
test_001_002_execute
};
/**
* @page test_001_003 OS_TaskDelete() errors
*
* <h2>Description</h2>
* Parameters checking in OS_TaskDelete() is tested.
*
* <h2>Test Steps</h2>
* - OS_TaskDelete() is invoked with task_id set to -1, an error is
* expected.
* .
*/
static void test_001_003_execute(void) {
/* OS_TaskDelete() is invoked with task_id set to -1, an error is
expected.*/
test_set_step(1);
{
int32 err;
err = OS_TaskDelete((uint32)-1);
test_assert(err == OS_ERR_INVALID_ID, "wrong task id not detected");
}
}
static const testcase_t test_001_003 = {
"OS_TaskDelete() errors",
NULL,
NULL,
test_001_003_execute
};
/**
* @page test_001_004 OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality
*
* <h2>Description</h2>
* OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for
* functionality.
*
* <h2>Test Steps</h2>
*/
static void test_001_004_execute(void) {
}
static const testcase_t test_001_004 = {
"OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality",
NULL,
NULL,
test_001_004_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
@ -458,5 +520,7 @@ static const testcase_t test_001_002 = {
const testcase_t * const test_sequence_001[] = {
&test_001_001,
&test_001_002,
&test_001_003,
&test_001_004,
NULL
};