reducing unit test noise

This commit is contained in:
rusefi 2019-08-25 02:01:09 -04:00
parent d338f4e9c9
commit 3ae955b3e5
6 changed files with 53 additions and 24 deletions

View File

@ -27,6 +27,10 @@
#include "efilib.h"
#include "efitime.h"
#if EFI_UNIT_TEST
extern bool verboseMode;
#endif /* EFI_UNIT_TEST */
// see https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method
// order must be match enumerated type for auto tune methods
Tuning tuningRule[PID_AutoTune::NO_OVERSHOOT_PID + 1] =
@ -113,6 +117,7 @@ void PID_AutoTune::setState(PidAutoTune_AutoTunerState state) {
this->state = state;
scheduleMsg(logger, "setState %s", getPidAutoTune_AutoTunerState(state));
#if EFI_UNIT_TEST
if (verboseMode)
printf("setState %s\r\n", getPidAutoTune_AutoTunerState(state));
#endif /* EFI_UNIT_TEST */
}
@ -121,6 +126,7 @@ void PID_AutoTune::setPeakType(PidAutoTune_Peak peakType) {
this->peakType = peakType;
scheduleMsg(logger, "setPeakType %s", getPidAutoTune_Peak(peakType));
#if EFI_UNIT_TEST
if (verboseMode)
printf("peakType %s\r\n", getPidAutoTune_Peak(peakType));
#endif /* EFI_UNIT_TEST */
}
@ -171,7 +177,8 @@ bool PID_AutoTune::Runtime(Logging *logger)
else if ((now - lastTime) < sampleTime)
{
#if EFI_UNIT_TEST
printf("too soon for new input %d %d %d\r\n", now, lastTime, sampleTime);
if (verboseMode)
printf("too soon for new input %d %d %d\r\n", now, lastTime, sampleTime);
#endif /* EFI_UNIT_TEST */
scheduleMsg(logger, "AT skipping now=%d %d %d", now, lastTime, sampleTime);
@ -225,7 +232,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
#endif /* AUTOTUNE_DEBUG */
#if EFI_UNIT_TEST
printf("asymmetry=%f\r\n", asymmetry);
if (verboseMode) {
printf("asymmetry=%f\r\n", asymmetry);
}
#endif /* EFI_UNIT_TEST */
if (asymmetry > AUTOTUNE_STEP_ASYMMETRY_TOLERANCE)
@ -273,7 +282,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
#endif /* AUTOTUNE_DEBUG */
#if EFI_UNIT_TEST
printf("deltaRelayBias=%f relayBias=%f\r\n", deltaRelayBias, relayBias);
if (verboseMode) {
printf("deltaRelayBias=%f relayBias=%f\r\n", deltaRelayBias, relayBias);
}
#endif /* EFI_UNIT_TEST */
// reset relay step counter
@ -348,7 +359,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
#endif
#if EFI_UNIT_TEST
printf("setpoint=%f refVal=%f\r\n", setpoint, refVal);
if (verboseMode) {
printf("setpoint=%f refVal=%f\r\n", setpoint, refVal);
}
#endif /* EFI_UNIT_TEST */
// store initial inputs
@ -360,7 +373,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
lastInputs[nLookBack - inputCount] = refVal;
scheduleMsg(logger, "AT need more data %d %d", inputCount, nLookBack);
#if EFI_UNIT_TEST
printf("need more data %d %d\r\n", inputCount, nLookBack);
if (verboseMode) {
printf("need more data %d %d\r\n", inputCount, nLookBack);
}
#endif /* EFI_UNIT_TEST */
return false;
}
@ -425,11 +440,10 @@ bool PID_AutoTune::Runtime(Logging *logger)
#if EFI_UNIT_TEST
printf("iMax=%f iMin=%f\r\n", iMax, iMin);
#endif /* EFI_UNIT_TEST */
#if EFI_UNIT_TEST
printf("avgInput=%f stable=%d\r\n", avgInput, stable);
if (verboseMode) {
printf("iMax=%f iMin=%f\r\n", iMax, iMin);
printf("avgInput=%f stable=%d\r\n", avgInput, stable);
}
#endif /* EFI_UNIT_TEST */
@ -447,7 +461,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
lastPeaks[0] = avgInput;
inputCount = 0;
#if EFI_UNIT_TEST
if (verboseMode) {
printf(":( 3\r\n");
}
#endif /* EFI_UNIT_TEST */
return false;
}
@ -461,7 +477,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
#endif
#if EFI_UNIT_TEST
printf("K_process=%f\r\n", K_process);
if (verboseMode) {
printf("K_process=%f\r\n", K_process);
}
#endif /* EFI_UNIT_TEST */
// bad estimate of process gain
@ -694,7 +712,9 @@ bool PID_AutoTune::Runtime(Logging *logger)
if (((byte) state & (CONVERGED | FAILED)) == 0)
{
#if EFI_UNIT_TEST
printf(":( 1 state=%s\r\n", getPidAutoTune_AutoTunerState(state));
if (verboseMode) {
printf(":( 1 state=%s\r\n", getPidAutoTune_AutoTunerState(state));
}
#endif /* EFI_UNIT_TEST */
return false;
}
@ -805,7 +825,9 @@ void PID_AutoTune::setOutput(float output) {
scheduleMsg(logger, "setOutput %f %s", output, getPidAutoTune_AutoTunerState(state));
#if EFI_UNIT_TEST
if (verboseMode) {
printf("output=%f\r\n", output);
}
#endif /* EFI_UNIT_TEST */
}

View File

@ -17,6 +17,10 @@
#include "efitime.h"
#include "os_util.h"
#if EFI_UNIT_TEST
extern bool verboseMode;
#endif /* EFI_UNIT_TEST */
uint32_t maxSchedulingPrecisionLoss = 0;
scheduling_s::scheduling_s() {
@ -49,8 +53,10 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitime_t timeX, schfunc_t
if (scheduling->isScheduled) {
#if EFI_UNIT_TEST
printf("Already scheduled was %d\r\n", (int)scheduling->momentX);
printf("Already scheduled now %d\r\n", (int)timeX);
if (verboseMode) {
printf("Already scheduled was %d\r\n", (int)scheduling->momentX);
printf("Already scheduled now %d\r\n", (int)timeX);
}
#endif /* EFI_UNIT_TEST */
return false;
}

View File

@ -18,6 +18,9 @@ extern TunerStudioOutputChannels tsOutputChannels;
#endif /* EFI_TUNER_STUDIO */
EXTERN_ENGINE;
#if EFI_UNIT_TEST
extern bool verboseMode;
#endif /* EFI_UNIT_TEST */
static cyclic_buffer<int> ignitionErrorDetection;
static Logging *logger;
@ -269,9 +272,11 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
TRIGGER_SHAPE(findTriggerPosition(&iEvent->sparkPosition, advance PASS_CONFIG_PARAM(engineConfiguration->globalTriggerAngleOffset)));
#if EFI_UNIT_TEST
printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.eventIndex, (int)iEvent->dwellPosition.angleOffset,
if (verboseMode) {
printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.eventIndex, (int)iEvent->dwellPosition.angleOffset,
iEvent->sparkPosition.eventIndex, (int)iEvent->sparkPosition.angleOffset,
iEvent->sparkId);
}
#endif
/**

View File

@ -15,11 +15,13 @@
#include "interpolation.h"
bool needInterpolationLoggingValue = true;
#if EFI_UNIT_TEST
bool needInterpolationLoggingValue = false;
int needInterpolationLogging(void) {
return needInterpolationLoggingValue;
}
#endif /* EFI_UNIT_TEST */
#define BINARY_PERF true

View File

@ -9,6 +9,7 @@
#include "global_execution_queue.h"
bool_t debugSignalExecutor = false;
extern bool verboseMode;
void TestExecutor::scheduleForLater(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
if (debugSignalExecutor) {

View File

@ -228,10 +228,8 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
}
static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty, float expectedGap) {
printTriggerDebug = true;
testTriggerDecoder2(msg, type, synchPointIndex, channel1duty, channel2duty);
assertEqualsM2("actual gap ratio", expectedGap, actualSynchGap, 0.001);
printTriggerDebug = false;
}
TEST(misc, testStartupFuelPumping) {
@ -320,7 +318,7 @@ TEST(misc, testRpmCalculator) {
eth.clearQueue();
debugSignalExecutor = true;
// debugSignalExecutor = true;
ASSERT_EQ(engine->triggerCentral.triggerState.shaft_is_synchronized, 1);
@ -536,8 +534,6 @@ TEST(misc, testTriggerDecoder) {
testTriggerDecoder3("neon NGC4", DODGE_NEON_2003_CAM, 6, 0.5000, 0.0, CHRYSLER_NGC4_GAP);
{
printTriggerDebug = true;
WITH_ENGINE_TEST_HELPER(DODGE_NEON_2003_CAM);
printf("!!!!!!!!!!!!!!!!!! Now trying with only rising edges !!!!!!!!!!!!!!!!!\r\n");
@ -545,13 +541,10 @@ TEST(misc, testTriggerDecoder) {
applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER_SUFFIX);
prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE);
printTriggerDebug = false;
}
testTriggerDecoder2("sachs", SACHS, 0, 0.4800, 0.000);
//printTriggerDebug = true;
testTriggerDecoder3("36+2+2+2", DAIHATSU, 28, 0.5000, 0.0, 0.5);
testTriggerDecoder3("stratus NGC6", DODGE_STRATUS, 0, 0.8833, 0.0, CHRYSLER_NGC6_GAP);