diff --git a/.github/workflows/build-unit-tests.yaml b/.github/workflows/build-unit-tests.yaml index 1f97577b34..1ee7c93448 100644 --- a/.github/workflows/build-unit-tests.yaml +++ b/.github/workflows/build-unit-tests.yaml @@ -90,3 +90,7 @@ jobs: with: github_token: ${{ github.token }} branch: master + + - name: Run Tests (sharded) + working-directory: ./unit_tests/ + run: bash ./run_sharded_tests.sh diff --git a/unit_tests/run_sharded_tests.sh b/unit_tests/run_sharded_tests.sh new file mode 100644 index 0000000000..9e1aafb16a --- /dev/null +++ b/unit_tests/run_sharded_tests.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# This script runs every test in its own process (own invocation of rusefi_test executable) +# This allows us to test for accidental cross-test leakage that fixes/breaks something + +set -e + +export GTEST_TOTAL_SHARDS=500 +for IDX in {0..499} +do + export GTEST_SHARD_INDEX=$IDX + build/rusefi_test +done + +unset GTEST_TOTAL_SHARDS +unset GTEST_SHARD_INDEX diff --git a/unit_tests/tests/test_etb.cpp b/unit_tests/tests/test_etb.cpp index 2df9548735..7752a01637 100644 --- a/unit_tests/tests/test_etb.cpp +++ b/unit_tests/tests/test_etb.cpp @@ -447,6 +447,9 @@ TEST(etb, etbTpsSensor) { Sensor::setMockValue(SensorType::WastegatePosition, 33.0f); Sensor::setMockValue(SensorType::IdlePosition, 66.0f); + // Redundant accelerator pedal required for init + Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); + // Test first throttle { EtbController etb; @@ -479,6 +482,10 @@ TEST(etb, etbTpsSensor) { TEST(etb, setOutputInvalid) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + // Redundant TPS & accelerator pedal required for init + Sensor::setMockValue(SensorType::Tps1, 0, true); + Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); + StrictMock motor; EtbController etb; @@ -644,6 +651,10 @@ TEST(etb, closedLoopPid) { TEST(etb, openLoopThrottle) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + // Redundant TPS & accelerator pedal required for init + Sensor::setMockValue(SensorType::Tps1, 0, true); + Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); + EtbController etb; INJECT_ENGINE_REFERENCE(&etb); etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); @@ -662,6 +673,10 @@ TEST(etb, openLoopThrottle) { TEST(etb, openLoopNonThrottle) { WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + // Redundant TPS & accelerator pedal required for init + Sensor::setMockValue(SensorType::Tps1, 0, true); + Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); + EtbController etb; INJECT_ENGINE_REFERENCE(&etb); etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false);