From 5798e1884494fd37cebe8d5a1ba42f8283d6504f Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 9 Oct 2024 16:26:25 +0100 Subject: [PATCH] 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 Link: https://github.com/kmod-project/kmod/pull/179 Signed-off-by: Lucas De Marchi --- .github/workflows/main.yml | 1 - Makefile.am | 1 + meson.build | 1 + scripts/test-wrapper.sh | 10 ++++++++++ testsuite/meson.build | 3 ++- 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 scripts/test-wrapper.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e3804a..7f1b8be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' }} diff --git a/Makefile.am b/Makefile.am index 213a1fe..c3b1749 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 = \ diff --git a/meson.build b/meson.build index 9b7b71f..251023a 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/scripts/test-wrapper.sh b/scripts/test-wrapper.sh new file mode 100755 index 0000000..78b4832 --- /dev/null +++ b/scripts/test-wrapper.sh @@ -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 "$@" diff --git a/testsuite/meson.build b/testsuite/meson.build index 643c259..394e4f3 100644 --- a/testsuite/meson.build +++ b/testsuite/meson.build @@ -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,