GitHub CI: fail sanitizer job if any logs were created.
[tinc] / .github / workflows / sanitizers / run.sh
1 #!/bin/bash
2
3 set -euo pipefail
4
5 logs="$GITHUB_WORKSPACE/sanitizer"
6 mkdir -p "$logs"
7
8 case "$SANITIZER" in
9 address)
10   export ASAN_OPTIONS="log_path=$logs/asan:detect_invalid_pointer_pairs=2:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
11   ;;
12
13 thread)
14   export TSAN_OPTIONS="log_path=$logs/tsan"
15   ;;
16
17 undefined)
18   export UBSAN_OPTIONS="log_path=$logs/ubsan:print_stacktrace=1"
19   ;;
20
21 *)
22   echo >&2 "unknown sanitizer $SANITIZER"
23   exit 1
24   ;;
25 esac
26
27 sudo --preserve-env=ASAN_OPTIONS,TSAN_OPTIONS,UBSAN_OPTIONS \
28   make check VERBOSE=1
29
30 # Check that the sanitizer has not created any log files.
31 # If it has, fail the job to notify the developer.
32 log_count=$(find "$logs" -type f -printf . | wc -c)
33
34 if [ "$log_count" != 0 ]; then
35   echo "expected zero sanitizer logs, found $log_count"
36   exit 1
37 fi