From 2b8e64aada976519f7a6d7f6c84b2eb7a6b2b779 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 24 Oct 2017 08:54:27 +0000 Subject: NASA OSAL test suite reworked. Fixes to the OSAL related to the API change. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10892 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/Makefile | 3 +- demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/chconf.h | 2 +- .../STM32/NASA-OSAL-STM32F746G-DISCOVERY/Makefile | 3 +- .../STM32/NASA-OSAL-STM32F746G-DISCOVERY/chconf.h | 2 +- os/common/abstractions/nasa_cfe/osal/src/osapi.c | 16 +- test/nasa_osal/configuration.xml | 3 + test/nasa_osal/nasa_osal_test.mk | 11 + test/nasa_osal/source/test/nasa_osal_test_root.c | 63 +++ test/nasa_osal/source/test/nasa_osal_test_root.h | 51 ++ .../source/test/nasa_osal_test_sequence_001.c | 565 +++++++++++++++++++++ .../source/test/nasa_osal_test_sequence_001.h | 13 + .../source/test/nasa_osal_test_sequence_002.c | 392 ++++++++++++++ .../source/test/nasa_osal_test_sequence_002.h | 13 + .../source/test/nasa_osal_test_sequence_003.c | 434 ++++++++++++++++ .../source/test/nasa_osal_test_sequence_003.h | 13 + .../source/test/nasa_osal_test_sequence_004.c | 433 ++++++++++++++++ .../source/test/nasa_osal_test_sequence_004.h | 13 + .../source/test/nasa_osal_test_sequence_005.c | 399 +++++++++++++++ .../source/test/nasa_osal_test_sequence_005.h | 13 + .../source/test/nasa_osal_test_sequence_006.c | 279 ++++++++++ .../source/test/nasa_osal_test_sequence_006.h | 13 + test/nasa_osal/source/test/test_root.c | 56 -- test/nasa_osal/source/test/test_root.h | 49 -- test/nasa_osal/source/test/test_sequence_001.c | 558 -------------------- test/nasa_osal/source/test/test_sequence_001.h | 13 - test/nasa_osal/source/test/test_sequence_002.c | 385 -------------- test/nasa_osal/source/test/test_sequence_002.h | 13 - test/nasa_osal/source/test/test_sequence_003.c | 427 ---------------- test/nasa_osal/source/test/test_sequence_003.h | 13 - test/nasa_osal/source/test/test_sequence_004.c | 426 ---------------- test/nasa_osal/source/test/test_sequence_004.h | 13 - test/nasa_osal/source/test/test_sequence_005.c | 392 -------------- test/nasa_osal/source/test/test_sequence_005.h | 13 - test/nasa_osal/source/test/test_sequence_006.c | 272 ---------- test/nasa_osal/source/test/test_sequence_006.h | 13 - test/nasa_osal/test.mk | 13 - 36 files changed, 2722 insertions(+), 2668 deletions(-) create mode 100644 test/nasa_osal/nasa_osal_test.mk create mode 100644 test/nasa_osal/source/test/nasa_osal_test_root.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_root.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_001.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_001.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_002.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_002.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_003.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_003.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_004.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_004.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_005.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_005.h create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_006.c create mode 100644 test/nasa_osal/source/test/nasa_osal_test_sequence_006.h delete mode 100644 test/nasa_osal/source/test/test_root.c delete mode 100644 test/nasa_osal/source/test/test_root.h delete mode 100644 test/nasa_osal/source/test/test_sequence_001.c delete mode 100644 test/nasa_osal/source/test/test_sequence_001.h delete mode 100644 test/nasa_osal/source/test/test_sequence_002.c delete mode 100644 test/nasa_osal/source/test/test_sequence_002.h delete mode 100644 test/nasa_osal/source/test/test_sequence_003.c delete mode 100644 test/nasa_osal/source/test/test_sequence_003.h delete mode 100644 test/nasa_osal/source/test/test_sequence_004.c delete mode 100644 test/nasa_osal/source/test/test_sequence_004.h delete mode 100644 test/nasa_osal/source/test/test_sequence_005.c delete mode 100644 test/nasa_osal/source/test/test_sequence_005.h delete mode 100644 test/nasa_osal/source/test/test_sequence_006.c delete mode 100644 test/nasa_osal/source/test/test_sequence_006.h delete mode 100644 test/nasa_osal/test.mk diff --git a/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/Makefile b/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/Makefile index 16eed43f1..20d8e28cc 100644 --- a/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/Makefile +++ b/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/Makefile @@ -98,7 +98,8 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk include $(CHIBIOS)/os/rt/rt.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk # Other files (optional). -include $(CHIBIOS)/test/nasa_osal/test.mk +include $(CHIBIOS)/test/lib/test.mk +include $(CHIBIOS)/test/nasa_osal/nasa_osal_test.mk include $(CHIBIOS)/os/common/abstractions/nasa_cfe/osal/cfe_osal.mk include $(CHIBIOS)/os/common/abstractions/nasa_cfe/psp/cfe_psp.mk diff --git a/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/chconf.h b/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/chconf.h index a4e130fdb..7a192f6ac 100644 --- a/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/chconf.h +++ b/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/chconf.h @@ -331,7 +331,7 @@ * * @note The default is @p FALSE. */ -#define CH_CFG_USE_FACTORY TRUE +#define CH_CFG_USE_FACTORY FALSE /** * @brief Maximum length for object names. diff --git a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/Makefile b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/Makefile index 0c23ce29f..4eb2de745 100644 --- a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/Makefile +++ b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/Makefile @@ -98,7 +98,8 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk include $(CHIBIOS)/os/rt/rt.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk # Other files (optional). -include $(CHIBIOS)/test/nasa_osal/test.mk +include $(CHIBIOS)/test/lib/test.mk +include $(CHIBIOS)/test/nasa_osal/nasa_osal_test.mk include $(CHIBIOS)/os/common/abstractions/nasa_cfe/osal/cfe_osal.mk include $(CHIBIOS)/os/common/abstractions/nasa_cfe/psp/cfe_psp.mk diff --git a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/chconf.h b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/chconf.h index 3da22fc8b..42edb2413 100644 --- a/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/chconf.h +++ b/demos/STM32/NASA-OSAL-STM32F746G-DISCOVERY/chconf.h @@ -331,7 +331,7 @@ * * @note The default is @p FALSE. */ -#define CH_CFG_USE_FACTORY TRUE +#define CH_CFG_USE_FACTORY FALSE /** * @brief Maximum length for object names. diff --git a/os/common/abstractions/nasa_cfe/osal/src/osapi.c b/os/common/abstractions/nasa_cfe/osal/src/osapi.c index 5107b6f79..0668daa22 100644 --- a/os/common/abstractions/nasa_cfe/osal/src/osapi.c +++ b/os/common/abstractions/nasa_cfe/osal/src/osapi.c @@ -161,7 +161,7 @@ static osal_t osal; * @brief System time callback. */ static void systime_update(void *p) { - systime_t delay = (systime_t)p; + sysinterval_t delay = (sysinterval_t)p; chSysLockFromISR(); osal.localtime.microsecs += 1000; @@ -185,7 +185,7 @@ static void timer_handler(void *p) { /* Timer restart if an interval is defined.*/ if (otp->interval_time != 0) { chSysLockFromISR(); - chVTSetI(&otp->vt, US2ST(otp->interval_time), timer_handler, p); + chVTSetI(&otp->vt, TIME_US2I(otp->interval_time), timer_handler, p); chSysUnlockFromISR(); } } @@ -268,7 +268,7 @@ int32 OS_API_Init(void) { osal.localtime.microsecs = 0; osal.localtime.seconds = 0; chVTObjectInit(&osal.vt); - chVTSet(&osal.vt, MS2ST(1), systime_update, (void *)MS2ST(1)); + chVTSet(&osal.vt, TIME_MS2I(1), systime_update, (void *)TIME_MS2I(1)); /* Timers pool initialization.*/ chPoolObjectInit(&osal.timers_pool, @@ -429,7 +429,7 @@ int32 OS_SetLocalTime(OS_time_t *time_struct) { */ int32 OS_Milli2Ticks(uint32 milli_seconds) { - return (int32)MS2ST(milli_seconds); + return (int32)TIME_MS2I(milli_seconds); } /*-- timers API -------------------------------------------------------------*/ @@ -560,7 +560,7 @@ int32 OS_TimerSet(uint32 timer_id, uint32 start_time, uint32 interval_time) { else { otp->start_time = start_time; otp->interval_time = interval_time; - chVTSetI(&otp->vt, US2ST(start_time), timer_handler, (void *)timer_id); + chVTSetI(&otp->vt, TIME_US2I(start_time), timer_handler, (void *)timer_id); } /* Leaving the critical zone.*/ @@ -833,7 +833,7 @@ int32 OS_QueueGet(uint32 queue_id, void *data, uint32 size, } } else { - msgsts = chMBFetchTimeout(&oqp->mb, &msg, (systime_t)timeout); + msgsts = chMBFetchTimeout(&oqp->mb, &msg, (sysinterval_t)timeout); if (msgsts < MSG_OK) { *size_copied = 0; return OS_QUEUE_TIMEOUT; @@ -1210,7 +1210,7 @@ int32 OS_BinSemTimedWait(uint32 sem_id, uint32 msecs) { return OS_SEM_FAILURE; } - msg = chBSemWaitTimeoutS(bsp, MS2ST(msecs)); + msg = chBSemWaitTimeoutS(bsp, TIME_MS2I(msecs)); chSysUnlock(); @@ -1467,7 +1467,7 @@ int32 OS_CountSemTimedWait(uint32 sem_id, uint32 msecs) { return OS_SEM_FAILURE; } - msg = chSemWaitTimeoutS(sp, MS2ST(msecs)); + msg = chSemWaitTimeoutS(sp, TIME_MS2I(msecs)); chSysUnlock(); diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index 4cb7755ae..24a01ea67 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -17,6 +17,9 @@ + + nasa_osal_ + Test Sequences + * - @subpage nasa_osal_test_sequence_001 + * - @subpage nasa_osal_test_sequence_002 + * - @subpage nasa_osal_test_sequence_003 + * - @subpage nasa_osal_test_sequence_004 + * - @subpage nasa_osal_test_sequence_005 + * - @subpage nasa_osal_test_sequence_006 + * . + */ + +/** + * @file nasa_osal_test_root.c + * @brief Test Suite root structures code. + */ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +#if !defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/** + * @brief Array of test sequences. + */ +const testsequence_t * const nasa_osal_test_suite_array[] = { + &nasa_osal_test_sequence_001, + &nasa_osal_test_sequence_002, + &nasa_osal_test_sequence_003, + &nasa_osal_test_sequence_004, + &nasa_osal_test_sequence_005, + &nasa_osal_test_sequence_006, + NULL +}; + +/** + * @brief Test suite root structure. + */ +const testsuite_t nasa_osal_test_suite = { + "Test specification for the NASA OSAL ChibiOS extension.", + nasa_osal_test_suite_array +}; + +/*===========================================================================*/ +/* Shared code. */ +/*===========================================================================*/ + +THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); +THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); +THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); +THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); + +#endif /* !defined(__DOXYGEN__) */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_root.h b/test/nasa_osal/source/test/nasa_osal_test_root.h new file mode 100644 index 000000000..88bad5dde --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_root.h @@ -0,0 +1,51 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_root.h + * @brief Test Suite root structures header. + */ + +#ifndef NASA_OSAL_TEST_ROOT_H +#define NASA_OSAL_TEST_ROOT_H + +#include "ch_test.h" + +#include "nasa_osal_test_sequence_001.h" +#include "nasa_osal_test_sequence_002.h" +#include "nasa_osal_test_sequence_003.h" +#include "nasa_osal_test_sequence_004.h" +#include "nasa_osal_test_sequence_005.h" +#include "nasa_osal_test_sequence_006.h" + +#if !defined(__DOXYGEN__) + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern const testsuite_t nasa_osal_test_suite; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Shared definitions. */ +/*===========================================================================*/ + +#define TEST_SUITE_NAME "NASA OSAL over ChibiOS/RT Test Suite" + +#define TASKS_BASE_PRIORITY 200 +#define TASKS_STACK_SIZE 256 + +extern THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); +extern THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); +extern THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); +extern THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); + +#endif /* !defined(__DOXYGEN__) */ + +#endif /* NASA_OSAL_TEST_ROOT_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_001.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_001.c new file mode 100644 index 000000000..b26f9911c --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_001.c @@ -0,0 +1,565 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_001.c + * @brief Test Sequence 001 code. + * + * @page nasa_osal_test_sequence_001 [1] Tasks Functionality + * + * File: @ref nasa_osal_test_sequence_001.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to threading. + * + *

Test Cases

+ * - @subpage nasa_osal_test_001_001 + * - @subpage nasa_osal_test_001_002 + * - @subpage nasa_osal_test_001_003 + * - @subpage nasa_osal_test_001_004 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include "osapi.h" + +static void test_task1(void) { + + test_emit_token('A'); +} + +static void test_task2(void) { + + test_emit_token('B'); +} + +static void test_task3(void) { + + test_emit_token('C'); +} + +static void test_task4(void) { + + test_emit_token('D'); +} + +static void delete_handler(void) { + + test_emit_token('C'); +} + +static void test_task_delete(void) { + + test_emit_token('A'); + (void) OS_TaskInstallDeleteHandler(delete_handler); + while (!OS_TaskDeleteCheck()) { + (void) OS_TaskDelay(1); + } + test_emit_token('B'); +} + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_001_001 [1.1] OS_TaskCreate() errors + * + *

Description

+ * Parameters checking in OS_TaskCreate() is tested. + * + *

Test Steps

+ * - [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an + * error is expected. + * - [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an + * error is expected. + * - [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL, + * an error is expected. + * - [1.1.4] OS_TaskCreate() is invoked with a very long task name, an + * error is expected. + * - [1.1.5] OS_TaskCreate() is invoked with priority below and above + * allowed range, an error is expected. + * - [1.1.6] OS_TaskCreate() is invoked with a stack size below + * minimum, an error is expected. + * - [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and + * then duplicated stack, an error is expected in both cases. + * . + */ + +static void nasa_osal_test_001_001_execute(void) { + + /* [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_TaskCreate(NULL, /* Error.*/ + "failing task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an + error is expected.*/ + test_set_step(2); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + NULL, /* Error.*/ + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL, + an error is expected.*/ + test_set_step(3); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + "failing task", + test_task1, + (uint32 *)NULL, /* Error.*/ + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.4] OS_TaskCreate() is invoked with a very long task name, an + error is expected.*/ + test_set_step(4); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + "this is a very very long task name", /* Error.*/ + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.5] OS_TaskCreate() is invoked with priority below and above + allowed range, an error is expected.*/ + test_set_step(5); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + "failing task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + 0, /* Error.*/ + 0); + test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected"); + test_assert_sequence("", "task executed"); + + err = OS_TaskCreate(&tid, + "failing task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + 256, /* Error.*/ + 0); + test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.6] OS_TaskCreate() is invoked with a stack size below + minimum, an error is expected.*/ + test_set_step(6); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + "failing task", + test_task1, + (uint32 *)wa_test1, + 16, /* Error.*/ + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_INVALID_INT_NUM, "stack insufficient size not detected"); + test_assert_sequence("", "task executed"); + } + + /* [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and + then duplicated stack, an error is expected in both cases.*/ + test_set_step(7); + { + int32 err; + uint32 tid; + + err = OS_TaskCreate(&tid, + "running task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_SUCCESS, "task creation failed"); + + err = OS_TaskCreate(&tid, + "running task", + test_task2, + (uint32 *)wa_test2, + sizeof wa_test2, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); + + err = OS_TaskCreate(&tid, + "conflicting task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_ERR_NO_FREE_IDS, "stack conflict not detected"); + + err = OS_TaskWait(tid); + test_assert(err == OS_SUCCESS, "wait failed"); + test_assert_sequence("A", "task not executed"); + + err = OS_TaskCreate(&tid, + "running task", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_SUCCESS, "task creation failed"); + + err = OS_TaskWait(tid); + test_assert(err == OS_SUCCESS, "wait failed"); + test_assert_sequence("A", "task not executed"); + } +} + +static const testcase_t nasa_osal_test_001_001 = { + "OS_TaskCreate() errors", + NULL, + NULL, + nasa_osal_test_001_001_execute +}; + +/** + * @page nasa_osal_test_001_002 [1.2] OS_TaskCreate() priority ordering + * + *

Description

+ * Four tasks are created at different priorities and in different + * order. The execution order must happen in order of priority + * regardless the creation order. + * + *

Test Steps

+ * - [1.2.1] Four tasks are created in priority order from low to high. + * - [1.2.2] Tasks are made runnable atomically and their execution + * order tested. + * - [1.2.3] Four tasks are created in priority order from high to low. + * - [1.2.4] Tasks are made runnable atomically and their execution + * order tested. + * - [1.2.5] Four tasks are created in an not ordered way. + * - [1.2.6] Tasks are made runnable atomically and their execution + * order tested. + * . + */ + +static void nasa_osal_test_001_002_execute(void) { + + /* [1.2.1] Four tasks are created in priority order from low to + high.*/ + test_set_step(1); + { + int32 err; + uint32 tid1, tid2, tid3, tid4; + + err = OS_TaskCreate(&tid4, + "running task 4", + test_task4, + (uint32 *)wa_test4, + sizeof wa_test4, + TASKS_BASE_PRIORITY - 0, + 0); + test_assert(err == OS_SUCCESS, "task 4 creation failed"); + + err = OS_TaskCreate(&tid3, + "running task 3", + test_task3, + (uint32 *)wa_test3, + sizeof wa_test3, + TASKS_BASE_PRIORITY - 1, + 0); + test_assert(err == OS_SUCCESS, "task 3 creation failed"); + + err = OS_TaskCreate(&tid2, + "running task 2", + test_task2, + (uint32 *)wa_test2, + sizeof wa_test2, + TASKS_BASE_PRIORITY - 2, + 0); + test_assert(err == OS_SUCCESS, "task 2 creation failed"); + + err = OS_TaskCreate(&tid1, + "running task 1", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY - 3, + 0); + test_assert(err == OS_SUCCESS, "task 1 creation failed"); + } + + /* [1.2.2] Tasks are made runnable atomically and their execution + order tested.*/ + test_set_step(2); + { + OS_TaskDelay(5); + test_assert_sequence("ABCD", "task order violation"); + } + + /* [1.2.3] Four tasks are created in priority order from high to + low.*/ + test_set_step(3); + { + int32 err; + uint32 tid1, tid2, tid3, tid4; + + err = OS_TaskCreate(&tid1, + "running task 1", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY - 3, + 0); + test_assert(err == OS_SUCCESS, "task 1 creation failed"); + + err = OS_TaskCreate(&tid2, + "running task 2", + test_task2, + (uint32 *)wa_test2, + sizeof wa_test2, + TASKS_BASE_PRIORITY - 2, + 0); + test_assert(err == OS_SUCCESS, "task 2 creation failed"); + + err = OS_TaskCreate(&tid3, + "running task 3", + test_task3, + (uint32 *)wa_test3, + sizeof wa_test3, + TASKS_BASE_PRIORITY - 1, + 0); + test_assert(err == OS_SUCCESS, "task 3 creation failed"); + + err = OS_TaskCreate(&tid4, + "running task 4", + test_task4, + (uint32 *)wa_test4, + sizeof wa_test4, + TASKS_BASE_PRIORITY - 0, + 0); + test_assert(err == OS_SUCCESS, "task 4 creation failed"); + } + + /* [1.2.4] Tasks are made runnable atomically and their execution + order tested.*/ + test_set_step(4); + { + OS_TaskDelay(5); + test_assert_sequence("ABCD", "task order violation"); + } + + /* [1.2.5] Four tasks are created in an not ordered way.*/ + test_set_step(5); + { + int32 err; + uint32 tid1, tid2, tid3, tid4; + + err = OS_TaskCreate(&tid2, + "running task 2", + test_task2, + (uint32 *)wa_test2, + sizeof wa_test2, + TASKS_BASE_PRIORITY - 2, + 0); + test_assert(err == OS_SUCCESS, "task 2 creation failed"); + + err = OS_TaskCreate(&tid1, + "running task 1", + test_task1, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY - 3, + 0); + test_assert(err == OS_SUCCESS, "task 1 creation failed"); + + err = OS_TaskCreate(&tid4, + "running task 4", + test_task4, + (uint32 *)wa_test4, + sizeof wa_test4, + TASKS_BASE_PRIORITY - 0, + 0); + test_assert(err == OS_SUCCESS, "task 4 creation failed"); + + err = OS_TaskCreate(&tid3, + "running task 3", + test_task3, + (uint32 *)wa_test3, + sizeof wa_test3, + TASKS_BASE_PRIORITY - 1, + 0); + test_assert(err == OS_SUCCESS, "task 3 creation failed"); + } + + /* [1.2.6] Tasks are made runnable atomically and their execution + order tested.*/ + test_set_step(6); + { + OS_TaskDelay(5); + test_assert_sequence("ABCD", "task order violation"); + } +} + +static const testcase_t nasa_osal_test_001_002 = { + "OS_TaskCreate() priority ordering", + NULL, + NULL, + nasa_osal_test_001_002_execute +}; + +/** + * @page nasa_osal_test_001_003 [1.3] OS_TaskDelete() errors + * + *

Description

+ * Parameters checking in OS_TaskDelete() is tested. + * + *

Test Steps

+ * - [1.3.1] OS_TaskDelete() is invoked with task_id set to -1, an + * error is expected. + * . + */ + +static void nasa_osal_test_001_003_execute(void) { + + /* [1.3.1] 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 nasa_osal_test_001_003 = { + "OS_TaskDelete() errors", + NULL, + NULL, + nasa_osal_test_001_003_execute +}; + +/** + * @page nasa_osal_test_001_004 [1.4] OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality + * + *

Description

+ * OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for + * functionality. + * + *

Test Steps

+ * - [1.4.1] Creating a task executing an infinite loop. + * - [1.4.2] Letting the task run for a while then deleting it. A check + * is performed on the correct execution of the delete handler. + * . + */ + +static void nasa_osal_test_001_004_execute(void) { + uint32 tid; + + /* [1.4.1] Creating a task executing an infinite loop.*/ + test_set_step(1); + { + int32 err; + + err = OS_TaskCreate(&tid, + "deletable task", + test_task_delete, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_SUCCESS, "deletable task creation failed"); + } + + /* [1.4.2] 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 nasa_osal_test_001_004 = { + "OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality", + NULL, + NULL, + nasa_osal_test_001_004_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_001_array[] = { + &nasa_osal_test_001_001, + &nasa_osal_test_001_002, + &nasa_osal_test_001_003, + &nasa_osal_test_001_004, + NULL +}; + +/** + * @brief Tasks Functionality. + */ +const testsequence_t nasa_osal_test_sequence_001 = { + "Tasks Functionality", + nasa_osal_test_sequence_001_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_001.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_001.h new file mode 100644 index 000000000..4365c302f --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_001.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_001.h + * @brief Test Sequence 001 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_001_H +#define NASA_OSAL_TEST_SEQUENCE_001_H + +extern const testsequence_t nasa_osal_test_sequence_001; + +#endif /* NASA_OSAL_TEST_SEQUENCE_001_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_002.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_002.c new file mode 100644 index 000000000..392e70211 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_002.c @@ -0,0 +1,392 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_002.c + * @brief Test Sequence 002 code. + * + * @page nasa_osal_test_sequence_002 [2] Queues Functionality + * + * File: @ref nasa_osal_test_sequence_002.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to queues. + * + *

Test Cases

+ * - @subpage nasa_osal_test_002_001 + * - @subpage nasa_osal_test_002_002 + * - @subpage nasa_osal_test_002_003 + * - @subpage nasa_osal_test_002_004 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include + +#include "osapi.h" + +uint32 qid, tid; + +#define WRITER_NUM_MESSAGES 16 +#define MESSAGE_SIZE 20 + +static void test_task_writer(void) { + unsigned i; + int32 err; + + for (i = 0; i < WRITER_NUM_MESSAGES; i++) { + err = OS_QueuePut(qid, "Hello World", 12, 0); + if (err != OS_SUCCESS) { + test_emit_token('*'); + } + } +} + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_002_001 [2.1] OS_QueueCreate() and OS_QueueDelete() errors + * + *

Description

+ * Parameters checking in OS_QueueCreate() and OS_QueueDelete() is + * tested. + * + *

Test Steps

+ * - [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an + * error is expected. + * - [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an + * error is expected. + * - [2.1.3] OS_QueueCreate() is invoked with a very long task name, an + * error is expected. + * - [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an + * error is expected. + * - [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an + * error is expected, then the queue is deleted using + * OS_QueueDelete(). + * . + */ + +static void nasa_osal_test_002_001_execute(void) { + + /* [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_QueueCreate(NULL, /* Error.*/ + "failing queue", + 4, + 128, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an + error is expected.*/ + test_set_step(2); + { + int32 err; + uint32 qid; + + err = OS_QueueCreate(&qid, + NULL, /* Error.*/ + 4, + 128, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [2.1.3] OS_QueueCreate() is invoked with a very long task name, an + error is expected.*/ + test_set_step(3); + { + int32 err; + uint32 qid; + + err = OS_QueueCreate(&qid, + "very very long queue name", /* Error.*/ + 4, + 128, + 0); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } + + /* [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an + error is expected.*/ + test_set_step(4); + { + int32 err; + + err = OS_QueueDelete((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "wrong queue id not detected"); + } + + /* [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an + error is expected, then the queue is deleted using + OS_QueueDelete().*/ + test_set_step(5); + { + int32 err; + uint32 qid1, qid2; + + err = OS_QueueCreate(&qid1, "my queue", 4, 128, 0); + test_assert(err == OS_SUCCESS, "queue creation failed"); + + err = OS_QueueCreate(&qid2, "my queue", 4, 128, 0); + test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); + + err = OS_QueueDelete(qid1); + test_assert(err == OS_SUCCESS, "queue deletion failed"); + } +} + +static const testcase_t nasa_osal_test_002_001 = { + "OS_QueueCreate() and OS_QueueDelete() errors", + NULL, + NULL, + nasa_osal_test_002_001_execute +}; + +/** + * @page nasa_osal_test_002_002 [2.2] OS_QueueGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_QueueGetIdByName() is tested. + * + *

Test Steps

+ * - [2.2.1] OS_QueueGetIdByName() is invoked with queue_id set to + * NULL, an error is expected. + * - [2.2.2] OS_QueueGetIdByName() is invoked with queue_name set to + * NULL, an error is expected. + * - [2.2.3] OS_QueueGetIdByName() is invoked with a very long task + * name, an error is expected. + * . + */ + +static void nasa_osal_test_002_002_execute(void) { + + /* [2.2.1] 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"); + } + + /* [2.2.2] 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"); + } + + /* [2.2.3] 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 nasa_osal_test_002_002 = { + "OS_QueueGetIdByName() errors", + NULL, + NULL, + nasa_osal_test_002_002_execute +}; + +/** + * @page nasa_osal_test_002_003 [2.3] OS_QueuePut() and OS_QueueGet() functionality + * + *

Description

+ * A task writes on a queue, the messages are retrieved on the other + * side in blocking mode. + * + *

Test Steps

+ * - [2.3.1] Creataing a queue with depth 4 and message size 20. + * - [2.3.2] Creating the writer task. + * - [2.3.3] Reading messages from the writer task. + * - [2.3.4] Waiting for task termination then checking for errors. + * . + */ + +static void nasa_osal_test_002_003_setup(void) { + qid = 0; + tid = 0; +} + +static void nasa_osal_test_002_003_teardown(void) { + if (qid != 0) { + (void) OS_QueueDelete(qid); + } + + if (tid != 0) { + (void) OS_TaskWait(tid); + } +} + +static void nasa_osal_test_002_003_execute(void) { + uint32 tid; + unsigned i; + + /* [2.3.1] Creataing a queue with depth 4 and message size 20.*/ + test_set_step(1); + { + int32 err; + + err = OS_QueueCreate(&qid, "test queue", 4, MESSAGE_SIZE, 0); + test_assert(err == OS_SUCCESS, "queue creation failed"); + } + + /* [2.3.2] Creating the writer task.*/ + test_set_step(2); + { + int32 err; + + err = OS_TaskCreate(&tid, + "writer task", + test_task_writer, + (uint32 *)wa_test1, + sizeof wa_test1, + TASKS_BASE_PRIORITY, + 0); + test_assert(err == OS_SUCCESS, "writer task creation failed"); + } + + /* [2.3.3] Reading messages from the writer task.*/ + test_set_step(3); + { + for (i = 0; i < WRITER_NUM_MESSAGES; i++) { + int32 err; + char data[MESSAGE_SIZE]; + uint32 copied; + + err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(200)); + test_assert(err == OS_SUCCESS, "timed out"); + test_assert(strncmp(data, "Hello World", sizeof (data)) == 0, + "wrong message"); + } + } + + /* [2.3.4] Waiting for task termination then checking for errors.*/ + test_set_step(4); + { + (void) OS_TaskWait(tid); + tid = 0; + test_assert_sequence("", "queue write errors occurred"); + } +} + +static const testcase_t nasa_osal_test_002_003 = { + "OS_QueuePut() and OS_QueueGet() functionality", + nasa_osal_test_002_003_setup, + nasa_osal_test_002_003_teardown, + nasa_osal_test_002_003_execute +}; + +/** + * @page nasa_osal_test_002_004 [2.4] OS_QueueGet() with timeout functionality + * + *

Description

+ * OS_QueueGet() timeout functionality is tested. + * + *

Test Steps

+ * - [2.4.1] Retrieving the queue by name. + * - [2.4.2] Get operation with a one second timeout, an error is + * expected. + * - [2.4.3] Get operation in non-blocking mode, an error is expected. + * . + */ + +static void nasa_osal_test_002_004_setup(void) { + qid = 0; + (void) OS_QueueCreate(&qid, "test queue", 2, MESSAGE_SIZE, 0); +} + +static void nasa_osal_test_002_004_teardown(void) { + if (qid != 0) { + OS_QueueDelete(qid); + } +} + +static void nasa_osal_test_002_004_execute(void) { + uint32 local_qid; + uint32 copied; + char data[MESSAGE_SIZE]; + + /* [2.4.1] Retrieving the queue by name.*/ + test_set_step(1); + { + int32 err; + + err = OS_QueueGetIdByName(&local_qid, "test queue"); + test_assert(err == OS_SUCCESS, "queue not found"); + } + + /* [2.4.2] 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"); + } + + /* [2.4.3] 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 nasa_osal_test_002_004 = { + "OS_QueueGet() with timeout functionality", + nasa_osal_test_002_004_setup, + nasa_osal_test_002_004_teardown, + nasa_osal_test_002_004_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_002_array[] = { + &nasa_osal_test_002_001, + &nasa_osal_test_002_002, + &nasa_osal_test_002_003, + &nasa_osal_test_002_004, + NULL +}; + +/** + * @brief Queues Functionality. + */ +const testsequence_t nasa_osal_test_sequence_002 = { + "Queues Functionality", + nasa_osal_test_sequence_002_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_002.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_002.h new file mode 100644 index 000000000..5fdff098c --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_002.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_002.h + * @brief Test Sequence 002 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_002_H +#define NASA_OSAL_TEST_SEQUENCE_002_H + +extern const testsequence_t nasa_osal_test_sequence_002; + +#endif /* NASA_OSAL_TEST_SEQUENCE_002_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_003.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_003.c new file mode 100644 index 000000000..699ad0f60 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_003.c @@ -0,0 +1,434 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_003.c + * @brief Test Sequence 003 code. + * + * @page nasa_osal_test_sequence_003 [3] Timers Functionality + * + * File: @ref nasa_osal_test_sequence_003.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to timers. + * + *

Test Cases

+ * - @subpage nasa_osal_test_003_001 + * - @subpage nasa_osal_test_003_002 + * - @subpage nasa_osal_test_003_003 + * - @subpage nasa_osal_test_003_004 + * - @subpage nasa_osal_test_003_005 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include + +#include "osapi.h" + +uint32 tmid; +uint32 cnt; + +static void tmr_callback(uint32 timer_id) { + + (void)timer_id; + + cnt++; +} + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_003_001 [3.1] OS_TimerCreate() and OS_TimerDelete() errors + * + *

Description

+ * Parameters checking in OS_TimerCreate() and OS_TimerDelete() is + * tested. + * + *

Test Steps

+ * - [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an + * error is expected. + * - [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL, + * an error is expected. + * - [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an + * error is expected. + * - [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL, + * an error is expected. + * - [3.1.5] OS_TimerCreate() is invoked with a very long timer name, + * an error is expected. + * - [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an + * error is expected. + * - [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an + * error is expected, then the queue is deleted using + * OS_TimerDelete(). + * . + */ + +static void nasa_osal_test_003_001_execute(void) { + + /* [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + uint32 accuracy; + + err = OS_TimerCreate(NULL, /* Error.*/ + "failing timer", + &accuracy, + tmr_callback); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL, + an error is expected.*/ + test_set_step(2); + { + int32 err; + uint32 tmid; + uint32 accuracy; + + err = OS_TimerCreate(&tmid, + NULL, /* Error.*/ + &accuracy, + tmr_callback); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an + error is expected.*/ + test_set_step(3); + { + int32 err; + uint32 tmid; + + err = OS_TimerCreate(&tmid, + "failing timer", + NULL, /* Error.*/ + tmr_callback); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL, + an error is expected.*/ + test_set_step(4); + { + int32 err; + uint32 tmid; + uint32 accuracy; + + err = OS_TimerCreate(&tmid, + "failing timer", + &accuracy, + NULL); /* Error.*/ + test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected"); + } + + /* [3.1.5] OS_TimerCreate() is invoked with a very long timer name, + an error is expected.*/ + test_set_step(5); + { + int32 err; + uint32 tmid; + uint32 accuracy; + + err = OS_TimerCreate(&tmid, + "very very long timer name", /* Error.*/ + &accuracy, + tmr_callback); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } + + /* [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an + error is expected.*/ + test_set_step(6); + { + int32 err; + + err = OS_TimerDelete((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected"); + } + + /* [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an + error is expected, then the queue is deleted using + OS_TimerDelete().*/ + test_set_step(7); + { + int32 err; + uint32 tmid1, tmid2; + uint32 accuracy; + + err = OS_TimerCreate(&tmid1, "my timer", &accuracy, tmr_callback); + test_assert(err == OS_SUCCESS, "timer creation failed"); + + err = OS_TimerCreate(&tmid2, "my timer", &accuracy, tmr_callback); + test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); + + err = OS_TimerDelete(tmid1); + test_assert(err == OS_SUCCESS, "timer deletion failed"); + } +} + +static const testcase_t nasa_osal_test_003_001 = { + "OS_TimerCreate() and OS_TimerDelete() errors", + NULL, + NULL, + nasa_osal_test_003_001_execute +}; + +/** + * @page nasa_osal_test_003_002 [3.2] OS_TimerSet() errors + * + *

Description

+ * Parameters checking in OS_TimerSet() is tested. + * + *

Test Steps

+ * - [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error + * is expected. + * . + */ + +static void nasa_osal_test_003_002_execute(void) { + + /* [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error + is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerSet((uint32)-1, 10, 10); + test_assert(err == OS_ERR_INVALID_ID, "invalid timer_id not detected"); + } +} + +static const testcase_t nasa_osal_test_003_002 = { + "OS_TimerSet() errors", + NULL, + NULL, + nasa_osal_test_003_002_execute +}; + +/** + * @page nasa_osal_test_003_003 [3.3] OS_TimerGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_TimerGetIdByName() is tested. + * + *

Test Steps

+ * - [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to + * NULL, an error is expected. + * - [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to + * NULL, an error is expected. + * - [3.3.3] OS_TimerGetIdByName() is invoked with a very long task + * name, an error is expected. + * . + */ + +static void nasa_osal_test_003_003_execute(void) { + + /* [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to + NULL, an error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerGetIdByName(NULL, "timer"); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to + NULL, an error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_TimerGetIdByName(&tmid, NULL); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [3.3.3] OS_TimerGetIdByName() is invoked with a very long task + name, an error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_TimerGetIdByName(&tmid, "very very long timer name"); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } +} + +static const testcase_t nasa_osal_test_003_003 = { + "OS_TimerGetIdByName() errors", + NULL, + NULL, + nasa_osal_test_003_003_execute +}; + +/** + * @page nasa_osal_test_003_004 [3.4] OS_TimerSet() one-shot functionality + * + *

Description

+ * A timer is tested in one-shot mode. + * + *

Test Steps

+ * - [3.4.1] Retrieving the timer by name. + * - [3.4.2] Setting up the timer for a 70mS one-shot tick. + * - [3.4.3] Waiting one second then counting the occurred ticks. + * . + */ + +static void nasa_osal_test_003_004_setup(void) { + uint32 accuracy; + + cnt = 0; + tmid = 0; + (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); +} + +static void nasa_osal_test_003_004_teardown(void) { + if (tmid != 0) { + (void) OS_TimerDelete(tmid); + } +} + +static void nasa_osal_test_003_004_execute(void) { + uint32 local_tmid; + + /* [3.4.1] Retrieving the timer by name.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerGetIdByName(&local_tmid, "test timer"); + test_assert(err == OS_SUCCESS, "timer not found"); + } + + /* [3.4.2] Setting up the timer for a 70mS one-shot tick.*/ + test_set_step(2); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 70000, 0); + test_assert(err == OS_SUCCESS, "timer setup failed"); + } + + /* [3.4.3] Waiting one second then counting the occurred ticks.*/ + test_set_step(3); + { + (void) OS_TaskDelay(1000); + test_assert(cnt == 1, "wrong ticks"); + } +} + +static const testcase_t nasa_osal_test_003_004 = { + "OS_TimerSet() one-shot functionality", + nasa_osal_test_003_004_setup, + nasa_osal_test_003_004_teardown, + nasa_osal_test_003_004_execute +}; + +/** + * @page nasa_osal_test_003_005 [3.5] OS_TimerSet() periodic functionality + * + *

Description

+ * A timer is tested in periodic mode. + * + *

Test Steps

+ * - [3.5.1] Retrieving the timer by name. + * - [3.5.2] Setting up the timer for a 70mS periodic tick. + * - [3.5.3] Waiting one second then counting the occurred ticks. + * - [3.5.4] Stopping the timer. + * . + */ + +static void nasa_osal_test_003_005_setup(void) { + uint32 accuracy; + + cnt = 0; + tmid = 0; + (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); +} + +static void nasa_osal_test_003_005_teardown(void) { + if (tmid != 0) { + (void) OS_TimerSet(tmid, 0, 0); + (void) OS_TimerDelete(tmid); + } +} + +static void nasa_osal_test_003_005_execute(void) { + uint32 local_tmid; + + /* [3.5.1] Retrieving the timer by name.*/ + test_set_step(1); + { + int32 err; + + err = OS_TimerGetIdByName(&local_tmid, "test timer"); + test_assert(err == OS_SUCCESS, "timer not found"); + } + + /* [3.5.2] Setting up the timer for a 70mS periodic tick.*/ + test_set_step(2); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 70000, 70000); + test_assert(err == OS_SUCCESS, "timer setup failed"); + } + + /* [3.5.3] Waiting one second then counting the occurred ticks.*/ + test_set_step(3); + { + (void) OS_TaskDelay(1000); + test_assert(cnt == 14, "wrong ticks"); + } + + /* [3.5.4] Stopping the timer.*/ + test_set_step(4); + { + uint32 err; + + err = OS_TimerSet(local_tmid, 0, 0); + test_assert(err == OS_SUCCESS, "timer stop failed"); + } +} + +static const testcase_t nasa_osal_test_003_005 = { + "OS_TimerSet() periodic functionality", + nasa_osal_test_003_005_setup, + nasa_osal_test_003_005_teardown, + nasa_osal_test_003_005_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_003_array[] = { + &nasa_osal_test_003_001, + &nasa_osal_test_003_002, + &nasa_osal_test_003_003, + &nasa_osal_test_003_004, + &nasa_osal_test_003_005, + NULL +}; + +/** + * @brief Timers Functionality. + */ +const testsequence_t nasa_osal_test_sequence_003 = { + "Timers Functionality", + nasa_osal_test_sequence_003_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_003.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_003.h new file mode 100644 index 000000000..f22851524 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_003.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_003.h + * @brief Test Sequence 003 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_003_H +#define NASA_OSAL_TEST_SEQUENCE_003_H + +extern const testsequence_t nasa_osal_test_sequence_003; + +#endif /* NASA_OSAL_TEST_SEQUENCE_003_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_004.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_004.c new file mode 100644 index 000000000..e9f346d06 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_004.c @@ -0,0 +1,433 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_004.c + * @brief Test Sequence 004 code. + * + * @page nasa_osal_test_sequence_004 [4] Binary Semaphores Functionality + * + * File: @ref nasa_osal_test_sequence_004.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to binary semaphores. + * + *

Test Cases

+ * - @subpage nasa_osal_test_004_001 + * - @subpage nasa_osal_test_004_002 + * - @subpage nasa_osal_test_004_003 + * - @subpage nasa_osal_test_004_004 + * - @subpage nasa_osal_test_004_005 + * - @subpage nasa_osal_test_004_006 + * - @subpage nasa_osal_test_004_007 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include "osapi.h" + +uint32 bsid; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_004_001 [4.1] OS_BinSemCreate() and OS_BinSemDelete() errors + * + *

Description

+ * Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is + * tested. + * + *

Test Steps

+ * - [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an + * error is expected. + * - [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an + * error is expected. + * - [4.1.3] OS_BinSemCreate() is invoked with an invalid + * sem_initial_value, an error is expected. + * - [4.1.4] OS_BinSemCreate() is invoked with a very long timer name, + * an error is expected. + * - [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an + * error is expected. + * - [4.1.6] OS_BinSemCreate() is invoked twice with duplicated name, + * an error is expected, then the queue is deleted using + * OS_BinSemDelete(). + * . + */ + +static void nasa_osal_test_004_001_execute(void) { + + /* [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemCreate(NULL, /* Error.*/ + "failing semaphore", + 0, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an + error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_BinSemCreate(&bsid, + NULL, /* Error.*/ + 0, + 0); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [4.1.3] OS_BinSemCreate() is invoked with an invalid + sem_initial_value, an error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_BinSemCreate(&bsid, + "failing semaphore", + 2, /* Error.*/ + 0); + test_assert(err == OS_INVALID_INT_NUM, "counter error not detected"); + } + + /* [4.1.4] OS_BinSemCreate() 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_BinSemCreate(&bsid, + "very very long semaphore name", /* Error.*/ + 0, + 0); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); +#endif + } + + /* [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an + error is expected.*/ + test_set_step(5); + { + int32 err; + + err = OS_BinSemDelete((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); + } + + /* [4.1.6] 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; + uint32 bsid1; /*, bsid2;*/ + + err = OS_BinSemCreate(&bsid1, "my semaphore", 0, 0); + test_assert(err == OS_SUCCESS, "semaphore creation failed"); + +#if 0 /* Semaphore name currently not implemented.*/ + err = OS_BinSemCreate(&bsid2, "my semaphore", 0, 0); + test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); +#endif + + err = OS_BinSemDelete(bsid1); + test_assert(err == OS_SUCCESS, "semaphore deletion failed"); + } +} + +static const testcase_t nasa_osal_test_004_001 = { + "OS_BinSemCreate() and OS_BinSemDelete() errors", + NULL, + NULL, + nasa_osal_test_004_001_execute +}; + +/** + * @page nasa_osal_test_004_002 [4.2] OS_BinSemFlush() errors + * + *

Description

+ * Parameters checking in OS_BinSemFlush() is tested. + * + *

Test Steps

+ * - [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an + * error is expected. + * . + */ + +static void nasa_osal_test_004_002_execute(void) { + + /* [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemFlush((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } +} + +static const testcase_t nasa_osal_test_004_002 = { + "OS_BinSemFlush() errors", + NULL, + NULL, + nasa_osal_test_004_002_execute +}; + +/** + * @page nasa_osal_test_004_003 [4.3] OS_BinSemGive() errors + * + *

Description

+ * Parameters checking in OS_BinSemGive() is tested. + * + *

Test Steps

+ * - [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error + * is expected. + * . + */ + +static void nasa_osal_test_004_003_execute(void) { + + /* [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error + is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemGive((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } +} + +static const testcase_t nasa_osal_test_004_003 = { + "OS_BinSemGive() errors", + NULL, + NULL, + nasa_osal_test_004_003_execute +}; + +/** + * @page nasa_osal_test_004_004 [4.4] OS_BinSemTake() errors + * + *

Description

+ * Parameters checking in OS_BinSemTake() is tested. + * + *

Test Steps

+ * - [4.4.1] OS_BinSemTake() is invoked with sem_id set to -1, an error + * is expected. + * . + */ + +static void nasa_osal_test_004_004_execute(void) { + + /* [4.4.1] 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 nasa_osal_test_004_004 = { + "OS_BinSemTake() errors", + NULL, + NULL, + nasa_osal_test_004_004_execute +}; + +/** + * @page nasa_osal_test_004_005 [4.5] OS_BinSemTimedWait() errors + * + *

Description

+ * Parameters checking in OS_BinSemTimedWait() is tested. + * + *

Test Steps

+ * - [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an + * error is expected. + * - [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an + * error is expected. + * . + */ + +static void nasa_osal_test_004_005_setup(void) { + bsid = 0; + (void) OS_BinSemCreate(&bsid, "test semaphore", 0, 0); +} + +static void nasa_osal_test_004_005_teardown(void) { + if (bsid > 0) { + (void) OS_BinSemDelete(bsid); + } +} + +static void nasa_osal_test_004_005_execute(void) { + + /* [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemTimedWait((uint32)-1, 1000); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } + + /* [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an + error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_BinSemTimedWait(bsid, 0); + test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected"); + } +} + +static const testcase_t nasa_osal_test_004_005 = { + "OS_BinSemTimedWait() errors", + nasa_osal_test_004_005_setup, + nasa_osal_test_004_005_teardown, + nasa_osal_test_004_005_execute +}; + +/** + * @page nasa_osal_test_004_006 [4.6] OS_BinSemGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_BinSemGetIdByName() is tested. + * + *

Test Steps

+ * - [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL, + * an error is expected. + * - [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set + * to NULL, an error is expected. + * - [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task + * name, an error is expected. + * . + */ + +static void nasa_osal_test_004_006_execute(void) { + + /* [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL, + an error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemGetIdByName(NULL, "semaphore"); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set + to NULL, an error is expected.*/ + test_set_step(2); + { + int32 err; + + err = OS_BinSemGetIdByName(&bsid, NULL); + test_assert(err == OS_INVALID_POINTER, "NULL not detected"); + } + + /* [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task + name, an error is expected.*/ + test_set_step(3); + { + int32 err; + + err = OS_BinSemGetIdByName(&bsid, "very very long semaphore name"); + test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); + } +} + +static const testcase_t nasa_osal_test_004_006 = { + "OS_BinSemGetIdByName() errors", + NULL, + NULL, + nasa_osal_test_004_006_execute +}; + +/** + * @page nasa_osal_test_004_007 [4.7] OS_BinSemTimedWait() timeout functionality + * + *

Description

+ * OS_BinSemCreate() timeout functionality is tested. + * + *

Test Steps

+ * - [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one + * second, an error is expected. + * . + */ + +static void nasa_osal_test_004_007_setup(void) { + bsid = 0; + (void) OS_BinSemCreate(&bsid, "test semaphore", 0, 0); +} + +static void nasa_osal_test_004_007_teardown(void) { + if (bsid > 0) { + (void) OS_BinSemDelete(bsid); + } +} + +static void nasa_osal_test_004_007_execute(void) { + + /* [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one + second, an error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_BinSemTimedWait(bsid, 1000); + test_assert(err == OS_SEM_TIMEOUT, "unexpected error code"); + } +} + +static const testcase_t nasa_osal_test_004_007 = { + "OS_BinSemTimedWait() timeout functionality", + nasa_osal_test_004_007_setup, + nasa_osal_test_004_007_teardown, + nasa_osal_test_004_007_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_004_array[] = { + &nasa_osal_test_004_001, + &nasa_osal_test_004_002, + &nasa_osal_test_004_003, + &nasa_osal_test_004_004, + &nasa_osal_test_004_005, + &nasa_osal_test_004_006, + &nasa_osal_test_004_007, + NULL +}; + +/** + * @brief Binary Semaphores Functionality. + */ +const testsequence_t nasa_osal_test_sequence_004 = { + "Binary Semaphores Functionality", + nasa_osal_test_sequence_004_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_004.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_004.h new file mode 100644 index 000000000..7c9da8393 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_004.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_004.h + * @brief Test Sequence 004 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_004_H +#define NASA_OSAL_TEST_SEQUENCE_004_H + +extern const testsequence_t nasa_osal_test_sequence_004; + +#endif /* NASA_OSAL_TEST_SEQUENCE_004_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_005.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_005.c new file mode 100644 index 000000000..ad0aecd18 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_005.c @@ -0,0 +1,399 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_005.c + * @brief Test Sequence 005 code. + * + * @page nasa_osal_test_sequence_005 [5] Counter Semaphores Functionality + * + * File: @ref nasa_osal_test_sequence_005.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to counter semaphores. + * + *

Test Cases

+ * - @subpage nasa_osal_test_005_001 + * - @subpage nasa_osal_test_005_002 + * - @subpage nasa_osal_test_005_003 + * - @subpage nasa_osal_test_005_004 + * - @subpage nasa_osal_test_005_005 + * - @subpage nasa_osal_test_005_006 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include "osapi.h" + +uint32 csid; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_005_001 [5.1] OS_CountSemCreate() and OS_CountSemDelete() errors + * + *

Description

+ * Parameters checking in OS_CountSemCreate() and OS_CountSemDelete() + * is tested. + * + *

Test Steps

+ * - [5.1.1] OS_CountSemCreate() is invoked with sem_id set to NULL, an + * error is expected. + * - [5.1.2] OS_CountSemCreate() is invoked with sem_name set to NULL, + * an error is expected. + * - [5.1.3] OS_CountSemCreate() is invoked with an invalid + * sem_initial_value, an error is expected. + * - [5.1.4] OS_CountSemCreate() is invoked with a very long timer + * name, an error is expected. + * - [5.1.5] OS_CountSemDelete() is invoked with timer_id set to -1, an + * error is expected. + * - [5.1.6] OS_CountSemCreate() is invoked twice with duplicated name, + * an error is expected, then the queue is deleted using + * OS_CountSemDelete(). + * . + */ + +static void nasa_osal_test_005_001_execute(void) { + + /* [5.1.1] 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"); + } + + /* [5.1.2] 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"); + } + + /* [5.1.3] 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"); + } + + /* [5.1.4] 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 + } + + /* [5.1.5] 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"); + } + + /* [5.1.6] 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 nasa_osal_test_005_001 = { + "OS_CountSemCreate() and OS_CountSemDelete() errors", + NULL, + NULL, + nasa_osal_test_005_001_execute +}; + +/** + * @page nasa_osal_test_005_002 [5.2] OS_CountSemGive() errors + * + *

Description

+ * Parameters checking in OS_CountSemGive() is tested. + * + *

Test Steps

+ * - [5.2.1] OS_CountSemGive() is invoked with sem_id set to -1, an + * error is expected. + * . + */ + +static void nasa_osal_test_005_002_execute(void) { + + /* [5.2.1] 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 nasa_osal_test_005_002 = { + "OS_CountSemGive() errors", + NULL, + NULL, + nasa_osal_test_005_002_execute +}; + +/** + * @page nasa_osal_test_005_003 [5.3] OS_CountSemTake() errors + * + *

Description

+ * Parameters checking in OS_CountSemTake() is tested. + * + *

Test Steps

+ * - [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an + * error is expected. + * . + */ + +static void nasa_osal_test_005_003_execute(void) { + + /* [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an + error is expected.*/ + test_set_step(1); + { + int32 err; + + err = OS_CountSemTake((uint32)-1); + test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); + } +} + +static const testcase_t nasa_osal_test_005_003 = { + "OS_CountSemTake() errors", + NULL, + NULL, + nasa_osal_test_005_003_execute +}; + +/** + * @page nasa_osal_test_005_004 [5.4] OS_CountSemTimedWait() errors + * + *

Description

+ * Parameters checking in OS_CountSemTimedWait() is tested. + * + *

Test Steps

+ * - [5.4.1] OS_CountSemTimedWait() is invoked with sem_id set to -1, + * an error is expected. + * - [5.4.2] OS_CountSemTimedWait() is invoked with msecs set to 0, an + * error is expected. + * . + */ + +static void nasa_osal_test_005_004_setup(void) { + csid = 0; + (void) OS_CountSemCreate(&csid, "test semaphore", 0, 0); +} + +static void nasa_osal_test_005_004_teardown(void) { + if (csid > 0) { + (void) OS_CountSemDelete(csid); + } +} + +static void nasa_osal_test_005_004_execute(void) { + + /* [5.4.1] 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"); + } + + /* [5.4.2] 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 nasa_osal_test_005_004 = { + "OS_CountSemTimedWait() errors", + nasa_osal_test_005_004_setup, + nasa_osal_test_005_004_teardown, + nasa_osal_test_005_004_execute +}; + +/** + * @page nasa_osal_test_005_005 [5.5] OS_CountSemGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_CountSemGetIdByName() is tested. + * + *

Test Steps

+ * - [5.5.1] OS_CountSemGetIdByName() is invoked with sem_id set to + * NULL, an error is expected. + * - [5.5.2] OS_CountSemGetIdByName() is invoked with semaphore name + * set to NULL, an error is expected. + * - [5.5.3] OS_CountSemGetIdByName() is invoked with a very long task + * name, an error is expected. + * . + */ + +static void nasa_osal_test_005_005_execute(void) { + + /* [5.5.1] 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"); + } + + /* [5.5.2] 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"); + } + + /* [5.5.3] 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 nasa_osal_test_005_005 = { + "OS_CountSemGetIdByName() errors", + NULL, + NULL, + nasa_osal_test_005_005_execute +}; + +/** + * @page nasa_osal_test_005_006 [5.6] OS_CountSemTimedWait() timeout functionality + * + *

Description

+ * OS_CountSemCreate() timeout functionality is tested. + * + *

Test Steps

+ * - [5.6.1] OS_CountSemTimedWait() is invoked with timeout set to one + * second, an error is expected. + * . + */ + +static void nasa_osal_test_005_006_setup(void) { + csid = 0; + (void) OS_CountSemCreate(&csid, "test semaphore", 0, 0); +} + +static void nasa_osal_test_005_006_teardown(void) { + if (csid > 0) { + (void) OS_CountSemDelete(csid); + } +} + +static void nasa_osal_test_005_006_execute(void) { + + /* [5.6.1] 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 nasa_osal_test_005_006 = { + "OS_CountSemTimedWait() timeout functionality", + nasa_osal_test_005_006_setup, + nasa_osal_test_005_006_teardown, + nasa_osal_test_005_006_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_005_array[] = { + &nasa_osal_test_005_001, + &nasa_osal_test_005_002, + &nasa_osal_test_005_003, + &nasa_osal_test_005_004, + &nasa_osal_test_005_005, + &nasa_osal_test_005_006, + NULL +}; + +/** + * @brief Counter Semaphores Functionality. + */ +const testsequence_t nasa_osal_test_sequence_005 = { + "Counter Semaphores Functionality", + nasa_osal_test_sequence_005_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_005.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_005.h new file mode 100644 index 000000000..36ea7b226 --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_005.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_005.h + * @brief Test Sequence 005 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_005_H +#define NASA_OSAL_TEST_SEQUENCE_005_H + +extern const testsequence_t nasa_osal_test_sequence_005; + +#endif /* NASA_OSAL_TEST_SEQUENCE_005_H */ diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_006.c b/test/nasa_osal/source/test/nasa_osal_test_sequence_006.c new file mode 100644 index 000000000..dd6f017cb --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_006.c @@ -0,0 +1,279 @@ +/* Copyright statement.*/ + +#include "hal.h" +#include "nasa_osal_test_root.h" + +/** + * @file nasa_osal_test_sequence_006.c + * @brief Test Sequence 006 code. + * + * @page nasa_osal_test_sequence_006 [6] Mutex Semaphores Functionality + * + * File: @ref nasa_osal_test_sequence_006.c + * + *

Description

+ * This sequence tests the NASA OSAL over ChibiOS/RT functionalities + * related to mutex semaphores. + * + *

Test Cases

+ * - @subpage nasa_osal_test_006_001 + * - @subpage nasa_osal_test_006_002 + * - @subpage nasa_osal_test_006_003 + * - @subpage nasa_osal_test_006_004 + * . + */ + +/**************************************************************************** + * Shared code. + ****************************************************************************/ + +#include "osapi.h" + +uint32 msid; + +/**************************************************************************** + * Test cases. + ****************************************************************************/ + +/** + * @page nasa_osal_test_006_001 [6.1] OS_MutSemCreate() and OS_MutSemDelete() errors + * + *

Description

+ * Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is + * tested. + * + *

Test Steps

+ * - [6.1.1] OS_MutSemCreate() is invoked with sem_id set to NULL, an + * error is expected. + * - [6.1.2] OS_MutSemCreate() is invoked with sem_name set to NULL, an + * error is expected. + * - [6.1.3] OS_MutSemCreate() is invoked with a very long timer name, + * an error is expected. + * - [6.1.4] OS_MutSemDelete() is invoked with timer_id set to -1, an + * error is expected. + * - [6.1.5] OS_MutSemCreate() is invoked twice with duplicated name, + * an error is expected, then the queue is deleted using + * OS_MutSemDelete(). + * . + */ + +static void nasa_osal_test_006_001_execute(void) { + + /* [6.1.1] 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"); + } + + /* [6.1.2] 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"); + } + + /* [6.1.3] 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 + } + + /* [6.1.4] 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"); + } + + /* [6.1.5] 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 nasa_osal_test_006_001 = { + "OS_MutSemCreate() and OS_MutSemDelete() errors", + NULL, + NULL, + nasa_osal_test_006_001_execute +}; + +/** + * @page nasa_osal_test_006_002 [6.2] OS_MutSemGive() errors + * + *

Description

+ * Parameters checking in OS_MutSemGive() is tested. + * + *

Test Steps

+ * - [6.2.1] OS_MutSemGive() is invoked with sem_id set to -1, an error + * is expected. + * . + */ + +static void nasa_osal_test_006_002_execute(void) { + + /* [6.2.1] 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 nasa_osal_test_006_002 = { + "OS_MutSemGive() errors", + NULL, + NULL, + nasa_osal_test_006_002_execute +}; + +/** + * @page nasa_osal_test_006_003 [6.3] OS_MutSemTake() errors + * + *

Description

+ * Parameters checking in OS_MutSemTake() is tested. + * + *

Test Steps

+ * - [6.3.1] OS_MutSemTake() is invoked with sem_id set to -1, an error + * is expected. + * . + */ + +static void nasa_osal_test_006_003_execute(void) { + + /* [6.3.1] 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 nasa_osal_test_006_003 = { + "OS_MutSemTake() errors", + NULL, + NULL, + nasa_osal_test_006_003_execute +}; + +/** + * @page nasa_osal_test_006_004 [6.4] OS_MutSemGetIdByName() errors + * + *

Description

+ * Parameters checking in OS_MutSemGetIdByName() is tested. + * + *

Test Steps

+ * - [6.4.1] OS_MutSemGetIdByName() is invoked with sem_id set to NULL, + * an error is expected. + * - [6.4.2] OS_MutSemGetIdByName() is invoked with semaphore name set + * to NULL, an error is expected. + * - [6.4.3] OS_MutSemGetIdByName() is invoked with a very long task + * name, an error is expected. + * . + */ + +static void nasa_osal_test_006_004_execute(void) { + + /* [6.4.1] 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"); + } + + /* [6.4.2] 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"); + } + + /* [6.4.3] 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 nasa_osal_test_006_004 = { + "OS_MutSemGetIdByName() errors", + NULL, + NULL, + nasa_osal_test_006_004_execute +}; + +/**************************************************************************** + * Exported data. + ****************************************************************************/ + +/** + * @brief Array of test cases. + */ +const testcase_t * const nasa_osal_test_sequence_006_array[] = { + &nasa_osal_test_006_001, + &nasa_osal_test_006_002, + &nasa_osal_test_006_003, + &nasa_osal_test_006_004, + NULL +}; + +/** + * @brief Mutex Semaphores Functionality. + */ +const testsequence_t nasa_osal_test_sequence_006 = { + "Mutex Semaphores Functionality", + nasa_osal_test_sequence_006_array +}; diff --git a/test/nasa_osal/source/test/nasa_osal_test_sequence_006.h b/test/nasa_osal/source/test/nasa_osal_test_sequence_006.h new file mode 100644 index 000000000..70959ba9d --- /dev/null +++ b/test/nasa_osal/source/test/nasa_osal_test_sequence_006.h @@ -0,0 +1,13 @@ +/* Copyright statement.*/ + +/** + * @file nasa_osal_test_sequence_006.h + * @brief Test Sequence 006 header. + */ + +#ifndef NASA_OSAL_TEST_SEQUENCE_006_H +#define NASA_OSAL_TEST_SEQUENCE_006_H + +extern const testsequence_t nasa_osal_test_sequence_006; + +#endif /* NASA_OSAL_TEST_SEQUENCE_006_H */ diff --git a/test/nasa_osal/source/test/test_root.c b/test/nasa_osal/source/test/test_root.c deleted file mode 100644 index be977e983..000000000 --- a/test/nasa_osal/source/test/test_root.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright statement.*/ - -/** - * @mainpage Test Suite Specification - * 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. - * - *

Test Sequences

- * - @subpage test_sequence_001 - * - @subpage test_sequence_002 - * - @subpage test_sequence_003 - * - @subpage test_sequence_004 - * - @subpage test_sequence_005 - * - @subpage test_sequence_006 - * . - */ - -/** - * @file test_root.c - * @brief Test Suite root structures code. - */ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -#if !defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Module exported variables. */ -/*===========================================================================*/ - -/** - * @brief Array of all the test sequences. - */ -const testcase_t * const *test_suite[] = { - test_sequence_001, - test_sequence_002, - test_sequence_003, - test_sequence_004, - test_sequence_005, - test_sequence_006, - NULL -}; - -/*===========================================================================*/ -/* Shared code. */ -/*===========================================================================*/ - -THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); -THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); -THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); -THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); - -#endif /* !defined(__DOXYGEN__) */ diff --git a/test/nasa_osal/source/test/test_root.h b/test/nasa_osal/source/test/test_root.h deleted file mode 100644 index eb6fbb801..000000000 --- a/test/nasa_osal/source/test/test_root.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_root.h - * @brief Test Suite root structures header. - */ - -#ifndef TEST_ROOT_H -#define TEST_ROOT_H - -#include "test_sequence_001.h" -#include "test_sequence_002.h" -#include "test_sequence_003.h" -#include "test_sequence_004.h" -#include "test_sequence_005.h" -#include "test_sequence_006.h" - -#if !defined(__DOXYGEN__) - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -extern const testcase_t * const *test_suite[]; - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Shared definitions. */ -/*===========================================================================*/ - -#define TEST_SUITE_NAME "NASA OSAL over ChibiOS/RT Test Suite" - -#define TASKS_BASE_PRIORITY 200 -#define TASKS_STACK_SIZE 256 - -extern THD_WORKING_AREA(wa_test1, TASKS_STACK_SIZE); -extern THD_WORKING_AREA(wa_test2, TASKS_STACK_SIZE); -extern THD_WORKING_AREA(wa_test3, TASKS_STACK_SIZE); -extern THD_WORKING_AREA(wa_test4, TASKS_STACK_SIZE); - -#endif /* !defined(__DOXYGEN__) */ - -#endif /* TEST_ROOT_H */ diff --git a/test/nasa_osal/source/test/test_sequence_001.c b/test/nasa_osal/source/test/test_sequence_001.c deleted file mode 100644 index 95bbeee8a..000000000 --- a/test/nasa_osal/source/test/test_sequence_001.c +++ /dev/null @@ -1,558 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_001.c - * @brief Test Sequence 001 code. - * - * @page test_sequence_001 [1] Tasks Functionality - * - * File: @ref test_sequence_001.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to threading. - * - *

Test Cases

- * - @subpage test_001_001 - * - @subpage test_001_002 - * - @subpage test_001_003 - * - @subpage test_001_004 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - -#include "osapi.h" - -static void test_task1(void) { - - test_emit_token('A'); -} - -static void test_task2(void) { - - test_emit_token('B'); -} - -static void test_task3(void) { - - test_emit_token('C'); -} - -static void test_task4(void) { - - test_emit_token('D'); -} - -static void delete_handler(void) { - - test_emit_token('C'); -} - -static void test_task_delete(void) { - - test_emit_token('A'); - (void) OS_TaskInstallDeleteHandler(delete_handler); - while (!OS_TaskDeleteCheck()) { - (void) OS_TaskDelay(1); - } - test_emit_token('B'); -} - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -/** - * @page test_001_001 [1.1] OS_TaskCreate() errors - * - *

Description

- * Parameters checking in OS_TaskCreate() is tested. - * - *

Test Steps

- * - [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an - * error is expected. - * - [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an - * error is expected. - * - [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL, - * an error is expected. - * - [1.1.4] OS_TaskCreate() is invoked with a very long task name, an - * error is expected. - * - [1.1.5] OS_TaskCreate() is invoked with priority below and above - * allowed range, an error is expected. - * - [1.1.6] OS_TaskCreate() is invoked with a stack size below - * minimum, an error is expected. - * - [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and - * then duplicated stack, an error is expected in both cases. - * . - */ - -static void test_001_001_execute(void) { - - /* [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_TaskCreate(NULL, /* Error.*/ - "failing task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an - error is expected.*/ - test_set_step(2); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - NULL, /* Error.*/ - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL, - an error is expected.*/ - test_set_step(3); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - "failing task", - test_task1, - (uint32 *)NULL, /* Error.*/ - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.4] OS_TaskCreate() is invoked with a very long task name, an - error is expected.*/ - test_set_step(4); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - "this is a very very long task name", /* Error.*/ - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.5] OS_TaskCreate() is invoked with priority below and above - allowed range, an error is expected.*/ - test_set_step(5); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - "failing task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - 0, /* Error.*/ - 0); - test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected"); - test_assert_sequence("", "task executed"); - - err = OS_TaskCreate(&tid, - "failing task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - 256, /* Error.*/ - 0); - test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.6] OS_TaskCreate() is invoked with a stack size below - minimum, an error is expected.*/ - test_set_step(6); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - "failing task", - test_task1, - (uint32 *)wa_test1, - 16, /* Error.*/ - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_INVALID_INT_NUM, "stack insufficient size not detected"); - test_assert_sequence("", "task executed"); - } - - /* [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and - then duplicated stack, an error is expected in both cases.*/ - test_set_step(7); - { - int32 err; - uint32 tid; - - err = OS_TaskCreate(&tid, - "running task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_SUCCESS, "task creation failed"); - - err = OS_TaskCreate(&tid, - "running task", - test_task2, - (uint32 *)wa_test2, - sizeof wa_test2, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); - - err = OS_TaskCreate(&tid, - "conflicting task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_ERR_NO_FREE_IDS, "stack conflict not detected"); - - err = OS_TaskWait(tid); - test_assert(err == OS_SUCCESS, "wait failed"); - test_assert_sequence("A", "task not executed"); - - err = OS_TaskCreate(&tid, - "running task", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_SUCCESS, "task creation failed"); - - err = OS_TaskWait(tid); - test_assert(err == OS_SUCCESS, "wait failed"); - test_assert_sequence("A", "task not executed"); - } -} - -static const testcase_t test_001_001 = { - "OS_TaskCreate() errors", - NULL, - NULL, - test_001_001_execute -}; - -/** - * @page test_001_002 [1.2] OS_TaskCreate() priority ordering - * - *

Description

- * Four tasks are created at different priorities and in different - * order. The execution order must happen in order of priority - * regardless the creation order. - * - *

Test Steps

- * - [1.2.1] Four tasks are created in priority order from low to high. - * - [1.2.2] Tasks are made runnable atomically and their execution - * order tested. - * - [1.2.3] Four tasks are created in priority order from high to low. - * - [1.2.4] Tasks are made runnable atomically and their execution - * order tested. - * - [1.2.5] Four tasks are created in an not ordered way. - * - [1.2.6] Tasks are made runnable atomically and their execution - * order tested. - * . - */ - -static void test_001_002_execute(void) { - - /* [1.2.1] Four tasks are created in priority order from low to - high.*/ - test_set_step(1); - { - int32 err; - uint32 tid1, tid2, tid3, tid4; - - err = OS_TaskCreate(&tid4, - "running task 4", - test_task4, - (uint32 *)wa_test4, - sizeof wa_test4, - TASKS_BASE_PRIORITY - 0, - 0); - test_assert(err == OS_SUCCESS, "task 4 creation failed"); - - err = OS_TaskCreate(&tid3, - "running task 3", - test_task3, - (uint32 *)wa_test3, - sizeof wa_test3, - TASKS_BASE_PRIORITY - 1, - 0); - test_assert(err == OS_SUCCESS, "task 3 creation failed"); - - err = OS_TaskCreate(&tid2, - "running task 2", - test_task2, - (uint32 *)wa_test2, - sizeof wa_test2, - TASKS_BASE_PRIORITY - 2, - 0); - test_assert(err == OS_SUCCESS, "task 2 creation failed"); - - err = OS_TaskCreate(&tid1, - "running task 1", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY - 3, - 0); - test_assert(err == OS_SUCCESS, "task 1 creation failed"); - } - - /* [1.2.2] Tasks are made runnable atomically and their execution - order tested.*/ - test_set_step(2); - { - OS_TaskDelay(5); - test_assert_sequence("ABCD", "task order violation"); - } - - /* [1.2.3] Four tasks are created in priority order from high to - low.*/ - test_set_step(3); - { - int32 err; - uint32 tid1, tid2, tid3, tid4; - - err = OS_TaskCreate(&tid1, - "running task 1", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY - 3, - 0); - test_assert(err == OS_SUCCESS, "task 1 creation failed"); - - err = OS_TaskCreate(&tid2, - "running task 2", - test_task2, - (uint32 *)wa_test2, - sizeof wa_test2, - TASKS_BASE_PRIORITY - 2, - 0); - test_assert(err == OS_SUCCESS, "task 2 creation failed"); - - err = OS_TaskCreate(&tid3, - "running task 3", - test_task3, - (uint32 *)wa_test3, - sizeof wa_test3, - TASKS_BASE_PRIORITY - 1, - 0); - test_assert(err == OS_SUCCESS, "task 3 creation failed"); - - err = OS_TaskCreate(&tid4, - "running task 4", - test_task4, - (uint32 *)wa_test4, - sizeof wa_test4, - TASKS_BASE_PRIORITY - 0, - 0); - test_assert(err == OS_SUCCESS, "task 4 creation failed"); - } - - /* [1.2.4] Tasks are made runnable atomically and their execution - order tested.*/ - test_set_step(4); - { - OS_TaskDelay(5); - test_assert_sequence("ABCD", "task order violation"); - } - - /* [1.2.5] Four tasks are created in an not ordered way.*/ - test_set_step(5); - { - int32 err; - uint32 tid1, tid2, tid3, tid4; - - err = OS_TaskCreate(&tid2, - "running task 2", - test_task2, - (uint32 *)wa_test2, - sizeof wa_test2, - TASKS_BASE_PRIORITY - 2, - 0); - test_assert(err == OS_SUCCESS, "task 2 creation failed"); - - err = OS_TaskCreate(&tid1, - "running task 1", - test_task1, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY - 3, - 0); - test_assert(err == OS_SUCCESS, "task 1 creation failed"); - - err = OS_TaskCreate(&tid4, - "running task 4", - test_task4, - (uint32 *)wa_test4, - sizeof wa_test4, - TASKS_BASE_PRIORITY - 0, - 0); - test_assert(err == OS_SUCCESS, "task 4 creation failed"); - - err = OS_TaskCreate(&tid3, - "running task 3", - test_task3, - (uint32 *)wa_test3, - sizeof wa_test3, - TASKS_BASE_PRIORITY - 1, - 0); - test_assert(err == OS_SUCCESS, "task 3 creation failed"); - } - - /* [1.2.6] Tasks are made runnable atomically and their execution - order tested.*/ - test_set_step(6); - { - OS_TaskDelay(5); - test_assert_sequence("ABCD", "task order violation"); - } -} - -static const testcase_t test_001_002 = { - "OS_TaskCreate() priority ordering", - NULL, - NULL, - test_001_002_execute -}; - -/** - * @page test_001_003 [1.3] OS_TaskDelete() errors - * - *

Description

- * Parameters checking in OS_TaskDelete() is tested. - * - *

Test Steps

- * - [1.3.1] OS_TaskDelete() is invoked with task_id set to -1, an - * error is expected. - * . - */ - -static void test_001_003_execute(void) { - - /* [1.3.1] 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 [1.4] OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality - * - *

Description

- * OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for - * functionality. - * - *

Test Steps

- * - [1.4.1] Creating a task executing an infinite loop. - * - [1.4.2] 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; - - /* [1.4.1] Creating a task executing an infinite loop.*/ - test_set_step(1); - { - int32 err; - - err = OS_TaskCreate(&tid, - "deletable task", - test_task_delete, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_SUCCESS, "deletable task creation failed"); - } - - /* [1.4.2] 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 = { - "OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality", - NULL, - NULL, - test_001_004_execute -}; - -/**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Tasks Functionality. - */ -const testcase_t * const test_sequence_001[] = { - &test_001_001, - &test_001_002, - &test_001_003, - &test_001_004, - NULL -}; diff --git a/test/nasa_osal/source/test/test_sequence_001.h b/test/nasa_osal/source/test/test_sequence_001.h deleted file mode 100644 index 080660f74..000000000 --- a/test/nasa_osal/source/test/test_sequence_001.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_001.h - * @brief Test Sequence 001 header. - */ - -#ifndef TEST_SEQUENCE_001_H -#define TEST_SEQUENCE_001_H - -extern const testcase_t * const test_sequence_001[]; - -#endif /* TEST_SEQUENCE_001_H */ diff --git a/test/nasa_osal/source/test/test_sequence_002.c b/test/nasa_osal/source/test/test_sequence_002.c deleted file mode 100644 index a993de35c..000000000 --- a/test/nasa_osal/source/test/test_sequence_002.c +++ /dev/null @@ -1,385 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_002.c - * @brief Test Sequence 002 code. - * - * @page test_sequence_002 [2] Queues Functionality - * - * File: @ref test_sequence_002.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to queues. - * - *

Test Cases

- * - @subpage test_002_001 - * - @subpage test_002_002 - * - @subpage test_002_003 - * - @subpage test_002_004 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - -#include - -#include "osapi.h" - -uint32 qid, tid; - -#define WRITER_NUM_MESSAGES 16 -#define MESSAGE_SIZE 20 - -static void test_task_writer(void) { - unsigned i; - int32 err; - - for (i = 0; i < WRITER_NUM_MESSAGES; i++) { - err = OS_QueuePut(qid, "Hello World", 12, 0); - if (err != OS_SUCCESS) { - test_emit_token('*'); - } - } -} - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -/** - * @page test_002_001 [2.1] OS_QueueCreate() and OS_QueueDelete() errors - * - *

Description

- * Parameters checking in OS_QueueCreate() and OS_QueueDelete() is - * tested. - * - *

Test Steps

- * - [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an - * error is expected. - * - [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an - * error is expected. - * - [2.1.3] OS_QueueCreate() is invoked with a very long task name, an - * error is expected. - * - [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an - * error is expected. - * - [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an - * error is expected, then the queue is deleted using - * OS_QueueDelete(). - * . - */ - -static void test_002_001_execute(void) { - - /* [2.1.1] OS_QueueCreate() is invoked with queue_id set to NULL, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_QueueCreate(NULL, /* Error.*/ - "failing queue", - 4, - 128, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [2.1.2] OS_QueueCreate() is invoked with task_name set to NULL, an - error is expected.*/ - test_set_step(2); - { - int32 err; - uint32 qid; - - err = OS_QueueCreate(&qid, - NULL, /* Error.*/ - 4, - 128, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [2.1.3] OS_QueueCreate() is invoked with a very long task name, an - error is expected.*/ - test_set_step(3); - { - int32 err; - uint32 qid; - - err = OS_QueueCreate(&qid, - "very very long queue name", /* Error.*/ - 4, - 128, - 0); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); - } - - /* [2.1.4] OS_QueueDelete() is invoked with queue_id set to -1, an - error is expected.*/ - test_set_step(4); - { - int32 err; - - err = OS_QueueDelete((uint32)-1); - test_assert(err == OS_ERR_INVALID_ID, "wrong queue id not detected"); - } - - /* [2.1.5] OS_QueueCreate() is invoked twice with duplicated name, an - error is expected, then the queue is deleted using - OS_QueueDelete().*/ - test_set_step(5); - { - int32 err; - uint32 qid1, qid2; - - err = OS_QueueCreate(&qid1, "my queue", 4, 128, 0); - test_assert(err == OS_SUCCESS, "queue creation failed"); - - err = OS_QueueCreate(&qid2, "my queue", 4, 128, 0); - test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); - - err = OS_QueueDelete(qid1); - test_assert(err == OS_SUCCESS, "queue deletion failed"); - } -} - -static const testcase_t test_002_001 = { - "OS_QueueCreate() and OS_QueueDelete() errors", - NULL, - NULL, - test_002_001_execute -}; - -/** - * @page test_002_002 [2.2] OS_QueueGetIdByName() errors - * - *

Description

- * Parameters checking in OS_QueueGetIdByName() is tested. - * - *

Test Steps

- * - [2.2.1] OS_QueueGetIdByName() is invoked with queue_id set to - * NULL, an error is expected. - * - [2.2.2] OS_QueueGetIdByName() is invoked with queue_name set to - * NULL, an error is expected. - * - [2.2.3] OS_QueueGetIdByName() is invoked with a very long task - * name, an error is expected. - * . - */ - -static void test_002_002_execute(void) { - - /* [2.2.1] 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"); - } - - /* [2.2.2] 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"); - } - - /* [2.2.3] 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_002 = { - "OS_QueueGetIdByName() errors", - NULL, - NULL, - test_002_002_execute -}; - -/** - * @page test_002_003 [2.3] OS_QueuePut() and OS_QueueGet() functionality - * - *

Description

- * A task writes on a queue, the messages are retrieved on the other - * side in blocking mode. - * - *

Test Steps

- * - [2.3.1] Creataing a queue with depth 4 and message size 20. - * - [2.3.2] Creating the writer task. - * - [2.3.3] Reading messages from the writer task. - * - [2.3.4] Waiting for task termination then checking for errors. - * . - */ - -static void test_002_003_setup(void) { - qid = 0; - tid = 0; -} - -static void test_002_003_teardown(void) { - if (qid != 0) { - (void) OS_QueueDelete(qid); - } - - if (tid != 0) { - (void) OS_TaskWait(tid); - } -} - -static void test_002_003_execute(void) { - uint32 tid; - unsigned i; - - /* [2.3.1] Creataing a queue with depth 4 and message size 20.*/ - test_set_step(1); - { - int32 err; - - err = OS_QueueCreate(&qid, "test queue", 4, MESSAGE_SIZE, 0); - test_assert(err == OS_SUCCESS, "queue creation failed"); - } - - /* [2.3.2] Creating the writer task.*/ - test_set_step(2); - { - int32 err; - - err = OS_TaskCreate(&tid, - "writer task", - test_task_writer, - (uint32 *)wa_test1, - sizeof wa_test1, - TASKS_BASE_PRIORITY, - 0); - test_assert(err == OS_SUCCESS, "writer task creation failed"); - } - - /* [2.3.3] Reading messages from the writer task.*/ - test_set_step(3); - { - for (i = 0; i < WRITER_NUM_MESSAGES; i++) { - int32 err; - char data[MESSAGE_SIZE]; - uint32 copied; - - err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(200)); - test_assert(err == OS_SUCCESS, "timed out"); - test_assert(strncmp(data, "Hello World", sizeof (data)) == 0, - "wrong message"); - } - } - - /* [2.3.4] Waiting for task termination then checking for errors.*/ - test_set_step(4); - { - (void) OS_TaskWait(tid); - tid = 0; - test_assert_sequence("", "queue write errors occurred"); - } -} - -static const testcase_t test_002_003 = { - "OS_QueuePut() and OS_QueueGet() functionality", - test_002_003_setup, - test_002_003_teardown, - test_002_003_execute -}; - -/** - * @page test_002_004 [2.4] OS_QueueGet() with timeout functionality - * - *

Description

- * OS_QueueGet() timeout functionality is tested. - * - *

Test Steps

- * - [2.4.1] Retrieving the queue by name. - * - [2.4.2] Get operation with a one second timeout, an error is - * expected. - * - [2.4.3] 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]; - - /* [2.4.1] Retrieving the queue by name.*/ - test_set_step(1); - { - int32 err; - - err = OS_QueueGetIdByName(&local_qid, "test queue"); - test_assert(err == OS_SUCCESS, "queue not found"); - } - - /* [2.4.2] 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"); - } - - /* [2.4.3] 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 functionality", - test_002_004_setup, - test_002_004_teardown, - test_002_004_execute -}; - -/**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Queues Functionality. - */ -const testcase_t * const test_sequence_002[] = { - &test_002_001, - &test_002_002, - &test_002_003, - &test_002_004, - NULL -}; diff --git a/test/nasa_osal/source/test/test_sequence_002.h b/test/nasa_osal/source/test/test_sequence_002.h deleted file mode 100644 index 56a3d36d7..000000000 --- a/test/nasa_osal/source/test/test_sequence_002.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_002.h - * @brief Test Sequence 002 header. - */ - -#ifndef TEST_SEQUENCE_002_H -#define TEST_SEQUENCE_002_H - -extern const testcase_t * const test_sequence_002[]; - -#endif /* TEST_SEQUENCE_002_H */ diff --git a/test/nasa_osal/source/test/test_sequence_003.c b/test/nasa_osal/source/test/test_sequence_003.c deleted file mode 100644 index c49e7395e..000000000 --- a/test/nasa_osal/source/test/test_sequence_003.c +++ /dev/null @@ -1,427 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_003.c - * @brief Test Sequence 003 code. - * - * @page test_sequence_003 [3] Timers Functionality - * - * File: @ref test_sequence_003.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to timers. - * - *

Test Cases

- * - @subpage test_003_001 - * - @subpage test_003_002 - * - @subpage test_003_003 - * - @subpage test_003_004 - * - @subpage test_003_005 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - -#include - -#include "osapi.h" - -uint32 tmid; -uint32 cnt; - -static void tmr_callback(uint32 timer_id) { - - (void)timer_id; - - cnt++; -} - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -/** - * @page test_003_001 [3.1] OS_TimerCreate() and OS_TimerDelete() errors - * - *

Description

- * Parameters checking in OS_TimerCreate() and OS_TimerDelete() is - * tested. - * - *

Test Steps

- * - [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an - * error is expected. - * - [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL, - * an error is expected. - * - [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an - * error is expected. - * - [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL, - * an error is expected. - * - [3.1.5] OS_TimerCreate() is invoked with a very long timer name, - * an error is expected. - * - [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an - * error is expected. - * - [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an - * error is expected, then the queue is deleted using - * OS_TimerDelete(). - * . - */ - -static void test_003_001_execute(void) { - - /* [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an - error is expected.*/ - test_set_step(1); - { - int32 err; - uint32 accuracy; - - err = OS_TimerCreate(NULL, /* Error.*/ - "failing timer", - &accuracy, - tmr_callback); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL, - an error is expected.*/ - test_set_step(2); - { - int32 err; - uint32 tmid; - uint32 accuracy; - - err = OS_TimerCreate(&tmid, - NULL, /* Error.*/ - &accuracy, - tmr_callback); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an - error is expected.*/ - test_set_step(3); - { - int32 err; - uint32 tmid; - - err = OS_TimerCreate(&tmid, - "failing timer", - NULL, /* Error.*/ - tmr_callback); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL, - an error is expected.*/ - test_set_step(4); - { - int32 err; - uint32 tmid; - uint32 accuracy; - - err = OS_TimerCreate(&tmid, - "failing timer", - &accuracy, - NULL); /* Error.*/ - test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected"); - } - - /* [3.1.5] OS_TimerCreate() is invoked with a very long timer name, - an error is expected.*/ - test_set_step(5); - { - int32 err; - uint32 tmid; - uint32 accuracy; - - err = OS_TimerCreate(&tmid, - "very very long timer name", /* Error.*/ - &accuracy, - tmr_callback); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); - } - - /* [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an - error is expected.*/ - test_set_step(6); - { - int32 err; - - err = OS_TimerDelete((uint32)-1); - test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected"); - } - - /* [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an - error is expected, then the queue is deleted using - OS_TimerDelete().*/ - test_set_step(7); - { - int32 err; - uint32 tmid1, tmid2; - uint32 accuracy; - - err = OS_TimerCreate(&tmid1, "my timer", &accuracy, tmr_callback); - test_assert(err == OS_SUCCESS, "timer creation failed"); - - err = OS_TimerCreate(&tmid2, "my timer", &accuracy, tmr_callback); - test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); - - err = OS_TimerDelete(tmid1); - test_assert(err == OS_SUCCESS, "timer deletion failed"); - } -} - -static const testcase_t test_003_001 = { - "OS_TimerCreate() and OS_TimerDelete() errors", - NULL, - NULL, - test_003_001_execute -}; - -/** - * @page test_003_002 [3.2] OS_TimerSet() errors - * - *

Description

- * Parameters checking in OS_TimerSet() is tested. - * - *

Test Steps

- * - [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error - * is expected. - * . - */ - -static void test_003_002_execute(void) { - - /* [3.2.1] OS_TimerSet() is invoked with timer_id set to -1, an error - is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_TimerSet((uint32)-1, 10, 10); - test_assert(err == OS_ERR_INVALID_ID, "invalid timer_id not detected"); - } -} - -static const testcase_t test_003_002 = { - "OS_TimerSet() errors", - NULL, - NULL, - test_003_002_execute -}; - -/** - * @page test_003_003 [3.3] OS_TimerGetIdByName() errors - * - *

Description

- * Parameters checking in OS_TimerGetIdByName() is tested. - * - *

Test Steps

- * - [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to - * NULL, an error is expected. - * - [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to - * NULL, an error is expected. - * - [3.3.3] OS_TimerGetIdByName() is invoked with a very long task - * name, an error is expected. - * . - */ - -static void test_003_003_execute(void) { - - /* [3.3.1] OS_TimerGetIdByName() is invoked with timer_id set to - NULL, an error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_TimerGetIdByName(NULL, "timer"); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [3.3.2] OS_TimerGetIdByName() is invoked with timer name set to - NULL, an error is expected.*/ - test_set_step(2); - { - int32 err; - - err = OS_TimerGetIdByName(&tmid, NULL); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [3.3.3] OS_TimerGetIdByName() is invoked with a very long task - name, an error is expected.*/ - test_set_step(3); - { - int32 err; - - err = OS_TimerGetIdByName(&tmid, "very very long timer name"); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); - } -} - -static const testcase_t test_003_003 = { - "OS_TimerGetIdByName() errors", - NULL, - NULL, - test_003_003_execute -}; - -/** - * @page test_003_004 [3.4] OS_TimerSet() one-shot functionality - * - *

Description

- * A timer is tested in one-shot mode. - * - *

Test Steps

- * - [3.4.1] Retrieving the timer by name. - * - [3.4.2] Setting up the timer for a 70mS one-shot tick. - * - [3.4.3] Waiting one second then counting the occurred ticks. - * . - */ - -static void test_003_004_setup(void) { - uint32 accuracy; - - cnt = 0; - tmid = 0; - (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); -} - -static void test_003_004_teardown(void) { - if (tmid != 0) { - (void) OS_TimerDelete(tmid); - } -} - -static void test_003_004_execute(void) { - uint32 local_tmid; - - /* [3.4.1] Retrieving the timer by name.*/ - test_set_step(1); - { - int32 err; - - err = OS_TimerGetIdByName(&local_tmid, "test timer"); - test_assert(err == OS_SUCCESS, "timer not found"); - } - - /* [3.4.2] Setting up the timer for a 70mS one-shot tick.*/ - test_set_step(2); - { - uint32 err; - - err = OS_TimerSet(local_tmid, 70000, 0); - test_assert(err == OS_SUCCESS, "timer setup failed"); - } - - /* [3.4.3] Waiting one second then counting the occurred ticks.*/ - test_set_step(3); - { - (void) OS_TaskDelay(1000); - test_assert(cnt == 1, "wrong ticks"); - } -} - -static const testcase_t test_003_004 = { - "OS_TimerSet() one-shot functionality", - test_003_004_setup, - test_003_004_teardown, - test_003_004_execute -}; - -/** - * @page test_003_005 [3.5] OS_TimerSet() periodic functionality - * - *

Description

- * A timer is tested in periodic mode. - * - *

Test Steps

- * - [3.5.1] Retrieving the timer by name. - * - [3.5.2] Setting up the timer for a 70mS periodic tick. - * - [3.5.3] Waiting one second then counting the occurred ticks. - * - [3.5.4] Stopping the timer. - * . - */ - -static void test_003_005_setup(void) { - uint32 accuracy; - - cnt = 0; - tmid = 0; - (void) OS_TimerCreate(&tmid, "test timer", &accuracy, tmr_callback); -} - -static void test_003_005_teardown(void) { - if (tmid != 0) { - (void) OS_TimerSet(tmid, 0, 0); - (void) OS_TimerDelete(tmid); - } -} - -static void test_003_005_execute(void) { - uint32 local_tmid; - - /* [3.5.1] Retrieving the timer by name.*/ - test_set_step(1); - { - int32 err; - - err = OS_TimerGetIdByName(&local_tmid, "test timer"); - test_assert(err == OS_SUCCESS, "timer not found"); - } - - /* [3.5.2] Setting up the timer for a 70mS periodic tick.*/ - test_set_step(2); - { - uint32 err; - - err = OS_TimerSet(local_tmid, 70000, 70000); - test_assert(err == OS_SUCCESS, "timer setup failed"); - } - - /* [3.5.3] Waiting one second then counting the occurred ticks.*/ - test_set_step(3); - { - (void) OS_TaskDelay(1000); - test_assert(cnt == 14, "wrong ticks"); - } - - /* [3.5.4] Stopping the timer.*/ - test_set_step(4); - { - uint32 err; - - err = OS_TimerSet(local_tmid, 0, 0); - test_assert(err == OS_SUCCESS, "timer stop failed"); - } -} - -static const testcase_t test_003_005 = { - "OS_TimerSet() periodic functionality", - test_003_005_setup, - test_003_005_teardown, - test_003_005_execute -}; - -/**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Timers Functionality. - */ -const testcase_t * const test_sequence_003[] = { - &test_003_001, - &test_003_002, - &test_003_003, - &test_003_004, - &test_003_005, - NULL -}; diff --git a/test/nasa_osal/source/test/test_sequence_003.h b/test/nasa_osal/source/test/test_sequence_003.h deleted file mode 100644 index 82f40587f..000000000 --- a/test/nasa_osal/source/test/test_sequence_003.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_003.h - * @brief Test Sequence 003 header. - */ - -#ifndef TEST_SEQUENCE_003_H -#define TEST_SEQUENCE_003_H - -extern const testcase_t * const test_sequence_003[]; - -#endif /* TEST_SEQUENCE_003_H */ diff --git a/test/nasa_osal/source/test/test_sequence_004.c b/test/nasa_osal/source/test/test_sequence_004.c deleted file mode 100644 index b342d845a..000000000 --- a/test/nasa_osal/source/test/test_sequence_004.c +++ /dev/null @@ -1,426 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_004.c - * @brief Test Sequence 004 code. - * - * @page test_sequence_004 [4] Binary Semaphores Functionality - * - * File: @ref test_sequence_004.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to binary semaphores. - * - *

Test Cases

- * - @subpage test_004_001 - * - @subpage test_004_002 - * - @subpage test_004_003 - * - @subpage test_004_004 - * - @subpage test_004_005 - * - @subpage test_004_006 - * - @subpage test_004_007 - * . - */ - -/**************************************************************************** - * Shared code. - ****************************************************************************/ - -#include "osapi.h" - -uint32 bsid; - -/**************************************************************************** - * Test cases. - ****************************************************************************/ - -/** - * @page test_004_001 [4.1] OS_BinSemCreate() and OS_BinSemDelete() errors - * - *

Description

- * Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is - * tested. - * - *

Test Steps

- * - [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an - * error is expected. - * - [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an - * error is expected. - * - [4.1.3] OS_BinSemCreate() is invoked with an invalid - * sem_initial_value, an error is expected. - * - [4.1.4] OS_BinSemCreate() is invoked with a very long timer name, - * an error is expected. - * - [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an - * error is expected. - * - [4.1.6] OS_BinSemCreate() is invoked twice with duplicated name, - * an error is expected, then the queue is deleted using - * OS_BinSemDelete(). - * . - */ - -static void test_004_001_execute(void) { - - /* [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemCreate(NULL, /* Error.*/ - "failing semaphore", - 0, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an - error is expected.*/ - test_set_step(2); - { - int32 err; - - err = OS_BinSemCreate(&bsid, - NULL, /* Error.*/ - 0, - 0); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [4.1.3] OS_BinSemCreate() is invoked with an invalid - sem_initial_value, an error is expected.*/ - test_set_step(3); - { - int32 err; - - err = OS_BinSemCreate(&bsid, - "failing semaphore", - 2, /* Error.*/ - 0); - test_assert(err == OS_INVALID_INT_NUM, "counter error not detected"); - } - - /* [4.1.4] OS_BinSemCreate() 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_BinSemCreate(&bsid, - "very very long semaphore name", /* Error.*/ - 0, - 0); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); -#endif - } - - /* [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an - error is expected.*/ - test_set_step(5); - { - int32 err; - - err = OS_BinSemDelete((uint32)-1); - test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected"); - } - - /* [4.1.6] 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; - uint32 bsid1; /*, bsid2;*/ - - err = OS_BinSemCreate(&bsid1, "my semaphore", 0, 0); - test_assert(err == OS_SUCCESS, "semaphore creation failed"); - -#if 0 /* Semaphore name currently not implemented.*/ - err = OS_BinSemCreate(&bsid2, "my semaphore", 0, 0); - test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); -#endif - - err = OS_BinSemDelete(bsid1); - test_assert(err == OS_SUCCESS, "semaphore deletion failed"); - } -} - -static const testcase_t test_004_001 = { - "OS_BinSemCreate() and OS_BinSemDelete() errors", - NULL, - NULL, - test_004_001_execute -}; - -/** - * @page test_004_002 [4.2] OS_BinSemFlush() errors - * - *

Description

- * Parameters checking in OS_BinSemFlush() is tested. - * - *

Test Steps

- * - [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an - * error is expected. - * . - */ - -static void test_004_002_execute(void) { - - /* [4.2.1] OS_BinSemFlush() is invoked with sem_id set to -1, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemFlush((uint32)-1); - test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); - } -} - -static const testcase_t test_004_002 = { - "OS_BinSemFlush() errors", - NULL, - NULL, - test_004_002_execute -}; - -/** - * @page test_004_003 [4.3] OS_BinSemGive() errors - * - *

Description

- * Parameters checking in OS_BinSemGive() is tested. - * - *

Test Steps

- * - [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error - * is expected. - * . - */ - -static void test_004_003_execute(void) { - - /* [4.3.1] OS_BinSemGive() is invoked with sem_id set to -1, an error - is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemGive((uint32)-1); - test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); - } -} - -static const testcase_t test_004_003 = { - "OS_BinSemGive() errors", - NULL, - NULL, - test_004_003_execute -}; - -/** - * @page test_004_004 [4.4] OS_BinSemTake() errors - * - *

Description

- * Parameters checking in OS_BinSemTake() is tested. - * - *

Test Steps

- * - [4.4.1] OS_BinSemTake() is invoked with sem_id set to -1, an error - * is expected. - * . - */ - -static void test_004_004_execute(void) { - - /* [4.4.1] 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_004_004 = { - "OS_BinSemTake() errors", - NULL, - NULL, - test_004_004_execute -}; - -/** - * @page test_004_005 [4.5] OS_BinSemTimedWait() errors - * - *

Description

- * Parameters checking in OS_BinSemTimedWait() is tested. - * - *

Test Steps

- * - [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an - * error is expected. - * - [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an - * error is expected. - * . - */ - -static void test_004_005_setup(void) { - bsid = 0; - (void) OS_BinSemCreate(&bsid, "test semaphore", 0, 0); -} - -static void test_004_005_teardown(void) { - if (bsid > 0) { - (void) OS_BinSemDelete(bsid); - } -} - -static void test_004_005_execute(void) { - - /* [4.5.1] OS_BinSemTimedWait() is invoked with sem_id set to -1, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemTimedWait((uint32)-1, 1000); - test_assert(err == OS_ERR_INVALID_ID, "invalid sem_id not detected"); - } - - /* [4.5.2] OS_BinSemTimedWait() is invoked with msecs set to 0, an - error is expected.*/ - test_set_step(2); - { - int32 err; - - err = OS_BinSemTimedWait(bsid, 0); - test_assert(err == OS_INVALID_INT_NUM, "invalid msec not detected"); - } -} - -static const testcase_t test_004_005 = { - "OS_BinSemTimedWait() errors", - test_004_005_setup, - test_004_005_teardown, - test_004_005_execute -}; - -/** - * @page test_004_006 [4.6] OS_BinSemGetIdByName() errors - * - *

Description

- * Parameters checking in OS_BinSemGetIdByName() is tested. - * - *

Test Steps

- * - [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL, - * an error is expected. - * - [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set - * to NULL, an error is expected. - * - [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task - * name, an error is expected. - * . - */ - -static void test_004_006_execute(void) { - - /* [4.6.1] OS_BinSemGetIdByName() is invoked with sem_id set to NULL, - an error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemGetIdByName(NULL, "semaphore"); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [4.6.2] OS_BinSemGetIdByName() is invoked with semaphore name set - to NULL, an error is expected.*/ - test_set_step(2); - { - int32 err; - - err = OS_BinSemGetIdByName(&bsid, NULL); - test_assert(err == OS_INVALID_POINTER, "NULL not detected"); - } - - /* [4.6.3] OS_BinSemGetIdByName() is invoked with a very long task - name, an error is expected.*/ - test_set_step(3); - { - int32 err; - - err = OS_BinSemGetIdByName(&bsid, "very very long semaphore name"); - test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected"); - } -} - -static const testcase_t test_004_006 = { - "OS_BinSemGetIdByName() errors", - NULL, - NULL, - test_004_006_execute -}; - -/** - * @page test_004_007 [4.7] OS_BinSemTimedWait() timeout functionality - * - *

Description

- * OS_BinSemCreate() timeout functionality is tested. - * - *

Test Steps

- * - [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one - * second, an error is expected. - * . - */ - -static void test_004_007_setup(void) { - bsid = 0; - (void) OS_BinSemCreate(&bsid, "test semaphore", 0, 0); -} - -static void test_004_007_teardown(void) { - if (bsid > 0) { - (void) OS_BinSemDelete(bsid); - } -} - -static void test_004_007_execute(void) { - - /* [4.7.1] OS_BinSemTimedWait() is invoked with timeout set to one - second, an error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_BinSemTimedWait(bsid, 1000); - test_assert(err == OS_SEM_TIMEOUT, "unexpected error code"); - } -} - -static const testcase_t test_004_007 = { - "OS_BinSemTimedWait() timeout functionality", - test_004_007_setup, - test_004_007_teardown, - test_004_007_execute -}; - -/**************************************************************************** - * Exported data. - ****************************************************************************/ - -/** - * @brief Binary Semaphores Functionality. - */ -const testcase_t * const test_sequence_004[] = { - &test_004_001, - &test_004_002, - &test_004_003, - &test_004_004, - &test_004_005, - &test_004_006, - &test_004_007, - NULL -}; diff --git a/test/nasa_osal/source/test/test_sequence_004.h b/test/nasa_osal/source/test/test_sequence_004.h deleted file mode 100644 index b34358d46..000000000 --- a/test/nasa_osal/source/test/test_sequence_004.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_004.h - * @brief Test Sequence 004 header. - */ - -#ifndef TEST_SEQUENCE_004_H -#define TEST_SEQUENCE_004_H - -extern const testcase_t * const test_sequence_004[]; - -#endif /* TEST_SEQUENCE_004_H */ diff --git a/test/nasa_osal/source/test/test_sequence_005.c b/test/nasa_osal/source/test/test_sequence_005.c deleted file mode 100644 index 8d9773ec7..000000000 --- a/test/nasa_osal/source/test/test_sequence_005.c +++ /dev/null @@ -1,392 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_005.c - * @brief Test Sequence 005 code. - * - * @page test_sequence_005 [5] Counter Semaphores Functionality - * - * File: @ref test_sequence_005.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to counter semaphores. - * - *

Test Cases

- * - @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 [5.1] OS_CountSemCreate() and OS_CountSemDelete() errors - * - *

Description

- * Parameters checking in OS_CountSemCreate() and OS_CountSemDelete() - * is tested. - * - *

Test Steps

- * - [5.1.1] OS_CountSemCreate() is invoked with sem_id set to NULL, an - * error is expected. - * - [5.1.2] OS_CountSemCreate() is invoked with sem_name set to NULL, - * an error is expected. - * - [5.1.3] OS_CountSemCreate() is invoked with an invalid - * sem_initial_value, an error is expected. - * - [5.1.4] OS_CountSemCreate() is invoked with a very long timer - * name, an error is expected. - * - [5.1.5] OS_CountSemDelete() is invoked with timer_id set to -1, an - * error is expected. - * - [5.1.6] 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) { - - /* [5.1.1] 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"); - } - - /* [5.1.2] 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"); - } - - /* [5.1.3] 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"); - } - - /* [5.1.4] 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 - } - - /* [5.1.5] 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"); - } - - /* [5.1.6] 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 [5.2] OS_CountSemGive() errors - * - *

Description

- * Parameters checking in OS_CountSemGive() is tested. - * - *

Test Steps

- * - [5.2.1] OS_CountSemGive() is invoked with sem_id set to -1, an - * error is expected. - * . - */ - -static void test_005_002_execute(void) { - - /* [5.2.1] 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 [5.3] OS_CountSemTake() errors - * - *

Description

- * Parameters checking in OS_CountSemTake() is tested. - * - *

Test Steps

- * - [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an - * error is expected. - * . - */ - -static void test_005_003_execute(void) { - - /* [5.3.1] OS_CountSemTake() is invoked with sem_id set to -1, an - error is expected.*/ - test_set_step(1); - { - int32 err; - - err = OS_CountSemTake((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 [5.4] OS_CountSemTimedWait() errors - * - *

Description

- * Parameters checking in OS_CountSemTimedWait() is tested. - * - *

Test Steps

- * - [5.4.1] OS_CountSemTimedWait() is invoked with sem_id set to -1, - * an error is expected. - * - [5.4.2] 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) { - - /* [5.4.1] 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"); - } - - /* [5.4.2] 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 [5.5] OS_CountSemGetIdByName() errors - * - *

Description

- * Parameters checking in OS_CountSemGetIdByName() is tested. - * - *

Test Steps

- * - [5.5.1] OS_CountSemGetIdByName() is invoked with sem_id set to - * NULL, an error is expected. - * - [5.5.2] OS_CountSemGetIdByName() is invoked with semaphore name - * set to NULL, an error is expected. - * - [5.5.3] OS_CountSemGetIdByName() is invoked with a very long task - * name, an error is expected. - * . - */ - -static void test_005_005_execute(void) { - - /* [5.5.1] 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"); - } - - /* [5.5.2] 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"); - } - - /* [5.5.3] 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 [5.6] OS_CountSemTimedWait() timeout functionality - * - *

Description

- * OS_CountSemCreate() timeout functionality is tested. - * - *

Test Steps

- * - [5.6.1] 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) { - - /* [5.6.1] 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 deleted file mode 100644 index 11aed54c1..000000000 --- a/test/nasa_osal/source/test/test_sequence_005.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_005.h - * @brief Test Sequence 005 header. - */ - -#ifndef TEST_SEQUENCE_005_H -#define TEST_SEQUENCE_005_H - -extern const testcase_t * const test_sequence_005[]; - -#endif /* TEST_SEQUENCE_005_H */ diff --git a/test/nasa_osal/source/test/test_sequence_006.c b/test/nasa_osal/source/test/test_sequence_006.c deleted file mode 100644 index 0e6ccec06..000000000 --- a/test/nasa_osal/source/test/test_sequence_006.c +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright statement.*/ - -#include "hal.h" -#include "ch_test.h" -#include "test_root.h" - -/** - * @file test_sequence_006.c - * @brief Test Sequence 006 code. - * - * @page test_sequence_006 [6] Mutex Semaphores Functionality - * - * File: @ref test_sequence_006.c - * - *

Description

- * This sequence tests the NASA OSAL over ChibiOS/RT functionalities - * related to mutex semaphores. - * - *

Test Cases

- * - @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 [6.1] OS_MutSemCreate() and OS_MutSemDelete() errors - * - *

Description

- * Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is - * tested. - * - *

Test Steps

- * - [6.1.1] OS_MutSemCreate() is invoked with sem_id set to NULL, an - * error is expected. - * - [6.1.2] OS_MutSemCreate() is invoked with sem_name set to NULL, an - * error is expected. - * - [6.1.3] OS_MutSemCreate() is invoked with a very long timer name, - * an error is expected. - * - [6.1.4] OS_MutSemDelete() is invoked with timer_id set to -1, an - * error is expected. - * - [6.1.5] 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) { - - /* [6.1.1] 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"); - } - - /* [6.1.2] 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"); - } - - /* [6.1.3] 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 - } - - /* [6.1.4] 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"); - } - - /* [6.1.5] 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 [6.2] OS_MutSemGive() errors - * - *

Description

- * Parameters checking in OS_MutSemGive() is tested. - * - *

Test Steps

- * - [6.2.1] OS_MutSemGive() is invoked with sem_id set to -1, an error - * is expected. - * . - */ - -static void test_006_002_execute(void) { - - /* [6.2.1] 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 [6.3] OS_MutSemTake() errors - * - *

Description

- * Parameters checking in OS_MutSemTake() is tested. - * - *

Test Steps

- * - [6.3.1] OS_MutSemTake() is invoked with sem_id set to -1, an error - * is expected. - * . - */ - -static void test_006_003_execute(void) { - - /* [6.3.1] 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 [6.4] OS_MutSemGetIdByName() errors - * - *

Description

- * Parameters checking in OS_MutSemGetIdByName() is tested. - * - *

Test Steps

- * - [6.4.1] OS_MutSemGetIdByName() is invoked with sem_id set to NULL, - * an error is expected. - * - [6.4.2] OS_MutSemGetIdByName() is invoked with semaphore name set - * to NULL, an error is expected. - * - [6.4.3] OS_MutSemGetIdByName() is invoked with a very long task - * name, an error is expected. - * . - */ - -static void test_006_004_execute(void) { - - /* [6.4.1] 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"); - } - - /* [6.4.2] 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"); - } - - /* [6.4.3] 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 -}; diff --git a/test/nasa_osal/source/test/test_sequence_006.h b/test/nasa_osal/source/test/test_sequence_006.h deleted file mode 100644 index a4f3bc211..000000000 --- a/test/nasa_osal/source/test/test_sequence_006.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright statement.*/ - -/** - * @file test_sequence_006.h - * @brief Test Sequence 006 header. - */ - -#ifndef TEST_SEQUENCE_006_H -#define TEST_SEQUENCE_006_H - -extern const testcase_t * const test_sequence_006[]; - -#endif /* TEST_SEQUENCE_006_H */ diff --git a/test/nasa_osal/test.mk b/test/nasa_osal/test.mk deleted file mode 100644 index cf9a9cdb7..000000000 --- a/test/nasa_osal/test.mk +++ /dev/null @@ -1,13 +0,0 @@ -# List of all the NASA OSAL over ChibiOS/RT test files. -TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \ - ${CHIBIOS}/test/nasa_osal/source/test/test_root.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_005.c \ - ${CHIBIOS}/test/nasa_osal/source/test/test_sequence_006.c - -# Required include directories -TESTINC = ${CHIBIOS}/test/lib \ - ${CHIBIOS}/test/nasa_osal/source/test/ -- cgit v1.2.3