Signed-off-by: Gu Yanhua <[email protected]>
---
client/tests/libvirt/tests/virsh_freecell.py | 55 ++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
create mode 100644 client/tests/libvirt/tests/virsh_freecell.py
diff --git a/client/tests/libvirt/tests/virsh_freecell.py
b/client/tests/libvirt/tests/virsh_freecell.py
new file mode 100644
index 0000000..1133033
--- /dev/null
+++ b/client/tests/libvirt/tests/virsh_freecell.py
@@ -0,0 +1,55 @@
+import re, logging
+from autotest.client.shared import utils, error
+from autotest.client.virt import libvirt_vm
+from autotest.client import *
+
+def run_virsh_freecell(test, params, env):
+ """
+ Test the command virsh freecell
+
+ (1) Call virsh freecell
+ (2) Call virsh freecell --all
+ (3) Call virsh freecell with a numeric argument
+ (4) Call virsh freecell xyz
+ (5) Call virsh freecell with libvirtd service stop
+ """
+
+ # Prepare libvirtd service
+ check_libvirtd = params.has_key("libvirtd")
+ if check_libvirtd:
+ libvirtd = params.get("libvirtd")
+ if libvirtd == "off":
+ libvirt_vm.service_libvirtd_control("stop")
+
+ # Run test case
+ option = params.get("virsh_freecell_options")
+ cmd_result = libvirt_vm.virsh_freecell(ignore_status=True, extra=option,
print_info=True)
+ output = cmd_result.stdout.strip()
+ status = cmd_result.exit_status
+
+ # Recover libvirtd service start
+ if check_libvirtd:
+ if libvirtd == "off":
+ libvirt_vm.service_libvirtd_control("start")
+
+ # Check the output
+ def output_check(freecell_output):
+ if not re.search("kB", freecell_output):
+ raise error.TestFail("virsh freecell output invalid!")
+
+ # Check status_error
+ status_error = params.get("status_error")
+ if status_error == "yes":
+ if status == 0:
+ if libvirtd == "off":
+ raise error.TestFail("Command 'virsh freecell' succeeded "
+ "with libvirtd service stopped,
incorrect")
+ else:
+ raise error.TestFail("Command 'virsh freecell %s' succeeded"
+ "(incorrect command)" % option)
+ elif status_error == "no":
+ output_check(output)
+ if status != 0:
+ raise error.TestFail("Command 'virsh freecell %s' failed "
+ "(correct command)" % option)
+
--
1.7.1
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest