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