On 2013-4-9 10:45, liyang wrote:
Signed-off-by: Li Yang <[email protected]>
---
libvirt/tests/cfg/virsh_net_dumpxml.cfg | 34 ++++++++++++++++
libvirt/tests/virsh_net_dumpxml.py | 67
+++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 libvirt/tests/cfg/virsh_net_dumpxml.cfg
create mode 100644 libvirt/tests/virsh_net_dumpxml.py
diff --git a/libvirt/tests/cfg/virsh_net_dumpxml.cfg
b/libvirt/tests/cfg/virsh_net_dumpxml.cfg
new file mode 100644
index 0000000..6c5bb26
--- /dev/null
+++ b/libvirt/tests/cfg/virsh_net_dumpxml.cfg
@@ -0,0 +1,34 @@
+- virsh_net_dumpxml:
+ type = virsh_net_dumpxml
+ vms = ""
+ main_vm = ""
+ kill_vm = "no"
+ kill_unresponsive_vms = "no"
+ encode_video_files = "no"
+ skip_image_processing = "yes"
+ take_regular_screendumps = "no"
+ net_dumpxml_network = "default"
+ net_dumpxml_vm_ref = "name"
Sorry, still "vm_ref"..I will change it to "net_ref"
+ net_dumpxml_extra = ""
+ net_dumpxml_network_status = "active"
+ variants:
+ - normal_test:
+ status_error = "no"
+ variants:
+ - name_option:
+ - uuid_option:
+ net_dumpxml_vm_ref = "uuid"
+ - inactive_option:
+ net_dumpxml_network_status = "inactive"
+ net_dumpxml_extra = "--inactive"
+ - error_test:
+ status_error = "yes"
+ variants:
+ - no_option:
+ net_dumpxml_vm_ref = ""
+ - no_exist_option:
+ net_dumpxml_vm_ref = "xyz"
+ - extra_option:
+ net_dumpxml_extra = "xyz"
+ - extra_args_option:
+ net_dumpxml_extra = "--xyz"
diff --git a/libvirt/tests/virsh_net_dumpxml.py
b/libvirt/tests/virsh_net_dumpxml.py
new file mode 100644
index 0000000..8ec5250
--- /dev/null
+++ b/libvirt/tests/virsh_net_dumpxml.py
@@ -0,0 +1,67 @@
+from autotest.client.shared import error
+from virttest import virsh
+
+def run_virsh_net_dumpxml(test, params, env):
+ """
+ Test command: virsh net-dumpxml.
+
+ This command can output the network information as an XML dump to
stdout.
+ 1.Get all parameters from config file.
+ 2.If test case's network status is inactive, destroy it.
+ 3.Perform virsh net-dumpxml operation.
+ 4.Recover test environment(network status).
+ 5.Confirm the test result.
+ """
+ status_error = params.get("status_error", "no")
+ vm_ref = params.get("net_dumpxml_vm_ref")
+ net_name = params.get("net_dumpxml_network", "default")
+ net_status = params.get("net_dumpxml_network_status", "active")
+ extra = params.get("net_dumpxml_extra", "")
+
+ # Run test case
+ if vm_ref == "uuid":
+ vm_ref = virsh.net_uuid(net_name).stdout.strip()
+ elif vm_ref == "name":
+ vm_ref = net_name
+
+ net_status_current = "active"
+ if not virsh.net_state_dict()[net_name]['active']:
+ net_status_current = "inactive"
+
+ if not virsh.net_state_dict()[net_name]['persistent']:
+ raise error.TestFail("Network is transient!")
+
+ if net_status == "inactive" and net_status_current == "active":
+ s = virsh.net_destroy(net_name, ignore_status=True).exit_status
+ if s != 0:
+ raise error.TestFail("Network destroied failed!")
+
+ result = virsh.net_dumpxml(vm_ref, extra, ignore_status=True)
+ status = result.exit_status
+ output = result.stdout.strip()
+ if extra.find("--") != -1:
+ options = extra.split("--")
+ for option in options:
+ if option.strip() == "":
+ continue
+ if not virsh.has_command_help_match("net-dumpxml",
option.strip()):
+ status_error = "yes"
+ break
+
+ # Recover network
+ if net_status == "inactive" and net_status_current == "active":
+ s = virsh.net_start(net_name, ignore_status=True).exit_status
+ if s != 0:
+ raise error.TestFail("Network started failed!")
+
+ # 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")
+ if output == "":
+ raise error.TestFail("The command has no detail outputed!")
+ else:
+ raise error.TestFail("The status_error must be 'yes' or 'no'!")
--
1.7.1
--
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