def test_false_match(self): address_str = "0000:0a:00.5" phys_addr1 = devspec.PhysicalPciAddress(address_str) addresses = ["0010:0a:00.5", "0000:0b:00.5", "0000:0a:01.5", "0000:0a:00.4"] for address in addresses: phys_addr2 = devspec.PhysicalPciAddress(address) self.assertFalse(phys_addr1.match(phys_addr2))
def test_init_by_string(self): address_str = "0000:0a:00.5" phys_addr = devspec.PhysicalPciAddress(address_str) self.assertEqual(phys_addr.domain, "0000") self.assertEqual(phys_addr.bus, "0a") self.assertEqual(phys_addr.slot, "00") self.assertEqual(phys_addr.func, "5")
def test_false_match(self): address_str = "0000:0a:00.5" phys_addr = devspec.PhysicalPciAddress(address_str) addresses = ["0010:0a:00.5", "0000:0b:00.5", "*:0a:01.5", "0000:0a:*.4"] for address in addresses: glob_addr = devspec.PciAddressGlobSpec(address) self.assertFalse(phys_addr.match(glob_addr))
def test_match(self): address_str = "0000:0a:00.5" phys_addr = devspec.PhysicalPciAddress(address_str) addresses = ["0000:0a:00.5", "*:0a:00.5", "0000:*:00.5", "0000:0a:*.5", "0000:0a:00.*"] for address in addresses: glob_addr = devspec.PciAddressGlobSpec(address) self.assertTrue(glob_addr.match(phys_addr))
def test_false_match(self): address_str = "0000:0b:00.5" phys_addr = devspec.PhysicalPciAddress(address_str) addresses = [{"domain": ".*", "bus": "0a", "slot": "00", "function": "[5-6]"}, {"domain": ".*", "bus": "02", "slot": ".*", "function": "[4-5]"}, {"domain": ".*", "bus": "02", "slot": "[0-3]", "function": ".*"}] for address in addresses: regex_addr = devspec.PciAddressRegexSpec(address) self.assertFalse(regex_addr.match(phys_addr))
def test_match(self): address_str = "0000:0a:00.5" phys_addr1 = devspec.PhysicalPciAddress(address_str) phys_addr2 = devspec.PhysicalPciAddress(address_str) self.assertTrue(phys_addr1.match(phys_addr2))
def test_init_by_dict(self): phys_addr = devspec.PhysicalPciAddress(self.pci_addr) self.assertEqual(phys_addr.domain, self.pci_addr['domain']) self.assertEqual(phys_addr.bus, self.pci_addr['bus']) self.assertEqual(phys_addr.slot, self.pci_addr['slot']) self.assertEqual(phys_addr.func, self.pci_addr['function'])