[virt-tools-list] [PATCH 2/2] Add and fix test cases for cpu mode attribute

Hu Tao hutao at cn.fujitsu.com
Fri Mar 29 07:09:27 UTC 2013


From: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>

This patch adds and fixes test cases for cpu mode attribute.

Signed-off-by: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>
Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
---
 tests/cli-test-xml/compare/kvm-f14-url.xml      |  4 ++--
 tests/cli-test-xml/compare/qemu-plain.xml       |  2 +-
 tests/xmlconfig-xml/boot-cpuset.xml             |  2 +-
 tests/xmlparse-xml/change-cpumode-in.xml        | 19 +++++++++++++++++++
 tests/xmlparse-xml/change-cpumode-out.xml       | 21 +++++++++++++++++++++
 tests/xmlparse-xml/change-guest-in.xml          |  2 +-
 tests/xmlparse-xml/change-guest-out.xml         |  2 +-
 tests/xmlparse-xml/change-minimal-guest-out.xml |  2 +-
 tests/xmlparse-xml/change-smartcard-in.xml      |  2 +-
 tests/xmlparse-xml/change-smartcard-out.xml     |  2 +-
 tests/xmlparse.py                               | 13 +++++++++++++
 11 files changed, 62 insertions(+), 9 deletions(-)
 create mode 100644 tests/xmlparse-xml/change-cpumode-in.xml
 create mode 100644 tests/xmlparse-xml/change-cpumode-out.xml

diff --git a/tests/cli-test-xml/compare/kvm-f14-url.xml b/tests/cli-test-xml/compare/kvm-f14-url.xml
index 323f6a6..84bc59c 100644
--- a/tests/cli-test-xml/compare/kvm-f14-url.xml
+++ b/tests/cli-test-xml/compare/kvm-f14-url.xml
@@ -13,7 +13,7 @@
   <features>
     <acpi/><apic/><pae/>
   </features>
-  <cpu match='exact'>
+  <cpu mode='custom' match='exact'>
     <model>core2duo</model>
     <vendor>Intel</vendor>
     <feature policy='require' name='pbe'/>
@@ -67,7 +67,7 @@
   <features>
     <acpi/><apic/><pae/>
   </features>
-  <cpu match='exact'>
+  <cpu mode='custom' match='exact'>
     <model>core2duo</model>
     <vendor>Intel</vendor>
     <feature policy='require' name='pbe'/>
diff --git a/tests/cli-test-xml/compare/qemu-plain.xml b/tests/cli-test-xml/compare/qemu-plain.xml
index 55ed250..adf71e2 100644
--- a/tests/cli-test-xml/compare/qemu-plain.xml
+++ b/tests/cli-test-xml/compare/qemu-plain.xml
@@ -11,7 +11,7 @@
   <features>
     <acpi/><apic/><pae/>
   </features>
-  <cpu match='exact'>
+  <cpu mode='custom' match='exact'>
     <model>Penryn</model>
   </cpu>
   <clock offset="utc"/>
diff --git a/tests/xmlconfig-xml/boot-cpuset.xml b/tests/xmlconfig-xml/boot-cpuset.xml
index 3dc173f..f9c1c01 100644
--- a/tests/xmlconfig-xml/boot-cpuset.xml
+++ b/tests/xmlconfig-xml/boot-cpuset.xml
@@ -12,7 +12,7 @@
   <features>
     <acpi/><apic/>
   </features>
-  <cpu match='minimum'>
+  <cpu mode='custom' match='minimum'>
     <model>footest</model>
     <vendor>Intel</vendor>
     <topology sockets='4' cores='5' threads='2'/>
diff --git a/tests/xmlparse-xml/change-cpumode-in.xml b/tests/xmlparse-xml/change-cpumode-in.xml
new file mode 100644
index 0000000..efe15f7
--- /dev/null
+++ b/tests/xmlparse-xml/change-cpumode-in.xml
@@ -0,0 +1,19 @@
+<domain type="kvm">
+  <name>TestGuest</name>
+  <currentMemory>204800</currentMemory>
+  <memory>409600</memory>
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <vcpu cpuset="1-3">4</vcpu>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+    <disk type="block" device="cdrom">
+      <target dev="hdc" bus="ide"/>
+      <readonly/>
+    </disk>
+  </devices>
+  <cpu mode="host-passthrough"/>
+</domain>
diff --git a/tests/xmlparse-xml/change-cpumode-out.xml b/tests/xmlparse-xml/change-cpumode-out.xml
new file mode 100644
index 0000000..23cc3e3
--- /dev/null
+++ b/tests/xmlparse-xml/change-cpumode-out.xml
@@ -0,0 +1,21 @@
+<domain type="kvm">
+  <name>TestGuest</name>
+  <currentMemory>204800</currentMemory>
+  <memory>409600</memory>
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <vcpu cpuset="1-3">4</vcpu>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+    <disk type="block" device="cdrom">
+      <target dev="hdc" bus="ide"/>
+      <readonly/>
+    </disk>
+  </devices>
+  <cpu mode="custom" match="exact">
+    <model>qemu64</model>
+  </cpu>
+</domain>
diff --git a/tests/xmlparse-xml/change-guest-in.xml b/tests/xmlparse-xml/change-guest-in.xml
index b6ab49c..55403e9 100644
--- a/tests/xmlparse-xml/change-guest-in.xml
+++ b/tests/xmlparse-xml/change-guest-in.xml
@@ -13,7 +13,7 @@
   <numatune>
     <memory mode='interleave' nodeset='1-5,^3,7'/>
   </numatune>
-  <cpu match='exact'>
+  <cpu mode='custom' match='exact'>
     <model>footest</model>
     <vendor>Intel</vendor>
     <topology sockets='4' cores='5' threads='2'/>
diff --git a/tests/xmlparse-xml/change-guest-out.xml b/tests/xmlparse-xml/change-guest-out.xml
index f77a24b..c8729fa 100644
--- a/tests/xmlparse-xml/change-guest-out.xml
+++ b/tests/xmlparse-xml/change-guest-out.xml
@@ -16,7 +16,7 @@
   <numatune>
     <memory nodeset="2,4,6"/>
   </numatune>
-  <cpu match="strict">
+  <cpu mode="custom" match="strict">
     <model>qemu64</model>
     <vendor>qemuvendor</vendor>
     <topology sockets="4" cores="3" threads="1"/>
diff --git a/tests/xmlparse-xml/change-minimal-guest-out.xml b/tests/xmlparse-xml/change-minimal-guest-out.xml
index 4095d9b..c9df30a 100644
--- a/tests/xmlparse-xml/change-minimal-guest-out.xml
+++ b/tests/xmlparse-xml/change-minimal-guest-out.xml
@@ -22,7 +22,7 @@
   <seclabel model="testSecurity" type="static">
     <label>frob</label>
   </seclabel>
-  <cpu match="exact">
+  <cpu mode="custom" match="exact">
     <model>foobar</model>
     <topology cores="4" sockets="1" threads="1"/>
     <feature policy="forbid" name="x2apic"/>
diff --git a/tests/xmlparse-xml/change-smartcard-in.xml b/tests/xmlparse-xml/change-smartcard-in.xml
index 944f03e..6302cf9 100644
--- a/tests/xmlparse-xml/change-smartcard-in.xml
+++ b/tests/xmlparse-xml/change-smartcard-in.xml
@@ -10,7 +10,7 @@
   <features>
     <acpi/><apic/>
   </features>
-  <cpu match='exact'>
+  <cpu mode='custom' match='exact'>
     <model>footest</model>
     <vendor>Intel</vendor>
     <topology sockets='4' cores='5' threads='2'/>
diff --git a/tests/xmlparse-xml/change-smartcard-out.xml b/tests/xmlparse-xml/change-smartcard-out.xml
index 91b9d4f..7f641d0 100644
--- a/tests/xmlparse-xml/change-smartcard-out.xml
+++ b/tests/xmlparse-xml/change-smartcard-out.xml
@@ -10,7 +10,7 @@
   <features>
     <acpi/><apic/>
   </features>
-  <cpu match="exact">
+  <cpu mode="custom" match="exact">
     <model>footest</model>
     <vendor>Intel</vendor>
     <topology sockets="4" cores="5" threads="2"/>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 04559ae..041daa9 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -230,6 +230,19 @@ class XMLParseTest(unittest.TestCase):
 
         self._alter_compare(guest.get_config_xml(), outfile)
 
+    def testAlterCpuMode(self):
+        infile  = "tests/xmlparse-xml/change-cpumode-in.xml"
+        outfile = "tests/xmlparse-xml/change-cpumode-out.xml"
+        guest = virtinst.Guest(conn=conn,
+                               parsexml=file(infile).read())
+
+        check = self._make_checker(guest.cpu)
+        check("mode", "host-passthrough", "custom")
+        check("mode", "custom", "host-model")
+        check("model", None, "qemu64") # mode will be "custom"
+
+        self._alter_compare(guest.get_config_xml(), outfile)
+
     def testAlterDisk(self):
         """
         Test changing VirtualDisk() parameters after parsing
-- 
1.8.1.4




More information about the virt-tools-list mailing list