From 66cd0da92f4bb3a50feddac40c1fca6abbf8ead3 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 7 May 2021 17:43:24 -0400 Subject: [PATCH] Break out unit tests #2627 --- unit_tests/Makefile | 6 +----- unit_tests/global_mocks.cpp | 25 +++++++++++++++++++++++++ unit_tests/main.cpp | 26 +------------------------- unit_tests/unit_test_rules.mk | 12 +++++++++++- 4 files changed, 38 insertions(+), 31 deletions(-) create mode 100644 unit_tests/global_mocks.cpp diff --git a/unit_tests/Makefile b/unit_tests/Makefile index edd8e5dd92..f7d2d5b44d 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -36,8 +36,6 @@ CSRC = $(ALLCSRC) \ # setting. CPPSRC = $(ALLCPPSRC) \ $(UTILSRC_CPP) \ - gtest-all.cpp \ - gmock-all.cpp \ $(CONTROLLERS_ALGO_SRC_CPP) \ $(TRIGGER_DECODERS_SRC_CPP) \ $(ENGINES_SRC_CPP) \ @@ -56,6 +54,7 @@ CPPSRC = $(ALLCPPSRC) \ $(PROJECT_DIR)/../unit_tests/logicdata.cpp \ $(DEVELOPMENT_DIR)/engine_sniffer.cpp \ $(PROJECT_DIR)/../unit_tests/main.cpp \ + $(PROJECT_DIR)/../unit_tests/global_mocks.cpp \ $(PROJECT_DIR)/console/binary/tooth_logger.cpp \ $(PROJECT_DIR)/console/binary_log/log_field.cpp \ @@ -73,9 +72,6 @@ INCDIR = $(UNIT_TESTS_DIR) \ $(HW_SENSORS_INC) \ $(HW_LAYER_DRIVERS_INC) \ $(UNIT_TESTS_DIR)/test_data_structures \ - $(UNIT_TESTS_DIR)/googletest/googlemock/include \ - $(UNIT_TESTS_DIR)/googletest/googletest \ - $(UNIT_TESTS_DIR)/googletest/googletest/include \ $(UNIT_TESTS_DIR)/tests \ $(UNIT_TESTS_DIR)/tests/sensor \ $(UNIT_TESTS_DIR)/test_basic_math diff --git a/unit_tests/global_mocks.cpp b/unit_tests/global_mocks.cpp new file mode 100644 index 0000000000..f0e0f0558d --- /dev/null +++ b/unit_tests/global_mocks.cpp @@ -0,0 +1,25 @@ + +#include "global.h" + +#include "engine_configuration.h" + +#include "test_signal_executor.h" +#include "trigger_central.h" +#include "map_resize.h" +#include "engine_math.h" +#include "engine_test_helper.h" + +bool verboseMode = false; + +int timeNowUs = 0; + +efitimeus_t getTimeNowUs(void) { + return timeNowUs; +} + +efitick_t getTimeNowNt(void) { + return getTimeNowUs() * US_TO_NT_MULTIPLIER; +} + +void initLogging(LoggingWithStorage *logging, const char *name) { +} diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 75f8a8bdb0..953e6de5ba 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -2,35 +2,13 @@ * @file main.cpp * @file Unit tests (and some integration tests to be fair) of rusEFI * - * @author Andrey Belomutskiy, (c) 2012-2020 + * @author Andrey Belomutskiy, (c) 2012-2021 */ #include - -#include "global.h" - -#include "engine_configuration.h" - -#include "test_signal_executor.h" -#include "trigger_central.h" -#include "map_resize.h" -#include "engine_math.h" -#include "engine_test_helper.h" #include "gtest/gtest.h" -int timeNowUs = 0; - -efitimeus_t getTimeNowUs(void) { - return timeNowUs; -} - -efitick_t getTimeNowNt(void) { - return getTimeNowUs() * US_TO_NT_MULTIPLIER; -} - -bool verboseMode = false; - GTEST_API_ int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); // uncomment if you only want to run selected tests @@ -43,5 +21,3 @@ GTEST_API_ int main(int argc, char **argv) { return result == 0 ? 0 : -1; } -void initLogging(LoggingWithStorage *logging, const char *name) { -} diff --git a/unit_tests/unit_test_rules.mk b/unit_tests/unit_test_rules.mk index 3fc3cb3b7d..20f99c54c2 100644 --- a/unit_tests/unit_test_rules.mk +++ b/unit_tests/unit_test_rules.mk @@ -1,5 +1,15 @@ -include $(PROJECT_DIR)/rusefi_rules.mk +UNIT_TESTS_DIR=$(PROJECT_DIR)/../unit_tests +CPPSRC += gtest-all.cpp \ + gmock-all.cpp \ + + +INCDIR += $(UNIT_TESTS_DIR)/googletest/googlemock/include \ + $(UNIT_TESTS_DIR)/googletest/googletest \ + $(UNIT_TESTS_DIR)/googletest/googletest/include \ + + +include $(PROJECT_DIR)/rusefi_rules.mk # Compiler options here. ifeq ($(USE_OPT),)