]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-64: run one more subtest on non-KVM environment with relaxed condition
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 28 Aug 2022 02:58:52 +0000 (11:58 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 28 Aug 2022 09:18:18 +0000 (09:18 +0000)
test/TEST-64-UDEV-STORAGE/test.sh
test/units/testsuite-64.sh

index 07b5df1d82ecb7998e29a4786bd89dc54ef1b345..6eed43cc25c4f8163f0e7a315e3da03ed630e053 100755 (executable)
@@ -207,10 +207,6 @@ testcase_nvme_basic() {
 
 # Test for issue https://github.com/systemd/systemd/issues/20212
 testcase_virtio_scsi_identically_named_partitions() {
-    if ! get_bool "$QEMU_KVM"; then
-        echo "This test requires KVM, skipping..."
-        return 77
-    fi
 
     if ! "${QEMU_BIN:?}" -device help | grep 'name "virtio-scsi-pci"'; then
         echo "virtio-scsi-pci device driver is not available, skipping test..."
@@ -221,25 +217,26 @@ testcase_virtio_scsi_identically_named_partitions() {
     # and attach them to a virtio-scsi controller
     local qemu_opts=("-device virtio-scsi-pci,id=scsi0,num_queues=4")
     local diskpath="${TESTDIR:?}/namedpart0.img"
-    local i lodev qemu_timeout
+    local i lodev num_disk num_part qemu_timeout
+
+    if get_bool "${IS_BUILT_WITH_ASAN:=}" || ! get_bool "$QEMU_KVM"; then
+        num_disk=4
+        num_part=4
+    else
+        num_disk=16
+        num_part=8
+    fi
 
     dd if=/dev/zero of="$diskpath" bs=1M count=18
     lodev="$(losetup --show -f -P "$diskpath")"
     sfdisk "${lodev:?}" <<EOF
 label: gpt
 
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
-name="Hello world", size=2M
+$(for ((i = 1; i <= num_part; i++)); do echo 'name="Hello world", size=2M'; done)
 EOF
     losetup -d "$lodev"
 
-    for i in {0..15}; do
+    for ((i = 0; i < num_disk; i++)); do
         diskpath="${TESTDIR:?}/namedpart$i.img"
         if [[ $i -gt 0 ]]; then
             cp -uv "${TESTDIR:?}/namedpart0.img" "$diskpath"
@@ -253,7 +250,13 @@ EOF
 
     # Bump the timeout when collecting test coverage, since the test is a bit
     # slower in that case
-    is_built_with_coverage && qemu_timeout=120 || qemu_timeout=60
+    if get_bool "${IS_BUILT_WITH_ASAN:=}" || ! get_bool "$QEMU_KVM"; then
+        qemu_timeout=240
+    elif is_built_with_coverage; then
+        qemu_timeout=120
+    else
+        qemu_timeout=60
+    fi
 
     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
index 2b35758213da345dd012a1a70fc645955767ea47..6704e9933c043ef4461907a3741862bbbdf47635 100755 (executable)
@@ -52,8 +52,16 @@ testcase_nvme_basic() {
 }
 
 testcase_virtio_scsi_identically_named_partitions() {
+    local num
+
+    if [[ -n "${ASAN_OPTIONS:-}" ]] || [[ "$(systemd-detect-virt -v)" == "qemu" ]]; then
+        num=$((4 * 4))
+    else
+        num=$((16 * 8))
+    fi
+
     lsblk --noheadings -a -o NAME,PARTLABEL
-    [[ "$(lsblk --noheadings -a -o NAME,PARTLABEL | grep -c "Hello world")" -eq $((16 * 8)) ]]
+    [[ "$(lsblk --noheadings -a -o NAME,PARTLABEL | grep -c "Hello world")" -eq "$num" ]]
 }
 
 testcase_multipath_basic_failover() {