On 11/17/2010 02:07 PM, Jason Wang wrote:
> This patch adds a command line wrapper in order make it easier to let
> user to run dedicated tests with specified params. The idea is simple:
> user specifiy the test params through commnad line, then wrapper
> modifiy the configuration file automatically. This is possible as the
> variants limitations are located at the end of file.
>
> The params are categorized into two kinds:
> - The params used to limit the variants, whose default configuration
> was stored with "key->value" in test_cli.cfg and can be changed by
> user. The cli just add 'only xxx' at the end of configuration file.
>
> The following options are used to limit the variants:
> --diskformat= qcow2/raw
> --nicmodel= virtio_net/rtl8139/e1000
> --driveformat= virtio_blk/ide/scsi
> --vcpu= up/smp2
> --pciassign= no_pci_assignable/pf_assignable/vf_assianable
> --pagesize= smallpages/hugepages
> --guest= Guest supports by autotest can be read from tests_base.cfg
> --testcase= Test cases you want to be run, can be read form
> test_base.cfg
>
> - The test specific params such as "nic_mode", when cli get
> "key=value" from cmdline, it just add it to the end of file.
>
> Problem:
> Use still need to know the configuration file (test_base.cfg) to
> understand the name and test params.
>
> TODO:
> Call autotest cli to submit jobs to autotest server?
>
> Example of usage:
>
> 1:./run-test.py --diskformat=qcow2 --nicmodel=virtio_net
> --driveformat=virtio_blk --vcpu=smp2 --pciassign=no_pci_assignable
> --pagesize=smallpages --guest=Fedora.14.64
> --testcase="unattended_install.cdrom"
>
> This would test installation for Fedora 14 64 bit guests with
> qcow2 as its image format, virtio-net as its nic model, virtio_blk as
> its drive format, 2 vcpus and with small pages and no assigned devices.
>
> 2: There's no need to specifiy all params through cmd line and you can
> only specify the options you are interested.
> ./run-test.py
> This would use default tests configuration just as the above.
>
>
> 3: Run an nfs based installation with 4 vcpu and 2G memory
> ./run-test.py --guest=RHEL.5.5.x86_64
> --testcase="unattend_install.nfs" --nfs_server=$server
> --nfs_dir=$directory --smp=4 --mem=2048
>
> 4: Use test specific params - run pxe using tap mode network
> ./run-test.py --nic_mode=tap --testcase=pxe
> ---
> client/tests/kvm/run-test.py | 47
> +++++++++++++++++++++++++++++++++
> client/tests/kvm/tests_cli.cfg.sample | 24 +++++++++++++++++
> 2 files changed, 71 insertions(+), 0 deletions(-)
> create mode 100755 client/tests/kvm/run-test.py
> create mode 100644 client/tests/kvm/tests_cli.cfg.sample
>
> 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
AFAIK it has recently become possible to pass parameters to control
files in autotest. Have you considered parsing command line options in
the control file and passing them as a string to fork_and_parse()? To
me that sounds like the cleanest way to do what you want, if it's indeed
possible.
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest