# 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..."
# 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"
# 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
}
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() {