udisks2/SOURCES/udisks-2.9.1-drive_ata_tests.patch
2021-09-10 05:27:44 +00:00

40 lines
1.3 KiB
Diff

commit 214d65ae4d2b779fc1674420a042082ae029eb6b
Author: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon Jul 13 16:16:47 2020 +0200
dbus_tests: Fix getting list of SATA drives for Drive.ATA test
Resolves: rhbz#1855785
diff --git a/src/tests/dbus-tests/test_drive_ata.py b/src/tests/dbus-tests/test_drive_ata.py
index ff6d01cc..df298a9c 100644
--- a/src/tests/dbus-tests/test_drive_ata.py
+++ b/src/tests/dbus-tests/test_drive_ata.py
@@ -14,8 +14,24 @@ SMART_ATA_CHECKSUM_FAIL = 1 << 2
smart_unsupported = set()
smart_supported = set()
-sata_disks = (dev for dev in os.listdir("/dev") if re.match(r'sd[a-z]+$', dev))
-for disk in sata_disks:
+
+DISK_PATH = "/dev/disk/by-path/"
+
+
+def _get_sata_disks():
+ sata_disks = []
+ by_path = os.listdir(DISK_PATH)
+ for dev in by_path:
+ if "ata" in dev and "part" not in dev:
+ path = os.path.realpath(os.path.join(DISK_PATH, dev))
+ name = os.path.basename(path)
+ if name.startswith("sd"):
+ # ignore devices like CD drives etc.
+ sata_disks.append(name)
+ return sata_disks
+
+
+for disk in _get_sata_disks():
ret, out = UdisksTestCase.run_command("smartctl -a /dev/%s" % disk)
# Only the following bits in the exit status mean the device failed to