Skip to content

Commit 26c1802

Browse files
henrybear327Chun-Hung Tseng
authored andcommitted
Introduce valgrind to the CI pipeline
The static analyzer alone can't catch all the runtime issues. In this commit, the dynamic analysis tool Valgrind is added to the CI pipeline. ENABLE_SDL is set to 0, in order to reduce noise caused by the external libraries. Reference: - https://valgrind.org/docs/manual/quick-start.html - https://linux.die.net/man/1/gcc
1 parent b8e20f6 commit 26c1802

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: install-dependencies
4343
run: |
4444
sudo apt-get update -q -y
45-
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev
45+
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev valgrind
4646
.ci/riscv-toolchain-install.sh
4747
shell: bash
4848
- name: default build
@@ -73,6 +73,16 @@ jobs:
7373
run: |
7474
make clean && make ENABLE_UBSAN=1 check -j$(nproc)
7575
make clean && make ENABLE_JIT=1 ENABLE_UBSAN=1 check -j$(nproc)
76+
- name: valgrind check (without JIT)
77+
run: |
78+
make clean && make ENABLE_SDL=0 ENABLE_JIT=0 ENABLE_VALGRIND=1
79+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf
80+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf
81+
- name: valgrind check (with JIT)
82+
run: |
83+
make clean && make ENABLE_SDL=0 ENABLE_JIT=1 ENABLE_VALGRIND=1
84+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf
85+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf
7686
7787
host-arm64:
7888
needs: [detect-code-related-file-changes]

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ CFLAGS = -std=gnu99 -O2 -Wall -Wextra
1111
CFLAGS += -Wno-unused-label
1212
CFLAGS += -include src/common.h
1313

14+
ENABLE_VALGRIND ?= 0
15+
ifeq ("$(ENABLE_UBSAN)", "1")
16+
# according to gcc's man page: "If you use multiple -O options, with or without level numbers, the last such option is the one that is effective."
17+
# In order to use Valgrind, we need to compile with -g
18+
CFLAGS += -g
19+
LDFLAGS += -g
20+
endif
21+
1422
# Enable link-time optimization (LTO)
1523
ENABLE_LTO ?= 1
1624
ifeq ($(call has, LTO), 1)

0 commit comments

Comments
 (0)