summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2021-11-23 10:32:41 +0000
committerGitHub <noreply@github.com>2021-11-23 10:32:41 +0000
commit7d34f26a32b0960db17ff9e619b174eb1d4276e1 (patch)
tree33fa0275674dd0f88dc14bb38605d0e41e623078 /test
parent7c5cef22115c1898cce8d501d912e2685c83e16e (diff)
parentc83f126a41cfc964f43a30f1089a73e61908868a (diff)
downloadsystemd-7d34f26a32b0960db17ff9e619b174eb1d4276e1.tar.gz
Merge pull request #21472 from mrc0mmand/sanitizer_suppressions
test: suppress certain leaks reported by LSan
Diffstat (limited to 'test')
-rw-r--r--test/test-functions22
-rwxr-xr-xtest/units/testsuite-55.sh19
2 files changed, 24 insertions, 17 deletions
diff --git a/test/test-functions b/test/test-functions
index 00a808bf28..a4b7efb5ec 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -778,9 +778,23 @@ if [[ ! -e "$ASAN_RT_PATH" ]]; then
exit 1
fi
+# Suppress certain leaks reported by LSan (either in external tools or bogus
+# ones)
+# Docs: # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions
+#
+# - fsck is called by systemd-homed and is reporting a leak we're not interested
+# in
+# - libLLVM is a "side effect" caused by the previous fsck leak
+cat >/systemd-lsan.supp <<INNER_EOF
+leak:/bin/fsck$
+leak:/sbin/fsck$
+leak:/lib/libLLVM
+INNER_EOF
+
+DEFAULT_LSAN_OPTIONS=${LSAN_OPTIONS:-}:suppressions=/systemd-lsan.supp
DEFAULT_ASAN_OPTIONS=${ASAN_OPTIONS:-strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1}
DEFAULT_UBSAN_OPTIONS=${UBSAN_OPTIONS:-print_stacktrace=1:print_summary=1:halt_on_error=1}
-DEFAULT_ENVIRONMENT="ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS"
+DEFAULT_ENVIRONMENT="ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS LSAN_OPTIONS=\$DEFAULT_LSAN_OPTIONS"
# As right now bash is the PID 1, we can't expect PATH to have a sane value.
# Let's make one to prevent unexpected "<bin> not found" issues in the future
@@ -2083,7 +2097,7 @@ dfatal() {
# Generic substring function. If $2 is in $1, return 0.
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
# normalize_path <path>
# Prints the normalized path, where it removes any duplicated
@@ -2498,12 +2512,12 @@ image_install() {
install_kmod_with_fw() {
local module="${1:?}"
# no need to go further if the module is already installed
- [[ -e "${initdir:?}/lib/modules/${KERNEL_VER:?}/${module##*/lib/modules/$KERNEL_VER/}" ]] && return 0
+ [[ -e "${initdir:?}/lib/modules/${KERNEL_VER:?}/${module##*"/lib/modules/$KERNEL_VER/"}" ]] && return 0
[[ -e "$initdir/.kernelmodseen/${module##*/}" ]] && return 0
[ -d "$initdir/.kernelmodseen" ] && : >"$initdir/.kernelmodseen/${module##*/}"
- inst_simple "$module" "/lib/modules/$KERNEL_VER/${module##*/lib/modules/$KERNEL_VER/}" || return $?
+ inst_simple "$module" "/lib/modules/$KERNEL_VER/${module##*"/lib/modules/$KERNEL_VER/"}" || return $?
local modname="${module##*/}"
local fwdir found fw
diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh
index b265c8cce7..db13964311 100755
--- a/test/units/testsuite-55.sh
+++ b/test/units/testsuite-55.sh
@@ -60,36 +60,29 @@ if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
# Make sure we also work correctly on user units.
-runas() {
- declare userid=$1
- shift
- # shellcheck disable=SC2016
- su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@"
-}
-
-runas testuser systemctl start --user testsuite-55-testchill.service
-runas testuser systemctl start --user testsuite-55-testbloat.service
+systemctl start --machine "testuser@.host" --user testsuite-55-testchill.service
+systemctl start --machine "testuser@.host" --user testsuite-55-testbloat.service
# Verify systemd-oomd is monitoring the expected units
oomctl | grep -E "/user.slice.*/testsuite-55-workload.slice"
oomctl | grep "20.00%"
oomctl | grep "Default Memory Pressure Duration: 2s"
-runas testuser systemctl --user status testsuite-55-testchill.service
+systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service
# systemd-oomd watches for elevated pressure for 2 seconds before acting.
# It can take time to build up pressure so either wait 2 minutes or for the service to fail.
timeout="$(date -ud "2 minutes" +%s)"
while [[ $(date -u +%s) -le $timeout ]]; do
- if ! runas testuser systemctl --user status testsuite-55-testbloat.service; then
+ if ! systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then
break
fi
sleep 2
done
# testbloat should be killed and testchill should be fine
-if runas testuser systemctl --user status testsuite-55-testbloat.service; then exit 42; fi
-if ! runas testuser systemctl --user status testsuite-55-testchill.service; then exit 24; fi
+if systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then exit 42; fi
+if ! systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service; then exit 24; fi
# only run this portion of the test if we can set xattrs
if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then