On Fri, 2010-02-12 at 16:47 -0500, Will Woods wrote:
On Wed, 2010-02-10 at 09:17 -0500, James Laska wrote:
> ---
> lib/python/rats.py | 3 +++
> lib/python/virtguest.py | 11 ++++++++++-
> tests/rats_install/install.py | 23 +++++++++++++++++++----
> 3 files changed, 32 insertions(+), 5 deletions(-)
>
> diff --git a/lib/python/rats.py b/lib/python/rats.py
> index ec72e43..3adda31 100644
> --- a/lib/python/rats.py
> +++ b/lib/python/rats.py
> @@ -82,6 +82,9 @@ def parse_args():
> parser.add_option("-x", "--extra-args",
action="store",
> default="",
> help="Additional arguments to pass to the kernel booted from the
specified TREEURL")
> + parser.add_option("-r", "--ram", action="store",
type="int", dest="memory",
> + default=768,
> + help="Memory to allocate for guest instance in megabytes (default:
%default)")
> (opt, args) = parser.parse_args()
I'd prefer that options that are only needed for one test be defined
inside that test. So it'd be better if we could define this option
inside install.py - it's kind of silly that you can pass --ram=768 to
sanity.py.
Perhaps rats.parse_args() could take an optional OptionGroup as input,
so tests can define their own arguments to add to the default rats
parser?
Good idea. I looked into this a bit and it seems that you can't just
pass an OptionGroup in as an argument since OptionGroup requires the
parser (OptionParser) when instantiated.
Instead, I looked at how other tools use OptionGroups, particularly
the /usr/bin/*virt* tools. I opted to create a RatsOptionParser class
(subclass of OptionParser) that the RATS tests can then use for argument
handling. This duplicates some code in each of the tests, but not to
the level which I'm concerned.
I've tested this patch with both sanity.py and install.py and things
work as expected. If no comments/concerns, I'll push this along with
the previous rats_install patches.
Thanks,
James