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