migrating to googletest

This commit is contained in:
rusefi 2019-01-14 15:31:56 -05:00
parent eec142390a
commit 73aa22573e
24 changed files with 37 additions and 211 deletions

View File

@ -9,25 +9,17 @@
#include <stdlib.h>
#include "global.h"
#include "test_accel_enrichment.h"
#include "test_interpolation_3d.h"
#include "test_find_index.h"
#include "test_speed_density.h"
#include "test_fuel_map.h"
#include "fuel_math.h"
#include "test_logic_expression.h"
#include "test_pid_auto.h"
#include "engine_configuration.h"
#include "test_idle_controller.h"
#include "afm2mapConverter.h"
#include "test_signal_executor.h"
#include "trigger_central.h"
#include "test_util.h"
#include "map_resize.h"
#include "engine_math.h"
#include "test_engine_math.h"
#include "test_trigger_decoder.h"
#include "gtest/gtest.h"
@ -58,51 +50,6 @@ extern bool printTriggerDebug;
GTEST_API_ int main(int argc, char **argv) {
// printTriggerDebug = true;
testMisc();
/**
* PID
*/
testPidAuto();
testLogicExpressions(); // fsio
testGpsParser();
testFuelMap();
testEngineMath();
testIgnitionPlanning();
/**
* Data structures and general methods
*/
testFindIndex();
testInterpolate3d();
testInterpolate2d();
testSetTableValue();
testFLStack();
testSignalExecutor();
testPwmGenerator();
/**
* Business logic tests
*/
testMalfunctionCentral();
testConsoleLogic();
testAngleResolver();
testPinHelper();
testMenuTree();
testMafLookup();
testIgnitionMapGenerator();
testMafFuelMath();
testTriggerDecoder();
// resizeMap();
printf("Success 20190103\r\n");
printAllTriggers();

View File

@ -15,7 +15,7 @@ static void testIndex(const int expected, const float array[], int size, float v
assertEquals(expected, findIndex2(array, size, value));
}
void testFindIndex(void) {
TEST(misc, testFindIndex) {
printf("*************************************************** testFindIndex\r\n");
/*
{
@ -66,7 +66,7 @@ void testFindIndex(void) {
}
}
void testInterpolate2d(void) {
TEST(misc, testInterpolate2d) {
printf("*************************************************** testInterpolate2d\r\n");
float bins4[] = { 1, 2, 3, 4 };
@ -92,7 +92,7 @@ void testInterpolate2d(void) {
assertEquals(215, result);
}
void testSetTableValue(void) {
TEST(misc, testSetTableValue) {
printf("*************************************************** testSetTableValue\r\n");
persistent_config_s config;

View File

@ -9,7 +9,5 @@
#define TEST_FIND_INDEX_H_
void testFindIndex(void);
void testInterpolate2d(void);
void testSetTableValue(void);
#endif /* TEST_FIND_INDEX_H_ */

View File

@ -79,7 +79,7 @@ static void newTestToComfirmInterpolation() {
assertEqualsM("320 @ -12.3 ", 3.2, getValue(/*rpm*/320, -12.3));
}
void testInterpolate3d(void) {
TEST(misc, testInterpolate3d) {
printf("*************************************************** testInterpolate3d\r\n");
printf("*** no interpolation here 1\r\n");

View File

@ -11,6 +11,5 @@
#ifndef TEST_INTERPOLATION_3D_H_
#define TEST_INTERPOLATION_3D_H_
void testInterpolate3d(void);
#endif /* TEST_INTERPOLATION_3D_H_ */

View File

@ -1,12 +0,0 @@
/**
* @file test_accel_enrichment.h
*
* Created on: apr 29, 2014
* Author: Dmitry Sidin
* Author: Andrey Belomutskiy, (c) 2012-2015
*/
#ifndef TEST_ACCEL_ENRICHMENT_H_
#define TEST_ACCEL_ENRICHMENT_H_
#endif /* TEST_ACCEL_ENRICHMENT_H_ */

View File

@ -5,7 +5,6 @@
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "test_engine_math.h"
#include "global.h"
#include "engine_math.h"
#include "engine_configuration.h"
@ -15,7 +14,7 @@
#include "maf.h"
#include "advance_map.h"
void testIgnitionPlanning(void) {
TEST(misc, testIgnitionPlanning) {
printf("*************************************************** testIgnitionPlanning\r\n");
EngineTestHelper eth(FORD_ESCORT_GT);
EXPAND_EngineTestHelper;
@ -26,7 +25,7 @@ void testIgnitionPlanning(void) {
assertEquals(IM_BATCH, engineConfiguration->injectionMode);
}
void testEngineMath(void) {
TEST(misc, testEngineMath) {
printf("*************************************************** testEngineMath\r\n");
EngineTestHelper eth(FORD_ESCORT_GT);
@ -59,7 +58,7 @@ void testEngineMath(void) {
assertEquals(65.5625f/*kg/h*/, engine->engineState.airFlow);
}
void testIgnitionMapGenerator(void) {
TEST(misc, testIgnitionMapGenerator) {
printf("*************************************************** testIgnitionMapGenerator\r\n");
assertEquals(35, getTopAdvanceForBore(CS_OPEN, 98, 8, 101.6));
@ -86,7 +85,7 @@ void testIgnitionMapGenerator(void) {
assertEqualsM2("20@800", 14.2, getInitialAdvance(800, 20, 36), 0.2);
}
void testMafLookup(void) {
TEST(misc, testMafLookup) {
printf("*************************************************** testMafLookup\r\n");
EngineTestHelper eth(FORD_ESCORT_GT);

View File

@ -1,16 +0,0 @@
/*
* @file test_engine_math.h
*
* Created on: Nov 14, 2013
* Author: Andrey Belomutskiy, (c) 2012-2015
*/
#ifndef TEST_ENGINE_MATH_H_
#define TEST_ENGINE_MATH_H_
void testEngineMath(void);
void testIgnitionPlanning(void);
void testMafLookup(void);
void testIgnitionMapGenerator(void);
#endif /* TEST_ENGINE_MATH_H_ */

View File

@ -32,7 +32,7 @@ TEST(sensors, testFasterEngineSpinningUp) {
// check RPM
assertEqualsM("RPM=0", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
// the queue should be empty, no trigger events yet
assertEqualsM("plain#1", 0, engine->executor.size());
ASSERT_EQ(0, engine->executor.size()) << "plain#1";
// check all events starting from now
int timeStartUs = eth.getTimeNowUs();
@ -41,15 +41,15 @@ TEST(sensors, testFasterEngineSpinningUp) {
eth.fireRise(200);
// check if the mode is changed
assertEquals(SPINNING_UP, engine->rpmCalculator.getState());
ASSERT_EQ(SPINNING_UP, engine->rpmCalculator.getState());
// due to isFasterEngineSpinUp=true, we should have already detected RPM!
assertEqualsM("spinning-RPM#1", 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
// two simultaneous injections
assertEqualsM("plain#1", 4, engine->executor.size());
ASSERT_EQ(4, engine->executor.size()) << "plain#2";
// test if they are simultaneous
assertEquals(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// test if ignition mode is temporary changed to wasted spark, if set to ind.coils
assertEquals(IM_WASTED_SPARK, getIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
ASSERT_EQ(IM_WASTED_SPARK, getIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// check real events
eth.assertEvent5(&engine->executor, "inj start#1", 0, (void*)startSimultaniousInjection, timeStartUs, MS2US(200) + 97975);
eth.assertEvent5(&engine->executor, "inj end#1", 1, (void*)endSimultaniousInjection, timeStartUs, MS2US(200) + 100000);
@ -63,13 +63,13 @@ TEST(sensors, testFasterEngineSpinningUp) {
eth.fireRise(200);
// check if the mode is changed when fully synched
assertEquals(CRANKING, engine->rpmCalculator.getState());
ASSERT_EQ(CRANKING, engine->rpmCalculator.getState());
// check RPM
assertEqualsM("RPM#2", 300, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
// test if they are simultaneous in cranking mode too
assertEquals(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
ASSERT_EQ(IM_SIMULTANEOUS, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// test if ignition mode is restored to ind.coils
assertEquals(IM_INDIVIDUAL_COILS, getIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
ASSERT_EQ(IM_INDIVIDUAL_COILS, getIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// two simultaneous injections
assertEqualsM("plain#2", 4, engine->executor.size());
// check real events

View File

@ -5,7 +5,6 @@
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "test_fuel_map.h"
#include "global.h"
#include "engine_configuration.h"
#include "fuel_math.h"
@ -19,7 +18,7 @@
extern float testMafValue;
void testMafFuelMath(void) {
TEST(misc, testMafFuelMath) {
printf("====================================================================================== testMafFuelMath\r\n");
EngineTestHelper eth(FORD_ASPIRE_1996);
EXPAND_EngineTestHelper;
@ -33,7 +32,7 @@ void testMafFuelMath(void) {
assertEqualsM("fuelMs", 26.7099, fuelMs);
}
void testFuelMap(void) {
TEST(misc, testFuelMap) {
printf("====================================================================================== testFuelMap\r\n");
printf("Setting up FORD_ASPIRE_1996\r\n");
@ -161,7 +160,7 @@ static void confgiureFordAspireTriggerShape(TriggerShape * s) {
assertEqualsM("expecting 1", 1, s->wave.findInsertionAngle(63.747 / 720.0, s->getSize()));
}
void testAngleResolver(void) {
TEST(misc, testAngleResolver) {
printf("*************************************************** testAngleResolver\r\n");
EngineTestHelper eth(FORD_ASPIRE_1996);
@ -217,7 +216,7 @@ void testAngleResolver(void) {
confgiureFordAspireTriggerShape(&t);
}
void testPinHelper(void) {
TEST(misc, testPinHelper) {
printf("*************************************************** testPinHelper\r\n");
assertEquals(0, getElectricalValue(0, OM_DEFAULT));
assertEquals(1, getElectricalValue(1, OM_DEFAULT));

View File

@ -1,16 +0,0 @@
/*
* test_fuel_map.h
*
* Created on: Nov 6, 2013
* Author: pc
*/
#ifndef TEST_FUEL_MAP_H_
#define TEST_FUEL_MAP_H_
void testFuelMap(void);
void testMafFuelMath(void);
void testAngleResolver(void);
void testPinHelper(void);
#endif /* TEST_FUEL_MAP_H_ */

View File

@ -8,7 +8,6 @@
*/
#include "global.h"
#include "test_logic_expression.h"
#include "fsio_impl.h"
#include "cli_registry.h"
#include "engine_test_helper.h"
@ -106,7 +105,7 @@ static void testExpression(const char *line, float expected) {
testExpression2(0, line, expected);
}
void testLogicExpressions(void) {
TEST(misc, testLogicExpressions) {
printf("*************************************************** testLogicExpressions\r\n");
testParsing();

View File

@ -1,13 +0,0 @@
/**
* @file test_logic_expression.h
*
* @date Oct 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef TEST_LOGIC_EXPRESSION_H_
#define TEST_LOGIC_EXPRESSION_H_
void testLogicExpressions(void);
#endif /* TEST_LOGIC_EXPRESSION_H_ */

View File

@ -6,7 +6,6 @@
*/
#include "global.h"
#include "test_pid_auto.h"
#include "pid_auto_tune.h"
#include "unit_test_framework.h"
#include "cyclic_buffer.h"
@ -214,7 +213,7 @@ TEST(pidAutoTune, delayLine) {
assertTrueM("should be true#5", result);
}
void testPidAuto() {
TEST(misc, testPidAuto) {
printf("*************************************************** testPidAuto\r\n");
testPidAutoZigZagStable();

View File

@ -1,13 +0,0 @@
/*
* @file test_pid_auto.h
*
* Created on: Sep 14, 2017
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef TEST_PID_AUTO_H_
#define TEST_PID_AUTO_H_
void testPidAuto();
#endif /* TEST_PID_AUTO_H_ */

View File

@ -101,7 +101,7 @@ static void testSwitchToNanPeriod() {
assertNextEvent("exec3@NAN", LOW_VALUE, &executor);
}
void testPwmGenerator() {
TEST(misc, testPwmGenerator) {
test100dutyCycle();
testSwitchToNanPeriod();

View File

@ -44,7 +44,7 @@ TEST(sensors, tps) {
assertEqualsM("test#2", 50.6667, getTpsValue(4 * 117 PASS_ENGINE_PARAMETER_SUFFIX));
}
void testTpsRateOfChange(void) {
TEST(sensors, testTpsRateOfChange) {
print("************************************************** testTpsRateOfChange\r\n");
// saveTpsState(0, 0);
// saveTpsState(CH_FREQUENCY, 50);

View File

@ -91,7 +91,7 @@ static void testSignalExecutor3(void) {
eq.executeAll(100);
}
void testSignalExecutor(void) {
TEST(misc, testSignalExecutor) {
testSignalExecutor3();
print("*************************************** testSignalExecutor\r\n");

View File

@ -9,7 +9,5 @@
#define TEST_SIGNAL_EXECUTOR_H_
int getRevolutionCounter();
void testSignalExecutor(void);
void testPwmGenerator();
#endif /* TEST_SIGNAL_EXECUTOR_H_ */

View File

@ -1,11 +0,0 @@
/**
* @file test_speed_density.h
*
* @date Jun 26, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#ifndef TEST_SPEED_DENSITY_H_
#define TEST_SPEED_DENSITY_H_
#endif /* TEST_SPEED_DENSITY_H_ */

View File

@ -112,7 +112,7 @@ static void assertTriggerPosition(event_trigger_position_s *position, int eventI
assertEqualsM("angleOffset", angleOffset, position->angleOffset);
}
void testSomethingWeird(void) {
TEST(misc, testSomethingWeird) {
printf("*************************************************** testSomethingWeird\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995);
@ -149,8 +149,7 @@ void testSomethingWeird(void) {
assertEquals(0, sta->getCurrentIndex()); // new revolution
}
void test1995FordInline6TriggerDecoder(void) {
testSomethingWeird();
TEST(misc, test1995FordInline6TriggerDecoder) {
printf("*************************************************** test1995FordInline6TriggerDecoder\r\n");
@ -194,7 +193,7 @@ void test1995FordInline6TriggerDecoder(void) {
assertEqualsM("running dwell", 0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX));
}
void testFordAspire(void) {
TEST(misc, testFordAspire) {
printf("*************************************************** testFordAspire\r\n");
assertEqualsM("getTriggerZeroEventIndex", 4, getTriggerZeroEventIndex(FORD_ASPIRE_1996));
@ -242,7 +241,7 @@ static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPo
printTriggerDebug = false;
}
void testStartupFuelPumping(void) {
TEST(misc, testStartupFuelPumping) {
printf("*************************************************** testStartupFuelPumping\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
@ -294,7 +293,7 @@ static void assertREqualsM(const char *msg, void *expected, void *actual) {
extern bool_t debugSignalExecutor;
extern EnginePins enginePins;
void testRpmCalculator(void) {
TEST(misc, testRpmCalculator) {
printf("*************************************************** testRpmCalculator\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995);
@ -445,7 +444,7 @@ void testRpmCalculator(void) {
engine->executor.clear();
}
void testTriggerDecoder(void) {
TEST(misc, testTriggerDecoder) {
printf("====================================================================================== testTriggerDecoder\r\n");
persistent_config_s c;
@ -470,7 +469,6 @@ void testTriggerDecoder(void) {
testDodgeNeonDecoder();
testTriggerDecoder2("Dodge Neon 1995", DODGE_NEON_1995, 8, 0.4931, 0.2070);
testFordAspire();
testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.0000, 0.5);
testTriggerDecoder2("dodge ram", DODGE_RAM, 16, 0.5000, 0.06);
@ -478,7 +476,6 @@ void testTriggerDecoder(void) {
//testTriggerDecoder2("bmw", BMW_E34, 0, 0.9750, 0.5167);
testTriggerDecoder2("bmw", BMW_E34, 0, 0.4667, 0.0);
test1995FordInline6TriggerDecoder();
testTriggerDecoder2("Miata NB", MAZDA_MIATA_NB1, 12, 0.0833, 0.0444);
testTriggerDecoder2("Miata 2003", MAZDA_MIATA_2003, 3, 0.0444, 0.0);
@ -574,10 +571,6 @@ void testTriggerDecoder(void) {
testTriggerDecoder3("stratus NGC6", DODGE_STRATUS, 0, 0.8833, 0.0, CHRYSLER_NGC6_GAP);
testTriggerDecoder2("vw ABA", VW_ABA, 114, 0.5000, 0.0);
testStartupFuelPumping();
testRpmCalculator();
}
extern fuel_Map3D_t fuelMap;

View File

@ -10,10 +10,6 @@
#include "engine_test_helper.h"
void testTriggerDecoder(void);
void testRpmCalculator(void);
void testStartupFuelPumping(void);
void test1995FordInline6TriggerDecoder(void);
void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty);
void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injMode = IM_BATCH);

View File

@ -7,7 +7,6 @@
#include <string.h>
#include "test_util.h"
#include "cyclic_buffer.h"
#include "global.h"
#include "histogram.h"
@ -184,7 +183,7 @@ static void testMalfunctionCentralRemoveFirstElement() {
assertEquals(secondElement, localCopy.error_codes[0]);
}
void testMalfunctionCentral(void) {
TEST(misc, testMalfunctionCentral) {
testMalfunctionCentralRemoveNonExistent();
testMalfunctionCentralSameElementAgain();
testMalfunctionCentralRemoveFirstElement();
@ -255,7 +254,7 @@ static loc_t GPSdata;
static char nmeaMessage[1000];
void testGpsParser(void) {
TEST(misc, testGpsParser) {
print("******************************************* testGpsParser\r\n");
strcpy(nmeaMessage, "");
@ -309,7 +308,7 @@ void testGpsParser(void) {
// this buffer is needed because on Unix you would not be able to change static char constants
static char buffer[300];
void testConsoleLogic(void) {
TEST(misc, testConsoleLogic) {
print("******************************************* testConsoleLogic\r\n");
resetConsoleActions();
@ -377,7 +376,7 @@ void testConsoleLogic(void) {
//addConsoleActionSSS("GPS", testGpsParser);
}
void testFLStack(void) {
TEST(misc, testFLStack) {
print("******************************************* testFLStack\r\n");
FLStack<int, 4> stack;
@ -409,7 +408,7 @@ void testFLStack(void) {
static char buff[32];
void testMisc(void) {
TEST(misc, testMisc) {
print("******************************************* testMisc\r\n");
strcpy(buff, " ab ");
// we need a mutable array here
@ -433,7 +432,7 @@ void testMisc(void) {
// assertEquals(SPARKOUT_12_OUTPUT, getPinByName("spa12"));
}
void testMenuTree(void) {
TEST(misc, testMenuTree) {
print("******************************************* testMenuTree\r\n");
MenuItem ROOT(NULL, NULL);

View File

@ -1,19 +0,0 @@
/**
* @file test_cyclic_buffer.h
*
* @date Dec 8, 2013
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef TEST_CYCLIC_BUFFER_H_
#define TEST_CYCLIC_BUFFER_H_
void testMisc(void);
void testMalfunctionCentral(void);
void testConsoleLogic(void);
void testGpsParser(void);
void testFLStack(void);
void testMisc(void);
void testMenuTree(void);
#endif /* TEST_CYCLIC_BUFFER_H_ */