From 6f255fe191900013d1c33aba59941d75dfbdb293 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 17 Oct 2022 14:31:25 +0200 Subject: [PATCH 1/3] test: ignore gcov errors in TEST-34 TEST-34 complains in `test_check_writable` when running with gcov, as the build directory tree is not writable with DynamicUser=true. As I had no luck with $GCOV_PREFIX and other runtime gcov configuration, let's just ignore the gcov errors for this test. --- test/TEST-34-DYNAMICUSERMIGRATE/test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh index 5acc57363e..4e8836648a 100755 --- a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh +++ b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh @@ -3,6 +3,11 @@ set -e TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back" +# Certain subtests run with DynamicUser=true which makes writing the gcov +# artifacts impossible. As $GCOV_PREFIX and friends seem to be ineffective +# in this situation, let's simply ignore all gcov complaints for the whole +# test to make it happy. +IGNORE_MISSING_COVERAGE=yes # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" From e6bd46a62ce2c07f9f4ea54ce46c38c7239967e6 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 17 Oct 2022 14:38:00 +0200 Subject: [PATCH 2/3] test: drop one layer of escaping --- test/units/testsuite-34.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/units/testsuite-34.sh b/test/units/testsuite-34.sh index beaf3ba31e..2172f7434b 100755 --- a/test/units/testsuite-34.sh +++ b/test/units/testsuite-34.sh @@ -116,7 +116,7 @@ test_check_writable() { rm -rf "/var/lib/$i" "/var/lib/private/$i" done - cat >/run/systemd/system/testservice-34-check-writable.service </run/systemd/system/testservice-34-check-writable.service <<\EOF [Unit] Description=Check writable directories when DynamicUser= with StateDirectory= @@ -133,18 +133,18 @@ ExecStart=bash -c ' \ set -eux; \ set -o pipefail; \ declare -a writable_dirs; \ - readarray -t writable_dirs < <(find / \\( -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o \ - -path /sys/fs/bpf -o -path /dev/.lxc -o -path /sys/devices/system/cpu \\) \ + readarray -t writable_dirs < <(find / \( -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o \ + -path /sys/fs/bpf -o -path /dev/.lxc -o -path /sys/devices/system/cpu \) \ -prune -o -type d -writable -print 2>/dev/null | sort -u); \ - [[ "\$\${#writable_dirs[@]}" == "8" ]]; \ - [[ "\$\${writable_dirs[0]}" == "/var/lib/private/aaa" ]]; \ - [[ "\$\${writable_dirs[1]}" == "/var/lib/private/aaa/bbb" ]]; \ - [[ "\$\${writable_dirs[2]}" == "/var/lib/private/aaa/ccc" ]]; \ - [[ "\$\${writable_dirs[3]}" == "/var/lib/private/quux/pief" ]]; \ - [[ "\$\${writable_dirs[4]}" == "/var/lib/private/waldo" ]]; \ - [[ "\$\${writable_dirs[5]}" == "/var/lib/private/xxx" ]]; \ - [[ "\$\${writable_dirs[6]}" == "/var/lib/private/xxx/yyy" ]]; \ - [[ "\$\${writable_dirs[7]}" == "/var/lib/private/xxx/zzz" ]]; \ + [[ "$${#writable_dirs[@]}" == "8" ]]; \ + [[ "$${writable_dirs[0]}" == "/var/lib/private/aaa" ]]; \ + [[ "$${writable_dirs[1]}" == "/var/lib/private/aaa/bbb" ]]; \ + [[ "$${writable_dirs[2]}" == "/var/lib/private/aaa/ccc" ]]; \ + [[ "$${writable_dirs[3]}" == "/var/lib/private/quux/pief" ]]; \ + [[ "$${writable_dirs[4]}" == "/var/lib/private/waldo" ]]; \ + [[ "$${writable_dirs[5]}" == "/var/lib/private/xxx" ]]; \ + [[ "$${writable_dirs[6]}" == "/var/lib/private/xxx/yyy" ]]; \ + [[ "$${writable_dirs[7]}" == "/var/lib/private/xxx/zzz" ]]; \ ' EOF systemctl daemon-reload From c0c03d9ce13a5b706a33ffdd8e69fa6cad63358e Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 17 Oct 2022 15:00:12 +0200 Subject: [PATCH 3/3] test: use SIGKILL to kill the container if necessary TEST-69 uses a Python wrapper around the systemd-nspawn call, which on error calls the `spawn.terminate()` method. However, with no arguments it will only use SIGHUP and SIGINT signals - this might leave a stuck container around, causing fails if the test is run again. With `force=True` SIGKILL is used as well (if necessary). --- test/test-shutdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-shutdown.py b/test/test-shutdown.py index 52207a4656..e181f976be 100755 --- a/test/test-shutdown.py +++ b/test/test-shutdown.py @@ -90,7 +90,7 @@ def run(args): except Exception as e: logger.error(e) logger.info("killing child pid %d", console.pid) - console.terminate() + console.terminate(force=True) return ret