Skip to content

Commit c50e0de

Browse files
committed
CI: build and test with valgrind memory checker too
Amongst others, this catches uninitialized memory access, which libasan does not. Signed-off-by: Jonas Rebmann <[email protected]>
1 parent c648398 commit c50e0de

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,61 @@ jobs:
2020
libreadline6-dev \
2121
autoconf \
2222
automake \
23-
python3-pytest
23+
python3-pytest \
24+
valgrind
2425
2526
- name: Prepare (autoreconf)
2627
run: autoreconf -i
2728

28-
- name: Prepare (configure)
29+
# Build 1: ASAN
30+
- name: Create ASAN build directory
31+
run: mkdir -p build-asan
32+
33+
- name: Configure ASAN build
34+
working-directory: build-asan
2935
env:
3036
CFLAGS: "-g -O2 -Wpedantic -Werror -Wno-error=unused-result -fsanitize=address,undefined -fno-omit-frame-pointer"
3137
LDFLAGS: "-fsanitize=address,undefined"
32-
run: ./configure
38+
run: ../configure
3339

34-
- name: Build
40+
- name: Build ASAN
41+
working-directory: build-asan
3542
run: make
3643

37-
- name: Run pytest
44+
- name: Run pytest with ASAN
45+
continue-on-error: true
46+
env:
47+
ASAN_OPTIONS: "detect_leaks=1"
48+
UBSAN_OPTIONS: "print_stacktrace=1"
49+
run: pytest -v --cmd="build-asan/microcom"
50+
51+
- name: Run check with ASAN
52+
continue-on-error: true
53+
working-directory: build-asan
3854
env:
3955
ASAN_OPTIONS: "detect_leaks=1"
4056
UBSAN_OPTIONS: "print_stacktrace=1"
41-
run: pytest -v
57+
run: make check
58+
59+
# Build 2: Valgrind
60+
- name: Create unoptimized build directory
61+
run: mkdir -p build-unopt
62+
63+
- name: Configure unoptimized build
64+
working-directory: build-unopt
65+
env:
66+
CFLAGS: "-g -O0 -Wpedantic -Werror -Wno-error=unused-result"
67+
run: ../configure
68+
69+
- name: Build unoptimized
70+
working-directory: build-unopt
71+
run: make
72+
73+
- name: Run pytest with Valgrind
74+
continue-on-error: true
75+
run: pytest -v --cmd="valgrind --tool=memcheck --error-exitcode=99 --quiet build-unopt/microcom"
4276

43-
- name: Run check
77+
- name: Run check with Valgrind
78+
continue-on-error: true
79+
working-directory: build-unopt
4480
run: make check

test/test_telnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run():
5454
break
5555
os.close(master_fd)
5656
proc.wait()
57-
assert proc.returncode in (0, 1), f"Exit code must be 0 or 1, got {proc.returncode}"
57+
assert proc.returncode in (0, 1)
5858

5959
return bytes(output)
6060
return _recv

0 commit comments

Comments
 (0)