Move sanitizer details into a test wrapper

We want the meson test target to be self contained and having an
essential variables defined in the GitHub CI is heading the opposite
direction.

Create a wrapper that does this for us.

v2:
 - add the script to the autotools tarball/EXTRA_DIST

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/179
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
Emil Velikov 2024-10-09 16:26:25 +01:00 committed by Lucas De Marchi
parent 01a48d2cdf
commit 5798e18844
5 changed files with 14 additions and 2 deletions

View File

@ -70,7 +70,6 @@ jobs:
git config --global --add safe.directory '*'
.github/print-kdir.sh >> "$GITHUB_ENV"
echo "ASAN_OPTIONS=verify_asan_link_order=0:halt_on_error=1:abort_on_error=1:print_summary=1" >> "$GITHUB_ENV"
- name: configure (meson)
if: ${{ matrix.build == 'meson' }}

View File

@ -24,6 +24,7 @@ EXTRA_DIST += \
testsuite/meson.build \
scripts/build-scdoc.sh \
scripts/test-gtkdoc.sh \
scripts/test-wrapper.sh \
scripts/kmod-symlink.sh
AM_CPPFLAGS = \

View File

@ -459,6 +459,7 @@ if get_option('build-tests')
setup_modules = find_program('scripts/setup-modules.sh')
setup_rootfs = find_program('scripts/setup-rootfs.sh')
top_include = include_directories('.')
test_wrapper = find_program('scripts/test-wrapper.sh')
subdir('testsuite')
endif

10
scripts/test-wrapper.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail
if [[ ${ASAN_OPTIONS-} || ${UBSAN_OPTIONS-} || ${MSAN_OPTIONS-} ]]; then
ASAN_OPTIONS=verify_asan_link_order=0:halt_on_error=1:abort_on_error=1:print_summary=1
export ASAN_OPTIONS
fi
exec "$@"

View File

@ -97,7 +97,8 @@ _testsuite = [
foreach input : _testsuite
test(
input,
executable(
test_wrapper,
args : executable(
input,
files('@0@.c'.format(input)),
include_directories : top_include,