]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block/011: skip when mounted block devices are affected
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 26 May 2023 04:58:42 +0000 (13:58 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 9 Jun 2023 04:53:11 +0000 (13:53 +0900)
The test case disables PCI device of the test target block device. When
the PCI device has other block devices mounted, those block devices are
disabled also. If the mounted device is the system disk, the test screws
up the system. To avoid such dangerous operation, check if the target
PCI device has mounted block devices. In that case, skip the test.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/block/011

index 4f331b4a75220edb5092340a3f0b50ead67118f3..069993615fa35392f71c2aa1db64f21ff9c0b0f0 100755 (executable)
@@ -10,12 +10,29 @@ DESCRIPTION="disable PCI device while doing I/O"
 TIMED=1
 CAN_BE_ZONED=1
 
+pci_dev_mounted() {
+       local d dev p pdev
+
+       pdev="$(_get_pci_dev_from_blkdev)"
+       for d in /sys/block/*; do
+               dev=${d##*/}
+               p=$(_get_pci_from_dev_sysfs "$d")
+               [[ $p != "$pdev" ]] && continue
+               grep -qe "/dev/$dev" /proc/mounts && return 0
+       done
+       return 1
+}
+
 requires() {
        _have_fio && _have_program setpci
 }
 
 device_requires() {
        _require_test_dev_is_pci
+       if pci_dev_mounted; then
+               SKIP_REASONS+=("mounted block device exists on test target PCI device")
+               return 1
+       fi
 }
 
 test_device() {