aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner/cmd
diff options
context:
space:
mode:
authorJohn Wren Kennedy <[email protected]>2016-08-30 12:01:41 -0700
committerBrian Behlendorf <[email protected]>2017-02-15 17:28:36 -0800
commit906091718936ded06aeef49096964b6fba1e2475 (patch)
tree31a4c7275e0632a89327b05819495567599895c2 /tests/test-runner/cmd
parentce456d483c6a30223bbbfd2308f44945d34dec8d (diff)
OpenZFS 7248 - large block support breaks rsend_009_pos
7249 rsend_015_pos produces false failures due to race 7250 testrunner can miss options specific to individual tests in runfiles Authored by: John Wren Kennedy <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Paul Dagnelie <[email protected]> Reviewed by: Igor Kozhukhov <[email protected]> Approved by: Robert Mustacchi <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Ported-by: George Melikov <[email protected]> OpenZFS-issue: https://www.illumos.org/issues/7248 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f9a78bf Closes #5799
Diffstat (limited to 'tests/test-runner/cmd')
-rwxr-xr-xtests/test-runner/cmd/test-runner.py65
1 files changed, 30 insertions, 35 deletions
diff --git a/tests/test-runner/cmd/test-runner.py b/tests/test-runner/cmd/test-runner.py
index b0ef79aaf..291ffa7bd 100755
--- a/tests/test-runner/cmd/test-runner.py
+++ b/tests/test-runner/cmd/test-runner.py
@@ -27,7 +27,6 @@ from subprocess import PIPE
from subprocess import Popen
from sys import argv
from sys import maxint
-from sys import exit
from threading import Timer
from time import time
@@ -131,8 +130,8 @@ class Cmd(object):
self.timeout = 60
def __str__(self):
- return "Pathname: %s\nOutputdir: %s\nTimeout: %d\nUser: %s\n" % (
- self.pathname, self.outputdir, self.timeout, self.user)
+ return "Pathname: %s\nOutputdir: %s\nTimeout: %d\nUser: %s\n" % \
+ (self.pathname, self.outputdir, self.timeout, self.user)
def kill_cmd(self, proc):
"""
@@ -311,10 +310,9 @@ class Test(Cmd):
if len(self.post_user):
post_user = ' (as %s)' % (self.post_user)
return "Pathname: %s\nOutputdir: %s\nTimeout: %d\nPre: %s%s\nPost: " \
- "%s%s\nUser: %s\n" % (
- self.pathname, self.outputdir,
- self.timeout, self.pre, pre_user, self.post, post_user,
- self.user)
+ "%s%s\nUser: %s\n" % \
+ (self.pathname, self.outputdir, self.timeout, self.pre,
+ pre_user, self.post, post_user, self.user)
def verify(self, logger):
"""
@@ -343,13 +341,13 @@ class Test(Cmd):
Create Cmd instances for the pre/post scripts. If the pre script
doesn't pass, skip this Test. Run the post script regardless.
"""
- pretest = Cmd(self.pre, outputdir=os.path.join(self.outputdir,
- os.path.basename(self.pre)), timeout=self.timeout,
+ odir = os.path.join(self.outputdir, os.path.basename(self.pre))
+ pretest = Cmd(self.pre, outputdir=odir, timeout=self.timeout,
user=self.pre_user)
test = Cmd(self.pathname, outputdir=self.outputdir,
timeout=self.timeout, user=self.user)
- posttest = Cmd(self.post, outputdir=os.path.join(self.outputdir,
- os.path.basename(self.post)), timeout=self.timeout,
+ odir = os.path.join(self.outputdir, os.path.basename(self.post))
+ posttest = Cmd(self.post, outputdir=odir, timeout=self.timeout,
user=self.post_user)
cont = True
@@ -387,8 +385,8 @@ class TestGroup(Test):
if len(self.post_user):
post_user = ' (as %s)' % (self.post_user)
return "Pathname: %s\nOutputdir: %s\nTests: %s\nTimeout: %d\n" \
- "Pre: %s%s\nPost: %s%s\nUser: %s\n" % (
- self.pathname, self.outputdir, self.tests, self.timeout,
+ "Pre: %s%s\nPost: %s%s\nUser: %s\n" % \
+ (self.pathname, self.outputdir, self.tests, self.timeout,
self.pre, pre_user, self.post, post_user, self.user)
def verify(self, logger):
@@ -442,11 +440,11 @@ class TestGroup(Test):
doesn't pass, skip all the tests in this TestGroup. Run the post
script regardless.
"""
- pretest = Cmd(self.pre, outputdir=os.path.join(self.outputdir,
- os.path.basename(self.pre)), timeout=self.timeout,
+ odir = os.path.join(self.outputdir, os.path.basename(self.pre))
+ pretest = Cmd(self.pre, outputdir=odir, timeout=self.timeout,
user=self.pre_user)
- posttest = Cmd(self.post, outputdir=os.path.join(self.outputdir,
- os.path.basename(self.post)), timeout=self.timeout,
+ odir = os.path.join(self.outputdir, os.path.basename(self.post))
+ posttest = Cmd(self.post, outputdir=odir, timeout=self.timeout,
user=self.post_user)
cont = True
@@ -565,11 +563,9 @@ class TestRun(object):
testgroup = TestGroup(os.path.abspath(pathname))
for prop in TestGroup.props:
- try:
- setattr(testgroup, prop, config.get('DEFAULT', prop))
- setattr(testgroup, prop, config.get(section, prop))
- except ConfigParser.NoOptionError:
- pass
+ for sect in ['DEFAULT', section]:
+ if config.has_option(sect, prop):
+ setattr(testgroup, prop, config.get(sect, prop))
# Repopulate tests using eval to convert the string to a list
testgroup.tests = eval(config.get(section, 'tests'))
@@ -579,11 +575,10 @@ class TestRun(object):
else:
test = Test(section)
for prop in Test.props:
- try:
- setattr(test, prop, config.get('DEFAULT', prop))
- setattr(test, prop, config.get(section, prop))
- except ConfigParser.NoOptionError:
- pass
+ for sect in ['DEFAULT', section]:
+ if config.has_option(sect, prop):
+ setattr(test, prop, config.get(sect, prop))
+
if test.verify(logger):
self.tests[section] = test
@@ -598,7 +593,7 @@ class TestRun(object):
"""
defaults = dict([(prop, getattr(options, prop)) for prop, _ in
- self.defaults])
+ self.defaults])
config = ConfigParser.RawConfigParser(defaults)
for test in sorted(self.tests.keys()):
@@ -614,7 +609,7 @@ class TestRun(object):
except IOError:
fail('Could not open \'%s\' for writing.' % options.template)
- def complete_outputdirs(self, options):
+ def complete_outputdirs(self):
"""
Collect all the pathnames for Tests, and TestGroups. Work
backwards one pathname component at a time, to create a unique
@@ -717,8 +712,8 @@ class TestRun(object):
m, s = divmod(time() - self.starttime, 60)
h, m = divmod(m, 60)
print '\nRunning Time:\t%02d:%02d:%02d' % (h, m, s)
- print 'Percent passed:\t%.1f%%' % (
- (float(Result.runresults['PASS']) / float(Result.total)) * 100)
+ print 'Percent passed:\t%.1f%%' % ((float(Result.runresults['PASS']) /
+ float(Result.total)) * 100)
print 'Log directory:\t%s' % self.outputdir
@@ -792,7 +787,7 @@ def options_cb(option, opt_str, value, parser):
path_options = ['runfile', 'outputdir', 'template', 'testdir']
if option.dest is 'runfile' and '-w' in parser.rargs or \
- option.dest is 'template' and '-c' in parser.rargs:
+ option.dest is 'template' and '-c' in parser.rargs:
fail('-c and -w are mutually exclusive.')
if opt_str in parser.rargs:
@@ -859,7 +854,7 @@ def parse_args():
return options
-def main(args):
+def main():
options = parse_args()
testrun = TestRun(options)
@@ -874,11 +869,11 @@ def main(args):
else:
fail('Unknown command specified')
- testrun.complete_outputdirs(options)
+ testrun.complete_outputdirs()
testrun.run(options)
testrun.summary()
exit(0)
if __name__ == '__main__':
- main(argv[1:])
+ main()