def test_misc_cpu_topology(): """ Various topology calculation corner cases """ conn = utils.URIs.open_testdefault_cached() cpu = virtinst.DomainCpu(conn) cpu.set_topology_defaults(6) assert cpu.topology.sockets is None cpu.topology.sockets = "2" cpu.set_topology_defaults(6) def get_top(_c): return [_c.topology.sockets, _c.topology.cores, _c.topology.threads] assert get_top(cpu) == [2, 3, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.cores = "4" cpu.set_topology_defaults(9) assert get_top(cpu) == [2, 4, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.threads = "3" cpu.set_topology_defaults(14) assert get_top(cpu) == [4, 1, 3] cpu = virtinst.DomainCpu(conn) cpu.topology.sockets = 5 cpu.topology.cores = 2 assert cpu.vcpus_from_topology() == 10 cpu = virtinst.DomainCpu(conn) assert cpu.vcpus_from_topology() == 1
def testCPUTopology(self): # Test CPU topology determining cpu = virtinst.DomainCpu(self.conn) cpu.set_topology_defaults(6) assert cpu.topology.sockets is None cpu.topology.sockets = "2" cpu.set_topology_defaults(6) def get_top(_c): return [_c.topology.sockets, _c.topology.cores, _c.topology.threads] self.assertEqual(get_top(cpu), [2, 3, 1]) cpu = virtinst.DomainCpu(self.conn) cpu.topology.cores = "4" cpu.set_topology_defaults(9) self.assertEqual(get_top(cpu), [2, 4, 1]) cpu = virtinst.DomainCpu(self.conn) cpu.topology.threads = "3" cpu.set_topology_defaults(14) self.assertEqual(get_top(cpu), [4, 1, 3]) cpu = virtinst.DomainCpu(self.conn) cpu.topology.sockets = 5 cpu.topology.cores = 2 self.assertEqual(cpu.vcpus_from_topology(), 10) cpu = virtinst.DomainCpu(self.conn) self.assertEqual(cpu.vcpus_from_topology(), 1)
def test_misc_cpu_topology(): """ Various topology calculation corner cases """ conn = utils.URIs.open_testdefault_cached() def get_top(_c): return [_c.topology.sockets, _c.topology.dies, _c.topology.cores, _c.topology.threads] cpu = virtinst.DomainCpu(conn) cpu.set_topology_defaults(6) assert cpu.topology.sockets is None cpu = virtinst.DomainCpu(conn) cpu.set_topology_defaults(6, create=True) assert get_top(cpu) == [1, 1, 6, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.sockets = "2" cpu.set_topology_defaults(6) assert get_top(cpu) == [2, 1, 3, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.dies = "3" cpu.set_topology_defaults(9) assert get_top(cpu) == [1, 3, 3, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.cores = "4" cpu.set_topology_defaults(8) assert get_top(cpu) == [2, 1, 4, 1] cpu = virtinst.DomainCpu(conn) cpu.topology.threads = "3" cpu.set_topology_defaults(12) assert get_top(cpu) == [1, 1, 4, 3] cpu = virtinst.DomainCpu(conn) cpu.topology.threads = "3" try: cpu.set_topology_defaults(14) assert False, "Topology unexpectedly validated" except ValueError: pass cpu = virtinst.DomainCpu(conn) cpu.topology.sockets = 5 cpu.topology.cores = 2 assert cpu.vcpus_from_topology() == 10 cpu = virtinst.DomainCpu(conn) cpu.topology.sockets = 3 cpu.topology.dies = 2 cpu.topology.cores = 2 assert cpu.vcpus_from_topology() == 12 cpu = virtinst.DomainCpu(conn) assert cpu.vcpus_from_topology() == 1
def testCPUTopology(self): # Test CPU topology determining cpu = virtinst.DomainCpu(self.conn) cpu.sockets = "2" cpu.set_topology_defaults(6) self.assertEqual([cpu.sockets, cpu.cores, cpu.threads], [2, 3, 1]) cpu = virtinst.DomainCpu(self.conn) cpu.cores = "4" cpu.set_topology_defaults(9) self.assertEqual([cpu.sockets, cpu.cores, cpu.threads], [2, 4, 1]) cpu = virtinst.DomainCpu(self.conn) cpu.threads = "3" cpu.set_topology_defaults(14) self.assertEqual([cpu.sockets, cpu.cores, cpu.threads], [4, 1, 3]) cpu = virtinst.DomainCpu(self.conn) cpu.sockets = 5 cpu.cores = 2 self.assertEqual(cpu.vcpus_from_topology(), 10) cpu = virtinst.DomainCpu(self.conn) self.assertEqual(cpu.vcpus_from_topology(), 1)