chiark / gitweb /
* adt-xenlvm-with-testbed: sleep 1 after xm destroy, which is racy.
[autopkgtest.git] / runner / adt-run
index 25529884af9a0676379b21d71749214b7ca95c3a..7787e5761971fb566993e8e87bd40058ed5d01b4 100755 (executable)
@@ -45,7 +45,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL) # undo stupid Python SIGINT thing
 tmpdir = None          # pathstring on host
 testbed = None         # Testbed
 errorcode = 0          # exit status that we are going to use
-timeouts = { 'short':10, 'install':900, 'test':600, 'build':3000 }
+timeouts = { 'short':100, 'install':3000, 'test':10000, 'build':100000 }
 binaries = None                # Binaries (.debs we have registered)
 build_essential = ["build-essential"]
 
@@ -188,7 +188,9 @@ def mkdir_okexist(pathname, mode=02755):
 
 def rmtree(what, pathname):
        debug('/ %s rmtree %s' % (what, pathname), 2)
-       shutil.rmtree(pathname)
+       try: shutil.rmtree(pathname)
+       except (IOError,OSError), oe:
+               if oe.errno != errno.EEXIST: raise
 
 def debug_subprocess(what, cmdl=None, script=None):
        o = '$ '+what+':'
@@ -406,7 +408,7 @@ class Action:
        return "<Action %s %s %s>" % (a.kind, a.what, `a.af`)
 
 def parse_args():
-       global opts
+       global opts, timeouts
        global n_non_actions # argh, stupid python scoping rules
        usage = "%prog <options> --- <virt-server>..."
        parser = OptionParser(usage=usage)
@@ -419,7 +421,8 @@ def parse_args():
                'deb_forbuilds': 'auto',
                'deb_fortests': 'auto',
                'tb': False,
-               'override_control': None
+               'override_control': None,
+               'set_lang': 'C'
        }
        initial_arghandling = arghandling.copy()
        n_non_actions = 0
@@ -507,7 +510,6 @@ def parse_args():
                     ' according to most recent --binaries-* settings')
        pa_setah('--no-built-binaries', ['dsc_filter'], '_',
                help='from subsequent sources, do not use any binaries')
-
        #---- binary package processing settings:
 
        def pa_setahbins(long,toset,how):
@@ -541,6 +543,11 @@ def parse_args():
        pa_path('output-dir', OutputDir, dir=True,
                help='write stderr/out files in PATH')
 
+       pa('--leave-lang', dest='set_lang', action='store_false',
+               help="leave LANG on testbed set to testbed's default")
+       pa('--set-lang', dest='set_lang', action='store', metavar='LANGVAL',
+               help='set LANG on testbed to LANGVAL', default='C')
+
        pa('','--tmp-dir',              type='string', dest='tmpdir',
                help='write temporary files to TMPDIR, emptying it'
                     ' beforehand and leaving it behind at the end')
@@ -551,6 +558,13 @@ def parse_args():
                help='write a summary report to SUMMARY,'
                     ' emptying it beforehand')
 
+       for k in timeouts.keys():
+               pa('','--timeout-'+k,   type='int', dest='timeout_'+k,
+                       metavar='T', help='set %s timeout to T')
+       pa('','--timeout-factor',       type='float', dest='timeout_factor',
+                       metavar='FACTOR', default=1.0,
+                       help='multiply all default timeouts by FACTOR')
+
        pa('','--user',                 type='string', dest='user',
                help='run tests as USER (needs root on testbed)')
        pa('','--gain-root',            type='string', dest='gainroot',
@@ -587,6 +601,11 @@ def parse_args():
        if n_non_actions >= len(parser.largs):
                parser.error('nothing to do specified')
 
+       for k in timeouts.keys():
+               t = getattr(opts,'timeout_'+k)
+               if t is None: t = timeouts[k] * opts.timeout_factor
+               timeouts[k] = int(t)
+
        arghandling = initial_arghandling
        opts.actions = []
        ix = 0
@@ -647,7 +666,7 @@ def setup_trace():
        if opts.summary is not None:
                summary_stream = open(opts.summary, 'w', 0)
 
-       debug('options: '+`opts`, 1)
+       debug('options: '+`opts`+'; timeouts: '+`timeouts`, 1)
 
 def finalise_options():
        global opts, tb, build_essential
@@ -891,6 +910,8 @@ class Testbed:
        if xdump is not None and 'execute-debug' in tb.caps: cmdl += [xdump]
        if tmpdir is not None: cmdl.append('env=TMPDIR=%s' % tmpdir)
        if kind=='install': cmdl.append('env=DEBIAN_FRONTEND=noninteractive')
+       if opts.set_lang is not False:
+               cmdl.append('env=LANG=%s' % opts.set_lang)
 
        rc = tb.commandr1('execute', cmdl)
        try: rc = int(rc)
@@ -1294,6 +1315,7 @@ END
  def apt_configs(b):
        return {
                "Dir::Etc::sourcelist": b.dir.read(True)+'sources.list',
+               "Debug::pkgProblemResolver": "true",
        }
 
  def apt_pkg_gdebi_script(b, arg, middle):
@@ -1561,7 +1583,7 @@ def build_source(act, control_override):
                        [ create_command ])
 
        script += [
-                       'cd */.',
+                       'cd [a-z0-9]*-*/.',
                        'pwd >&3',
                        'set +e; test -f debian/tests/control; echo $? >&3'
                ]
@@ -1660,7 +1682,7 @@ def build_source(act, control_override):
        debug_b('filter=%s' % filter)
        if filter != '_':
                script = tmpdir_script + [
-                       'cd '+work.write(True)+'/*/.',
+                       'cd '+work.write(True)+'/[a-z0-9]*-*/.',
                        opts.user_wrap(opts.gainroot+' debian/rules binary'),
                        'cd ..',
                        'echo *.deb >&3',
@@ -1668,7 +1690,7 @@ def build_source(act, control_override):
                result_debs = source_rules_command(act,script,what,
                                'binary',work,work.write(True),
                                results_lines=1, xargs=['x',tmpdir])
-               if result_debs == '*': debs = []
+               if result_debs == '*.deb': debs = []
                else: debs = result_debs.split(' ')
                debug_b('debs='+`debs`)
                re = regexp.compile('^([-+.0-9a-z]+)_[^_/]+(?:_[^_/]+)\.deb$')