googletest

This commit is contained in:
rusefi 2019-01-03 20:14:23 -05:00
parent e5695c36ee
commit 2b8f586276
6 changed files with 25 additions and 19 deletions

View File

@ -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

10
unit_tests/gtest-all.cpp Normal file
View File

@ -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"

View File

@ -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, ...) {

View File

@ -8,6 +8,4 @@
#ifndef TEST_C125_H_
#define TEST_C125_H_
void testCJ125();
#endif /* TEST_C125_H_ */

View File

@ -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);
}

View File

@ -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();