Use Valgrind to detect unitialized variable references. (#3555)
* Use Valgrind to detect unitialized variable references. Fix the edge cases that pop up * Comment and disable Mac run
This commit is contained in:
parent
5d65c70a62
commit
c354d30a71
|
@ -24,9 +24,7 @@ jobs:
|
|||
if: ${{ matrix.os != 'macos-latest' }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install mtools
|
||||
sudo apt-get install zip
|
||||
sudo apt-get install dosfstools
|
||||
sudo apt-get install mtools zip dosfstools sshpass lcov valgrind
|
||||
|
||||
- name: Install required software (macos)
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
|
@ -53,15 +51,11 @@ jobs:
|
|||
- name: Build Tests
|
||||
working-directory: ./unit_tests/
|
||||
run: make -j4 COVERAGE=yes
|
||||
|
||||
|
||||
- name: Run Tests
|
||||
working-directory: ./unit_tests/
|
||||
run: ASAN_OPTIONS=detect_stack_use_after_return=1 build/rusefi_test
|
||||
|
||||
- name: Install Coverage Tools
|
||||
if: ${{ matrix.os != 'macos-latest' }}
|
||||
run: sudo apt-get install sshpass lcov
|
||||
|
||||
- name: Generate Code Coverage
|
||||
if: ${{ matrix.os != 'macos-latest' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||
working-directory: ./unit_tests/
|
||||
|
@ -70,3 +64,16 @@ jobs:
|
|||
- name: Run Tests (sharded)
|
||||
working-directory: ./unit_tests/
|
||||
run: bash ./run_sharded_tests.sh
|
||||
|
||||
- name: Rebuild Tests For Valgrind
|
||||
# Valgrind isn't compatible with address sanitizer, so we have to rebuild the code
|
||||
if: ${{ matrix.os != 'macos-latest' }}
|
||||
working-directory: ./unit_tests/
|
||||
run: |
|
||||
make clean
|
||||
make -j4 SANITIZE=no
|
||||
|
||||
- name: Run Tests (Valgrind)
|
||||
if: ${{ matrix.os != 'macos-latest' }}
|
||||
working-directory: ./unit_tests/
|
||||
run: valgrind --error-exitcode=1 --leak-check=no build/rusefi_test
|
||||
|
|
|
@ -130,6 +130,9 @@ void setManualIdleValvePosition(int positionPercent) {
|
|||
#endif /* EFI_UNIT_TEST */
|
||||
|
||||
void IdleController::init(pid_s* idlePidConfig) {
|
||||
engine->idle.shouldResetPid = false;
|
||||
engine->idle.mightResetPid = false;
|
||||
engine->idle.wasResetPid = false;
|
||||
m_timingPid.initPidClass(idlePidConfig);
|
||||
}
|
||||
|
||||
|
|
|
@ -339,6 +339,7 @@ void NamedOutputPin::setLow() {
|
|||
}
|
||||
|
||||
InjectorOutputPin::InjectorOutputPin() : NamedOutputPin() {
|
||||
overlappingCounter = 1; // Force update in reset
|
||||
reset();
|
||||
injectorIndex = -1;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ private:
|
|||
FILE *fp;
|
||||
char buffer[255];
|
||||
|
||||
bool currentState[2];
|
||||
bool currentVvtState[CAM_INPUTS_COUNT];
|
||||
bool currentState[2] = {0, 0};
|
||||
bool currentVvtState[CAM_INPUTS_COUNT] = {0, 0};
|
||||
|
||||
int m_lineIndex = -1;
|
||||
|
||||
|
|
|
@ -87,8 +87,9 @@ TEST(misc, testFuelMap) {
|
|||
}
|
||||
|
||||
|
||||
static void confgiureFordAspireTriggerWaveform(TriggerWaveform * s) {
|
||||
static void configureFordAspireTriggerWaveform(TriggerWaveform * s) {
|
||||
s->initialize(FOUR_STROKE_CAM_SENSOR);
|
||||
s->useOnlyRisingEdgeForTriggerTemp = false;
|
||||
|
||||
s->addEvent720(53.747, T_SECONDARY, TV_RISE);
|
||||
s->addEvent720(121.90, T_SECONDARY, TV_FALL);
|
||||
|
@ -182,7 +183,7 @@ TEST(misc, testAngleResolver) {
|
|||
ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
TriggerWaveform t;
|
||||
confgiureFordAspireTriggerWaveform(&t);
|
||||
configureFordAspireTriggerWaveform(&t);
|
||||
}
|
||||
|
||||
TEST(misc, testPinHelper) {
|
||||
|
|
|
@ -465,6 +465,7 @@ TEST(misc, testTriggerDecoder) {
|
|||
EXPAND_Engine;
|
||||
TriggerWaveform * s = &e.triggerCentral.triggerShape;
|
||||
|
||||
s->useOnlyRisingEdgeForTriggerTemp = false;
|
||||
initializeSkippedToothTriggerWaveformExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR);
|
||||
assertEqualsM("shape size", s->getSize(), 4);
|
||||
ASSERT_EQ(s->wave->getSwitchTime(0), 0.25);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
TEST(trigger, miataNA) {
|
||||
TriggerWaveform naShape;
|
||||
naShape.useOnlyRisingEdgeForTriggerTemp = false;
|
||||
initializeMazdaMiataNaShape(&naShape);
|
||||
|
||||
WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_MAP);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
UNIT_TESTS_DIR=$(PROJECT_DIR)/../unit_tests
|
||||
|
||||
CPPSRC += gtest-all.cpp \
|
||||
gmock-all.cpp \
|
||||
gmock-all.cpp \
|
||||
|
||||
|
||||
INCDIR += $(UNIT_TESTS_DIR)/googletest/googlemock/include \
|
||||
$(UNIT_TESTS_DIR)/googletest/googletest \
|
||||
$(UNIT_TESTS_DIR)/googletest/googletest/include \
|
||||
$(UNIT_TESTS_DIR)/googletest/googletest \
|
||||
$(UNIT_TESTS_DIR)/googletest/googletest/include \
|
||||
|
||||
PCH_DIR = ../firmware/pch
|
||||
PCHSRC = $(PCH_DIR)/pch.h
|
||||
|
@ -14,6 +14,13 @@ PCHSUB = unit_tests
|
|||
|
||||
include $(PROJECT_DIR)/rusefi_rules.mk
|
||||
|
||||
ifneq ($(OS),Windows_NT)
|
||||
SANITIZE = yes
|
||||
else
|
||||
SANITIZE = no
|
||||
endif
|
||||
|
||||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
# -O2 is needed for mingw, without it there is a linking issue to isnanf?!?!
|
||||
|
@ -35,7 +42,7 @@ endif
|
|||
USE_OPT += -DEFI_UNIT_TEST=1 -DEFI_PROD_CODE=0 -DEFI_SIMULATOR=0
|
||||
|
||||
# Enable address sanitizer, but not on Windows since x86_64-w64-mingw32-g++ doesn't support it.
|
||||
ifneq ($(OS),Windows_NT)
|
||||
ifeq ($(SANITIZE),yes)
|
||||
USE_OPT += -fsanitize=address
|
||||
endif
|
||||
|
||||
|
@ -189,7 +196,7 @@ ifeq ($(COVERAGE),yes)
|
|||
ULIBS += --coverage
|
||||
endif
|
||||
|
||||
ifneq ($(OS),Windows_NT)
|
||||
ifeq ($(SANITIZE),yes)
|
||||
ULIBS += -fsanitize=address
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue