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