From 4f63d2b4765d2804928510a353e7a122383bf656 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 15 May 2021 05:27:33 -0400 Subject: [PATCH] More low-level firmware coverage for the simulator/unit-tests #2656 --- firmware/controllers/system/thread_controller.h | 4 ---- unit_tests/Makefile | 1 + unit_tests/chibios-mock/mock-threads.h | 8 ++++++++ unit_tests/global.h | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 unit_tests/chibios-mock/mock-threads.h diff --git a/firmware/controllers/system/thread_controller.h b/firmware/controllers/system/thread_controller.h index 84c58fae32..4d8a2c25e5 100644 --- a/firmware/controllers/system/thread_controller.h +++ b/firmware/controllers/system/thread_controller.h @@ -10,8 +10,6 @@ #include "global.h" #include "controller_base.h" -#if ! EFI_UNIT_TEST - /** * @brief A base class for a controller that requires its own thread. * @@ -68,5 +66,3 @@ public: m_isStarted = true; } }; - -#endif diff --git a/unit_tests/Makefile b/unit_tests/Makefile index 54f6e78cd5..9c847ab1b5 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -74,6 +74,7 @@ INCDIR += $(UNIT_TESTS_DIR) \ $(HW_SENSORS_INC) \ $(HW_LAYER_DRIVERS_INC) \ $(UNIT_TESTS_DIR)/test_data_structures \ + $(UNIT_TESTS_DIR)/chibios-mock \ $(UNIT_TESTS_DIR)/tests \ $(UNIT_TESTS_DIR)/tests/sensor \ $(UNIT_TESTS_DIR)/test_basic_math diff --git a/unit_tests/chibios-mock/mock-threads.h b/unit_tests/chibios-mock/mock-threads.h new file mode 100644 index 0000000000..9a2c528184 --- /dev/null +++ b/unit_tests/chibios-mock/mock-threads.h @@ -0,0 +1,8 @@ +#define THD_WORKING_AREA(name, size) uint8_t name[size]; + +typedef int tprio_t; + +class thread_t { + char *name; + +}; diff --git a/unit_tests/global.h b/unit_tests/global.h index e69aa690f9..1fb898a011 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -29,6 +29,7 @@ typedef uint32_t ioportmask_t; #ifdef __cplusplus +#include "mock-threads.h" // todo: include it right here? #include "unit_test_framework.h" extern "C" {