diff mbox

[RFC] KVM test: Introduce a command-line wrapper

Message ID 20101117120143.20711.74019.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Wang Nov. 17, 2010, 12:01 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/run-test.py b/client/tests/kvm/run-test.py
new file mode 100755
index 0000000..1ef171e
--- /dev/null
+++ b/client/tests/kvm/run-test.py
@@ -0,0 +1,47 @@ 
+#!/usr/bin/python
+"""
+Program to run dedicated test from command line.
+
+@copyright: Red Hat 2010
+"""
+
+import sys, re, shutil, os
+
+def_params = {}
+help = {}
+extra_params = {}
+verbose = False
+
+def help(params):
+    print "%s: kvm-autotest client test cli" % sys.argv[0]
+    print "available options: "
+    for key in params.keys():
+        print "--%s=" % key
+
+if __name__ == "__main__":
+
+    # Read default configuration
+    for (key, value) in re.findall("#\s+(.*)->(.*)",
+                                   file("tests_cli.cfg").read()):
+        def_params[key] = value
+
+    for argv in sys.argv[1:]:
+        if "help" in argv:
+            help(def_params)
+            sys.exit(0)
+        try:
+            (key, value) = re.findall("--(.*)=(.*)", argv)[0]
+            if key in def_params.keys():
+                def_params[key] = value
+            else:
+                extra_params[key] = value
+        except IndexError:
+            pass
+
+    shutil.copy("tests_cli.cfg", "tests.cfg")
+    for key in def_params.keys():
+        file("tests.cfg","a+").write("only %s\n" % def_params[key])
+    for (key, value) in extra_params.items():
+        file("tests.cfg","a+").write("%s = %s\n" % (key, value))
+
+    os.system("../../bin/autotest control --verbose")
diff --git a/client/tests/kvm/tests_cli.cfg.sample b/client/tests/kvm/tests_cli.cfg.sample
new file mode 100644
index 0000000..f5074bd
--- /dev/null
+++ b/client/tests/kvm/tests_cli.cfg.sample
@@ -0,0 +1,24 @@ 
+# Do not edit this file directly, it is used by run-test.py
+#
+include tests_base.cfg
+include cdkeys.cfg
+
+# As for the defaults:
+# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and
+#   /usr/bin/qemu-img respectively.
+# * All image files are expected under /tmp/kvm_autotest_root/images/
+# * All iso files are expected under /tmp/kvm_autotest_root/isos/
+qemu_img_binary = /usr/bin/qemu-img
+qemu_binary = /usr/bin/qemu-kvm
+image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
+cdrom(_.*)? ?<= /tmp/kvm_autotest_root/isos/
+
+# you can change default configuration here:
+# diskformat->qcow2
+# nicmodel->virtio_net
+# driveformat->virtio_blk
+# vcpu->smp2
+# pciassign->no_pci_assignable
+# pagesize->smallpages
+# guest->Fedora.14.64
+# testcase->unattended_install.cdrom