summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2011-07-25 15:57:19 +0200
committerAles Kozumplik <akozumpl@redhat.com>2011-07-26 08:30:03 +0200
commit5a846a0748ab16c73e9c45b1e86b3e00283831f4 (patch)
treebb914a6a6e4c3347b524554b1530208ac42eb746 /tests
parente069a71aedf7837be862c91990fe45fdeca8f8b7 (diff)
downloadanaconda-5a846a0748ab16c73e9c45b1e86b3e00283831f4.tar.gz
anaconda-5a846a0748ab16c73e9c45b1e86b3e00283831f4.tar.xz
anaconda-5a846a0748ab16c73e9c45b1e86b3e00283831f4.zip
edd: do not traceback when can not find the respective pci device.
Resolves: rhbz#723344
Diffstat (limited to 'tests')
-rw-r--r--tests/mock/disk.py9
-rw-r--r--tests/storage_test/devicelibs_test/edd_test.py17
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/mock/disk.py b/tests/mock/disk.py
index 424e08c21..fbd61815f 100644
--- a/tests/mock/disk.py
+++ b/tests/mock/disk.py
@@ -25,6 +25,7 @@ _orig_glob_glob = glob.glob
_orig_open = open
_orig_os_listdir = os.listdir
_orig_os_path_exists = os.path.exists
+_orig_os_path_isdir = os.path.isdir
class DiskIO(object):
"""Simple object to simplify mocking of file operations in Mock
@@ -117,6 +118,12 @@ class DiskIO(object):
path = os.path.join(self._pwd, path)
return self.fs.has_key(path)
+ def os_path_isdir(self, path):
+ if not path.endswith("/"):
+ path += "/"
+ path += "*"
+ return len(fnmatch.filter(self.fs.keys(), path)) > 0
+
def os_remove(self, path):
path = os.path.join(self._pwd, path)
try:
@@ -137,6 +144,7 @@ class DiskIO(object):
module.glob.glob = self.glob_glob
module.os.listdir = self.os_listdir
module.os.path.exists = self.os_path_exists
+ module.os.path.isdir = self.os_path_isdir
@staticmethod
def restore_module(module):
@@ -144,3 +152,4 @@ class DiskIO(object):
module.glob.glob = _orig_glob_glob
module.os.listdir = _orig_os_listdir
module.os.path.exists = _orig_os_path_exists
+ module.os.path.isdir = _orig_os_path_isdir
diff --git a/tests/storage_test/devicelibs_test/edd_test.py b/tests/storage_test/devicelibs_test/edd_test.py
index e28990b0c..17952fbbe 100644
--- a/tests/storage_test/devicelibs_test/edd_test.py
+++ b/tests/storage_test/devicelibs_test/edd_test.py
@@ -66,6 +66,15 @@ class EddTestCase(mock.TestCase):
path = analyzer.devname_from_pci_dev()
self.assertEqual(path, "vda")
+ def test_bad_device_path(self):
+ from pyanaconda.storage.devicelibs import edd
+ fs = EddTestFS(edd).sda_vda_no_pcidev()
+ edd_dict = edd.collect_edd_data()
+
+ analyzer = edd.EddMatcher(edd_dict[0x80])
+ path = analyzer.devname_from_pci_dev()
+ self.assertEqual(path, None)
+
def test_get_edd_dict_1(self):
""" Test get_edd_dict()'s pci_dev matching. """
from pyanaconda.storage.devicelibs import edd
@@ -85,8 +94,6 @@ class EddTestCase(mock.TestCase):
{'sda' : 0x80,
'vda' : 0x81})
-
-
class EddTestFS(object):
def __init__(self, target_module):
self.fs = mock.DiskIO()
@@ -119,6 +126,12 @@ class EddTestFS(object):
return self.fs
+ def sda_vda_no_pcidev(self):
+ self.sda_vda()
+ entries = [e for e in self.fs.fs if e.startswith("/sys/devices/pci")]
+ map(self.fs.os_remove, entries)
+ return self.fs
+
def vda_vdb(self):
self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir()
self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 00:05.0 channel: 0\n"