Skip to content

Commit

Permalink
googletest
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jan 4, 2019
1 parent e5695c3 commit 2b8f586
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
4 changes: 4 additions & 0 deletions unit_tests/Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ CSRC = $(UTILSRC) \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting. # setting.
CPPSRC = $(UTILSRC_CPP) \ CPPSRC = $(UTILSRC_CPP) \
gtest-all.cpp \
$(CONTROLLERS_ALGO_SRC_CPP) \ $(CONTROLLERS_ALGO_SRC_CPP) \
$(TRIGGER_DECODERS_SRC_CPP) \ $(TRIGGER_DECODERS_SRC_CPP) \
$(ENGINES_SRC_CPP) \ $(ENGINES_SRC_CPP) \
Expand All @@ -124,6 +125,7 @@ CPPSRC = $(UTILSRC_CPP) \
$(TRIGGER_SRC_CPP) \ $(TRIGGER_SRC_CPP) \
main.cpp main.cpp



# C sources to be compiled in ARM mode regardless of the global setting. # C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size. # option that results in lower performance and larger code size.
Expand Down Expand Up @@ -168,6 +170,8 @@ INCDIR = . \
$(PROJECT_DIR)/hw_layer/algo \ $(PROJECT_DIR)/hw_layer/algo \
$(PROJECT_DIR)/hw_layer/sensors/ \ $(PROJECT_DIR)/hw_layer/sensors/ \
test_data_structures \ test_data_structures \
googletest/googletest \
googletest/googletest/include \
test_basic_math test_basic_math




Expand Down
10 changes: 10 additions & 0 deletions unit_tests/gtest-all.cpp
Original file line number Original file line Diff line number Diff line change
@@ -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"
9 changes: 5 additions & 4 deletions unit_tests/main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "engine_configuration.h" #include "engine_configuration.h"


#include "test_idle_controller.h" #include "test_idle_controller.h"
#include "test_c125.h"
#include "afm2mapConverter.h" #include "afm2mapConverter.h"
#include "test_signal_executor.h" #include "test_signal_executor.h"
#include "trigger_central.h" #include "trigger_central.h"
Expand All @@ -34,6 +33,7 @@
#include "engine_math.h" #include "engine_math.h"
#include "test_engine_math.h" #include "test_engine_math.h"
#include "test_trigger_decoder.h" #include "test_trigger_decoder.h"
#include "gtest/gtest.h"


typedef int32_t msg_t; typedef int32_t msg_t;


Expand All @@ -59,7 +59,7 @@ int getRevolutionCounter(void) {
} }
extern bool printTriggerDebug; extern bool printTriggerDebug;


int main(void) { GTEST_API_ int main(int argc, char **argv) {
// printTriggerDebug = true; // printTriggerDebug = true;


testMisc(); testMisc();
Expand Down Expand Up @@ -125,13 +125,14 @@ int main(void) {


testTriggerDecoder(); testTriggerDecoder();


testCJ125();


// resizeMap(); // resizeMap();
printf("Success 20190103\r\n"); printf("Success 20190103\r\n");
printAllTriggers(); printAllTriggers();
// printConvertedTable(); // printConvertedTable();
return EXIT_SUCCESS; testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} }


void print(const char *format, ...) { void print(const char *format, ...) {
Expand Down
2 changes: 0 additions & 2 deletions unit_tests/test_c125.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
#ifndef TEST_C125_H_ #ifndef TEST_C125_H_
#define TEST_C125_H_ #define TEST_C125_H_


void testCJ125();

#endif /* TEST_C125_H_ */ #endif /* TEST_C125_H_ */
9 changes: 3 additions & 6 deletions unit_tests/test_cj125.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
* @author Andrey Belomutskiy, (c) 2012-2019 * @author Andrey Belomutskiy, (c) 2012-2019
*/ */



#include "test_c125.h" #include "test_c125.h"
#include "CJ125.h" #include "gtest/gtest.h"

void testCJ125() {
printf("====================================================================================== testCJ125\r\n");


TEST(testCJ125, todo) {
EXPECT_EQ(1, 2 - 1);
} }





10 changes: 3 additions & 7 deletions unit_tests/test_pid_auto.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "pid_auto_tune.h" #include "pid_auto_tune.h"
#include "unit_test_framework.h" #include "unit_test_framework.h"
#include "cyclic_buffer.h" #include "cyclic_buffer.h"
#include "gtest/gtest.h"


efitimems_t mockTimeMs = 0; efitimems_t mockTimeMs = 0;


Expand Down Expand Up @@ -159,9 +160,7 @@ static void testPidAutoZigZagGrowingOsc() {


} }


static void testPidZeroLine() { TEST(pidAutoTune, zeroLine) {
printf("*************************************************** testPidAutoZigZagGrowingOsc\r\n");

mockTimeMs = 0; mockTimeMs = 0;


PID_AutoTune at; PID_AutoTune at;
Expand All @@ -182,8 +181,7 @@ static void testPidZeroLine() {
// nothing happens in this test since we do not allow time play a role // nothing happens in this test since we do not allow time play a role
} }


static void testPidDelayLine(void) { TEST(pidAutoTune, delayLine) {
printf("*************************************************** testPidDelayLine\r\n");


static const int delayBufSize = 8; static const int delayBufSize = 8;


Expand Down Expand Up @@ -220,8 +218,6 @@ static void testPidDelayLine(void) {
void testPidAuto() { void testPidAuto() {
printf("*************************************************** testPidAuto\r\n"); printf("*************************************************** testPidAuto\r\n");


testPidDelayLine();
testPidZeroLine();
testPidAutoZigZagStable(); testPidAutoZigZagStable();


testPidAutoZigZagGrowingOsc(); testPidAutoZigZagGrowingOsc();
Expand Down

0 comments on commit 2b8f586

Please sign in to comment.