def testCPUMap(self): caps = self._buildCaps("libvirt-0.7.6-qemu-caps.xml") cpu_64 = caps.get_cpu_values(None, "x86_64") cpu_32 = caps.get_cpu_values(None, "i486") cpu_random = caps.get_cpu_values(None, "mips") def test_cpu_map(cpumap, cpus): cpunames = sorted([c.model for c in cpumap], key=str.lower) for c in cpus: self.assertTrue(c in cpunames) self.assertEquals(cpu_64, cpu_32) x86_cpunames = [ '486', 'athlon', 'Conroe', 'core2duo', 'coreduo', 'n270', 'Nehalem', 'Opteron_G1', 'Opteron_G2', 'Opteron_G3', 'Penryn', 'pentium', 'pentium2', 'pentium3', 'pentiumpro', 'phenom', 'qemu32', 'qemu64'] test_cpu_map(cpu_64, x86_cpunames) test_cpu_map(cpu_random, []) conn = utils.open_testdriver() cpu_64 = caps.get_cpu_values(conn, "x86_64") self.assertTrue(len(cpu_64) > 0)
def testCPUMap(self): _CPUMapFileValues.update_cpu_filename("tests/capabilities-xml/cpu_map.xml") caps = self._buildCaps("libvirt-0.7.6-qemu-caps.xml") cpu_64 = caps.get_cpu_values(None, "x86_64") cpu_32 = caps.get_cpu_values(None, "i486") cpu_random = caps.get_cpu_values(None, "mips") def test_cpu_map(cpumap, cpus): cpunames = sorted([c.model for c in cpumap], key=str.lower) for c in cpus: self.assertTrue(c in cpunames) self.assertEquals(cpu_64, cpu_32) x86_cpunames = [ '486', 'athlon', 'Conroe', 'core2duo', 'coreduo', 'n270', 'Nehalem', 'Opteron_G1', 'Opteron_G2', 'Opteron_G3', 'Penryn', 'pentium', 'pentium2', 'pentium3', 'pentiumpro', 'phenom', 'qemu32', 'qemu64'] test_cpu_map(cpu_64, x86_cpunames) test_cpu_map(cpu_random, []) conn = utils.open_testdriver() cpu_64 = caps.get_cpu_values(conn, "x86_64") self.assertTrue(len(cpu_64) > 0)
def _clone_helper(self, filebase, disks=None, force_list=None, skip_list=None, compare=True, conn=None, clone_disks_file=None): """Helper for comparing clone input/output from 2 xml files""" infile = os.path.join(clonexml_dir, filebase + "-in.xml") in_content = utils.read_file(infile) if not conn: conn = utils.open_testdriver() cloneobj = Cloner(conn) cloneobj.original_xml = in_content for force in force_list or []: cloneobj.force_target = force for skip in skip_list or []: cloneobj.skip_target = skip cloneobj = self._default_clone_values(cloneobj, disks) if compare: self._clone_compare(cloneobj, filebase, clone_disks_file=clone_disks_file) self._clone_define(filebase) else: cloneobj.setup_original() cloneobj.setup_clone()
def _clone_define(self, filebase): """Take the valid output xml and attempt to define it on the connection to ensure we don't get any errors""" outfile = os.path.join(clonexml_dir, filebase + "-out.xml") outxml = utils.read_file(outfile) conn = utils.open_testdriver() utils.test_create(conn, outxml)
def testDomainCapabilities(self): xml = open("tests/capabilities-xml/test-domcaps.xml").read() caps = DomainCapabilities(utils.open_testdriver(), xml) self.assertEqual(caps.os.loader.supported, True) self.assertEqual(caps.os.loader.get_values(), ["/foo/bar", "/tmp/my_path"]) self.assertEqual(caps.os.loader.enum_names(), ["type", "readonly"]) self.assertEqual( caps.os.loader.get_enum("type").get_values(), ["rom", "pflash"])
def testDomainCapabilities(self): xml = file("tests/capabilities-xml/test-domcaps.xml").read() caps = DomainCapabilities(utils.open_testdriver(), xml) self.assertEqual(caps.os.loader.supported, True) self.assertEquals(caps.os.loader.get_values(), ["/foo/bar", "/tmp/my_path"]) self.assertEquals(caps.os.loader.enum_names(), ["type", "readonly"]) self.assertEquals(caps.os.loader.get_enum("type").get_values(), ["rom", "pflash"])
def test_recommended_resources(self): conn = utils.open_testdriver() guest = conn.caps.lookup_virtinst_guest() assert not OSDB.lookup_os("generic").get_recommended_resources(guest) res = OSDB.lookup_os("fedora21").get_recommended_resources(guest) assert res["n-cpus"] == 2 guest.type = "qemu" res = OSDB.lookup_os("fedora21").get_recommended_resources(guest) assert res["n-cpus"] == 1
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA. import glob import traceback import unittest import virtinst from tests import utils conn = utils.open_testdriver() kvmconn = utils.open_kvm() def sanitize_file_xml(xml): # s/"/'/g from generated XML, matches what libxml dumps out # This won't work all the time, but should be good enough for testing return xml.replace("'", "\"") class XMLParseTest(unittest.TestCase): def _roundtrip_compare(self, filename): expectXML = sanitize_file_xml(file(filename).read()) guest = virtinst.Guest(conn, parsexml=expectXML) actualXML = guest.get_xml_config() utils.diff_compare(actualXML, expect_out=expectXML)
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA. import unittest import os import virtinst from virtinst import VirtualDisk from virtcli import CLIConfig from tests import utils _default_conn = utils.open_testdriver() def _make_guest(installer=None, conn=None, os_variant=None): if conn is None: conn = _default_conn g = conn.caps.lookup_virtinst_guest() g.type = "kvm" g.name = "TestGuest" g.memory = int(200 * 1024) g.maxmemory = int(400 * 1024) g.uuid = "12345678-1234-1234-1234-123456789012" gdev = virtinst.VirtualGraphics(conn) gdev.type = "vnc" gdev.keymap = "ja"
DISKPOOL = "/dev/disk-pool" local_files = [FILE1, FILE2] clonexml_dir = os.path.join(os.getcwd(), "tests/clone-xml") clone_files = [] for tmpf in os.listdir(clonexml_dir): black_list = ["managed-storage", "cross-pool", "force", "skip", "fullpool"] if tmpf.endswith("-out.xml"): tmpf = tmpf[0:(len(tmpf) - len("-out.xml"))] if tmpf not in clone_files and tmpf not in black_list: clone_files.append(tmpf) conn = utils.open_testdriver() class TestClone(unittest.TestCase): def setUp(self): for f in local_files: os.system("touch %s" % f) def tearDown(self): for f in local_files: os.unlink(f) def _clone_helper(self, filebase, disks=None, force_list=None, skip_list=None, compare=True, useconn=None): """Helper for comparing clone input/output from 2 xml files"""
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA. import unittest import os import virtinst from virtinst import VirtualDisk from virtcli import CLIConfig from tests import utils _default_conn = utils.open_testdriver() def _make_guest(installer=None, conn=None): if conn is None: conn = _default_conn g = virtinst.Guest(conn) g.type = "kvm" g.name = "TestGuest" g.memory = int(200 * 1024) g.maxmemory = int(400 * 1024) g.uuid = "12345678-1234-1234-1234-123456789012" gdev = virtinst.VirtualGraphics(conn) gdev.type = "vnc" gdev.keymap = "ja"