[rhel6-branch] edd: fix syntax in situation when two edd directories point to the same device.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adds a unit test for this case.

Resolves: rhbz#725777
---
 storage/devicelibs/edd.py            |    2 +-
 tests/storage/devicelibs/edd_test.py |   31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/storage/devicelibs/edd.py b/storage/devicelibs/edd.py
index 86abca4..d494ec2 100644
--- a/storage/devicelibs/edd.py
+++ b/storage/devicelibs/edd.py
@@ -218,7 +218,7 @@ def get_edd_dict(devices):
             old_edd_number = edd_dict.get(name)
             if old_edd_number:
                 log.info("edd: both edd entries 0x%x and 0x%x seem to map to %s" %
-                          old_edd_number, edd_number, name)
+                          (old_edd_number, edd_number, name))
                 # this means all the other data can be confused and useless
                 return {}
             edd_dict[name] = edd_number
diff --git a/tests/storage/devicelibs/edd_test.py b/tests/storage/devicelibs/edd_test.py
index 00a91b4..60b1e43 100644
--- a/tests/storage/devicelibs/edd_test.py
+++ b/tests/storage/devicelibs/edd_test.py
@@ -102,6 +102,21 @@ class EddTestCase(mock.TestCase):
                          {'sda' : 0x80,
                           'vda' : 0x81})
 
+    def test_get_edd_dict_3(self):
+        """ Test scenario when the 0x80 and 0x81 edd directories contain the
+            same data and give no way to distinguish among the two devices.
+        """
+        from storage.devicelibs import edd
+        edd.log = mock.Mock()
+        edd.collect_mbrs = mock.Mock(return_value = {
+                'sda' : '0x000ccb01',
+                'vda' : '0x0006aef1'})
+        fs = EddTestFS(edd).sda_sdb_same()
+        self.assertEqual(edd.get_edd_dict([]),
+                         {})
+        self.assertIn((('edd: both edd entries 0x80 and 0x81 seem to map to sda',), {}),
+                      edd.log.info.call_args_list)
+
 class EddTestFS(object):
     def __init__(self, target_module):
         self.fs = mock.DiskIO()
@@ -161,3 +176,19 @@ class EddTestFS(object):
         self.fs["/sys/firmware/edd/int13_dev81/sectors"] = "4194304\n"
 
         return self.fs
+
+    def sda_sdb_same(self):
+        self.fs["/sys/firmware/edd/int13_dev80"] = self.fs.Dir()
+        self.fs["/sys/firmware/edd/int13_dev80/host_bus"] = "PCI 	00:01.1  channel: 0\n"
+        self.fs["/sys/firmware/edd/int13_dev80/interface"] = "ATA     	device: 0\n"
+        self.fs["/sys/firmware/edd/int13_dev80/mbr_signature"] = "0x000ccb01"
+        self.fs["/sys/firmware/edd/int13_dev80/sectors"] = "2097152\n"
+
+        self.fs["/sys/firmware/edd/int13_dev81"] = self.fs.Dir()
+        self.fs["/sys/firmware/edd/int13_dev81/host_bus"] = "PCI 	00:01.1  channel: 0\n"
+        self.fs["/sys/firmware/edd/int13_dev81/interface"] = "ATA     	device: 0\n"
+        self.fs["/sys/firmware/edd/int13_dev81/mbr_signature"] = "0x0006aef1"
+        self.fs["/sys/firmware/edd/int13_dev81/sectors"] = "2097152\n"
+
+        self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block"] = self.fs.Dir()
+        self.fs["/sys/devices/pci0000:00/0000:00:01.1/host0/target0:0:0/0:0:0:0/block/sda"] = self.fs.Dir()
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux