Test specification for the NASA OSAL ChibiOS extension. NASA OSAL Test Suite. 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. nasa_osal_ Internal Tests Tasks Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to threading. OS_TaskCreate() errors Parameters checking in OS_TaskCreate() is tested. OS_TaskCreate() is invoked with task_id set to NULL, an error is expected. OS_TaskCreate() is invoked with task_name set to NULL, an error is expected. OS_TaskCreate() is invoked with stack_pointer set to NULL, an error is expected. OS_TaskCreate() is invoked with a very long task name, an error is expected. OS_TaskCreate() is invoked with priority below and above allowed range, an error is expected. OS_TaskCreate() is invoked with a stack size below minimum, an error is expected. OS_TaskCreate() is invoked twice with duplicated name and then duplicated stack, an error is expected in both cases. OS_TaskCreate() priority ordering Four tasks are created at different priorities and in different order. The execution order must happen in order of priority regardless the creation order. Four tasks are created in priority order from low to high. Tasks are made runnable atomically and their execution order tested. Four tasks are created in priority order from high to low. Tasks are made runnable atomically and their execution order tested. Four tasks are created in an not ordered way. Tasks are made runnable atomically and their execution order tested. OS_TaskDelete() errors Parameters checking in OS_TaskDelete() is tested. OS_TaskDelete() is invoked with task_id set to -1, an error is expected. OS_TaskDelete() and OS_TaskInstallDeleteHandler() functionality OS_TaskDelete() and OS_TaskInstallDeleteHandler() are tested for functionality. Creating a task executing an infinite loop. Letting the task run for a while then deleting it. A check is performed on the correct execution of the delete handler. Internal Tests Queues Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to queues #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('*'); } } }]]> OS_QueueCreate() and OS_QueueDelete() errors Parameters checking in OS_QueueCreate() and OS_QueueDelete() is tested. OS_QueueCreate() is invoked with queue_id set to NULL, an error is expected. OS_QueueCreate() is invoked with task_name set to NULL, an error is expected. OS_QueueCreate() is invoked with a very long task name, an error is expected. OS_QueueDelete() is invoked with queue_id set to -1, an error is expected. OS_QueueCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_QueueDelete(). OS_QueueGetIdByName() errors Parameters checking in OS_QueueGetIdByName() is tested. OS_QueueGetIdByName() is invoked with queue_id set to NULL, an error is expected. OS_QueueGetIdByName() is invoked with queue_name set to NULL, an error is expected. OS_QueueGetIdByName() is invoked with a very long task name, an error is expected. OS_QueuePut() and OS_QueueGet() functionality A task writes on a queue, the messages are retrieved on the other side in blocking mode. Creataing a queue with depth 4 and message size 20 Creating the writer task. Reading messages from the writer task. Waiting for task termination then checking for errors. OS_QueueGet() with timeout functionality OS_QueueGet() timeout functionality is tested. Retrieving the queue by name. Get operation with a one second timeout, an error is expected. Get operation in non-blocking mode, an error is expected. Internal Tests Timers Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to timers #include "osapi.h" uint32 tmid; uint32 cnt; static void tmr_callback(uint32 timer_id) { (void)timer_id; cnt++; }]]> OS_TimerCreate() and OS_TimerDelete() errors Parameters checking in OS_TimerCreate() and OS_TimerDelete() is tested. OS_TimerCreate() is invoked with timer_id set to NULL, an error is expected. OS_TimerCreate() is invoked with timer_name set to NULL, an error is expected. OS_TimerCreate() is invoked with accuracy set to NULL, an error is expected. OS_TimerCreate() is invoked with callback_ptr set to NULL, an error is expected. OS_TimerCreate() is invoked with a very long timer name, an error is expected. OS_TimerDelete() is invoked with timer_id set to -1, an error is expected. OS_TimerCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_TimerDelete(). OS_TimerSet() errors Parameters checking in OS_TimerSet() is tested. OS_TimerSet() is invoked with timer_id set to -1, an error is expected. OS_TimerGetIdByName() errors Parameters checking in OS_TimerGetIdByName() is tested. OS_TimerGetIdByName() is invoked with timer_id set to NULL, an error is expected. OS_TimerGetIdByName() is invoked with timer name set to NULL, an error is expected. OS_TimerGetIdByName() is invoked with a very long task name, an error is expected. OS_TimerSet() one-shot functionality A timer is tested in one-shot mode. Retrieving the timer by name. Setting up the timer for a 70mS one-shot tick. Waiting one second then counting the occurred ticks. OS_TimerSet() periodic functionality A timer is tested in periodic mode. Retrieving the timer by name. Setting up the timer for a 70mS periodic tick. Waiting one second then counting the occurred ticks. Stopping the timer. Internal Tests Binary Semaphores Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to binary semaphores. OS_BinSemCreate() and OS_BinSemDelete() errors Parameters checking in OS_BinSemCreate() and OS_BinSemDelete() is tested. OS_BinSemCreate() is invoked with sem_id set to NULL, an error is expected. OS_BinSemCreate() is invoked with sem_name set to NULL, an error is expected. OS_BinSemCreate() is invoked with an invalid sem_initial_value, an error is expected. OS_BinSemCreate() is invoked with a very long timer name, an error is expected. OS_BinSemDelete() is invoked with timer_id set to -1, an error is expected. OS_BinSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_BinSemDelete(). OS_BinSemFlush() errors Parameters checking in OS_BinSemFlush() is tested. OS_BinSemFlush() is invoked with sem_id set to -1, an error is expected. OS_BinSemGive() errors Parameters checking in OS_BinSemGive() is tested. OS_BinSemGive() is invoked with sem_id set to -1, an error is expected. OS_BinSemTake() errors Parameters checking in OS_BinSemTake() is tested. OS_BinSemTake() is invoked with sem_id set to -1, an error is expected. OS_BinSemTimedWait() errors Parameters checking in OS_BinSemTimedWait() is tested. 0) { (void) OS_BinSemDelete(bsid); }]]> OS_BinSemTimedWait() is invoked with sem_id set to -1, an error is expected. OS_BinSemTimedWait() is invoked with msecs set to 0, an error is expected. OS_BinSemGetIdByName() errors Parameters checking in OS_BinSemGetIdByName() is tested. OS_BinSemGetIdByName() is invoked with sem_id set to NULL, an error is expected. OS_BinSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected. OS_BinSemGetIdByName() is invoked with a very long task name, an error is expected. OS_BinSemTimedWait() timeout functionality OS_BinSemCreate() timeout functionality is tested. 0) { (void) OS_BinSemDelete(bsid); }]]> OS_BinSemTimedWait() is invoked with timeout set to one second, an error is expected. Internal Tests Counter Semaphores Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to counter semaphores. OS_CountSemCreate() and OS_CountSemDelete() errors Parameters checking in OS_CountSemCreate() and OS_CountSemDelete() is tested. OS_CountSemCreate() is invoked with sem_id set to NULL, an error is expected. OS_CountSemCreate() is invoked with sem_name set to NULL, an error is expected. OS_CountSemCreate() is invoked with an invalid sem_initial_value, an error is expected. OS_CountSemCreate() is invoked with a very long timer name, an error is expected. OS_CountSemDelete() is invoked with timer_id set to -1, an error is expected. OS_CountSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_CountSemDelete(). OS_CountSemGive() errors Parameters checking in OS_CountSemGive() is tested. OS_CountSemGive() is invoked with sem_id set to -1, an error is expected. OS_CountSemTake() errors Parameters checking in OS_CountSemTake() is tested. OS_CountSemTake() is invoked with sem_id set to -1, an error is expected. OS_CountSemTimedWait() errors Parameters checking in OS_CountSemTimedWait() is tested. 0) { (void) OS_CountSemDelete(csid); }]]> OS_CountSemTimedWait() is invoked with sem_id set to -1, an error is expected. OS_CountSemTimedWait() is invoked with msecs set to 0, an error is expected. OS_CountSemGetIdByName() errors Parameters checking in OS_CountSemGetIdByName() is tested. OS_CountSemGetIdByName() is invoked with sem_id set to NULL, an error is expected. OS_CountSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected. OS_CountSemGetIdByName() is invoked with a very long task name, an error is expected. OS_CountSemTimedWait() timeout functionality OS_CountSemCreate() timeout functionality is tested. 0) { (void) OS_CountSemDelete(csid); }]]> OS_CountSemTimedWait() is invoked with timeout set to one second, an error is expected. Internal Tests Mutex Semaphores Functionality This sequence tests the NASA OSAL over ChibiOS/RT functionalities related to mutex semaphores. OS_MutSemCreate() and OS_MutSemDelete() errors Parameters checking in OS_MutSemCreate() and OS_MutSemDelete() is tested. OS_MutSemCreate() is invoked with sem_id set to NULL, an error is expected. OS_MutSemCreate() is invoked with sem_name set to NULL, an error is expected. OS_MutSemCreate() is invoked with a very long timer name, an error is expected. OS_MutSemDelete() is invoked with timer_id set to -1, an error is expected. OS_MutSemCreate() is invoked twice with duplicated name, an error is expected, then the queue is deleted using OS_MutSemDelete(). OS_MutSemGive() errors Parameters checking in OS_MutSemGive() is tested. OS_MutSemGive() is invoked with sem_id set to -1, an error is expected. OS_MutSemTake() errors Parameters checking in OS_MutSemTake() is tested. OS_MutSemTake() is invoked with sem_id set to -1, an error is expected. OS_MutSemGetIdByName() errors Parameters checking in OS_MutSemGetIdByName() is tested. OS_MutSemGetIdByName() is invoked with sem_id set to NULL, an error is expected. OS_MutSemGetIdByName() is invoked with semaphore name set to NULL, an error is expected. OS_MutSemGetIdByName() is invoked with a very long task name, an error is expected.