diff --git a/unit_tests/Makefile b/unit_tests/Makefile index 59c44d9022..a9fe0fb5dc 100644 --- a/unit_tests/Makefile +++ b/unit_tests/Makefile @@ -110,6 +110,7 @@ CSRC = $(UTILSRC) \ # C++ sources that can be compiled in ARM or THUMB mode depending on the global # setting. CPPSRC = $(UTILSRC_CPP) \ + gtest-all.cpp \ $(CONTROLLERS_ALGO_SRC_CPP) \ $(TRIGGER_DECODERS_SRC_CPP) \ $(ENGINES_SRC_CPP) \ @@ -124,6 +125,7 @@ CPPSRC = $(UTILSRC_CPP) \ $(TRIGGER_SRC_CPP) \ main.cpp + # C sources to be compiled in ARM mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. @@ -168,6 +170,8 @@ INCDIR = . \ $(PROJECT_DIR)/hw_layer/algo \ $(PROJECT_DIR)/hw_layer/sensors/ \ test_data_structures \ + googletest/googletest \ + googletest/googletest/include \ test_basic_math diff --git a/unit_tests/gtest-all.cpp b/unit_tests/gtest-all.cpp new file mode 100644 index 0000000000..ef8093b79e --- /dev/null +++ b/unit_tests/gtest-all.cpp @@ -0,0 +1,10 @@ +// this is a work-around since our Makefile does not recognice .cc format +// todo: adjust the makefile so that we can remove this + +#include "googletest/googletest/src/gtest.cc" +#include "googletest/googletest/src/gtest-death-test.cc" +#include "googletest/googletest/src/gtest-filepath.cc" +#include "googletest/googletest/src/gtest-port.cc" +#include "googletest/googletest/src/gtest-printers.cc" +#include "googletest/googletest/src/gtest-test-part.cc" +#include "googletest/googletest/src/gtest-typed-test.cc" diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index bd308ec701..484b319460 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -23,7 +23,6 @@ #include "engine_configuration.h" #include "test_idle_controller.h" -#include "test_c125.h" #include "afm2mapConverter.h" #include "test_signal_executor.h" #include "trigger_central.h" @@ -34,6 +33,7 @@ #include "engine_math.h" #include "test_engine_math.h" #include "test_trigger_decoder.h" +#include "gtest/gtest.h" typedef int32_t msg_t; @@ -59,7 +59,7 @@ int getRevolutionCounter(void) { } extern bool printTriggerDebug; -int main(void) { +GTEST_API_ int main(int argc, char **argv) { // printTriggerDebug = true; testMisc(); @@ -125,13 +125,14 @@ int main(void) { testTriggerDecoder(); - testCJ125(); + // resizeMap(); printf("Success 20190103\r\n"); printAllTriggers(); // printConvertedTable(); - return EXIT_SUCCESS; + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } void print(const char *format, ...) { diff --git a/unit_tests/test_c125.h b/unit_tests/test_c125.h index 8e4334e7f3..a7712c5abb 100644 --- a/unit_tests/test_c125.h +++ b/unit_tests/test_c125.h @@ -8,6 +8,4 @@ #ifndef TEST_C125_H_ #define TEST_C125_H_ -void testCJ125(); - #endif /* TEST_C125_H_ */ diff --git a/unit_tests/test_cj125.cpp b/unit_tests/test_cj125.cpp index c8a1cdf847..b0f2b6c740 100644 --- a/unit_tests/test_cj125.cpp +++ b/unit_tests/test_cj125.cpp @@ -5,14 +5,11 @@ * @author Andrey Belomutskiy, (c) 2012-2019 */ - #include "test_c125.h" -#include "CJ125.h" - -void testCJ125() { - printf("====================================================================================== testCJ125\r\n"); +#include "gtest/gtest.h" +TEST(testCJ125, todo) { + EXPECT_EQ(1, 2 - 1); } - diff --git a/unit_tests/test_pid_auto.cpp b/unit_tests/test_pid_auto.cpp index 04be5f055d..ecd2c8ca69 100644 --- a/unit_tests/test_pid_auto.cpp +++ b/unit_tests/test_pid_auto.cpp @@ -10,6 +10,7 @@ #include "pid_auto_tune.h" #include "unit_test_framework.h" #include "cyclic_buffer.h" +#include "gtest/gtest.h" efitimems_t mockTimeMs = 0; @@ -159,9 +160,7 @@ static void testPidAutoZigZagGrowingOsc() { } -static void testPidZeroLine() { - printf("*************************************************** testPidAutoZigZagGrowingOsc\r\n"); - +TEST(pidAutoTune, zeroLine) { mockTimeMs = 0; PID_AutoTune at; @@ -182,8 +181,7 @@ static void testPidZeroLine() { // nothing happens in this test since we do not allow time play a role } -static void testPidDelayLine(void) { - printf("*************************************************** testPidDelayLine\r\n"); +TEST(pidAutoTune, delayLine) { static const int delayBufSize = 8; @@ -220,8 +218,6 @@ static void testPidDelayLine(void) { void testPidAuto() { printf("*************************************************** testPidAuto\r\n"); - testPidDelayLine(); - testPidZeroLine(); testPidAutoZigZagStable(); testPidAutoZigZagGrowingOsc();