to prevent bugs like https://github.com/rusefi/rusefi/issues/6424#issuecomment-2294958949 now tests reuse real boost controller from test engine #6424
This commit is contained in:
parent
2dadfc6c79
commit
c51b945b54
|
@ -13,14 +13,12 @@ const BoostTestBase::ValueByIndexRetriever BoostTestBase::emptyValue = [](const
|
|||
void BoostTestBase::SetUp() {
|
||||
TestBase::SetUp();
|
||||
|
||||
bc = std::make_unique<BoostController>();
|
||||
initBoostControllerTables();
|
||||
initBoostCtrl();
|
||||
|
||||
Sensor::resetAllMocks();
|
||||
}
|
||||
|
||||
void BoostTestBase::TearDown() {
|
||||
bc.reset();
|
||||
TestBase::TearDown();
|
||||
}
|
||||
|
||||
|
@ -34,31 +32,10 @@ void BoostTestBase::initTestBoostCurve(
|
|||
initBoostCurveArray(testValues, dstValues);
|
||||
}
|
||||
|
||||
BoostController& BoostTestBase::getBoostController() const {
|
||||
return engine->module<BoostController>().unmock();
|
||||
}
|
||||
|
||||
void BoostTestBase::initBoostCurveArray(const float (&src)[BOOST_CURVE_SIZE], float (&dst)[BOOST_CURVE_SIZE]) {
|
||||
std::copy(std::begin(src), std::end(src), std::begin(dst));
|
||||
}
|
||||
|
||||
void BoostTestBase::initBoostControllerTables() {
|
||||
// The code below is very similar to code in file boost_control.cpp
|
||||
// TODO: think how we can get rid of duplicated code
|
||||
|
||||
// Set up open & closed loop tables
|
||||
boostMapOpen.initTable(config->boostTableOpenLoop, config->boostRpmBins, config->boostTpsBins);
|
||||
boostMapClosed.initTable(config->boostTableClosedLoop, config->boostRpmBins, config->boostTpsBins);
|
||||
boostCltCorr.initTable(config->cltBoostCorr, config->cltBoostCorrBins);
|
||||
boostIatCorr.initTable(config->iatBoostCorr, config->iatBoostCorrBins);
|
||||
boostCltAdder.initTable(config->cltBoostAdder, config->cltBoostAdderBins);
|
||||
boostIatAdder.initTable(config->iatBoostAdder, config->iatBoostAdderBins);
|
||||
|
||||
// Set up boost controller instance
|
||||
bc->init(
|
||||
&boostPwmControl,
|
||||
&boostMapOpen,
|
||||
&boostMapClosed,
|
||||
boostCltCorr,
|
||||
boostIatCorr,
|
||||
boostCltAdder,
|
||||
boostIatAdder,
|
||||
&engineConfiguration->boostPid
|
||||
);
|
||||
}
|
|
@ -22,10 +22,9 @@ protected:
|
|||
float (&dstValues)[BOOST_CURVE_SIZE]
|
||||
);
|
||||
|
||||
std::unique_ptr<BoostController> bc;
|
||||
BoostController& getBoostController() const;
|
||||
private:
|
||||
void initBoostCurveArray(const float (&src)[BOOST_CURVE_SIZE], float (&dst)[BOOST_CURVE_SIZE]);
|
||||
void initBoostControllerTables();
|
||||
|
||||
Map3D<BOOST_RPM_COUNT, BOOST_LOAD_COUNT, uint8_t, uint8_t, uint8_t> boostMapOpen{ "bo" };
|
||||
Map3D<BOOST_RPM_COUNT, BOOST_LOAD_COUNT, uint8_t, uint8_t, uint8_t> boostMapClosed{ "bc" };
|
||||
|
|
|
@ -65,8 +65,8 @@ namespace {
|
|||
}
|
||||
|
||||
void ClosedLoopAddersTest::initLuaTargetCorrections(const float luaTargetMult, const int luaTargetAdd) {
|
||||
bc->luaTargetMult = luaTargetMult;
|
||||
bc->luaTargetAdd = luaTargetAdd;
|
||||
getBoostController().luaTargetMult = luaTargetMult;
|
||||
getBoostController().luaTargetAdd = luaTargetAdd;
|
||||
}
|
||||
|
||||
std::optional<float> ClosedLoopAddersTest::getTestCltBoostBin(const int index) {
|
||||
|
@ -102,7 +102,7 @@ namespace {
|
|||
if (iat.has_value()) {
|
||||
Sensor::setMockValue(SensorType::Iat, iat.value());
|
||||
}
|
||||
const expected<percent_t> setPoint = bc->getSetpoint();
|
||||
const expected<percent_t> setPoint = getBoostController().getSetpoint();
|
||||
EXPECT_TRUE(setPoint.Valid) << "clt: " << clt.value_or(-1) << ", iat: " << iat.value_or(-1) ;
|
||||
ASSERT_NEAR(setPoint.Value, expectedSetPoint, EPS5D)
|
||||
<< "clt: " << clt.value_or(-1) << ", iat: " << iat.value_or(-1) ;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace {
|
|||
}
|
||||
|
||||
void OpenLoopMultipliersTest::initLuaOpenLoopAdd(const float value) {
|
||||
bc->luaOpenLoopAdd = value;
|
||||
getBoostController().luaOpenLoopAdd = value;
|
||||
}
|
||||
|
||||
std::optional<float> OpenLoopMultipliersTest::getTestCltBoostBin(const int index) {
|
||||
|
@ -85,7 +85,7 @@ namespace {
|
|||
if (iat.has_value()) {
|
||||
Sensor::setMockValue(SensorType::Iat, iat.value());
|
||||
}
|
||||
const expected<percent_t> openLoop = bc->getOpenLoop(0.0f);
|
||||
const expected<percent_t> openLoop = getBoostController().getOpenLoop(0.0f);
|
||||
EXPECT_TRUE(openLoop.Valid) << "clt: " << clt.value_or(-1) << ", iat: " << iat.value_or(-1) ;
|
||||
EXPECT_EQ(openLoop.Value, expectedOpenLoop) << "clt: " << clt.value_or(-1) << ", iat: " << iat.value_or(-1) ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue