neil / rpms / udisks2

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