chiark / gitweb /
bugfixes; prep for stderr capture
[autopkgtest.git] / runner / adt-run
index 8b52320c5fc30285170ed1abf43dbcb797a36787..0a50a0ac09a239404cf24868e10ed3a07e497601 100755 (executable)
@@ -92,14 +92,18 @@ class Path:
        elif p.p[:1] == '/': pfx = '/HOST'
        else: pfx = './'
        return pfx + p.p
- def onhost(p):
-       if p.local is not None: return p.local
+ def onhost(p, lpath = None):
+       if p.local is not None:
+               if lpath is not none: assert(p.local == lpath)
+               return p.local
        testbed.open()
-       p.local = tmpdir + '/tb-' + p.what
+       p.local = lpath
+       if p.local is None: p.local = tmpdir + '/tb-' + p.what
        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()
        p.down = testbed.scratch.p + '/host-' + p.what
        testbed.command('copydown', (p.path(), p.down + p.dirsfx))
        return p.down
@@ -129,6 +133,7 @@ def parse_args():
 
        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('-d', '--debug', action='store_true', dest='debug');
        # pa('','--user', type='string',
@@ -189,6 +194,7 @@ class Testbed:
  def close(tb):
        if tb.scratch is None: return
        tb.scratch = None
+       if tb.sp is None: return
        tb.command('close')
  def bomb(tb, m):
        if tb.sp is not None:
@@ -200,14 +206,16 @@ class Testbed:
        tb.sp = None
        raise Quit(16, 'testbed failed: %s' % m)
  def send(tb, string):
+       tb.sp.stdin
        try:
                debug('>> '+string)
                print >>tb.sp.stdin, string
                tb.sp.stdin.flush()
                tb.lastsend = string
        except:
-               tb.bomb('cannot send to testbed: %s' %
-                       formatexception_only(sys.last_type, sys.last_value))
+               (type, value, dummy) = sys.exc_info()
+               tb.bomb('cannot send to testbed: %s' % traceback.
+                       format_exception_only(type, value))
  def expect(tb, keyword, nresults=-1):
        l = tb.sp.stdout.readline()
        if not l: tb.bomb('unexpected eof from the testbed')
@@ -306,7 +314,9 @@ class Test:
                'test name may not contain / character')
        for k in base: setattr(t,k,base[k])
        t.tname = tname
-       t.p = opts.build_tree.append(tname, 'test-'+tname)
+       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)