---
lib/python/rats.py | 30 +++++++++++++-----------------
tests/rats_install/install.py | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 49 insertions(+), 18 deletions(-)
diff --git a/lib/python/rats.py b/lib/python/rats.py
index 3adda31..f40be66 100644
--- a/lib/python/rats.py
+++ b/lib/python/rats.py
@@ -61,9 +61,11 @@ def report_results(testlist, keyvals, url=None, username='',
password=''):
# TODO: handle other statuses (e.g. WARN)
irb.send_request('/add_result', auth=True, req_params=params)
-def parse_args():
- archlist = ['i386', 'x86_64', 'ppc']
+def get_parser():
+
parser = optparse.OptionParser(usage="%prog [options] TREEURL")
+
+ archlist = ['i386', 'x86_64', 'ppc']
parser.add_option("-a", "--arch", action="store",
type="choice",
choices=archlist, default=util.get_basearch(),
help="target architecture (%default)")
@@ -76,33 +78,27 @@ def parse_args():
parser.add_option("-b", "--bindir", action="store",
default=config.bindir,
help="binary dir - contains minimon, ks.cfg, etc. (%default)")
- parser.add_option("-i", "--image-url", action="store",
- default="",
- help="Specify alternative URL for boot and install images")
- 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)")
+ return parser
+
+def parse_args(parser=None):
+ # If no parser supplied, get one
+ if parser is None:
+ parser = get_parser()
+
(opt, args) = parser.parse_args()
# Validate arguments
if len(args) != 1:
parser.error("incorrect number of arguments")
- # Set the default URL prefix for all urlgrabber operations
- url_prefix = opt.image_url or args[0]
- if not url_prefix.endswith('/'):
- url_prefix = url_prefix + '/'
- util.grabber.opts.prefix = url_prefix
-
# Process TREEURL
baseurl = args[0]
if not baseurl.endswith('/'):
baseurl = baseurl + '/'
+ util.grabber.opts.prefix = baseurl
config.set_scratchdir(opt.scratchdir)
config.logdir = opt.logdir
config.bindir = opt.bindir
return (opt, baseurl)
+
diff --git a/tests/rats_install/install.py b/tests/rats_install/install.py
index c596239..923d089 100755
--- a/tests/rats_install/install.py
+++ b/tests/rats_install/install.py
@@ -27,6 +27,7 @@ import gzip
import time
import ConfigParser
import re
+import optparse
from subprocess import *
from minimon import MinimonServer
from autoqa import rats, util, config
@@ -324,15 +325,49 @@ def system_sanity():
print msg
return False
+def parse_args():
+
+ # establish install-specific command-line options
+ parser = rats.get_parser()
+ optgroup = optparse.OptionGroup(parser, "Installation Options")
+ optgroup.add_option("-i", "--image-url",
action="store",
+ default="",
+ help="Specify alternative URL for boot and install images")
+ optgroup.add_option("-x", "--extra-args",
action="store",
+ default="",
+ help="Additional arguments to pass to the kernel booted from the specified
TREEURL")
+ optgroup.add_option("-r", "--ram", action="store",
type="int", dest="memory",
+ default=768,
+ help="Memory to allocate for guest instance in megabytes (default:
%default)")
+ parser.add_option_group(optgroup)
+
+ # Process command-line arguments
+ (opt, baseuri) = rats.parse_args(parser)
+
+ # Set the default URL prefix for subsequent urlgrabber operations
+ if opt.image_url:
+ url_prefix = opt.image_url
+ if not url_prefix.endswith('/'):
+ url_prefix = url_prefix + '/'
+ print "Setting util.grabber prefix"
+ util.grabber.opts.prefix = url_prefix
+
+ return (opt, baseuri)
+
#http://fedoraproject.org/wiki/QA:Rawhide_Acceptance_Test_Plan#Installability_2
if __name__ == '__main__':
- (opt, baseuri) = rats.parse_args()
+
+ # Process command-line arguments
+ (opt, baseuri) = parse_args()
+
+ # Environment sanity checks
if not os.getuid() == 0:
print "ERROR: this can't be run as a normal user (yet)"
sys.exit(1)
if not system_sanity():
sys.exit(1)
+ # Start testing
print "== installer image sanity test =="
timestamp = util.test("images", installer_image_test(opt.arch))
util.write_keyval("treeinfo_timestamp", timestamp)
--
1.6.6.1