// UnityTest.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include "unity.h" #include "FreeRTOSHooks.h" #include "motium_base.h" #include "QueueCPP.h" #include "iotask.h" #include "readtask.h" #include "writetask.h" #include using namespace rw_tasks; using namespace io_tasks; void setUp() {} void tearDown() {} void test_function1(void) { TEST_ASSERT(TRUE); } void test_function2(void) { TEST_PASS(); } void test_function3(void) { class testTask : public TaskClass { public: testTask(const char* task_name, TaskPriority priority, uint32_t stack_size) : TaskClass(task_name, priority, stack_size) {}; void task() { TEST_ASSERT(TRUE); vTaskEndScheduler(); //end the test } }; new testTask("test_task", TaskPrio_Low, configMINIMAL_STACK_SIZE); /* Start scheduling. */ vTaskStartScheduler(); } void test_function4(void) { static EventGroupHandle_t pevent_group = xEventGroupCreate(); static Queue* ioQueue = new Queue(8, "ioQ"); static uint16_t msg; class testTask : public TaskClass { public: testTask(const char* task_name, TaskPriority priority, uint32_t stack_size) : TaskClass(task_name, priority, stack_size) { }; void task() { xEventGroupSetBits(pevent_group, B0); ioQueue->pop(msg, 1000); TEST_ASSERT_EQUAL_UINT16((int)msg, 1); xEventGroupSetBits(pevent_group, B1); ioQueue->pop(msg, 1000); TEST_ASSERT_EQUAL_UINT16((int)msg, 1); xEventGroupSetBits(pevent_group, B0 + B1); ioQueue->pop(msg, 1000); TEST_ASSERT_EQUAL_UINT16((int)msg, 0); vTaskEndScheduler(); //end the test } }; //TODO place assert on objects creation new readTask(ioQueue, pevent_group, "READ_TASK", TaskPrio_HMI, configMINIMAL_STACK_SIZE); new testTask("test_taskx", TaskPrio_Low, configMINIMAL_STACK_SIZE); /* Start scheduling. */ vTaskStartScheduler(); } int main(void) { //Win32 FreeRTOS simulator port allows us to run one or more 'task tests' within a FreeRTOS environment //running on a windows machine as part of GIT/CI unit testing process. UNITY_BEGIN(); prvInitialiseHeap(); //init heap for FreeRTOS RUN_TEST(test_function1); //non-FreeRTOS test RUN_TEST(test_function3); //creates a 'test task' to test unity assertion RUN_TEST(test_function2); //another non-FreeRTOS test placed between two FreeRTOS tests to ensure Unity is OK RUN_TEST(test_function4); //Finally create another 'test task' to test a application 'task under test' UNITY_END(); //result should be PASS,PASS,PASS,FAIL }