I just found this patch set has been pushed to next:-( , I will resend a
new patch set about cpu-compare.
On 2013-4-7 10:58, Alex Jia wrote:
On 04/04/2013 05:22 AM, Lucas Meneghel Rodrigues wrote:
From: liyang<[email protected]>
Signed-off-by: Li Yang<[email protected]>
---
libvirt/tests/cfg/virsh_cpu_compare.cfg | 31 +++++++++++++++
libvirt/tests/virsh_cpu_compare.py | 69
+++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 libvirt/tests/cfg/virsh_cpu_compare.cfg
create mode 100644 libvirt/tests/virsh_cpu_compare.py
diff --git a/libvirt/tests/cfg/virsh_cpu_compare.cfg
b/libvirt/tests/cfg/virsh_cpu_compare.cfg
new file mode 100644
index 0000000..7fd9184
--- /dev/null
+++ b/libvirt/tests/cfg/virsh_cpu_compare.cfg
@@ -0,0 +1,31 @@
+- virsh_cpu_compare:
+ type = virsh_cpu_compare
+ vms = ""
+ main_vm = ""
+ kill_vm = "no"
+ kill_unresponsive_vms = "no"
+ encode_video_files = "no"
+ skip_image_processing = "yes"
+ take_regular_screendumps = "no"
+ cpu_compare_ref = "file"
+ cpu_compare_extra = ""
+ cpu_compare_mode = ""
+ cpu_compare_file_name = "cpu.xml"
+ variants:
+ - expected_test:
+ status_error = "no"
+ - error_test:
+ status_error = "yes"
+ variants:
+ - no_option:
+ cpu_compare_ref = ""
+ - modified_option:
+ cpu_compare_mode = "modify"
+ - no_detail_option:
+ cpu_compare_mode = "clear"
+ - extra_option:
+ cpu_compare_extra = "xyz"
+ - invalid_option:
+ cpu_compare_extra = "--xyz"
+ - invalid_ref_option:
+ cpu_compare_ref = "xyz"
diff --git a/libvirt/tests/virsh_cpu_compare.py
b/libvirt/tests/virsh_cpu_compare.py
new file mode 100644
index 0000000..d64448b
--- /dev/null
+++ b/libvirt/tests/virsh_cpu_compare.py
@@ -0,0 +1,69 @@
+import os
+from autotest.client.shared import error
+from virttest import virsh
+from xml.dom.minidom import parseString
+
+
+def run_virsh_cpu_compare(test, params, env):
+ """
+ Test command: virsh cpu-compare.
+
+ Compare host CPU with a CPU described by an XML file.
+ 1.Get all parameters from configuration.
+ 2.Prepare temp file saves of CPU infomation.
+ 3.Perform virsh net-compare operation.
Oh, s/net-compare/cpu-compare/, it's a typo, I have pointed out it in
original patch.
+ 4.Confirm the result.
+ """
+ def get_cpu_xml(mode, tmp_file):
+ """
+ Get CPU infomation and put it into a file.
+
+ @param: mode: Test mode, decides file's detail.
+ @param: tmp_file: File saves CPU infomation.
+ """
+ cpu_xml_file = open(tmp_file, 'wb')
+ domxml = virsh.capabilities()
+ dom = parseString(domxml)
+ cpu_node = dom.getElementsByTagName('cpu')[0]
+ if mode == "modify":
+ vendor = cpu_node.getElementsByTagName('vendor')[0]
+ for node in vendor.childNodes:
+ if node.nodeType == node.TEXT_NODE:
+ vendor.removeChild(node)
+ break
+ text_node = dom.createTextNode('test_vendor')
+ vendor.appendChild(text_node)
+ cpu_node.writexml(cpu_xml_file)
+ elif mode == "clear":
+ # Clear up file detail
+ cpu_xml_file.truncate(0)
+ else:
+ cpu_node.writexml(cpu_xml_file)
+ cpu_xml_file.close()
+ dom.unlink()
+
+ # Get all parameters.
+ ref = params["cpu_compare_ref"]
+ mode = params.get("cpu_compare_mode", "")
+ status_error = params.get("status_error", "no")
+ extra = params.get("cpu_compare_extra", "")
+ file_name = params.get("cpu_compare_file_name", "cpu.xml")
+ tmp_file = os.path.join(test.tmpdir, file_name)
+
+ # Prepare temp file.
+ get_cpu_xml(mode, tmp_file)
+
+ if ref == "file":
+ ref = tmp_file
+ ref = "%s %s" % (ref, extra)
+
+ # Perform virsh cpu-compare operation.
+ status = virsh.cpu_compare(ref, ignore_status=True,
debug=True).exit_status
+
+ # Check status_error
+ if status_error == "yes":
+ if status == 0:
+ raise error.TestFail("Run successfully with wrong command!")
+ elif status_error == "no":
+ if status != 0:
+ raise error.TestFail("Run failed with right command")
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel
--
Regards,
--------------------------------------------------
Li Yang
No. 6 Wenzhu Road, Nanjing, 210012, China
TEL:+86+25-86630566-8526
FUJITSU INTERNAL:7998-8526
FAX:+86+25-83317685
EMail:[email protected]
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain
information that is privileged, confidential and exempt from disclosure under
applicable law. If you are not an intended recipient of this communication, you
are hereby notified that any dissemination, distribution or copying hereof is
strictly prohibited. If you have received this communication in error, please
notify me by reply e-mail, permanently delete this communication from your
system, and destroy any hard copies you may have printed
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel