This patch adds test to file virsh_net_create.py.
Signed-off-by: Yu Mingfei <[email protected]>
---
client/tests/libvirt/tests/virsh_net_create.py | 61 ++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
create mode 100644 client/tests/libvirt/tests/virsh_net_create.py
diff --git a/client/tests/libvirt/tests/virsh_net_create.py
b/client/tests/libvirt/tests/virsh_net_create.py
new file mode 100644
index 0000000..3a02970
--- /dev/null
+++ b/client/tests/libvirt/tests/virsh_net_create.py
@@ -0,0 +1,61 @@
+import re, logging, time
+from autotest.client.shared import utils, error
+from autotest.client.virt import libvirt_vm
+
+
+def run_virsh_net_create(test, params, env):
+ """
+ Test command: virsh net-create.
+
+ 1) Create default network with default XML file.
+ 2) Create network with none.
+ 3) Create network with a not exist option.
+ 4) Create default network with an additional string.
+ 5) Create default network with an additional option.
+ 6) Create default network with libvirtd stop.
+ """
+ #If default network exists, destroy it for test.
+ list_output = libvirt_vm.virsh_net_list("", print_info=True).stdout.strip()
+ if re.search("default", list_output):
+ libvirt_vm.virsh_net_destroy("default", print_info=True)
+
+ #Prepare libvirtd status
+ libvirtd = params.get("libvirtd", "on")
+ if libvirtd == "off":
+ libvirt_vm.service_libvirtd_control("stop")
+
+ #Run test case
+ options_ref = params.get("options_ref", "default")
+ extra = params.get("extra", "")
+ if options_ref == "default":
+ options_ref = "/etc/libvirt/qemu/networks/default.xml"
+ elif options_ref == "additional":
+ options_ref = "/etc/libvirt/qemu/networks/default.xml"
+ elif options_ref == "none":
+ options_ref == ""
+
+ result = libvirt_vm.virsh_net_create(options_ref, extra,
ignore_status=True, print_info=True)
+ status = result.exit_status
+ output = result.stdout.strip()
+
+ #Recover libvirtd service start
+ if libvirtd == "off":
+ libvirt_vm.service_libvirtd_control("start")
+
+ #Recover default network if neccessary.
+ list_output = libvirt_vm.virsh_net_list("", print_info=True).stdout.strip()
+ if not re.search("default", list_output):
+ libvirt_vm.virsh_net_create("/etc/libvirt/qemu/networks/default.xml",
print_info=True)
+
+ #Check status_error
+ status_error = params.get("status_error", "no")
+ addition_status_error = params.get("addition_status_error", "no")
+ status_error = (status_error == "no") and (addition_status_error == "no")
+ if not status_error:
+ if status == 0:
+ raise error.TestFail("Run successful with wrong command!")
+ else:
+ if status != 0:
+ raise error.TestFail("Run failed with right command.")
+ if not re.search(options_ref, output):
+ raise error.TestFail("Run successful but result is not expected.")
--
1.7.1
--
Best Regards
Yu Mingfei
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest