3 # adt-run is part of autopkgtest
4 # autopkgtest is a tool for testing Debian binary packages
6 # autopkgtest is Copyright (C) 2006-2007 Canonical Ltd.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # See the file CREDITS for a full list of credits information (often
23 # installed as /usr/share/doc/autopkgtest/CREDITS).
40 from optparse import OptionParser
41 signal.signal(signal.SIGINT, signal.SIG_DFL) # undo stupid Python SIGINT thing
43 #---------- global variables
45 tmpdir = None # pathstring on host
46 testbed = None # Testbed
47 errorcode = 0 # exit status that we are going to use
48 binaries = None # Binaries (.debs we have registered)
49 build_essential = ["build-essential"]
51 #---------- output handling
53 # There are at least the following kinds of output:
55 # 1. stderr output which consists of
57 # 1b. stuff printed to stderr by the virtualisation server
58 # 1c. stuff printed to stderr by our short-lived subprocesseses
59 # which we don't expect to fail
61 # 2. trace information, which consists of
62 # 2a. our trace information from calls to debug()
63 # 2b. progress information and stderr output from
64 # general scripts we run on the host
65 # 2c. progress information and stderr output from things
66 # we run on the testbed including builds
67 # 2d. stderr and stdout output from actual tests
70 # 3. actual test results (printed to our stdout)
72 # Cloning of 1a and 2a, where necessary, is done by us writing
73 # the data twice. Cloning of 1[bc] and 2[bc], where necessary,
74 # is done by forking off a copy of ourselves to do plumbing,
75 # which copy we wait for at the appropriate point.
78 def __init__(do): do.debuglevel = 0
86 if trace_stream is not None: print >>trace_stream, m
88 def debug(m, minlevel=0):
89 if opts.debuglevel < minlevel: return
90 if opts.quiet and trace_stream is None: return
92 if minlevel: p += `minlevel`
94 for l in m.rstrip('\n').split('\n'):
96 if not opts.quiet: print >>sys.stderr, s
97 if trace_stream is not None: print >>trace_stream, s
99 def debug_file(hp, minlevel=0):
100 if opts.debuglevel < minlevel: return
101 def do_copy(stream, what):
102 rc = subprocess.call(['cat',hp], stdout=stream)
103 if rc: bomb('cat failed copying data from %s'
104 ' to %s, exit code %d' % (hp, what, rc))
105 if not opts.quiet: do_copy(sys.stderr, 'stderr')
106 if trace_stream is not None: do_copy(trace_stream, 'trace log')
109 def __init__(ep, critical=False):
110 to_stderr = critical or not opts.quiet
111 count = to_stderr + (trace_stream is not None)
113 ep.stream = open('/dev/null','w')
116 if to_stderr: ep.stream = sys.stderr
117 else: ep.stream = trace_stream
120 ep._sp = subprocess.Popen(['tee','-a','/dev/stderr'],
121 stdin=subprocess.PIPE, stdout=trace_stream,
123 ep.stream = ep._sp.stdin
125 if ep._sp is None: return
128 if rc: bomb('stderr plumbing tee(1) failed, exit code %d' % rc)
131 def subprocess_cooked(cmdl, critical=False, dbg=None, **kwargs):
133 if isinstance(dbg,tuple): (what,script) = dbg
134 else: (what,script) = (dbg,None)
135 debug_subprocess(what, cmdl, script=script)
136 ep = Errplumb(critical)
137 running = subprocess.Popen(cmdl, stderr=ep.stream, **kwargs)
138 output = running.communicate()[0]
144 if summary_stream is not None: print >>summary_stream, m
149 if trace_stream is not None: print >>trace_stream, m
152 def report(tname, result):
153 preport('%-20s %s' % (tname, result))
155 #---------- errors we define
158 def __init__(q,ec,m): q.ec = ec; q.m = m
161 raise Quit(20, "unexpected error: %s" % m)
164 preport('blame: ' + ' '.join(testbed.blamed))
165 preport('badpkg: ' + m)
166 raise Quit(12, "erroneous package: %s" % m)
169 def __init__(u, lno, m):
170 if lno >= 0: u.m = '%s (control line %d)' % (m, lno)
172 def report(u, tname):
175 report(tname, 'SKIP %s' % u.m)
177 #---------- convenience function
179 def mkdir_okexist(pathname, mode=02755):
181 os.mkdir(pathname, mode)
183 if oe.errno != errno.EEXIST: raise
185 def rmtree(what, pathname):
186 debug('/ %s rmtree %s' % (what, pathname), 2)
187 shutil.rmtree(pathname)
189 def debug_subprocess(what, cmdl=None, script=None):
194 if x is script: x = '<SCRIPT>'
195 ol.append(x. replace('\\','\\\\').
197 o += ' '+ ' '.join(ol)
199 if script is not None and opts.debuglevel >= 1:
201 for l in script.rstrip('\n').split('\n'):
206 return reduce((lambda a,b: a + b), l, [])
208 #---------- fancy automatic file-copying class
212 # p.path[tb] None or path not None => path known
213 # p.file[tb] None or path not None => file exists
214 # p.spec string or None
215 # p.spec_tbp True or False, or not set if spec is None
218 def __init__(p, what):
226 return "<AF@%s>" % p.__str__()
229 if p.path[tbp] is None: return '-'+p.dir
230 elif p.file[tbp] is None: return p.path[tbp]+p.dir+'?'
231 else: return p.path[tbp]+p.dir+'!'
233 if p.spec is not None:
234 if not hasattr(p,'spec_tb'): out += '~'
235 elif p.spec_tbp: out += '#'
246 if p.spec is not None:
247 xtra = ' spec[%s]=%s' % (p.spec, getattr(p,'spec_tb',None))
248 raise ("internal error: %s (%s)" % (how, str(p)))
250 def _ensure_path(p, tbp):
251 if p.path[tbp] is None:
253 p._debug('tmp-parent %s...' % 'HT'[tbp])
254 TemporaryDir(os.path.dirname(p.what)).write(tbp)
256 p.path[tbp] = tmpdir+'/'+p.what
258 p.path[tbp] = testbed.scratch.path[True]+'/'+p.what
260 def write(p, tbp=False):
261 p._debug('write %s...' % 'HT'[tbp])
264 if p.dir and not p.file[tbp]:
267 mkdir_okexist(p.path[tbp])
270 'test -d "$1" || mkdir -p "$1"',
272 tf_what = urllib.quote(p.what).replace('/','%2F')
273 rc = testbed.execute('mkdir-'+tf_what, cmdl)
274 if rc: bomb('failed to create directory %s' %
277 p.file[tbp] = p.path[tbp]
280 def read(p, tbp=False):
281 p._debug('read %s...' % 'HT'[tbp])
284 if p.file[tbp] is None:
285 if p.file[not tbp] is None:
286 p._wrong("requesting read but nonexistent")
287 cud = ['copyup','copydown'][tbp]
288 src = p.file[not tbp] + p.dir
289 dst = p.path[tbp] + p.dir
290 testbed.command(cud, (src, dst))
291 p.file[tbp] = p.path[tbp]
293 return p.file[tbp] + p.dir
295 def invalidate(p, tbp=False):
297 p._debug('invalidated %s' % 'HT'[tbp])
300 debug('/ %s#%x: %s' % (p.what, id(p), m), 3)
303 p._debug('constructed: '+str(p))
307 for tbp in [False,True]:
308 for pf in [p.path, p.file]:
309 if pf[tbp] is None: continue
310 if not pf[tbp]: bomb('empty path specified for %s' % p.what)
311 if p.dir and pf[tbp].endswith('/'):
312 pf[tbp] = pf[tbp].rstrip('/')
313 if not pf[tbp]: pf[tbp] = '/'
314 if not p.dir and pf[tbp].endswith('/'):
315 bomb("directory `%s' specified for "
316 "non-directory %s" % (pf[tbp], p.what))
318 def _relative_init(p, what, parent, leaf, onlyon_tbp, setfiles, sibling):
319 AutoFile.__init__(p,what)
320 sh_on = ''; sh_sibl = ''
321 if onlyon_tbp is not None: sh_on = ' (on %s)' % ('HT'[onlyon_tbp])
322 if sibling: sh_sibl=' (sibling)'
323 parent._debug('using as base: %s: %s%s%s' %
324 (str(parent), leaf, sh_on, sh_sibl))
325 if not sibling and not parent.dir:
326 parent._wrong('asked for non-sibling relative path of non-dir')
327 if sibling: trim = os.path.dirname
328 else: trim = lambda x: x
329 for tbp in [False,True]:
330 if parent.path[tbp] is None: continue
331 trimmed = trim(parent.path[tbp])
332 if trimmed: trimmed += '/'
333 p.path[tbp] = trimmed + leaf
334 if setfiles and (onlyon_tbp is None or onlyon_tbp == tbp):
335 p.file[tbp] = p.path[tbp]
337 class InputFile(AutoFile):
338 def _init(p, what, spec, spec_tbp=False):
339 AutoFile.__init__(p, what)
341 p.spec_tbp = spec_tbp
342 p.path[spec_tbp] = spec
343 p.file[p.spec_tbp] = p.path[p.spec_tbp]
344 def __init__(p, what, spec, spec_tbp=False):
345 p._init(what,spec,spec_tbp)
348 class InputDir(InputFile):
349 def __init__(p, what, spec, spec_tbp=False):
350 InputFile._init(p,what,spec,spec_tbp)
354 class OutputFile(AutoFile):
355 def _init(p, what, spec, spec_tbp=False):
356 AutoFile.__init__(p, what)
358 p.spec_tbp = spec_tbp
359 p.path[spec_tbp] = spec
360 def __init__(p, what, spec, spec_tbp=False):
361 p._init(what,spec,spec_tbp)
364 class OutputDir(OutputFile):
365 def __init__(p, what, spec, spec_tbp=False):
366 OutputFile._init(p,what,spec,spec_tbp)
370 class RelativeInputFile(AutoFile):
371 def __init__(p, what, parent, leaf, onlyon_tbp=None, sibling=False):
372 p._relative_init(what, parent, leaf, onlyon_tbp, True, sibling)
375 class RelativeOutputFile(AutoFile):
376 def __init__(p, what, parent, leaf, sibling=False):
377 p._relative_init(what, parent, leaf, None, False, sibling)
380 class TemporaryFile(AutoFile):
381 def __init__(p, what):
382 AutoFile.__init__(p, what)
385 class TemporaryDir(AutoFile):
386 def __init__(p, what):
387 AutoFile.__init__(p, what)
391 #---------- parsing and representation of the arguments
394 def __init__(a, kind, af, arghandling, what):
395 # extra attributes get added during processing
400 a.missing_tests_control = False
402 return "<Action %s %s %s>" % (a.kind, a.what, `a.af`)
406 global n_non_actions # argh, stupid python scoping rules
407 usage = "%prog <options> --- <virt-server>..."
408 parser = OptionParser(usage=usage)
409 pa = parser.add_option
410 pe = parser.add_option
415 'deb_forbuilds': 'auto',
416 'deb_fortests': 'auto',
418 'override_control': None
420 initial_arghandling = arghandling.copy()
424 # actions (ie, test sets to run, sources to build, binaries to use):
426 def cb_action(op,optstr,value,parser, long,kindpath,is_act):
428 parser.largs.append((value,kindpath))
429 n_non_actions += not(is_act)
431 def pa_action(long, metavar, kindpath, help, is_act=True):
432 pa('','--'+long, action='callback', callback=cb_action,
433 nargs=1, type='string',
434 callback_args=(long,kindpath,is_act), help=help)
436 pa_action('built-tree', 'TREE', '@/',
437 help='run tests from build tree TREE')
439 pa_action('unbuilt-tree', 'TREE', '@//',
440 help='run tests from build tree TREE')
442 pa_action('source', 'DSC', '@.dsc',
443 help='build DSC and use its tests and/or'
444 ' generated binary packages')
446 pa_action('binary', 'DEB', '@.deb',
447 help='use binary package DEB according'
448 ' to most recent --binaries-* settings')
450 pa_action('override-control', 'CONTROL', ('control',), is_act=0,
451 help='run tests from control file CONTROL instead,'
452 ' (applies to next test suite only)')
455 # argument handling settings (what ways to use action
456 # arguments, and pathname processing):
458 def cb_setah(option, opt_str, value, parser, toset,setval):
459 if type(setval) == list:
460 if not value in setval:
461 parser.error('value for %s option (%s) is not '
462 'one of the permitted values (%s)' %
463 (value, opt_str, setval.join(' ')))
464 elif setval is not None:
467 arghandling[v] = value
468 parser.largs.append(arghandling.copy())
470 def pa_setah(long, affected,effect, metavar=None, **kwargs):
472 if type is not None: type = 'string'
473 pa('',long, action='callback', callback=cb_setah,
474 callback_args=(affected,effect), **kwargs)
476 #---- paths: host or testbed:
478 pa_setah('--paths-testbed', ['tb'],True,
479 help='subsequent path specifications refer to the testbed')
480 pa_setah('--paths-host', ['tb'],False,
481 help='subsequent path specifications refer to the host')
483 #---- source processing settings:
485 pa_setah('--sources-tests', ['dsc_tests'],True,
486 help='run tests from builds of subsequent sources')
487 pa_setah('--sources-no-tests', ['dsc_tests'],False,
488 help='do not run tests from builds of subsequent sources')
490 pa_setah('--built-binaries-filter', ['dsc_filter'],None,
491 type='string', metavar='PATTERN-LIST',
492 help='from subsequent sources, use binaries matching'
493 ' PATTERN-LIST (comma-separated glob patterns)'
494 ' according to most recent --binaries-* settings')
495 pa_setah('--no-built-binaries', ['dsc_filter'], '_',
496 help='from subsequent sources, do not use any binaries')
498 #---- binary package processing settings:
500 def pa_setahbins(long,toset,how):
501 pa_setah(long, toset,['ignore','auto','install'],
502 type='string', metavar='IGNORE|AUTO|INSTALL', default='auto',
503 help=how+' ignore binaries, install them as needed'
504 ' for dependencies, or unconditionally install'
505 ' them, respectively')
506 pa_setahbins('--binaries', ['deb_forbuilds','deb_fortests'], '')
507 pa_setahbins('--binaries-forbuilds', ['deb_forbuilds'], 'for builds, ')
508 pa_setahbins('--binaries-fortests', ['deb_fortests'], 'for tests, ')
513 def cb_vserv(op,optstr,value,parser):
514 parser.values.vserver = list(parser.rargs)
517 def cb_path(op,optstr,value,parser, constructor,long,dir):
518 name = long.replace('-','_')
519 af = constructor(long, value,arghandling['tb'])
520 setattr(parser.values, name, af)
522 def pa_path(long, constructor, help, dir=False):
523 pa('','--'+long, action='callback', callback=cb_path,
524 callback_args=(constructor,long,dir),
525 nargs=1, type='string',
526 help=help, metavar='PATH')
528 pa_path('output-dir', OutputDir, dir=True,
529 help='write stderr/out files in PATH')
531 pa('','--tmp-dir', type='string', dest='tmpdir',
532 help='write temporary files to TMPDIR, emptying it'
533 ' beforehand and leaving it behind at the end')
534 pa('','--log-file', type='string', dest='logfile',
535 help='write the log LOGFILE, emptying it beforehand,'
536 ' instead of using OUTPUT-DIR/log or TMPDIR/log')
537 pa('','--summary-file', type='string', dest='summary',
538 help='write a summary report to SUMMARY,'
539 ' emptying it beforehand')
541 pa('','--user', type='string', dest='user',
542 help='run tests as USER (needs root on testbed)')
543 pa('','--gain-root', type='string', dest='gainroot',
544 help='prefix debian/rules binary with GAINROOT')
545 pa('-q', '--quiet', action='store_false', dest='quiet', default=False);
546 pa('-d', '--debug', action='count', dest='debuglevel', default=0);
547 pa('','--gnupg-home', type='string', dest='gnupghome',
548 default='~/.autopkgtest/gpg',
549 help='use GNUPGHOME rather than ~/.autopkgtest (for'
550 " signing private apt archive);"
551 " `fresh' means generate new key each time.")
556 class SpecialOption(optparse.Option): pass
557 vs_op = SpecialOption('','--VSERVER-DUMMY')
558 vs_op.action = 'callback'
562 vs_op.callback = cb_vserv
563 vs_op.callback_args = ( )
564 vs_op.callback_kwargs = { }
565 vs_op.help = 'introduces virtualisation server and args'
566 vs_op._short_opts = []
567 vs_op._long_opts = ['---']
571 (opts,args) = parser.parse_args()
572 if not hasattr(opts,'vserver'):
573 parser.error('you must specifiy --- <virt-server>...')
574 if n_non_actions >= len(parser.largs):
575 parser.error('nothing to do specified')
577 arghandling = initial_arghandling
581 if type(act) == dict:
584 elif type(act) == tuple:
586 elif type(act) == str:
589 raise ("unknown action in list `%s' having"
590 " type `%s'" % (act, type(act)))
591 (pathstr, kindpath) = act
593 constructor = InputFile
594 if type(kindpath) is tuple: kind = kindpath[0]
595 elif kindpath.endswith('.deb'): kind = 'deb'
596 elif kindpath.endswith('.dsc'): kind = 'dsc'
597 elif kindpath.endswith('//'):
599 constructor = InputDir
600 elif kindpath.endswith('/'):
602 constructor = InputDir
603 else: parser.error("do not know how to handle filename \`%s';"
604 " specify --source --binary or --build-tree")
606 what = '%s%s' % (kind,ix); ix += 1
608 if kind == 'dsc': fwhatx = '/' + os.path.basename(pathstr)
609 else: fwhatx = '-'+kind
611 af = constructor(what+fwhatx, pathstr, arghandling['tb'])
612 opts.actions.append(Action(kind, af, arghandling, what))
615 global trace_stream, tmpdir, summary_stream
617 if opts.tmpdir is not None:
618 rmtree('tmpdir(specified)',opts.tmpdir)
619 mkdir_okexist(opts.tmpdir, 0700)
622 assert(tmpdir is None)
623 tmpdir = tempfile.mkdtemp()
625 if opts.logfile is None:
626 if opts.output_dir is not None and opts.output_dir.spec_tbp:
627 opts.logfile = opts.output_dir.spec + '/log'
628 elif opts.tmpdir is not None:
629 opts.logfile = opts.tmpdir + '/log'
630 if opts.logfile is not None:
631 trace_stream = open(opts.logfile, 'w', 0)
632 if opts.summary is not None:
633 summary_stream = open(opts.summary, 'w', 0)
635 debug('options: '+`opts`, 1)
637 def finalise_options():
638 global opts, tb, build_essential
640 if opts.user is None and 'root-on-testbed' not in testbed.caps:
643 if opts.user is None:
644 su = 'suggested-normal-user='
647 for e in testbed.caps
656 if 'root-on-testbed' not in testbed.caps:
657 pstderr("warning: virtualisation"
658 " system does not offer root on testbed,"
659 " but --user option specified: failure likely")
660 opts.user_wrap = lambda x: "su %s -c '%s'" % (opts.user, x)
662 opts.user_wrap = lambda x: x
664 if opts.gainroot is None:
667 'root-on-testbed' not in testbed.caps):
668 opts.gainroot = 'fakeroot'
669 build_essential += ['fakeroot']
671 if opts.gnupghome.startswith('~/'):
672 try: home = os.environ['HOME']
674 parser.error("HOME environment variable"
675 " not set, needed for --gnupghome=`%s"
677 opts.gnupghome = home + opts.gnupghome[1:]
678 elif opts.gnupghome == 'fresh':
679 opts.gnupghome = None
681 #---------- testbed management - the Testbed class
692 tb._need_reset_apt = False
693 def _debug(tb, m, minlevel=0):
694 debug('** '+m, minlevel)
698 debug_subprocess('vserver', opts.vserver)
699 tb._errplumb = Errplumb(True)
700 tb.sp = subprocess.Popen(opts.vserver,
701 stdin=p, stdout=p, stderr=tb._errplumb.stream)
703 tb.caps = tb.commandr('capabilities')
707 if tb.sp is None: return
708 ec = tb.sp.returncode
715 tb.bomb('testbed gave exit status %d after quit' % ec)
718 tb._debug('open, scratch=%s' % tb.scratch)
719 if tb.scratch is not None: return
720 pl = tb.commandr('open')
721 tb.scratch = InputDir('tb-scratch', pl[0], True)
722 tb.deps_processed = []
723 def mungeing_apt(tb):
724 if not 'revert' in tb.caps:
725 tb._need_reset_apt = True
727 if not tb._need_reset_apt: return
728 what = 'aptget-update-reset'
729 cmdl = ['apt-get','-qy','update']
730 rc = tb.execute(what, cmdl)
732 pstderr("\n" "warning: failed to restore"
733 " testbed apt cache, exit code %d" % rc)
734 tb._need_reset_apt = False
736 tb._debug('close, scratch=%s' % tb.scratch)
737 if tb.scratch is None: return
739 if tb.sp is None: return
741 def prepare1(tb, deps_new):
742 tb._debug('prepare1, modified=%s, deps_processed=%s, deps_new=%s' %
743 (tb.modified, tb.deps_processed, deps_new), 1)
744 if 'revert' in tb.caps and (tb.modified or
745 [d for d in tb.deps_processed if d not in deps_new]):
746 for af in tb._ephemeral: af.read(False)
747 tb._debug('reset **')
750 for af in tb._ephemeral: af.invalidate(True)
752 def prepare2(tb, deps_new):
753 tb._debug('prepare2, deps_new=%s' % deps_new, 1)
755 tb._install_deps(deps_new)
756 def prepare(tb, deps_new):
757 tb.prepare1(deps_new)
758 tb.prepare2(deps_new)
759 def register_ephemeral(tb, af):
760 tb._ephemeral.append(af)
761 def _install_deps(tb, deps_new):
762 tb._debug(' installing dependencies '+`deps_new`, 1)
763 tb.deps_processed = deps_new
764 if not deps_new: return
765 dstr = ', '.join(deps_new)
766 script = binaries.apt_pkg_gdebi_script(
768 'from GDebi.DebPackage import DebPackage',
769 'd = DebPackage(cache)',
770 'res = d.satisfyDependsStr(arg)',
772 cmdl = ['python','-c',script]
773 what = 'install-deps'
774 rc = testbed.execute(what+'-debinstall', cmdl, script=script)
775 if rc: badpkg('dependency install failed, exit code %d' % rc)
777 tb._debug('needs_reset, previously=%s' % tb.modified, 1)
780 tb._debug('blame += %s' % m, 1)
783 tb._debug('bomb %s' % m)
784 if tb.sp is not None:
788 if ec: pstderr('adt-run: testbed failing,'
789 ' exit status %d' % ec)
791 raise Quit(16, 'testbed failed: %s' % m)
792 def send(tb, string):
795 debug('>> '+string, 2)
796 print >>tb.sp.stdin, string
800 (type, value, dummy) = sys.exc_info()
801 tb.bomb('cannot send to testbed: %s' % traceback.
802 format_exception_only(type, value))
803 def expect(tb, keyword, nresults=None):
804 l = tb.sp.stdout.readline()
805 if not l: tb.bomb('unexpected eof from the testbed')
806 if not l.endswith('\n'): tb.bomb('unterminated line from the testbed')
810 if not ll: tb.bomb('unexpected whitespace-only line from the testbed')
812 if tb.lastsend is None:
813 tb.bomb("got banner `%s', expected `%s...'" %
816 tb.bomb("sent `%s', got `%s', expected `%s...'" %
817 (tb.lastsend, l, keyword))
819 if nresults is not None and len(ll) != nresults:
820 tb.bomb("sent `%s', got `%s' (%d result parameters),"
821 " expected %d result parameters" %
822 (string, l, len(ll), nresults))
824 def commandr(tb, cmd, args=(), nresults=None):
825 # pass args=[None,...] or =(None,...) to avoid more url quoting
826 if type(cmd) is str: cmd = [cmd]
827 if len(args) and args[0] is None: args = args[1:]
828 else: args = map(urllib.quote, args)
830 tb.send(string.join(al))
831 ll = tb.expect('ok', nresults)
832 rl = map(urllib.unquote, ll)
834 def command(tb, cmd, args=()):
835 tb.commandr(cmd, args, 0)
836 def commandr1(tb, cmd, args=()):
837 rl = tb.commandr(cmd, args, 1)
839 def execute(tb, what, cmdl,
840 si='/dev/null', so='/dev/null', se=None, cwd=None,
841 script=False, tmpdir=None):
842 # Options for script:
843 # False - do not call debug_subprocess, no synch. reporting required
844 # None or string - call debug_subprocess with that value,
845 # plumb stderr through synchronously if possible
847 # None - usual Errplumb (output is of kind 2c)
848 # string - path on testbed (output is of kind 2d)
850 if script is not False: debug_subprocess(what, cmdl, script=script)
851 if cwd is None: cwd = tb.scratch.write(True)
856 se_catch = TemporaryFile(what+'-xerr')
857 se_use = se_catch.write(True)
858 if not opts.quiet: xdump = 'debug=2-2'
859 elif trace_stream is not None:
860 xdump = 'debug=2-%d' % trace_stream.fileno()
867 ','.join(map(urllib.quote, cmdl)),
870 if xdump is not None and 'execute-debug' in tb.caps: cmdl += [xdump]
871 if tmpdir is not None: cmdl.append('env=TMPDIR=%s' % tmpdir)
873 rc = tb.commandr1('execute', cmdl)
875 except ValueError: bomb("execute for %s gave invalid response `%s'"
878 if se_catch is not None:
879 debug_file(se_catch.read())
885 #---------- representation of test control files: Field*, Test, etc.
888 def __init__(f, fname, stz, base, tnames, vl):
898 r = map((lambda w: (lno, w)), r)
900 return flatten(map(distribute, f.vl))
905 raise Unsupported(f.vl[1][0],
906 'only one %s field allowed' % fn)
909 class FieldIgnore(FieldBase):
913 def __init__(r,rname,base): pass
915 class Restriction_rw_build_tree(Restriction): pass
916 class Restriction_breaks_testbed(Restriction):
917 def __init__(r, rname, base):
918 if 'revert' not in testbed.caps:
919 raise Unsupported(f.lno,
920 'Test breaks testbed but testbed cannot revert')
921 class Restriction_needs_root(Restriction):
922 def __init__(r, rname, base):
923 if 'root-on-testbed' not in testbed.caps:
924 raise Unsupported(f.lno,
925 'Test needs root on testbed which is not available')
927 class Field_Restrictions(FieldBase):
929 for wle in f.words():
931 nrname = rname.replace('-','_')
932 try: rclass = globals()['Restriction_'+nrname]
933 except KeyError: raise Unsupported(lno,
934 'unknown restriction %s' % rname)
935 r = rclass(nrname, f.base)
936 f.base['restriction_names'].append(rname)
937 f.base['restrictions'].append(r)
939 class Field_Features(FieldIgnore):
941 for wle in f.words():
943 f.base['feature_names'].append(fname)
944 nfname = fname.replace('-','_')
945 try: fclass = globals()['Feature_'+nfname]
946 except KeyError: continue
947 ft = fclass(nfname, f.base)
948 f.base['features'].append(ft)
950 class Field_Tests(FieldIgnore): pass
952 class Field_Depends(FieldBase):
954 print >>sys.stderr, "Field_Depends:", `f.stz`, `f.base`, `f.tnames`, `f.vl`
955 dl = map(lambda x: x.strip(),
956 flatten(map(lambda (lno, v): v.split(','), f.vl)))
957 re = regexp.compile('[^-.+:~0-9a-z()<>=*@]')
960 badpkg("Test Depends field contains dependency"
961 " `%s' with invalid characters" % d)
962 f.base['depends'] = dl
964 class Field_Tests_directory(FieldBase):
967 if td.startswith('/'): raise Unspported(f.lno,
968 'Tests-Directory may not be absolute')
969 f.base['testsdir'] = td
971 def run_tests(stanzas, tree):
972 global errorcode, testbed
974 report('*', 'SKIP no tests in this package')
976 for stanza in stanzas:
977 tests = stanza[' tests']
979 report('*', 'SKIP package has metadata but no tests')
984 if 'breaks-testbed' in t.restriction_names:
985 testbed.needs_reset()
986 testbed.needs_reset()
989 def __init__(t, tname, base, act):
990 if '/' in tname: raise Unsupported(base[' lno'],
991 'test name may not contain / character')
992 for k in base: setattr(t,k,base[k])
995 t.what = act.what+'t-'+tname
996 if len(base['testsdir']): t.path = base['testsdir'] + '/' + tname
998 t._debug('constructed; path=%s' % t.path)
999 t._debug(' .depends=%s' % t.depends)
1001 debug('& %s: %s' % (t.what, m))
1004 def reportfail(t, m):
1007 report(t.what, 'FAIL ' + m)
1009 t._debug('preparing')
1012 t._debug(' processing dependency '+d)
1014 t._debug(' literal dependency '+d)
1017 for (pkg,bin) in t.act.binaries:
1018 d = d.replace('@',pkg)
1019 t._debug(' synthesised dependency '+d)
1023 t._debug('[----------------------------------------')
1025 idstr = t.what + '-' + oe
1026 if opts.output_dir is not None and opts.output_dir.spec_tbp:
1027 use_dir = opts.output_dir
1029 use_dir = testbed.scratch
1030 return RelativeOutputFile(idstr, use_dir, idstr)
1032 t.act.work.write(True)
1034 af = RelativeInputFile(t.what, tree, t.path)
1035 so = stdouterr('stdout')
1036 se = stdouterr('stderr')
1042 rc = testbed.execute('testchmod-'+t.what, ['chmod','+x','--',tf])
1043 if rc: bomb('failed to chmod +x %s' % tf)
1045 if 'needs-root' not in t.restriction_names and opts.user is not None:
1046 tfl = ['su',opts.user,'-c',tf]
1047 tmpdir = '%s%s-tmpdir' % (testbed.scratch.read(True), t.what)
1048 script = 'rm -rf -- "$1"; mkdir -- "$1"'
1049 if opts.user: script += '; chown %s "$1"' % opts.user
1050 if 'rw-build-tree' in t.restriction_names:
1051 script += '; chown -R %s "$2"' % opts.user
1052 rc = testbed.execute('mktmpdir-'+t.what,
1053 ['sh','-xec',script,'x',tmpdir,tree.read(True)])
1054 if rc: bomb("could not create test tmpdir `%s', exit code %d"
1059 rc = testbed.execute('test-'+t.what, tfl,
1060 so=so.write(True), se=se.write(True), cwd=tree.read(True),
1066 t._debug(' - - - - - - - - - - results - - - - - - - - - -')
1067 stab = os.stat(se_read)
1068 if stab.st_size != 0:
1069 l = open(se_read).readline()
1070 l = l.rstrip('\n \t\r')
1071 if len(l) > 35: l = l[:35] + '...'
1072 t.reportfail('status: %d, stderr: %s' % (rc, l))
1073 t._debug(' - - - - - - - - - - stderr - - - - - - - - - -')
1076 t.reportfail('non-zero exit status %d' % rc)
1080 stab = os.stat(so_read)
1081 if stab.st_size != 0:
1082 t._debug(' - - - - - - - - - - stdout - - - - - - - - - -')
1085 t._debug('----------------------------------------]')
1087 def read_control(act, tree, control_override):
1090 if control_override is not None:
1091 control_af = control_override
1092 testbed.blame('arg:'+control_override.spec)
1094 if act.missing_tests_control:
1096 control_af = RelativeInputFile(act.what+'-testcontrol',
1097 tree, 'debian/tests/control')
1099 control = open(control_af.read(), 'r')
1101 if oe[0] != errno.ENOENT: raise
1105 def badctrl(m): act.bomb('tests/control line %d: %s' % (lno, m))
1106 stz = None # stz[field_name][index] = (lno, value)
1107 # special field names:
1108 # stz[' lno'] = number
1109 # stz[' tests'] = list of Test objects
1110 def end_stanza(stz):
1111 if stz is None: return
1117 initre = regexp.compile('([A-Z][-0-9a-z]*)\s*\:\s*(.*)$')
1119 l = control.readline()
1122 if not l.endswith('\n'): badctrl('unterminated line')
1123 if regexp.compile('\s*\#').match(l): continue
1124 if not regexp.compile('\S').match(l): end_stanza(stz); continue
1125 initmat = initre.match(l)
1127 (fname, l) = initmat.groups()
1128 fname = string.capwords(fname)
1130 stz = { ' lno': lno, ' tests': [] }
1131 if not stz.has_key(fname): stz[fname] = [ ]
1132 hcurrent = stz[fname]
1133 elif regexp.compile('\s').match(l):
1134 if not hcurrent: badctrl('unexpected continuation')
1136 badctrl('syntax error')
1137 hcurrent.append((lno, l))
1140 def testbadctrl(stz, lno, m):
1141 report_badctrl(lno, m)
1146 try: tnames = stz['Tests']
1149 raise Unsupported(stz[' lno'],
1151 tnames = map((lambda lt: lt[1]), tnames)
1152 tnames = string.join(tnames).split()
1154 'restriction_names': [],
1156 'feature_names': [],
1158 'testsdir': 'debian/tests',
1161 for fname in stz.keys():
1162 if fname.startswith(' '): continue
1164 try: fclass = globals()['Field_'+
1165 fname.replace('-','_')]
1166 except KeyError: raise Unsupported(vl[0][0],
1167 'unknown metadata field %s' % fname)
1168 f = fclass(stz, fname, base, tnames, vl)
1170 for tname in tnames:
1171 t = Test(tname, base, act)
1172 stz[' tests'].append(t)
1173 except Unsupported, u:
1174 for tname in tnames: u.report(tname)
1179 def print_exception(ei, msgprefix=''):
1180 if msgprefix: pstderr(msgprefix)
1183 pstderr('adt-run: ' + q.m)
1184 psummary('quitting: '+q.m)
1187 pstderr("adt-run: unexpected, exceptional, error:")
1188 psummary('quitting: unexpected error, consult transcript')
1189 traceback.print_exc(None, sys.stderr)
1190 if trace_stream is not None:
1191 traceback.print_exc(None, trace_stream)
1198 if opts.tmpdir is None and tmpdir is not None:
1199 rmtree('tmpdir', tmpdir)
1200 if testbed is not None:
1203 if rm_ec: bomb('rm -rf -- %s failed, code %d' % (tmpdir, ec))
1204 if trace_stream is not None:
1205 trace_stream.close()
1208 print_exception(sys.exc_info(),
1209 '\nadt-run: error cleaning up:\n')
1212 #---------- registration, installation etc. of .deb's: Binaries
1214 def determine_package(act):
1215 cmd = 'dpkg-deb --info --'.split(' ')+[act.af.read(),'control']
1216 (rc, output) = subprocess_cooked(cmd, stdout=subprocess.PIPE)
1217 if rc: badpkg('failed to parse binary package, code %d' % rc)
1218 re = regexp.compile('^\s*Package\s*:\s*([0-9a-z][-+.0-9a-z]*)\s*$')
1220 for l in output.split('\n'):
1223 if act.pkg: badpkg('two Package: lines in control file')
1224 act.pkg = m.groups()[0]
1225 if not act.pkg: badpkg('no good Package: line in control file')
1229 b.dir = TemporaryDir('binaries')
1233 if opts.gnupghome is None:
1234 opts.gnupghome = tmpdir+'/gnupg'
1236 b._debug('initialising')
1238 for x in ['pubring','secring']:
1239 os.stat(opts.gnupghome + '/' + x + '.gpg')
1242 if oe.errno != errno.ENOENT: raise
1244 if ok: b._debug('no key generation needed')
1251 b._debug('preparing for key generation')
1253 mkdir_okexist(os.path.dirname(opts.gnupghome), 02755)
1254 mkdir_okexist(opts.gnupghome, 0700)
1259 cat <<"END" >key-gen-params
1263 Name-Real: autopkgtest per-run key
1264 Name-Comment: do not trust this key
1265 Name-Email: autopkgtest@example.com
1268 gpg --homedir="$1" --batch --gen-key key-gen-params
1270 cmdl = ['sh','-ec',script,'x',opts.gnupghome]
1271 rc = subprocess_cooked(cmdl, dbg=(genkey,script))[0]
1274 f = open(opts.gnupghome+'/key-gen-log')
1276 except OSError, e: tp = e
1278 bomb('key generation failed, code %d' % rc)
1282 "Dir::Etc::sourcelist": b.dir.read(True)+'sources.list',
1285 def apt_pkg_gdebi_script(b, arg, middle):
1289 'arg = urllib.unquote("%s")' % urllib.quote(arg),
1291 for (k,v) in b.apt_configs().iteritems():
1293 script.append('apt_pkg.Config.Set("%s",urllib.unquote("%s"))'
1296 'from GDebi.Cache import Cache',
1302 'print d.missingDeps',
1303 'print d.requiredChanges',
1304 'if not res: raise "gdebi failed (%s, %s, %s): %s" % '+
1305 ' (`res`, `d.missingDeps`, `d.requiredChanges`, '+
1306 'd._failureString)',
1310 return '\n'.join(script)
1312 ag = ['apt-get','-qy']
1313 for kv in b.apt_configs().iteritems():
1314 ag += ['-o', '%s=%s' % kv]
1319 rmtree('binaries', b.dir.read())
1324 b.registered = set()
1326 def register(b, act, pkg, af, forwhat, blamed):
1327 b._debug('register what=%s deb_%s=%s pkg=%s af=%s'
1328 % (act.what, forwhat, act.ah['deb_'+forwhat], pkg, str(af)))
1330 if act.ah['deb_'+forwhat] == 'ignore': return
1332 b.blamed += testbed.blamed
1334 leafname = pkg+'.deb'
1335 dest = RelativeOutputFile('binaries--'+leafname, b.dir, leafname)
1337 try: os.remove(dest.write())
1339 if oe.errno != errno.ENOENT: raise e
1341 try: os.link(af.read(), dest.write())
1343 if oe.errno != errno.EXDEV: raise e
1344 shutil.copy(af.read(), dest)
1346 if act.ah['deb_'+forwhat] == 'install':
1347 b.install.append(pkg)
1349 b.registered.add(pkg)
1357 apt-ftparchive packages . >Packages
1358 gzip <Packages >Packages.gz
1359 apt-ftparchive release . >Release
1361 gpg --homedir="$2" --batch --detach-sign --armour -o Release.gpg Release
1362 gpg --homedir="$2" --batch --export >archive-key.pgp
1364 cmdl = ['sh','-ec',script,'x',b.dir.write(),opts.gnupghome]
1365 rc = subprocess_cooked(cmdl, dbg=('ftparchive',script))[0]
1366 if rc: bomb('apt-ftparchive or signature failed, code %d' % rc)
1368 b.dir.invalidate(True)
1369 apt_source = b.dir.read(True)
1371 so = TemporaryFile('vlds')
1374 apt-key add archive-key.pgp
1375 echo "deb file://'''+apt_source+''' /" >sources.list
1376 cat /etc/apt/sources.list >>sources.list
1377 if [ "x`ls /var/lib/dpkg/updates`" != x ]; then
1378 echo >&2 "/var/lib/dpkg/updates contains some files, aargh"; exit 1
1380 '''+ ' '.join(b.apt_get()) +''' update >&2
1381 cat /var/lib/dpkg/status >&3
1383 testbed.mungeing_apt()
1384 rc = testbed.execute('apt-key', ['sh','-ec',script],
1385 so=so.write(True), cwd=b.dir.write(True),
1387 if rc: bomb('apt setup failed with exit code %d' % rc)
1389 testbed.blamed += b.blamed
1391 b._debug('publish reinstall checking...')
1392 pkgs_reinstall = set()
1394 for l in open(so.read()):
1395 if l.startswith('Package: '):
1396 pkg = l[9:].rstrip()
1397 elif l.startswith('Status: install '):
1398 if pkg in b.registered:
1399 pkgs_reinstall.add(pkg)
1400 b._debug(' publish reinstall needs '+pkg)
1403 for pkg in pkgs_reinstall: testbed.blame(pkg)
1404 what = 'apt-get-reinstall'
1405 cmdl = (b.apt_get() + ['--reinstall','install'] +
1406 [pkg for pkg in pkgs_reinstall])
1407 rc = testbed.execute(what, cmdl, script=None)
1408 if rc: badpkg("installation of basic binarries failed,"
1409 " exit code %d" % rc)
1411 b._debug('publish install...')
1412 for pkg in b.install:
1413 what = 'apt-get-install-%s' % pkg
1415 cmdl = b.apt_get() + ['install',pkg]
1416 rc = testbed.execute(what, cmdl, script=None)
1417 if rc: badpkg("installation of %s failed, exit code %d"
1420 b._debug('publish done')
1422 #---------- processing of sources (building)
1424 def source_rules_command(act,script,what,which,work,cwd,
1425 results_lines=0,xargs=[]):
1426 script = [ "exec 3>&1 >&2",
1428 script = '\n'.join(script)
1429 so = TemporaryFile('%s-%s-results' % (what,which))
1430 rc = testbed.execute('%s-%s' % (what,which),
1431 ['sh','-ec',script]+xargs, script=script,
1432 so=so.write(True), cwd=cwd)
1433 results = open(so.read()).read().rstrip('\n')
1434 if len(results): results = results.split("\n")
1436 if rc: badpkg("rules %s failed with exit code %d" % (which,rc))
1437 if results_lines is not None and len(results) != results_lines:
1438 badpkg("got %d lines of results from %s where %d expected"
1439 % (len(results), which, results_lines))
1440 if results_lines==1: return results[0]
1443 def build_source(act, control_override):
1444 act.blame = 'arg:'+act.af.spec
1445 testbed.blame(act.blame)
1446 testbed.prepare1([])
1447 testbed.needs_reset()
1450 basename = act.af.spec
1451 debiancontrol = None
1454 def debug_b(m): debug('* <%s:%s> %s' % (act.kind, act.what, m))
1456 if act.kind == 'dsc':
1458 dsc_file = open(dsc.read())
1460 fre = regexp.compile('^\s+[0-9a-f]+\s+\d+\s+([^/.][^/]*)$')
1463 if l.startswith('Files:'): in_files = True; continue
1464 elif l.startswith('#'): pass
1465 elif not l.startswith(' '):
1467 if l.startswith('Source:'):
1468 act.blame = 'dsc:'+l[7:].strip()
1469 testbed.blame(act.blame)
1470 if not in_files: continue
1473 if not m: badpkg(".dsc contains unparseable line"
1474 " in Files: `%s'" % l)
1475 leaf = m.groups(0)[0]
1476 subfile = RelativeInputFile(what+'/'+leaf, dsc, leaf,
1481 if act.kind == 'ubtree':
1482 debiancontrol = RelativeInputFile(what+'-debiancontrol',
1483 act.af, 'debian/control')
1484 dsc = TemporaryFile(what+'-fakedsc')
1485 dsc_w = open(dsc.write(), 'w')
1486 for l in open(debiancontrol.read()):
1488 if not len(l): break
1490 print >>dsc_w, 'Binary: none-so-this-is-not-a-package-name'
1493 if act.kind == 'dsc':
1494 testbed.prepare2([])
1495 script = binaries.apt_pkg_gdebi_script('', [[
1496 'from GDebi.DebPackage import DebPackage',
1497 'd = DebPackage(cache)',
1498 'res = d.satisfyDependsStr("dpkg-dev")',
1500 cmdl = ['python','-c',script]
1501 whatp = what+'-dpkgsource'
1502 rc = testbed.execute(what, cmdl, script=script)
1503 if rc: badpkg('dpkg-source install failed, exit code %d' % rc)
1505 work = TemporaryDir(what+'-build')
1508 tmpdir = work.write(True)+'/tmpdir'
1511 'rm -rf -- "$TMPDIR"',
1513 opts.user_wrap('mkdir -- "$TMPDIR"'),
1516 if act.kind == 'ubtree':
1517 spec = '%s/real-tree' % work.write(True)
1518 create_command = '''
1521 cp -rP --preserve=timestamps,links -- "$origpwd"/. "$spec"/.
1523 initcwd = act.af.read(True)
1525 if act.kind == 'dsc':
1526 spec = dsc.read(True)
1527 create_command = '''
1528 dpkg-source -x $spec
1530 initcwd = work.write(True)
1535 'cd '+work.write(True)
1539 script += ([ 'chown '+opts.user+' .' ] +
1541 [ 'spec="$spec" origpwd="$origpwd" '
1542 +opts.user_wrap(create_command) ])
1544 script += (tmpdir_script +
1550 'set +e; test -f debian/tests/control; echo $? >&3'
1552 (result_pwd, control_test_rc) = source_rules_command(
1553 act,script,what,'extract',work,
1554 cwd=initcwd, results_lines=2, xargs=['x',tmpdir,spec])
1556 filter = act.ah['dsc_filter']
1558 if control_test_rc == '1': act.missing_tests_control = True
1560 # For optional builds:
1562 # We might need to build the package because:
1563 # - we want its binaries (filter isn't _ and at least one of the
1564 # deb_... isn't ignore)
1565 # - the test control file says so
1566 # (assuming we have any tests)
1568 class NeedBuildException: pass
1569 def build_needed(m):
1570 debug_b('build needed for %s' % m)
1571 raise NeedBuildException()
1574 if filter != '_' and (act.ah['deb_forbuilds'] != 'ignore' or
1575 act.ah['deb_fortests'] != 'ignore'):
1576 build_needed('binaries')
1578 result_pwd_af = InputDir(what+'-treeforcontrol',
1580 stanzas = read_control(act, result_pwd_af, control_override)
1581 for stanza in stanzas:
1582 for t in stanza[' tests']:
1583 if 'no-build-needed' not in t.feature_names:
1584 build_needed('test %s' % t.tname)
1587 build_needed('test %s '
1588 'dependency %s' % (t.tname,d))
1590 debug_b('build not needed')
1593 except NeedBuildException:
1595 if act.kind != 'dsc':
1596 testbed.prepare2([])
1598 script = binaries.apt_pkg_gdebi_script(
1600 'from GDebi.DscSrcPackage import DscSrcPackage',
1601 'd = DscSrcPackage(cache, arg)',
1602 'res = d.checkDeb()',
1604 'from GDebi.DebPackage import DebPackage',
1605 'd = DebPackage(cache)',
1606 'res = d.satisfyDependsStr("'+
1607 ','.join(build_essential)+
1611 cmdl = ['python','-c',script]
1612 whatp = what+'-builddeps'
1613 rc = testbed.execute(what, cmdl, script=script)
1614 if rc: badpkg('build-depends install failed,'
1615 ' exit code %d' % rc)
1617 script = tmpdir_script + [
1619 'dpkg-checkbuilddeps',
1620 opts.user_wrap('debian/rules build'),
1622 source_rules_command(act,script,what,'build',work,
1623 cwd=initcwd, xargs=['x',tmpdir,result_pwd])
1625 if os.path.dirname(result_pwd)+'/' != work.read(True):
1626 badpkg("results dir `%s' is not in expected parent"
1627 " dir `%s'" % (result_pwd, work.read(True)))
1631 act.tests_tree = InputDir(what+'-tests-tree',
1632 work.read(True)+os.path.basename(result_pwd),
1634 if act.ah['dsc_tests']:
1635 testbed.register_ephemeral(act.work)
1636 testbed.register_ephemeral(act.tests_tree)
1642 act.blamed = copy.copy(testbed.blamed)
1644 debug_b('filter=%s' % filter)
1646 script = tmpdir_script + [
1647 'cd '+work.write(True)+'/*/.',
1648 opts.user_wrap(opts.gainroot+' debian/rules binary'),
1652 result_debs = source_rules_command(act,script,what,
1653 'binary',work,work.write(True),
1654 results_lines=1, xargs=['x',tmpdir])
1655 if result_debs == '*': debs = []
1656 else: debs = result_debs.split(' ')
1657 debug_b('debs='+`debs`)
1658 re = regexp.compile('^([-+.0-9a-z]+)_[^_/]+(?:_[^_/]+)\.deb$')
1661 if not m: badpkg("badly-named binary `%s'" % deb)
1663 debug_b(' deb=%s, pkg=%s' % (deb,pkg))
1664 for pat in filter.split(','):
1665 debug_b(' pat=%s' % pat)
1666 if not fnmatch.fnmatchcase(pkg,pat):
1667 debug_b(' no match')
1669 deb_what = pkg+'_'+what+'.deb'
1670 bin = RelativeInputFile(deb_what,work,deb,True)
1671 debug_b(' deb_what=%s, bin=%s' %
1672 (deb_what, str(bin)))
1673 binaries.register(act,pkg,bin,
1674 'forbuilds',testbed.blamed)
1675 act.binaries.append((pkg,bin))
1677 debug_b('all done.')
1679 #---------- main processing loop and main program
1681 def process_actions():
1684 def debug_a1(m): debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ '+m)
1685 def debug_a2(m): debug('@@@@@@@@@@@@@@@@@@@@ '+m)
1686 def debug_a3(m): debug('@@@@@@@@@@ '+m)
1688 debug_a1('starting')
1690 binaries = Binaries()
1692 for act in opts.actions:
1693 if not act.af.spec_tbp:
1694 testbed.register_ephemeral(act.af)
1697 control_override = None
1699 debug_a1('builds ...')
1700 for act in opts.actions:
1702 (act.kind, act.what))
1704 if act.kind == 'control':
1705 control_override = act.af
1706 if act.kind == 'deb':
1707 testbed.blame('arg:'+act.af.spec)
1708 determine_package(act)
1709 testbed.blame('deb:'+act.pkg)
1710 binaries.register(act,act.pkg,act.af,
1711 'forbuilds',testbed.blamed)
1712 if act.kind == 'dsc' or act.kind == 'ubtree':
1713 build_source(act, control_override)
1714 if act.kind == 'tree':
1716 if act.kind.endswith('tree') or act.kind == 'dsc':
1717 control_override = None
1719 debug_a1('builds done.')
1722 control_override = None
1724 debug_a1('tests ...')
1725 for act in opts.actions:
1726 debug_a2('test %s %s' % (act.kind, act.what))
1728 testbed.needs_reset()
1729 if act.kind == 'control':
1730 control_override = act.af
1731 if act.kind == 'deb':
1732 binaries.register(act,act.pkg,act.af,'fortests',
1734 if act.kind == 'dsc' or act.kind == 'ubtree':
1735 for (pkg,bin) in act.binaries:
1736 binaries.register(act,pkg,bin,'fortests',
1738 if act.kind == 'dsc':
1739 if act.ah['dsc_tests']:
1740 debug_a3('read control ...')
1741 stanzas = read_control(act, act.tests_tree,
1743 testbed.blamed += act.blamed
1744 debug_a3('run_tests ...')
1745 run_tests(stanzas, act.tests_tree)
1746 control_override = None
1747 if act.kind == 'tree' or act.kind == 'ubtree':
1748 testbed.blame('arg:'+act.af.spec)
1749 stanzas = read_control(act, act.af, control_override)
1750 debug_a3('run_tests ...')
1751 run_tests(stanzas, act.af)
1752 control_override = None
1753 debug_a1('tests done.')
1760 except SystemExit, se:
1769 ec = print_exception(sys.exc_info(), '')