From 776fc8c3859ba859d4212685fb383c9db9a55030 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 17:45:39 +0200 Subject: [PATCH 01/11] test: unify handling of supported "features" --- test/TEST-64-UDEV-STORAGE/test.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 89de1ea692..fe1a88f0aa 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -26,6 +26,25 @@ if ! get_bool "$QEMU_KVM"; then exit 0 fi +_host_has_feature() { + case "${1:?}" in + multipath) + command -v multipath && command -v multipathd + ;; + lvm) + command -v lvm + ;; + btrfs) + modprobe -nv btrfs && command -v mkfs.btrfs + ;; + *) + echo >&2 "ERROR: Unknown feature '$1'" + # Make this a hard error to distinguish an invalid feature from + # a missing feature + exit 1 + esac +} + test_append_files() { ( instmods "=block" "=md" "=nvme" "=scsi" @@ -34,12 +53,12 @@ test_append_files() { image_install lsblk wc # Configure multipath - if command -v multipath && command -v multipathd; then + if _host_has_feature "multipath"; then install_multipath fi # Configure LVM - if command -v lvm; then + if _host_has_feature "lvm"; then install_lvm fi @@ -201,7 +220,7 @@ EOF } testcase_multipath_basic_failover() { - if ! command -v multipath || ! command -v multipathd; then + if ! _host_has_feature "multipath"; then echo "Missing multipath tools, skipping the test..." return 77 fi @@ -260,7 +279,7 @@ testcase_simultaneous_events() { } testcase_lvm_basic() { - if ! command -v lvm; then + if ! _host_has_feature "lvm"; then echo "Missing lvm tools, skipping the test..." return 77 fi From dbc04797c1271f1486f124c5921265b6f80833da Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 18 Sep 2021 20:43:50 +0200 Subject: [PATCH 02/11] test: lower the number of iterations in LVM tests as some of the operations take a really long time. --- test/units/testsuite-64.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 1574d51401..ffac49089e 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -237,11 +237,11 @@ testcase_lvm_basic() { helper_check_device_symlinks "/dev/disk" "/dev/$vgroup" # Same as above, but now with more "stress" - for i in {1..100}; do + for i in {1..50}; do lvm vgchange -an "$vgroup" lvm vgchange -ay "$vgroup" - if ((i % 10 == 0)); then + if ((i % 5 == 0)); then udevadm settle test -e "/dev/$vgroup/mypart1" test -e "/dev/$vgroup/mypart2" @@ -258,7 +258,7 @@ testcase_lvm_basic() { helper_check_device_symlinks "/dev/disk" "/dev/$vgroup" # Create & remove LVs in a loop, i.e. with more "stress" - for i in {1..50}; do + for i in {1..16}; do # 1) Create 16 logical volumes for part in {0..15}; do lvm lvcreate -y -L 4M "$vgroup" -n "looppart$part" @@ -267,9 +267,9 @@ testcase_lvm_basic() { # 2) Immediately remove them lvm lvremove -y "$vgroup"/looppart{0..15} - # 3) On every 10th iteration settle udev and check if all partitions are + # 3) On every 4th iteration settle udev and check if all partitions are # indeed gone, and if all symlinks are still valid - if ((i % 10 == 0)); then + if ((i % 4 == 0)); then udevadm settle for part in {0..15}; do test ! -e "/dev/$vgroup/looppart$part" From babe935563bbd9509ce0ded9119f0620ba25a42b Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 19:19:23 +0200 Subject: [PATCH 03/11] test: add a btrfs helper --- test/test-functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test-functions b/test/test-functions index 8ed0dbfe06..9eb37fce58 100644 --- a/test/test-functions +++ b/test/test-functions @@ -950,6 +950,14 @@ install_lvm() { mkdir -p "${initdir:?}/etc/lvm" } +install_btrfs() { + instmods btrfs + # Not all utilities provided by btrfs-progs are listed here; extend the list + # if necessary + image_install btrfs btrfstune mkfs.btrfs + inst_rules 64-btrfs-dm.rules +} + install_compiled_systemd() { dinfo "Install compiled systemd" From 70ec7736f835a834b455fb1e23c39b938b0aebe4 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 19:28:22 +0200 Subject: [PATCH 04/11] test: tidy up the feature handling --- test/TEST-64-UDEV-STORAGE/test.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index fe1a88f0aa..fe386050e3 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -47,20 +47,25 @@ _host_has_feature() { test_append_files() { ( + local feature + # An associative array of requested (but optional) features and their + # respective "handlers" from test/test-functions + local -A features=( + [multipath]=install_multipath + [lvm]=install_lvm + ) + instmods "=block" "=md" "=nvme" "=scsi" install_dmevent generate_module_dependencies image_install lsblk wc - # Configure multipath - if _host_has_feature "multipath"; then - install_multipath - fi - - # Configure LVM - if _host_has_feature "lvm"; then - install_lvm - fi + # Install the optional features if the host has the respective tooling + for feature in "${!features[@]}"; do + if _host_has_feature "$feature"; then + "${features[$feature]}" + fi + done for i in {0..127}; do dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1 From b216501a8eb01ae99924359ec6ecc9decd1f20ed Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 23:03:44 +0200 Subject: [PATCH 05/11] test: cleanup the intermediate disk images --- test/TEST-64-UDEV-STORAGE/test.sh | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index fe386050e3..cddd5229b0 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -187,11 +187,9 @@ testcase_virtio_scsi_identically_named_partitions() { local diskpath="${TESTDIR:?}/namedpart0.img" local lodev - # Save some time (and storage life) during local testing - if [[ ! -e "$diskpath" ]]; then - dd if=/dev/zero of="$diskpath" bs=1M count=18 - lodev="$(losetup --show -f -P "$diskpath")" - sfdisk "${lodev:?}" < Date: Fri, 17 Sep 2021 23:59:38 +0200 Subject: [PATCH 06/11] test: use subshells a bit more to tweak shell flags in specific functions without affecting the rest of the script. --- test/TEST-64-UDEV-STORAGE/test.sh | 58 +++++++++++++++---------------- test/units/testsuite-64.sh | 8 ++--- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index cddd5229b0..4c4b39dd3f 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -26,7 +26,9 @@ if ! get_bool "$QEMU_KVM"; then exit 0 fi -_host_has_feature() { +_host_has_feature() {( + set -e + case "${1:?}" in multipath) command -v multipath && command -v multipathd @@ -43,36 +45,34 @@ _host_has_feature() { # a missing feature exit 1 esac -} +)} -test_append_files() { - ( - local feature - # An associative array of requested (but optional) features and their - # respective "handlers" from test/test-functions - local -A features=( - [multipath]=install_multipath - [lvm]=install_lvm - ) - - instmods "=block" "=md" "=nvme" "=scsi" - install_dmevent - generate_module_dependencies - image_install lsblk wc - - # Install the optional features if the host has the respective tooling - for feature in "${!features[@]}"; do - if _host_has_feature "$feature"; then - "${features[$feature]}" - fi - done - - for i in {0..127}; do - dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1 - echo "device$i" >"${TESTDIR:?}/disk$i.img" - done +test_append_files() {( + local feature + # An associative array of requested (but optional) features and their + # respective "handlers" from test/test-functions + local -A features=( + [multipath]=install_multipath + [lvm]=install_lvm ) -} + + instmods "=block" "=md" "=nvme" "=scsi" + install_dmevent + generate_module_dependencies + image_install lsblk wc + + # Install the optional features if the host has the respective tooling + for feature in "${!features[@]}"; do + if _host_has_feature "$feature"; then + "${features[$feature]}" + fi + done + + for i in {0..127}; do + dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1 + echo "device$i" >"${TESTDIR:?}/disk$i.img" + done +)} test_run_one() { local test_id="${1:?}" diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index ffac49089e..0dbfbc8e88 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -6,10 +6,8 @@ set -o pipefail # Check if all symlinks under /dev/disk/ are valid # shellcheck disable=SC2120 -helper_check_device_symlinks() { - # Disable verbose logging only for this function (and reset the signal handler - # when leaving the function) - set +x; trap "trap - RETURN; set -x" RETURN +helper_check_device_symlinks() {( + set +x local dev link path paths target @@ -40,7 +38,7 @@ helper_check_device_symlinks() { return 1 fi done < <(find "${paths[@]}" -type l) -} +)} testcase_megasas2_basic() { lsblk -S From 677acd210126c27c05ddb754d1f1c99e9518f0fb Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 18 Sep 2021 19:02:10 +0200 Subject: [PATCH 07/11] test: check symlinks under /dev/mapper by default as well --- test/units/testsuite-64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 0dbfbc8e88..693cd87ade 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -11,7 +11,7 @@ helper_check_device_symlinks() {( local dev link path paths target - [[ $# -gt 0 ]] && paths=("$@") || paths=("/dev/disk") + [[ $# -gt 0 ]] && paths=("$@") || paths=("/dev/disk" "/dev/mapper") # Check if all given paths are valid for path in "${paths[@]}"; do From b1471e559e8dc4ea78c896ed365f5b043c2d6ce0 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 19:28:38 +0200 Subject: [PATCH 08/11] test: btrfs-related udev tests --- test/TEST-64-UDEV-STORAGE/test.sh | 50 +++++++++++-- test/units/testsuite-64.sh | 120 ++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 6 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 4c4b39dd3f..c4119cf9ec 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -5,9 +5,7 @@ # * iSCSI # * LVM over iSCSI (?) # * SW raid (mdadm) -# * LUKS -> MD (mdadm) -> LVM -# * BTRFS -# * MD BTRFS +# * MD (mdadm) -> DM-CRYPT -> LVM set -e TEST_DESCRIPTION="systemd-udev storage tests" @@ -37,7 +35,7 @@ _host_has_feature() {( command -v lvm ;; btrfs) - modprobe -nv btrfs && command -v mkfs.btrfs + modprobe -nv btrfs && command -v mkfs.btrfs && command -v btrfs ;; *) echo >&2 "ERROR: Unknown feature '$1'" @@ -51,15 +49,19 @@ test_append_files() {( local feature # An associative array of requested (but optional) features and their # respective "handlers" from test/test-functions + # + # Note: we install cryptsetup unconditionally, hence it's not explicitly + # checked for here local -A features=( - [multipath]=install_multipath + [btrfs]=install_btrfs [lvm]=install_lvm + [multipath]=install_multipath ) instmods "=block" "=md" "=nvme" "=scsi" install_dmevent generate_module_dependencies - image_install lsblk wc + image_install lsblk wc wipefs # Install the optional features if the host has the respective tooling for feature in "${!features[@]}"; do @@ -74,6 +76,13 @@ test_append_files() {( done )} +_image_cleanup() { + mount_initdir + # Clean up certain "problematic" files which may be left over by failing tests + : >"${initdir:?}/etc/fstab" + : >"${initdir:?}/etc/crypttab" +} + test_run_one() { local test_id="${1:?}" @@ -100,6 +109,7 @@ test_run() { # Execute each currently defined function starting with "testcase_" for testcase in "${TESTCASES[@]}"; do + _image_cleanup echo "------ $testcase: BEGIN ------" { "$testcase" "$test_id"; ec=$?; } || : case $ec in @@ -311,6 +321,34 @@ testcase_lvm_basic() { rm -f "${TESTDIR:?}"/lvmbasic*.img } +testcase_btrfs_basic() { + if ! _host_has_feature "btrfs"; then + echo "Missing btrfs tools/modules, skipping the test..." + return 77 + fi + + local qemu_opts=("-device ahci,id=ahci0") + local diskpath i size + + for i in {0..3}; do + diskpath="${TESTDIR:?}/btrfsbasic${i}.img" + # Make the first disk larger for multi-partition tests + [[ $i -eq 0 ]] && size=350 || size=128 + + dd if=/dev/zero of="$diskpath" bs=1M count="$size" + qemu_opts+=( + "-device ide-hd,bus=ahci0.$i,drive=drive$i,model=foobar,serial=deadbeefbtrfs$i" + "-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i" + ) + done + + KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" + QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" + test_run_one "${1:?}" + + rm -f "${TESTDIR:?}"/btrfsbasic*.img +} + # Allow overriding which tests should be run from the "outside", useful for manual # testing (make -C test/... TESTCASES="testcase1 testcase2") if [[ -v "TESTCASES" && -n "$TESTCASES" ]]; then diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 693cd87ade..4380fa0fcf 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -277,6 +277,126 @@ testcase_lvm_basic() { done } +testcase_btrfs_basic() { + local dev_stub i label mpoint uuid + local devices=( + /dev/disk/by-id/ata-foobar_deadbeefbtrfs{0..3} + ) + + ls -l "${devices[@]}" + + echo "Single device: default settings" + uuid="deadbeef-dead-dead-beef-000000000000" + label="btrfs_root" + mkfs.btrfs -L "$label" -U "$uuid" "${devices[0]}" + udevadm settle + btrfs filesystem show + test -e "/dev/disk/by-uuid/$uuid" + test -e "/dev/disk/by-label/$label" + helper_check_device_symlinks + + echo "Multiple devices: using partitions, data: single, metadata: raid1" + uuid="deadbeef-dead-dead-beef-000000000001" + label="btrfs_mpart" + sfdisk --wipe=always "${devices[0]}" </etc/crypttab + for ((i = 0; i < ${#devices[@]}; i++)); do + # Intentionally use weaker cipher-related settings, since we don't care + # about security here as it's a throwaway LUKS partition + cryptsetup luksFormat -q \ + --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \ + --uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile + udevadm settle + test -e "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" + test -e "/dev/disk/by-label/encdisk$i" + # Add the device into /etc/crypttab, reload systemd, and then activate + # the device so we can create a filesystem on it later + echo "encbtrfs$i UUID=deadbeef-dead-dead-beef-11111111111$i /etc/btrfs_keyfile luks,noearly" >>/etc/crypttab + systemctl daemon-reload + systemctl start "systemd-cryptsetup@encbtrfs$i" + done + helper_check_device_symlinks + # Check if we have all necessary DM devices + ls -l /dev/mapper/encbtrfs{0..3} + # Create a multi-device btrfs filesystem on the LUKS devices + mkfs.btrfs -M -d raid1 -m raid1 -L "$label" -U "$uuid" /dev/mapper/encbtrfs{0..3} + udevadm settle + btrfs filesystem show + test -e "/dev/disk/by-uuid/$uuid" + test -e "/dev/disk/by-label/$label" + helper_check_device_symlinks + # Mount it and write some data to it we can compare later + mount -t btrfs /dev/mapper/encbtrfs0 "$mpoint" + echo "hello there" >"$mpoint/test" + # "Deconstruct" the btrfs device and check if we're in a sane state (symlink-wise) + umount "$mpoint" + systemctl stop systemd-cryptsetup@encbtrfs{0..3} + test ! -e "/dev/disk/by-uuid/$uuid" + helper_check_device_symlinks + # Add the mount point to /etc/fstab and check if the device can be put together + # automagically. The source device is the DM name of the first LUKS device + # (from /etc/crypttab). We have to specify all LUKS devices manually, as + # registering the necessary devices is usually initrd's job (via btrfs device scan) + dev_stub="/dev/mapper/encbtrfs" + echo "/dev/mapper/encbtrfs0 $mpoint btrfs device=${dev_stub}0,device=${dev_stub}1,device=${dev_stub}2,device=${dev_stub}3 0 2" >>/etc/fstab + # Tell systemd about the new mount + systemctl daemon-reload + # Restart cryptsetup.target to trigger autounlock of partitions in /etc/crypttab + systemctl restart cryptsetup.target + # Start the corresponding mount unit and check if the btrfs device was reconstructed + # correctly + systemctl start "${mpoint##*/}.mount" + btrfs filesystem show + test -e "/dev/disk/by-uuid/$uuid" + test -e "/dev/disk/by-label/$label" + helper_check_device_symlinks + grep "hello there" "$mpoint/test" + # Cleanup + systemctl stop "${mpoint##*/}.mount" + systemctl stop systemd-cryptsetup@encbtrfs{0..3} + sed -i "/${mpoint##*/}/d" /etc/fstab + : >/etc/crypttab + rm -fr "$mpoint" + systemctl daemon-reload + udevadm settle +} + : >/failed udevadm settle From abfa9a0e7de2352ad3bdc7109843ffe083d3df4e Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 18 Sep 2021 21:44:38 +0200 Subject: [PATCH 09/11] test: fix error handling with `set -e` Unfortunately, when checking the return/exit code using &&, ||, if, while, etc., `set -e` is disabled for all nested functions as well, which leads to incorrectly ignored errors, *sigh*. Example: ``` set -eu set -o pipefail task() { echo "task init" echo "this should fail" false nonexistentcommand echo "task end (we shouldn't be here)" } if ! task; then echo >&2 "The task failed" exit 1 else echo "The task passed" fi ``` ``` $ bash test.sh task init this should fail test.sh: line 10: nonexistentcommand: command not found task end (we shouldn't be here) The task passed $ echo $? 0 ``` But without the `if`, everything works "as expected": ``` set -eu set -o pipefail task() { echo "task init" echo "this should fail" false nonexistentcommand echo "task end (we shouldn't be here)" } task ``` ``` $ bash test.sh task init this should fail $ echo $? 1 ``` Wonderful. --- test/TEST-64-UDEV-STORAGE/test.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index c4119cf9ec..bcf8d9bb6e 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -29,13 +29,13 @@ _host_has_feature() {( case "${1:?}" in multipath) - command -v multipath && command -v multipathd + command -v multipath && command -v multipathd || return $? ;; lvm) - command -v lvm + command -v lvm || return $? ;; btrfs) - modprobe -nv btrfs && command -v mkfs.btrfs && command -v btrfs + modprobe -nv btrfs && command -v mkfs.btrfs && command -v btrfs || return $? ;; *) echo >&2 "ERROR: Unknown feature '$1'" @@ -111,7 +111,17 @@ test_run() { for testcase in "${TESTCASES[@]}"; do _image_cleanup echo "------ $testcase: BEGIN ------" - { "$testcase" "$test_id"; ec=$?; } || : + # Note for my future frustrated self: `fun && xxx` (as wel as ||, if, while, + # until, etc.) _DISABLES_ the `set -e` behavior in _ALL_ nested function + # calls made from `fun()`, i.e. the function _CONTINUES_ even when a called + # command returned non-zero EC. That may unexpectedly hide failing commands + # if not handled properly. See: bash(1) man page, `set -e` section. + # + # So, be careful when adding clean up snippets in the testcase_*() functions - + # if the `test_run_one()` function isn't the last command, you have propagate + # the exit code correctly (e.g. `test_run_one() || return $?`, see below). + ec=0 + "$testcase" "$test_id" || ec=$? case $ec in 0) passed+=("$testcase") @@ -228,7 +238,7 @@ EOF KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" # Limit the number of VCPUs and set a timeout to make sure we trigger the issue QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" - QEMU_SMP=1 QEMU_TIMEOUT=60 test_run_one "${1:?}" + QEMU_SMP=1 QEMU_TIMEOUT=60 test_run_one "${1:?}" || return $? rm -f "${TESTDIR:?}"/namedpart*.img } @@ -271,7 +281,7 @@ EOF KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" - test_run_one "${1:?}" + test_run_one "${1:?}" || return $? rm -f "$partdisk" } @@ -289,7 +299,7 @@ testcase_simultaneous_events() { KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" - test_run_one "${1:?}" + test_run_one "${1:?}" || return $? rm -f "$partdisk" } @@ -316,7 +326,7 @@ testcase_lvm_basic() { KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" - test_run_one "${1:?}" + test_run_one "${1:?}" || return $? rm -f "${TESTDIR:?}"/lvmbasic*.img } @@ -344,7 +354,7 @@ testcase_btrfs_basic() { KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" - test_run_one "${1:?}" + test_run_one "${1:?}" || return $? rm -f "${TESTDIR:?}"/btrfsbasic*.img } From 41187e716d61505acbdffa03be35b8ec1bbec622 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 18 Sep 2021 23:06:36 +0200 Subject: [PATCH 10/11] test: regenerate module dependencies after installing all modules --- test/TEST-64-UDEV-STORAGE/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index bcf8d9bb6e..0c6e9dfa27 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -60,7 +60,6 @@ test_append_files() {( instmods "=block" "=md" "=nvme" "=scsi" install_dmevent - generate_module_dependencies image_install lsblk wc wipefs # Install the optional features if the host has the respective tooling @@ -70,6 +69,8 @@ test_append_files() {( fi done + generate_module_dependencies + for i in {0..127}; do dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1 echo "device$i" >"${TESTDIR:?}/disk$i.img" From 26a5ae8e95c0cb0262bf6f9b462bd74322f8ece3 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 18 Sep 2021 23:18:57 +0200 Subject: [PATCH 11/11] test: dump the test output to console as well for easier debugging --- test/units/testsuite-64.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/units/testsuite-64.service b/test/units/testsuite-64.service index 4c8f701e73..0f8cfa3770 100644 --- a/test/units/testsuite-64.service +++ b/test/units/testsuite-64.service @@ -5,3 +5,5 @@ Description=TEST-64-UDEV ExecStartPre=rm -f /failed /testok ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh Type=oneshot +StandardOutput=journal+console +StandardError=journal+console