From b13d59243bf0f22c599d9e6be71573e39bf70369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 29 May 2023 23:18:55 +0200 Subject: [PATCH 1/4] test/README: fix advice for testsuite debugging KERNEL_APPEND="systemd.unit=multi-user.target" is not very useful, because the machine will still shut down as soon as the tests succeeds or fails. But INTERACTIVE_DEBUG=1 works great, so let's simplify the instructions and recommend that. --- test/README.testsuite | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/README.testsuite b/test/README.testsuite index 9070d0c60c..695cce15aa 100644 --- a/test/README.testsuite +++ b/test/README.testsuite @@ -99,7 +99,7 @@ INTERACTIVE_DEBUG=1 the test, etc.) The kernel and initrd can be specified with $KERNEL_BIN and $INITRD. (Fedora's -or Debian's default kernel path and initrd are used by default) +or Debian's default kernel path and initrd are used by default.) A script will try to find your qemu binary. If you want to specify a different one with $QEMU_BIN. @@ -107,12 +107,12 @@ one with $QEMU_BIN. Debugging the qemu image ======================== -If you want to log in the testsuite virtual machine, you can specify additional -kernel command line parameter with $KERNEL_APPEND and then log in as root. +If you want to log in the testsuite virtual machine, use INTERACTIVE_DEBUG=1 +and log in as root: -$ sudo make -C test/TEST-01-BASIC KERNEL_APPEND="systemd.unit=multi-user.target" run +$ sudo make -C test/TEST-01-BASIC INTERACTIVE_DEBUG=1 run -Root password is empty. +The root password is empty. Ubuntu CI ========= From dfb3ebfd60b138eb9d02e1be71db8b376fb8bc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 29 May 2023 20:52:33 +0200 Subject: [PATCH 2/4] TEST-58: create config files as root There is really no reason to go out of our way to create the config files as the unprivileged user. And in the logs, the runas calls are quite verbose, distracting from the interesting stuff. Also add .defs/.imgs/.root to the temporary paths to make them easier to distinguish in the logs. --- test/units/testsuite-58.sh | 183 +++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 81 deletions(-) diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index b1b40851db..0aaf597e9a 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -95,10 +95,11 @@ testcase_basic() { local defs imgs output local loop volume - defs="$(runas testuser mktemp --directory "/tmp/test-repart.XXXXXXXXXX")" - imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.XXXXXXXXXX")" + defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")" + imgs="$(runas testuser mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")" # shellcheck disable=SC2064 trap "rm -rf '$defs' '$imgs'" RETURN + chmod a+rx "$defs" # 1. create an empty image @@ -118,21 +119,21 @@ last-lba: 2097118" # 2. Testing with root, root2, home, and swap - runas testuser tee "$defs/root.conf" <"$defs/verity.openssl.cnf" <"$defs/verity.openssl.cnf" < Date: Mon, 29 May 2023 20:54:20 +0200 Subject: [PATCH 3/4] TEST-58: add echo calls to print what is happening This makes it easier to identify the relevant test in the logs when something fails. --- test/units/testsuite-58.sh | 44 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index 0aaf597e9a..06bceb5a86 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -101,7 +101,7 @@ testcase_basic() { trap "rm -rf '$defs' '$imgs'" RETURN chmod a+rx "$defs" - # 1. create an empty image + echo "*** 1. create an empty image ***" runas testuser systemd-repart --empty=create \ --size=1G \ @@ -117,7 +117,7 @@ unit: sectors first-lba: 2048 last-lba: 2097118" - # 2. Testing with root, root2, home, and swap + echo "*** 2. Testing with root, root2, home, and swap ***" tee "$defs/root.conf" < Date: Mon, 29 May 2023 20:54:44 +0200 Subject: [PATCH 4/4] TEST-58: remove whitespace between redirection operator and its argument --- test/units/testsuite-58.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index 06bceb5a86..37dfa9cefe 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -838,9 +838,9 @@ EOF --certificate="$defs/verity.crt" \ "$imgs/verity") - drh=$(jq -r ".[] | select(.type == \"root-${architecture}\") | .roothash" <<< "$output") - hrh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<< "$output") - srh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity-sig\") | .roothash" <<< "$output") + drh=$(jq -r ".[] | select(.type == \"root-${architecture}\") | .roothash" <<<"$output") + hrh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity\") | .roothash" <<<"$output") + srh=$(jq -r ".[] | select(.type == \"root-${architecture}-verity-sig\") | .roothash" <<<"$output") assert_eq "$drh" "$hrh" assert_eq "$hrh" "$srh"