From e47add9edceaf688634449a68f66a24c7b818b0e Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 9 Jun 2020 16:51:55 +0200 Subject: [PATCH] test: make TEST-02-CRYPTSETUP a bit more robust Prompted by systemd/systemd#16111. * check if /var is a mountpoint - if not, something went wrong. In case of systemd/systemd#16111 the /failed file was created, because systemd-cryptsetup failed, but it ended up being empty, making the result check incorrectly pass * forward journal messages to console - if we fail to mount /var, journald won't flush logs to the persistent storage and we end up empty handed and with no clue what went wrong For example, without systemd/systemd#16111 and with this patch: ... [FAILED] Failed to start systemd-cryptsetup@varcrypt.service. See 'systemctl status systemd-cryptsetup@varcrypt.service' for details. [DEPEND] Dependency failed for cryptsetup.target. ... [ 3.882451] systemd-cryptsetup[581]: Key file /etc/varkey is world-readable. This is not a good idea! [ 3.883946] systemd-cryptsetup[581]: WARNING: Locking directory /run/cryptsetup is missing! [ 3.884846] systemd-cryptsetup[581]: Failed to load Bitlocker superblock on device /dev/disk/by-uuid/180ba5ef-873b-4018-9968-47c23431f71a: Invalid argument ... [ 4.099451] sh[606]: + mountpoint /var [ 4.100025] sh[603]: + systemctl poweroff --no-block [ 4.101636] systemd[1]: Finished systemd-user-sessions.service. [ 4.102598] sh[608]: /var is not a mountpoint [FAILED] Failed to start testsuite-02.service. --- test/TEST-02-CRYPTSETUP/test.sh | 4 ++++ test/test-functions | 1 + test/units/testsuite-02.service | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 27b42223d1..ef1811122e 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -52,6 +52,10 @@ EOF cat >>$initdir/etc/fstab <> $initdir/etc/systemd/journald.conf ) } diff --git a/test/test-functions b/test/test-functions index 7302b207b0..df87261ea2 100644 --- a/test/test-functions +++ b/test/test-functions @@ -80,6 +80,7 @@ BASICTOOLS=( mktemp modprobe mount + mountpoint mv nc nproc diff --git a/test/units/testsuite-02.service b/test/units/testsuite-02.service index 701610b790..13e7ec3639 100644 --- a/test/units/testsuite-02.service +++ b/test/units/testsuite-02.service @@ -4,5 +4,5 @@ After=multi-user.target [Service] ExecStartPre=rm -f /failed /testok -ExecStart=sh -x -c 'systemctl --state=failed --no-legend --no-pager >/failed ; echo OK > /testok' +ExecStart=sh -x -e -c 'mountpoint /var; systemctl --state=failed --no-legend --no-pager >/failed; echo OK >/testok' Type=oneshot