return reduce((lambda a,b: a + b), l, [])
class Path:
- def __init__(p, tb, path, what, dir=False):
+ def __init__(p, tb, path, what, dir=False, tbscratch=None):
p.tb = tb
p.p = path
p.what = what
p.dir = dir
+ p.tbscratch = tbscratch
if p.tb:
if p.p[:1] != '/':
bomb("path %s specified as being in testbed but"
def path(p):
return p.p + p.dirsfx
def append(p, suffix, what, dir=False):
- return Path(p.tb, p.path() + suffix, what=what, dir=dir)
+ return Path(p.tb, p.path() + suffix, what=what, dir=dir,
+ tbscratch=p.tbscratch)
def __str__(p):
if p.tb: pfx = '/VIRT'
elif p.p[:1] == '/': pfx = '/HOST'
return pfx + p.p
def onhost(p, lpath = None):
if p.local is not None:
- if lpath is not none: assert(p.local == lpath)
+ if lpath is not None: assert(p.local == lpath)
return p.local
testbed.open()
p.local = lpath
testbed.command('copyup', (p.path(), p.local + p.dirsfx))
return p.local
def ontb(p):
- if p.down is not None: return p.down
testbed.open()
+ if p.tbscratch is not None:
+ if p.tbscratch != testbed.scratch:
+ p.down = None
+ if p.down is not None: return p.down
+ if p.tb:
+ bomb("testbed scratch path " + str(p) + " survived testbed")
p.down = testbed.scratch.p + '/host-' + p.what
+ p.tbscratch = testbed.scratch
testbed.command('copydown', (p.path(), p.down + p.dirsfx))
return p.down
pa_path('build-tree', True, 'use build tree from PATH on %s')
pa_path('control', False, 'read control file PATH on %s')
- pa_path('output-dir', False, 'write stderr/out files in PATH on %s')
+ pa_path('output-dir', True, 'write stderr/out files in PATH on %s')
pa('-d', '--debug', action='store_true', dest='debug');
# pa('','--user', type='string',
if tb.scratch is not None: return
p = tb.commandr1('open')
tb.scratch = Path(True, p, 'tb-scratch', dir=True)
+ tb.scratch.tbscratch = tb.scratch
def close(tb):
if tb.scratch is None: return
tb.scratch = None
if len(base['testsdir']): tpath = base['testsdir'] + '/' + tname
else: tpath = tname
t.p = opts.build_tree.append(tpath, 'test-'+tname)
- t.p.ontb()
def report(t, m):
report(t.tname, m)
def reportfail(t, m):
report(t.tname, 'FAIL ' + m)
def run(t):
testbed.open()
- so = testbed.scratch.append('stdout-' + t.tname, 'stdout-' + t.tname)
- se = testbed.scratch.append('stdout-' + t.tname, 'stdout-' + t.tname)
+ def stdouterr(oe):
+ idstr = oe + '-' + t.tname
+ if opts.output_dir is not None and opts.output_dir.tb:
+ return opts.output_dir.append(idstr)
+ else:
+ return testbed.scratch.append(idstr, idstr)
+ def stdouterrh(p, oe):
+ idstr = oe + '-' + t.tname
+ if opts.output_dir is None or opts.output_dir.tb:
+ return p.onhost()
+ else:
+ return p.onhost(opts.output_dir.onhost() + '/' + idstr)
+ so = stdouterr('stdout')
+ se = stdouterr('stderr')
rc = testbed.commandr1('execute',(t.p.ontb(),
'/dev/null', so.ontb(), se.ontb()))
- soh = so.onhost()
- seh = se.onhost()
+ soh = stdouterrh(so, 'stdout')
+ soe = stdouterrh(se, 'stderr')
testbed.close()
rc = int(rc)
stab = os.stat(soh)
tmpdir = tempfile.mkdtemp()
testbed = Testbed()
testbed.start()
+ testbed.open()
+ testbed.close()
read_control()
run_tests()
except: