Skip to content

Commit

Permalink
Remove valgrind and just rely on ASAN
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Sep 8, 2024
1 parent 2f95b08 commit 36607c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 38 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ RUN apt-get -y update && \
cmake \
gdb \
gdbserver \
valgrind \
wget \
unzip && \
git config --global --add safe.directory "*"
Expand Down
41 changes: 4 additions & 37 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ vpath %.c ../src

CC=gcc
SGDK?=/sgdk
VALGRIND=valgrind
VFLAGS=--leak-check=full --trace-children=yes --error-exitcode=1

ifeq ($(DEBUG),1)
GDB=gdbserver :2345
Expand Down Expand Up @@ -199,12 +197,13 @@ MD_MOCKS=SYS_setVIntCallback \
fix32Frac \
mw_uart_is_present

LDFLAGS=-ggdb -ffreestanding -lcmocka -L$(CMOCKA_DIR)/build/src -Wl,-rpath=$(CMOCKA_DIR)/build/src
LDFLAGS=-ggdb -ffreestanding -lcmocka \
-L$(CMOCKA_DIR)/build/src -Wl,-rpath=$(CMOCKA_DIR)/build/src \
-fsanitize=address -fsanitize=undefined -fsanitize=leak
LDFLAGS+=$(foreach MOCK,$(MD_MOCKS),-Wl,--wrap=$(MOCK))

SYSTEM_TEST_LDFLAGS=$(LDFLAGS)
UNIT_TEST_LDFLAGS=$(LDFLAGS) $(foreach MOCK,$(MOCKS),-Wl,--wrap=$(MOCK))
SANITISE_LDFLAGS=-fsanitize=address

SRC=$(shell find ../src/* -maxdepth 0 -type f -name '*.c' ! -name '*main.c*' -printf '%f\n')
SRC+=$(shell find ../src/comm/* -maxdepth 0 -type f -name '*.c' ! -name '*main.c*' -printf 'comm/%f\n')
Expand All @@ -224,12 +223,8 @@ CMOCKA_DIR=cmocka

UNIT_TESTS_TARGET=$(BIN_DIR)/unit_tests
SYSTEM_TESTS_TARGET=$(BIN_DIR)/system_tests
UNIT_TESTS_SANITISE_TARGET=$(BIN_DIR)/unit_tests_sanitise
SYSTEM_TESTS_SANITISE_TARGET=$(BIN_DIR)/system_tests_sanitise

all: clean-target \
unit sanitise-unit valgrind-unit \
system sanitise-system valgrind-system
all: clean-target unit system

unit: $(UNIT_TESTS_TARGET)
$(GDB) ./$(UNIT_TESTS_TARGET)
Expand All @@ -239,26 +234,6 @@ system: $(SYSTEM_TESTS_TARGET)
$(GDB) ./$(SYSTEM_TESTS_TARGET)
.PHONY: system

valgrind-unit: $(UNIT_TESTS_TARGET)
$(VALGRIND) $(VFLAGS) $(UNIT_TESTS_TARGET) > /dev/null
.PHONY: valgrind-unit

valgrind-system: $(SYSTEM_TESTS_TARGET)
$(VALGRIND) $(VFLAGS) $(SYSTEM_TESTS_TARGET) > /dev/null
.PHONY: valgrind-system

sanitise-unit: $(UNIT_TESTS_SANITISE_TARGET)
if [ "$(ENABLE_SANITISE_CHECKS)" = "1" ]; then \
$(GDB) ./$(UNIT_TESTS_SANITISE_TARGET); \
fi;
.PHONY: sanitise-unit

sanitise-system: $(SYSTEM_TESTS_SANITISE_TARGET)
if [ "$(ENABLE_SANITISE_CHECKS)" = "1" ]; then \
$(GDB) ./$(SYSTEM_TESTS_SANITISE_TARGET); \
fi;
.PHONY: sanitise-system

$(SRC_OBJ): | $(OBJ_DIR) $(CMOCKA_DIR)

$(OBJ_DIR):
Expand All @@ -274,18 +249,10 @@ $(UNIT_TESTS_TARGET): $(SRC_OBJ) $(UNIT_TEST_OBJ) $(COMMON_TEST_OBJ)
mkdir -p $(BIN_DIR)
$(CC) -o $@ $^ $(UNIT_TEST_LDFLAGS)

$(UNIT_TESTS_SANITISE_TARGET): $(SRC_OBJ) $(UNIT_TEST_OBJ) $(COMMON_TEST_OBJ)
mkdir -p $(BIN_DIR)
$(CC) -o $@ $^ $(UNIT_TEST_LDFLAGS) $(SANITISE_LDFLAGS)

$(SYSTEM_TESTS_TARGET): $(SRC_OBJ) $(SYSTEM_TEST_OBJ) $(COMMON_TEST_OBJ)
mkdir -p $(BIN_DIR)
$(CC) -o $@ $^ $(SYSTEM_TEST_LDFLAGS)

$(SYSTEM_TESTS_SANITISE_TARGET): $(SRC_OBJ) $(SYSTEM_TEST_OBJ) $(COMMON_TEST_OBJ)
mkdir -p $(BIN_DIR)
$(CC) -o $@ $^ $(SYSTEM_TEST_LDFLAGS) $(SANITISE_LDFLAGS)

$(CMOCKA_DIR):
mkdir -p $@
tar -xf $(CMOCKA_TAR) -C $@ --strip-components 1 --no-same-owner
Expand Down

0 comments on commit 36607c8

Please sign in to comment.