diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0/device new file mode 120000 index 000000000..5be613c3c --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0/device @@ -0,0 +1 @@ +../../../6:0:0:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb/device new file mode 120000 index 000000000..420088f24 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb/device @@ -0,0 +1 @@ +../../../6:0:1:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/ata_link/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/ata_link/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/ata_link/link7/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/ata_link/link7/device new file mode 120000 index 000000000..592725223 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/ata_link/link7/device @@ -0,0 +1 @@ +../../../link7 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.0/ata_device/dev7.0/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.0/ata_device/dev7.0/device new file mode 120000 index 000000000..79f3f95a8 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.0/ata_device/dev7.0/device @@ -0,0 +1 @@ +../../../dev7.0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.0/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.0/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.1/ata_device/dev7.1/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.1/ata_device/dev7.1/device new file mode 120000 index 000000000..8ef79ff84 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.1/ata_device/dev7.1/device @@ -0,0 +1 @@ +../../../dev7.1 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.1/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:01.1/ata7/link7/dev7.1/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda/device new file mode 120000 index 000000000..79ba80254 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda/device @@ -0,0 +1 @@ +../../../0:0:0:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:03.0/ata1/host0/target0:0:0/0:0:0:0/block/sda/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd/device new file mode 120000 index 000000000..f083126c1 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd/device @@ -0,0 +1 @@ +../../../9:0:0:0/ \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:06.7/usb1/1-1/1-1:1.0/host9/target9:0:0/9:0:0:0/block/sdd/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:07.0/virtio1/block/vda/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:07.0/virtio1/block/vda/device new file mode 120000 index 000000000..9cc4643ad --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:07.0/virtio1/block/vda/device @@ -0,0 +1 @@ +../../../virtio1 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:07.0/virtio1/block/vda/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:07.0/virtio1/block/vda/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde/device new file mode 120000 index 000000000..761363536 --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde/device @@ -0,0 +1 @@ +../../../10:0:1:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0a.0/host10/target10:0:1/10:0:1:0/block/sde/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc/device b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc/device new file mode 120000 index 000000000..04ec5f3be --- /dev/null +++ b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc/device @@ -0,0 +1 @@ +../../../8:0:0:0 \ No newline at end of file diff --git a/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc/foo b/tests/devicelibs_test/edd_data/absurd_virt/sys/devices/pci0000:00/0000:00:0b.0/virtio3/host8/target8:0:0/8:0:0:0/block/sdc/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py index 380d8da59..1f147c2ac 100644 --- a/tests/devicelibs_test/edd_test.py +++ b/tests/devicelibs_test/edd_test.py @@ -73,7 +73,7 @@ def tearDown(self): edd.testdata_log.removeHandler(self.td_log_handler) super(EddTestCase, self).tearDown() - def check_logs(self, debugs=None, infos=None, warnings=None, errors=None): + def checkLogs(self, debugs=None, infos=None, warnings=None, errors=None): def check(left, right_object): newleft = [mock.call(*x) for x in left or []] right = copy.copy(right_object.call_args_list or []) @@ -137,7 +137,7 @@ def test_collect_edd_data_sata_usb(self): lib.assertVerboseEqual(len(edd_dict), 2) lib.assertVerboseEqual(fakeedd[0x80], edd_dict[0x80]) lib.assertVerboseEqual(fakeedd[0x81], edd_dict[0x81]) - self.check_logs(debugs=debugs) + self.checkLogs(debugs=debugs) def test_get_edd_dict_sata_usb(self): # test with sata sda, usb sdb @@ -191,4 +191,171 @@ def test_get_edd_dict_sata_usb(self): "/sys/firmware/edd/int13_dev81/"), ("edd: interface details: %s", "USB \tserial_number: 30302e31"), ] - self.check_logs(debugs=debugs, infos=infos, warnings=warnings) + self.checkLogs(debugs=debugs, infos=infos, warnings=warnings) + + def test_collect_edd_data_absurd_virt(self): + self._edd_logger.debug("starting test %s", self._testMethodName) + edd.testdata_log.debug("starting test %s", self._testMethodName) + # siiiigh - this is actually the data out of sysfs on a virt I have + # created. Apparently even qemu claims 3.0 sometimes and gives us + # bad data. + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x86531966", + sectors=10485760, host_bus="PCI", type="SCSI", + pci_dev="00:07.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfspath="/sys/firmware/edd/int13_dev80/"), + 0x81: FakeEddEntry(version="0x30", mbr_sig="0x7dfff0db", + sectors=209716, host_bus="PCI", type="ATA", + pci_dev="00:01.1", channel=0, + interface="ATA \tdevice: 1", ata_device=1, + sysfspath="/sys/firmware/edd/int13_dev81/"), + 0x82: FakeEddEntry(version="0x30", mbr_sig="0xe3bf124b", + sectors=419432, + sysfspath="/sys/firmware/edd/int13_dev82/"), + 0x83: FakeEddEntry(version="0x30", mbr_sig="0xfa0a111d", + sectors=629146, + sysfspath="/sys/firmware/edd/int13_dev83/"), + 0x84: FakeEddEntry(version="0x30", mbr_sig="0x63f1d7d8", + sectors=838862, host_bus="PCI", type="SCSI", + pci_dev="00:0b.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfspath="/sys/firmware/edd/int13_dev84/"), + 0x85: FakeEddEntry(version="0x30", mbr_sig="0xee331b19", + sectors=1258292, + sysfspath="/sys/firmware/edd/int13_dev85/"), + } + edd_dict = edd.collect_edd_data(root=self.root('absurd_virt')) + self.debug('edd_dict: %s', edd_dict) + lib.assertVerboseEqual(len(edd_dict), 6) + lib.assertVerboseEqual(fakeedd[0x80], edd_dict[0x80]) + lib.assertVerboseEqual(fakeedd[0x81], edd_dict[0x81]) + lib.assertVerboseEqual(fakeedd[0x82], edd_dict[0x82]) + lib.assertVerboseEqual(fakeedd[0x83], edd_dict[0x83]) + lib.assertVerboseEqual(fakeedd[0x84], edd_dict[0x84]) + lib.assertVerboseEqual(fakeedd[0x85], edd_dict[0x85]) + debugs = [ + ("edd: found device 0x%x at %s", 0x80, + '/sys/firmware/edd/int13_dev80/'), + ("edd: found device 0x%x at %s", 0x81, + '/sys/firmware/edd/int13_dev81/'), + ("edd: found device 0x%x at %s", 0x82, + '/sys/firmware/edd/int13_dev82/'), + ("edd: found device 0x%x at %s", 0x83, + '/sys/firmware/edd/int13_dev83/'), + ("edd: found device 0x%x at %s", 0x84, + '/sys/firmware/edd/int13_dev84/'), + ("edd: found device 0x%x at %s", 0x85, + '/sys/firmware/edd/int13_dev85/'), + ] + self.checkLogs(debugs=debugs) + + def test_get_edd_dict_absurd_virt(self): + self._edd_logger.debug("starting test %s", self._testMethodName) + edd.testdata_log.debug("starting test %s", self._testMethodName) + # siiiigh - this is actually the data out of sysfs on a virt I have + # created. Apparently even qemu claims 3.0 sometimes and gives us + # bad data. + fakeedd = { + 0x80: FakeEddEntry(version="0x30", mbr_sig="0x86531966", + sectors=10485760, host_bus="PCI", type="SCSI", + pci_dev="00:07.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfspath="/sys/firmware/edd/int13_dev80/", + sysfslink="../devices/pci0000:00"\ + "/0000:00:07.0/virtio1/block/vda"), + 0x81: FakeEddEntry(version="0x30", mbr_sig="0x7dfff0db", + sectors=209716, host_bus="PCI", type="ATA", + pci_dev="00:01.1", channel=0, + interface="ATA \tdevice: 1", ata_device=1, + sysfslink="../devices/pci0000:00/0000:00:01.1/"\ + "ata7/host6/target6:0:1/6:0:1:0/"\ + "block/sdb", + sysfspath="/sys/firmware/edd/int13_dev81/"), + 0x82: FakeEddEntry(version="0x30", mbr_sig="0xe3bf124b", + sectors=419432, + sysfslink="../devices/pci0000:00/0000:00:03.0/"\ + "ata1/host0/target0:0:0/0:0:0:0/"\ + "block/sda", + sysfspath="/sys/firmware/edd/int13_dev82/"), + 0x83: FakeEddEntry(version="0x30", mbr_sig="0xfa0a111d", + sectors=629146, + sysfslink="../devices/pci0000:00/0000:00:0a.0/"\ + "host10/target10:0:1/10:0:1:0/"\ + "block/sde", + sysfspath="/sys/firmware/edd/int13_dev83/"), + 0x84: FakeEddEntry(version="0x30", mbr_sig="0x63f1d7d8", + sectors=838862, host_bus="PCI", type="SCSI", + pci_dev="00:0b.0", channel=0, scsi_id=0, + scsi_lun=0, interface="SCSI \tid: 0 lun: 0", + sysfslink="../devices/pci0000:00/0000:00:0b.0/"\ + "virtio3/host8/target8:0:0/8:0:0:0/"\ + "block/sdc", + sysfspath="/sys/firmware/edd/int13_dev84/"), + 0x85: FakeEddEntry(version="0x30", mbr_sig="0xee331b19", + sectors=1258292, + sysfslink="../devices/pci0000:00/0000:00:06.7/"\ + "usb1/1-1/1-1:1.0/host9/target9:0:0/"\ + "9:0:0:0/block/sdd", + sysfspath="/sys/firmware/edd/int13_dev85/"), + } + devices=(FakeDevice("sda"), + FakeDevice("sdb"), + FakeDevice("sdc"), + FakeDevice("sdd"), + FakeDevice("sde"), + FakeDevice("vda"), + ) + + edd_dict = edd.get_edd_dict(devices, root=self.root("absurd_virt")) + self.debug('edd_dict: %s', edd_dict) + lib.assertVerboseEqual(len(edd_dict), 6) + # this order is *completely unlike* the order in virt-manager, + # but it does appear to be what EDD is displaying. + lib.assertVerboseEqual(edd_dict["vda"], 0x80) + lib.assertVerboseEqual(edd_dict["sdb"], 0x81) + lib.assertVerboseEqual(edd_dict["sda"], 0x82) + lib.assertVerboseEqual(edd_dict["sde"], 0x83) + lib.assertVerboseEqual(edd_dict["sdc"], 0x84) + lib.assertVerboseEqual(edd_dict["sdd"], 0x85) + debugs = [ + ("edd: data extracted from 0x%x:%r", 0x80, fakeedd[0x80]), + ("edd: data extracted from 0x%x:%r", 0x81, fakeedd[0x81]), + ("edd: data extracted from 0x%x:%r", 0x82, fakeedd[0x82]), + ("edd: data extracted from 0x%x:%r", 0x83, fakeedd[0x83]), + ("edd: data extracted from 0x%x:%r", 0x84, fakeedd[0x84]), + ("edd: data extracted from 0x%x:%r", 0x85, fakeedd[0x85]), + ("edd: found device 0x%x at %s", 0x80, + '/sys/firmware/edd/int13_dev80/'), + ("edd: found device 0x%x at %s", 0x81, + '/sys/firmware/edd/int13_dev81/'), + ("edd: found device 0x%x at %s", 0x82, + '/sys/firmware/edd/int13_dev82/'), + ("edd: found device 0x%x at %s", 0x83, + '/sys/firmware/edd/int13_dev83/'), + ("edd: found device 0x%x at %s", 0x84, + '/sys/firmware/edd/int13_dev84/'), + ("edd: found device 0x%x at %s", 0x85, + '/sys/firmware/edd/int13_dev85/'), + ] + infos = [ + ("edd: collected mbr signatures: %s",{ 'vda': '0x86531966', + 'sda': '0xe3bf124b', + 'sdb': '0x7dfff0db', + 'sdc': '0x63f1d7d8', + 'sdd': '0xee331b19', + 'sde': '0xfa0a111d', + }), + ("edd: matched 0x%x to %s using PCI dev", 0x80, "vda"), + ("edd: matched 0x%x to %s using PCI dev", 0x81, "sdb"), + ("edd: matched 0x%x to %s using MBR sig", 0x82, "sda"), + ("edd: matched 0x%x to %s using MBR sig", 0x83, "sde"), + ("edd: matched 0x%x to %s using PCI dev", 0x84, "sdc"), + ("edd: matched 0x%x to %s using MBR sig", 0x85, "sdd"), + ('edd: Could not find Virtio device for pci dev %s channel %s', '00:01.1', 0), + ('edd: Could not find Virtio device for pci dev %s channel %s', '00:0b.0', 0), + ] + errors = [ + ('edd: Found too many ATA devices for EDD device 0x%x: %s', 129, ['../devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:1/6:0:1:0/block/sdb', '../devices/pci0000:00/0000:00:01.1/ata7/host6/target6:0:0/6:0:0:0/block/sr0']), + ] + self.checkLogs(debugs=debugs, infos=infos, errors=errors)