From 1c8b3555ba022ff63be257b69111f2137f08f449 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 8 Mar 2016 09:30:01 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9054 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- .../NASA-OSAL-STM32F746G-DISCOVERY/main.c | 5 +- test/nasa_osal/configuration.xml | 76 +++++++++++++++---- .../nasa_osal/source/test/test_sequence_001.c | 45 ++++++++++- 3 files changed, 103 insertions(+), 23 deletions(-) diff --git a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c index 31026f70c..9f94a613e 100644 --- a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c +++ b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/main.c @@ -50,11 +50,8 @@ int main(void) { /* OS initialization.*/ (void) OS_API_Init(); - /* Activates the serial driver 2 using the driver default configuration. - PA2(TX) and PA3(RX) are routed to USART2.*/ + /* Activates the serial driver 1 using the driver default configuration.*/ sdStart(&SD1, NULL); - palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); - palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); /* GPIOI1 is programmed as output (board LED).*/ palClearLine(LINE_ARD_D13); diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index 7eab9b5a9..732f80946 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -44,7 +44,7 @@ THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE);]]> This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to threading. - @@ -528,9 +535,9 @@ test_assert_sequence("ABCD", "task order violation");]]> - @@ -554,10 +561,47 @@ test_assert(err == OS_ERR_INVALID_ID, "wrong task id not detected");]]> - + - + + + + Creating a task executing an infinite loop. + + + + + + + + + + + Letting the task run for a while then deleting it. A check is performed on the correct execution of the delete handler. + + + + + + + + + diff --git a/test/nasa_osal/source/test/test_sequence_001.c b/test/nasa_osal/source/test/test_sequence_001.c index 7c7829d8a..f8081cde1 100644 --- a/test/nasa_osal/source/test/test_sequence_001.c +++ b/test/nasa_osal/source/test/test_sequence_001.c @@ -61,12 +61,19 @@ static void test_thread4(void) { test_emit_token('D'); } +static void delete_handler(void) { + + test_emit_token('C'); +} + static void test_thread_delete(void) { - while (!OS_TaskDeleteCheck()) { - OS_TaskDelay(1); - } test_emit_token('A'); + (void) OS_TaskInstallDeleteHandler(delete_handler); + while (!OS_TaskDeleteCheck()) { + (void) OS_TaskDelay(1); + } + test_emit_token('B'); } /**************************************************************************** @@ -498,9 +505,41 @@ static const testcase_t test_001_003 = { * functionality. * *

Test Steps

+ * - Creating a task executing an infinite loop. + * - Letting the task run for a while then deleting it. A check is + * performed on the correct execution of the delete handler. + * . */ static void test_001_004_execute(void) { + uint32 tid; + + /* Creating a task executing an infinite loop.*/ + test_set_step(1); + { + int32 err; + + err = OS_TaskCreate(&tid, + "deletable thread", + test_thread_delete, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_SUCCESS, "deletable task creation failed"); + } + + /* Letting the task run for a while then deleting it. A check is + performed on the correct execution of the delete handler.*/ + test_set_step(2); + { + int32 err; + + (void) OS_TaskDelay(50); + err = OS_TaskDelete(tid); + test_assert(err == OS_SUCCESS, "delete failed"); + test_assert_sequence("ABC", "events order violation"); + } } static const testcase_t test_001_004 = {