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