d3c43a
From 1358d1e5208d71d5a70f17a242eda00f079a9d0b Mon Sep 17 00:00:00 2001
d3c43a
From: Tomas Bzatek <tbzatek@redhat.com>
d3c43a
Date: Thu, 22 Apr 2021 18:20:48 +0200
d3c43a
Subject: [PATCH 2/2] tests: Handle missing /dev/disk/by-path gracefully
d3c43a
d3c43a
Limited testing environments may not have this path always available.
d3c43a
---
d3c43a
 src/tests/dbus-tests/test_drive_ata.py | 19 +++++++++++--------
d3c43a
 1 file changed, 11 insertions(+), 8 deletions(-)
d3c43a
d3c43a
diff --git a/src/tests/dbus-tests/test_drive_ata.py b/src/tests/dbus-tests/test_drive_ata.py
d3c43a
index e91bd02f..37740c60 100644
d3c43a
--- a/src/tests/dbus-tests/test_drive_ata.py
d3c43a
+++ b/src/tests/dbus-tests/test_drive_ata.py
d3c43a
@@ -20,14 +20,17 @@ DISK_PATH = "/dev/disk/by-path/"
d3c43a
 
d3c43a
 def _get_sata_disks():
d3c43a
     sata_disks = []
d3c43a
-    by_path = os.listdir(DISK_PATH)
d3c43a
-    for dev in by_path:
d3c43a
-        if "ata" in dev and "part" not in dev:
d3c43a
-            path = os.path.realpath(os.path.join(DISK_PATH, dev))
d3c43a
-            name = os.path.basename(path)
d3c43a
-            if name.startswith("sd"):
d3c43a
-                # ignore devices like CD drives etc.
d3c43a
-                sata_disks.append(name)
d3c43a
+    try:
d3c43a
+        by_path = os.listdir(DISK_PATH)
d3c43a
+        for dev in by_path:
d3c43a
+            if "ata" in dev and "part" not in dev:
d3c43a
+                path = os.path.realpath(os.path.join(DISK_PATH, dev))
d3c43a
+                name = os.path.basename(path)
d3c43a
+                if name.startswith("sd"):
d3c43a
+                    # ignore devices like CD drives etc.
d3c43a
+                    sata_disks.append(name)
d3c43a
+    except:
d3c43a
+        pass
d3c43a
     return sata_disks
d3c43a
 
d3c43a
 
d3c43a
-- 
d3c43a
2.30.2
d3c43a