[reprotest] 01/01: Remove more unused autopkgtest files
Ximin Luo
infinity0 at debian.org
Mon Nov 28 19:27:38 UTC 2016
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository reprotest.
commit 1d780c6bd086a993d92508dc2f58a67b300a67a9
Author: Ximin Luo <infinity0 at debian.org>
Date: Mon Nov 28 20:24:23 2016 +0100
Remove more unused autopkgtest files
---
reprotest/lib/README.running-tests.rst | 279 -------------
reprotest/lib/adt_binaries.py | 133 -------
reprotest/lib/adt_run_args.py | 392 ------------------
reprotest/lib/testdesc.py | 541 -------------------------
reprotest/runner/README.running-tests.rst | 279 -------------
reprotest/runner/adt-run | 634 ------------------------------
reprotest/runner/adt-run.1 | 511 ------------------------
7 files changed, 2769 deletions(-)
diff --git a/reprotest/lib/README.running-tests.rst b/reprotest/lib/README.running-tests.rst
deleted file mode 100644
index f30629e..0000000
--- a/reprotest/lib/README.running-tests.rst
+++ /dev/null
@@ -1,279 +0,0 @@
-Autopkgtest - Running tests
-===========================
-
-This document gives an overview how to run tests with autopkgtest. It
-does not cover each detail, please consult the individual manpages like
-adt-run(1), adt-virt-schroot(1), etc. for all available options.
-
-Ingredients for Debian packages:
-
-- A source package which defines tests in ``debian/tests/``. See
- README.package-tests for how to define them.
-
- There are plenty of existing package tests in Debian/Ubuntu which you
- can use as examples and inspiration, just look for a source package
- with a ``Testsuite: autopkgtest`` header, or the automatic test
- running services `in Debian <http://ci.debian.net/>`_ and Ubuntu (e.
- g. for `14.04 LTS <https://jenkins.qa.ubuntu.com/view/Trusty/view/AutoPkgTest/>`_).
-
-- A location for the source/tests: This can be a local source tree, a
- local .dsc, or "download with apt-get source".
-
-- Optionally some pre-built binary packages which should be tested.
-
-Ingredients for Click packages:
-
-- A binary .click package (local ``*.click`` file or already installed)
- whose manifest specifies tests and their metadata. See
- README.click-tests.rst for details.
-
-- The corresponding click source package which contains the tests
- defined in the manifest.
-
-Finally you need a virtualization server, which creates the environment
-in which the test runs. Depending on how intrusive the test is this can
-provide various degrees of isolation, from "run on my local system"
-(fastest, but unsafe) to "run in a temporary virtual machine" (slowest,
-but highest possible isolation). These are described in detail below.
-
-adt-run
--------
-The ``adt-run`` program is the main program to run tests which gets all
-these ingredients as arguments, in the following form:
-
-::
-
- adt-run [options] <source package> --- <virt-server> [<virt-server options>]
-
-Specifying tests and packages
------------------------------
-
-All possible options are explained in the adt-run(1) manpage. This
-section shows the most common scenarios, with using "mysrc" as source
-package name. Note that specifying the virtualization server and its
-options is handled in the following section, and it is independent of
-specifying tests and packages, so it is merely abbreviated as
-*virt-server* here.
-
-- Run tests from the Debian source package in the distribution. This
- calls ``apt-get source mysrc`` in the virt-server, thus will use
- whichever distribution/release that ``/etc/apt/sources.list``
- configures:
-
- ``adt-run mysrc ---`` *virt-server*
-
-- Run tests from a local unbuilt source tree, using the binary packages
- from the distribution. This is useful if you are creating or fixing
- tests, but the actual binary packages are fine:
-
- ``adt-run -B --unbuilt-tree=packages/mysrc ---`` *virt-server*
-
- Note that you can abbreviate ``--unbuilt-tree=`` with just the
- directory with two(!) trailing slashes, i. e.
-
- ``adt-run -B packages/mysrc// ---`` *virt-server*
-
-- Run tests from a local built source tree, using the binary packages
- from the distribution:
-
- ``adt-run -B --built-tree=packages/mysrc ---`` *virt-server*
-
- Note that you can abbreviate ``--built-tree=`` with just the
- directory with one(!) trailing slash, i. e.
-
- ``adt-run -B packages/mysrc/ ---`` *virt-server*
-
- Built vs. unbuilt only makes a difference for tests which declare the
- ``build-needed`` restriction (see README.package-tests), in which
- case ``--built-tree`` avoids having to re-build the source in the
- virt-server.
-
-- Build a local source package in the virt-server, then run its tests
- against the built binaries. This is useful if you need to fix a bug
- in the actual packages to make the tests succeed:
-
- ``adt-run packages/mysrc// ---`` *virt-server*
-
-- Same as above, but with specifying a built source package instead of
- a source tree:
-
- ``adt-run packages/mysrc_*.dsc ---`` *virt-server*
-
-- Test new built binaries with a new source and avoid rebuilding them
- in virt-server. This is useful if you e. g. update a package to a new
- version and now want to check whether its tests still succeed:
-
- ``adt-run -B packages/*.deb packages/mysrc_*.dsc ---`` *virt-server*
-
-- The previous case can be simplified if you have a binary .changes
- from a previous build:
-
-
- ``adt-run packages/*.changes ---`` *virt-server*
-
-- Run tests for a locally built click package:
-
- ``adt-run myclickapp/ myclickapp_0.1_all.click ---`` *virt-server*
-
- Note that for this you need to specify a virt-server which has
- "click" itself and the click app's required framework already
- installed. To run this on an actual Ubuntu phone, you can use the SSH
- testbed server:
-
- ::
-
- adt-run ubuntu-calculator-app/ com.ubuntu.calculator_1.3.283_all.click --- ssh -s adb
-
- (This is using the shipped ``adb`` setup script in
- ``/usr/share/autopkgtest/ssh-setup/``.)
-
- If you aren't running the test on an Ubuntu touch device, you can
- approximate the environment in a normal schroot/LXC/QEMU testbed with
- the ``--setup-commands`` scripts that autopkgtest provides (note that
- you do not need to specify the full
- ``/usr/share/autopkgtest/setup-commands/`` path for shipped scripts):
-
- ::
-
- adt-run --setup-commands ubuntu-touch-session \
- --setup-commands ro-apt \
- myclickapp/ myclickapp_0.1_all.click --- lxc adt-utopic
-
- See the comments in the setup-commands scripts for details.
-
-- Run tests for an already installed click package:
-
- ``adt-run --click=com.example.myapp ---`` *virt-server*
-
- This will work for click apps which have an ``x-source/vcs-bzr`` entry
- in their manifest. If that's not the case, you will need to explicitly
- specify the click source directory as above.
-
-Output
-------
-
-Unless you specify some options, adt-run just writes the logging, test
-outputs, and test results to stdout/stderr and exits with code 0 on
-success, or some non-zero code if there were skipped or failed tests or
-problems with the virt-server. (See adt-run(1) for defined codes).
-
-For getting output files you have three choices:
-
-- If you just want the "testname: PASS/FAIL" results, use
-
- ``--summary-file=/path/to/summary.txt``.
-
-- If you want the complete output of adt-run in a file, use
-
- ``-l /path/to/test.log`` (or the long option ``--log-file``)
-
-- If you want the log file, the individual test stdout and stderr
- output, and built binaries (if any) in a directory, use
-
- ``-o /path/to/test-output/`` (or the long option ``--output-dir``).
-
-You can also combine these.
-
-Virtualization server
----------------------
-
-schroot
-~~~~~~~
-::
-
- adt-run ... --- schroot schroot-name
-
-Run tests in the specified schroot. You can use mk-sbuild(1) to
-conveniently create schroots, and run this as normal user if you
-configured schroot accordingly.
-
-This server is the fastest available that provides "proper" file system
-isolation and revert, but it does not provide enough isolation for tests
-that need to start services, reconfigure the network, or open TCP ports
-which are already open at the host. If your test does not need to do
-these things this is the recommended server, as schroots are also useful
-for other tasks like building packages with sbuild.
-
-See adt-virt-schroot(1) manpage.
-
-LXC
-~~~
-::
-
- adt-run ... --- lxc container-name
-
-Run tests in the specified LXC container. Containers provide full
-service and network isolation, but tests or packages cannot change the
-kernel or hardware configuration. If your test does not need that, this
-is the recommended server as it is faster than QEMU and works on all
-Linux architectures.
-
-``container-name`` will be cloned or be called with a temporary overlay
-file system if you specify the ``-e`` (``--ephemeral``) option, thus it
-will never be modified and you can run several tests in parallel safely.
-Unless your test or architecture or RAM availability doesn't work with
-overlayfs, using -e is highly recommended for better performance.
-
-If your user can get root privileges with sudo, you can call adt-run as
-your normal user and specify ``-s`` (``--sudo``) so that the container
-can be started as root.
-
-See adt-virt-lxc(1) manpage. This also explains how to build containers.
-
-QEMU
-~~~~
-::
-
- adt-run ... --- qemu path/to/image
-
-Run tests with QEMU/KVM using the specified image. The image will be run
-with a temporary overlay file system, thus it will never be modified and
-you can run several tests in parallel safely.
-
-If your test needs a full machine including kernel/hardware access, this
-is the recommended runner; it provides complete system isolation, revert
-and breaks-testbed capabilities. But it is also the one with the biggest
-overhead and only works well on architectures with KVM acceleration (i.
-e. mostly x86).
-
-See adt-virt-qemu(1) manpage. This also explains how to build suitable
-images, and the requirements of the guest.
-
-null
-~~~~
-::
-
- adt-run ... --- null
-
-This does not do any virtualization, but runs tests straight on the
-host. Beware that this will leave some clutter on your system (installed
-test or build dependency packages, configuration changes that the tests
-might make, etc.). It is not able to run tests with the "breaks-testbed"
-restriction. See adt-virt-null(1) manpage.
-
-chroot
-~~~~~~
-::
-
- adt-run ... --- chroot /path/to/chroot
-
-Run tests in the specified chroot. You need to call adt-run as root for
-this. There is no automatic cleanup or revert for the chroot, so unless
-you can provide this by some other means, don't use this.
-
-ssh
-~~~
-::
-
- adt-run ... --- ssh -l joe -h testhost.example.com
-
-This is a generic runner for an externally set up testbed which assumes
-nothing else than a working ssh connection. This can call a "setup
-script" to create/configure a testbed (such as spinning up a cloud VM
-with nova or setting up SSH on a phone through ADB). See the manpage for
-details. autopkgtest ships setup scripts for an adb host (mostly for
-Ubuntu Touch), for nova (for cloud instances) and for Ubuntu Snappy
-currently; see their comment headers in
-``/usr/share/autopkgtest/ssh-setup/``.
-
-.. vim: ft=rst tw=72
diff --git a/reprotest/lib/adt_binaries.py b/reprotest/lib/adt_binaries.py
deleted file mode 100644
index c544b00..0000000
--- a/reprotest/lib/adt_binaries.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Licensed under the GPL: https://www.gnu.org/licenses/gpl-3.0.en.html
-# For details: reprotest/debian/copyright
-
-import os
-import subprocess
-import atexit
-import shutil
-import errno
-
-# TODO: not sure if this file is necessary
-
-# import adtlog
-# import adt_testbed
-
-
-class DebBinaries:
- '''Registration and installation of .debs'''
-
- def __init__(self, testbed, output_dir):
- adtlog.debug('Binaries: initialising')
-
- self.testbed = testbed
- self.output_dir = output_dir
-
- # the binary dir must exist across testbed reopenings, so don't use a
- # TempPath
- self.dir = adt_testbed.Path(
- self.testbed, os.path.join(self.output_dir, 'binaries'),
- os.path.join(self.testbed.scratch, 'binaries'), is_dir=True)
- os.mkdir(self.dir.host)
- self.registered = set()
-
- # clean up an empty binaries output dir
- atexit.register(lambda: os.path.exists(self.dir.host) and (
- os.listdir(self.dir.host) or os.rmdir(self.dir.host)))
-
- self.need_apt_reset = False
-
- def register(self, path, pkgname):
- adtlog.debug('Binaries: register deb=%s pkgname=%s ' % (path, pkgname))
-
- dest = os.path.join(self.dir.host, pkgname + '.deb')
-
- # link or copy to self.dir
- try:
- os.remove(dest)
- except (IOError, OSError) as oe:
- if oe.errno != errno.ENOENT:
- raise oe
- try:
- os.link(path, dest)
- except (IOError, OSError) as oe:
- if oe.errno != errno.EXDEV:
- raise oe
- shutil.copy(path, dest)
- # clean up locally built debs (what=ubtreeN) to keep a clean
- # --output-dir, but don't clean up --binary arguments
- if path.startswith(self.output_dir):
- atexit.register(lambda f: os.path.exists(f) and os.unlink(f), path)
- self.registered.add(pkgname)
-
- def publish(self):
- if not self.registered:
- adtlog.debug('Binaries: no registered binaries, not publishing anything')
- return
- adtlog.debug('Binaries: publish')
-
- try:
- with open(os.path.join(self.dir.host, 'Packages'), 'w') as f:
- subprocess.check_call(['apt-ftparchive', 'packages', '.'],
- cwd=self.dir.host, stdout=f)
- with open(os.path.join(self.dir.host, 'Release'), 'w') as f:
- subprocess.call(['apt-ftparchive', 'release', '.'],
- cwd=self.dir.host, stdout=f)
- except subprocess.CalledProcessError as e:
- adtlog.bomb('apt-ftparchive failed: %s' % e)
-
- # copy binaries directory to testbed; self.dir.tb might have changed
- # since last time due to a reset, so update it
- self.dir.tb = os.path.join(self.testbed.scratch, 'binaries')
- self.testbed.check_exec(['rm', '-rf', self.dir.tb])
- self.dir.copydown()
-
- aptupdate_out = adt_testbed.TempPath(self.testbed, 'apt-update.out')
- script = '''
- printf 'Package: *\\nPin: origin ""\\nPin-Priority: 1002\\n' > /etc/apt/preferences.d/90autopkgtest
- echo "deb [trusted=yes] file://%(d)s /" >/etc/apt/sources.list.d/autopkgtest.list
- if [ "x`ls /var/lib/dpkg/updates`" != x ]; then
- echo >&2 "/var/lib/dpkg/updates contains some files, aargh"; exit 1
- fi
- apt-get --quiet --no-list-cleanup -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/autopkgtest.list -o Dir::Etc::sourceparts=/dev/null update 2>&1
- cp /var/lib/dpkg/status %(o)s
- ''' % {'d': self.dir.tb, 'o': aptupdate_out.tb}
- self.need_apt_reset = True
- self.testbed.check_exec(['sh', '-ec', script], kind='install')
-
- aptupdate_out.copyup()
-
- adtlog.debug('Binaries: publish reinstall checking...')
- pkgs_reinstall = set()
- pkg = None
- for l in open(aptupdate_out.host, encoding='UTF-8'):
- if l.startswith('Package: '):
- pkg = l[9:].rstrip()
- elif l.startswith('Status: install '):
- if pkg in self.registered:
- pkgs_reinstall.add(pkg)
- adtlog.debug('Binaries: publish reinstall needs ' + pkg)
-
- if pkgs_reinstall:
- rc = self.testbed.execute(
- ['apt-get', '--quiet', '-o', 'Debug::pkgProblemResolver=true',
- '-o', 'APT::Get::force-yes=true',
- '-o', 'APT::Get::Assume-Yes=true',
- '--reinstall', 'install'] + list(pkgs_reinstall),
- kind='install')[0]
- if rc:
- adtlog.badpkg('installation of basic binaries failed, exit code %d' % rc)
-
- adtlog.debug('Binaries: publish done')
-
- def reset(self):
- '''Revert apt configuration for testbeds without reset'''
-
- if self.need_apt_reset and 'revert' not in self.testbed.caps:
- adtlog.info('Binaries: resetting testbed apt configuration')
- self.testbed.check_exec(
- ['sh', '-ec',
- 'rm -f /etc/apt/sources.list.d/autopkgtest.list /etc/apt/preferences.d/90autopkgtest; '
- '(apt-get --quiet update || (sleep 15; apt-get update)) 2>&1'],
- kind='install')
-
- self.need_apt_reset = False
diff --git a/reprotest/lib/adt_run_args.py b/reprotest/lib/adt_run_args.py
deleted file mode 100644
index 034c6d7..0000000
--- a/reprotest/lib/adt_run_args.py
+++ /dev/null
@@ -1,392 +0,0 @@
-# Licensed under the GPL: https://www.gnu.org/licenses/gpl-3.0.en.html
-# For details: reprotest/debian/copyright
-
-import os
-import re
-import argparse
-from glob import glob
-
-import adtlog
-import testdesc
-import adt_testbed
-
-__all__ = ['parse_args']
-
-
-def is_click_src(path):
- '''Check if path is a click source tree'''
-
- if os.path.isdir(os.path.join(path, 'click')):
- return True
- if glob(os.path.join(path, 'manifest.json*')):
- return True
- return False
-
-
-def interpret_implicit_args(parser, args):
- '''Heuristically translate positional arguments to actions'''
-
- known_suffix = {
- '.dsc': '--source',
- '.deb': '--binary',
- '.changes': '--changes',
- '.click': '--click',
- }
- pos = 0
- result = []
-
- while pos < len(args):
- # jump over option args
- if args[pos] == '-B':
- args[pos] = '--no-built-binaries'
- if args[pos].startswith('--') and 'binaries' in args[pos]:
- result.append(args[pos])
- pos += 1
- continue
-
- if args[pos].startswith('--'):
- result.append(args[pos])
- if '=' not in args[pos]:
- try:
- result.append(args[pos + 1])
- except IndexError:
- pass
- pos += 1
- pos += 1
- continue
-
- # actions based on file name suffix
- for suffix, action in known_suffix.items():
- if args[pos].endswith(suffix):
- result += [action, args[pos]]
- break
- else:
- if is_click_src(args[pos]):
- result += ['--click-source', args[pos]]
- elif os.path.isdir(args[pos]) and args[pos].endswith('//'):
- result += ['--unbuilt-tree', args[pos]]
- elif os.path.isdir(args[pos]) and args[pos].endswith('/'):
- result += ['--built-tree', args[pos]]
- # actions based on patterns
- elif re.match('[0-9a-z][0-9a-z.+-]+$', args[pos]):
- result += ['--apt-source', args[pos]]
- else:
- parser.error('%s: unsupported action argument' % args[pos])
-
- pos += 1
-
- return result
-
-actions = None
-built_binaries = None
-
-
-class ArgumentParser(argparse.ArgumentParser):
- '''autopkgtest ArgumentParser
-
- It enables include files with '@' and trims whitespace from their lines.
- '''
- def __init__(self, **kwargs):
- super(ArgumentParser, self).__init__(fromfile_prefix_chars='@',
- **kwargs)
-
- def convert_arg_line_to_args(self, arg_line):
- return [arg_line.strip()]
-
-
-class ActionArg(argparse.Action):
- def __call__(self, parser, args, value, option_string):
- global actions, built_binaries
- if option_string == '--changes':
- try:
- files = testdesc.parse_rfc822(value).__next__()['Files']
- except (StopIteration, KeyError):
- parser.error('%s is invalid and does not contain Files:'
- % value)
- dsc_dir = os.path.dirname(value)
- act_bin = []
- act_src = []
- for f in files.split():
- if '.' in f and '_' in f:
- fpath = os.path.join(dsc_dir, f)
- if f.endswith('.deb'):
- act_bin.append(('binary', fpath, None))
- elif f.endswith('.dsc'):
- act_src.append(('source', fpath, False))
-
- # we need to register the binaries before the source
- actions += act_bin + act_src
- return
-
- if option_string in ('--apt-source', '--built-tree'):
- bins = False
- # these are the only types where built_binaries applies
- elif option_string in ('--unbuilt-tree', '--source', '--git-source'):
- bins = built_binaries
- else:
- bins = None
- actions.append((option_string.lstrip('-'), value, bins))
-
-
-class BinariesArg(argparse.Action):
- def __call__(self, parser, args, value, option_string=None):
- global built_binaries
-
- if option_string == '--no-built-binaries':
- built_binaries = False
- elif option_string == '--built-binaries':
- built_binaries = True
- else:
- raise NotImplementedError('cannot handle BinariesArg ' +
- option_string)
-
-
-def parse_args(arglist=None):
- '''Parse adt-run command line arguments.
-
- Return (options, actions, virt-server-args).
- '''
- global actions, built_binaries
-
- actions = []
- built_binaries = True
-
- # action parser; instantiated first to use generated help
- action_parser = argparse.ArgumentParser(usage=argparse.SUPPRESS,
- add_help=False)
- action_parser.add_argument(
- '--unbuilt-tree', action=ActionArg, metavar='DIR or DIR//',
- help='run tests from unbuilt Debian source tree DIR')
- action_parser.add_argument(
- '--built-tree', action=ActionArg, metavar='DIR or DIR/',
- help='run tests from built Debian source tree DIR')
- action_parser.add_argument(
- '--source', action=ActionArg, metavar='DSC or some/pkg.dsc',
- help='build DSC and use its tests and/or generated binary packages')
- action_parser.add_argument(
- '--git-source', action=ActionArg, metavar='GITURL [branchname]',
- help='check out git URL (optionally a non-default branch), build it '
- 'if necessary, and run its tests')
- action_parser.add_argument(
- '--binary', action=ActionArg, metavar='DEB or some/pkg.deb',
- help='use binary package DEB for subsequent tests')
- action_parser.add_argument(
- '--changes', action=ActionArg, metavar='CHANGES or some/pkg.changes',
- help='run tests from dsc and binary debs from a .changes file')
- action_parser.add_argument(
- '--apt-source', action=ActionArg, metavar='SRCPKG or somesrc',
- help='download with apt-get source in testbed and use its tests')
- action_parser.add_argument(
- '--click-source', action=ActionArg, metavar='CLICKSRC or some/src',
- help='click source tree for subsequent --click package')
- action_parser.add_argument(
- '--click', action=ActionArg, metavar='CLICKPKG or some/pkg.click',
- help='install click package into testbed (path to *.click) or '
- 'use an already installed click package ("com.example.myapp") '
- 'and run its tests (from manifest\'s x-source or preceding '
- '--click-source)')
- action_parser.add_argument(
- '--override-control', action=ActionArg,
- metavar='CONTROL', help='run tests from control file/manifest CONTROL'
- ' instead in the next package')
- action_parser.add_argument(
- '--testname', action=ActionArg,
- help='run only given test name in the next package')
- action_parser.add_argument(
- '-B', '--no-built-binaries', nargs=0, action=BinariesArg,
- help='do not use any binaries from subsequent --source, '
- '--git-source, or --unbuilt-tree actions')
- action_parser.add_argument(
- '--built-binaries', nargs=0, action=BinariesArg,
- help='use binaries from subsequent --source, --git-source, or '
- '--unbuilt-tree actions')
-
- # main / options parser
- usage = '%(prog)s [options] action [action ...] --- virt-server [options]'
- description = '''Test installed binary packages using the tests in the source package.
-
-Actions specify the source and binary packages to test, or change
-what happens with package arguments:
-%s
-''' % action_parser.format_help().split('\n', 1)[1]
-
- epilog = '''The --- argument separates the adt-run actions and options from the
-virt-server which provides the testbed. See e. g. man adt-virt-schroot for
-details.'''
-
- parser = argparse.ArgumentParser(
- usage=usage, description=description,
- formatter_class=argparse.RawDescriptionHelpFormatter, epilog=epilog,
- add_help=False)
- # logging
- g_log = parser.add_argument_group('logging options')
- g_log.add_argument('-o', '--output-dir',
- help='Write test artifacts (stdout/err, log, debs, etc)'
- ' to OUTPUT-DIR (must not exist or be empty)')
- g_log.add_argument('-l', '--log-file', dest='logfile',
- help='Write the log LOGFILE, emptying it beforehand,'
- ' instead of using OUTPUT-DIR/log')
- g_log.add_argument('--summary-file', dest='summary',
- help='Write a summary report to SUMMARY, emptying it '
- 'beforehand')
- g_log.add_argument('-q', '--quiet', action='store_const', dest='verbosity',
- const=0, default=1,
- help='Suppress all messages from %(prog)s itself '
- 'except for the test results')
-
- # test bed setup
- g_setup = parser.add_argument_group('test bed setup options')
- g_setup.add_argument('--setup-commands', metavar='COMMANDS_OR_PATH',
- action='append', default=[],
- help='Run these commands after opening the testbed '
- '(e. g. "apt-get update" or adding apt sources); '
- 'can be a string with the commands, or a file '
- 'containing the commands')
- g_setup.add_argument('-U', '--apt-upgrade', dest='setup_commands',
- action='append_const',
- const='(apt-get update || (sleep 15; apt-get update)'
- ' || (sleep 60; apt-get update))'
- ' && $(which eatmydata || true) apt-get dist-upgrade -y -o '
- 'Dpkg::Options::="--force-confnew"',
- help='Run apt update/dist-upgrade before the tests')
- g_setup.add_argument('--apt-pocket', action='append',
- metavar='POCKETNAME[=pkgname,src:srcname,...]',
- default=[],
- help='Enable additional apt source for POCKETNAME. '
- 'If packages are given, set up apt pinning to use '
- 'only those packages from POCKETNAME; src:srcname '
- ' expands to all binaries of srcname')
- g_setup.add_argument('--copy', metavar='HOSTFILE:TESTBEDFILE',
- action='append', default=[],
- help='Copy file or dir from host into testbed after '
- 'opening')
- g_setup.add_argument('--env', metavar='VAR=value',
- action='append', default=[],
- help='Set arbitrary environment variable for builds and test')
-
- # privileges
- g_priv = parser.add_argument_group('user/privilege handling options')
- g_priv.add_argument('-u', '--user',
- help='run tests as USER (needs root on testbed)')
- g_priv.add_argument('--gain-root', dest='gainroot',
- help='Command to gain root during package build, '
- 'passed to dpkg-buildpackage -r')
-
- # debugging
- g_dbg = parser.add_argument_group('debugging options')
- g_dbg.add_argument('-d', '--debug', action='store_const', dest='verbosity',
- const=2,
- help='Show lots of internal adt-run debug messages')
- g_dbg.add_argument('-s', '--shell-fail', action='store_true',
- help='Run a shell in the testbed after any failed '
- 'build or test')
- g_dbg.add_argument('--shell', action='store_true',
- help='Run a shell in the testbed after every test')
-
- # timeouts
- g_time = parser.add_argument_group('timeout options')
- for k, v in adt_testbed.timeouts.items():
- g_time.add_argument(
- '--timeout-' + k, type=int, dest='timeout_' + k, metavar='T',
- help='set %s timeout to T seconds (default: %us)' %
- (k, v))
- g_time.add_argument(
- '--timeout-factor', type=float, metavar='FACTOR', default=1.0,
- help='multiply all default timeouts by FACTOR')
-
- # locale
- g_loc = parser.add_argument_group('locale options')
- g_loc.add_argument('--set-lang', metavar='LANGVAL',
- help='set LANG on testbed to LANGVAL '
- '(default: C.UTF-8')
-
- # misc
- g_misc = parser.add_argument_group('other options')
- g_misc.add_argument(
- '--no-auto-control', dest='auto_control', action='store_false',
- default=True,
- help='Disable automatic test generation with autodep8')
- g_misc.add_argument('--build-parallel', metavar='N',
- help='Set "parallel=N" DEB_BUILD_OPTION for building '
- 'packages (default: number of available processors)')
- g_misc.add_argument(
- '-h', '--help', action='help', default=argparse.SUPPRESS,
- help='show this help message and exit')
-
- # first, expand argument files
- file_parser = ArgumentParser(add_help=False)
- arglist = file_parser.parse_known_args(arglist)[1]
-
- # split off virt-server args
- try:
- sep = arglist.index('---')
- virt_args = arglist[sep + 1:]
- arglist = arglist[:sep]
- except ValueError:
- # still allow --help
- virt_args = None
-
- # parse options first
- (args, action_args) = parser.parse_known_args(arglist)
- adtlog.verbosity = args.verbosity
- adtlog.debug('Parsed options: %s' % args)
- adtlog.debug('Remaining arguments: %s' % action_args)
-
- # now turn implicit "bare" args into option args, so that we can parse them
- # with argparse, and split off the virt-server args
- action_args = interpret_implicit_args(parser, action_args)
- adtlog.debug('Interpreted actions: %s' % action_args)
- adtlog.debug('Virt runner arguments: %s' % virt_args)
-
- if not virt_args:
- parser.error('You must specify --- <virt-server>...')
-
- action_parser.parse_args(action_args)
-
- # verify --env validity
- for e in args.env:
- if '=' not in e:
- parser.error('--env must be KEY=value')
-
- if args.set_lang:
- args.env.append('LANG=' + args.set_lang)
-
- # set (possibly adjusted) timeout defaults
- for k in adt_testbed.timeouts:
- v = getattr(args, 'timeout_' + k)
- if v is None:
- adt_testbed.timeouts[k] = int(adt_testbed.timeouts[k] * args.timeout_factor)
- else:
- adt_testbed.timeouts[k] = v
-
- # this timeout is for adt-virt-*, so pass it down via environment
- os.environ['ADT_VIRT_COPY_TIMEOUT'] = str(adt_testbed.timeouts['copy'])
-
- if not actions:
- parser.error('You must specify at least one action')
-
- # if we have --setup-commands and it points to a file, read its contents
- for i, c in enumerate(args.setup_commands):
- # shortcut for shipped scripts
- if '/' not in c:
- shipped = os.path.join('/usr/share/autopkgtest/setup-commands', c)
- if os.path.exists(shipped):
- c = shipped
- if os.path.exists(c):
- with open(c, encoding='UTF-8') as f:
- args.setup_commands[i] = f.read().strip()
-
- # parse --copy arguments
- copy_pairs = []
- for arg in args.copy:
- try:
- (host, tb) = arg.split(':', 1)
- except ValueError:
- parser.error('--copy argument must be HOSTPATH:TESTBEDPATH: %s'
- % arg)
- if not os.path.exists(host):
- parser.error('--copy host path %s does not exist' % host)
- copy_pairs.append((host, tb))
- args.copy = copy_pairs
-
- return (args, actions, virt_args)
diff --git a/reprotest/lib/testdesc.py b/reprotest/lib/testdesc.py
deleted file mode 100644
index 401ac40..0000000
--- a/reprotest/lib/testdesc.py
+++ /dev/null
@@ -1,541 +0,0 @@
-# Licensed under the GPL: https://www.gnu.org/licenses/gpl-3.0.en.html
-# For details: reprotest/debian/copyright
-
-import string
-import re
-import errno
-import os.path
-import json
-import subprocess
-import tempfile
-import atexit
-import shutil
-
-# TODO: probably this file is unnecessary.
-
-# import debian.deb822
-# import debian.debian_support
-# import debian.debfile
-
-# import adtlog
-
-#
-# Abstract test representation
-#
-
-known_restrictions = ['rw-build-tree', 'breaks-testbed', 'needs-root',
- 'build-needed', 'allow-stderr', 'isolation-container',
- 'isolation-machine', 'needs-recommends']
-
-
-class Unsupported(Exception):
- '''Test cannot be run in the testbed'''
-
- def __init__(self, testname, message):
- self.testname = testname
- self.message = message
-
- def __str__(self):
- return 'Unsupported test %s: %s' % (self.testname, self.message)
-
- def report(self):
- adtlog.report(self.testname, 'SKIP %s' % self.message)
-
-
-class InvalidControl(Exception):
- '''Test has invalid control data'''
-
- def __init__(self, testname, message):
- self.testname = testname
- self.message = message
-
- def __str__(self):
- return 'InvalidControl test %s: %s' % (self.testname, self.message)
-
- def report(self):
- adtlog.report(self.testname, 'BROKEN %s' % self.message)
-
-
-class Test:
- '''Test description.
-
- This is only a representation of the metadata, it does not have any
- actions.
- '''
- def __init__(self, name, path, command, restrictions, features, depends,
- clicks, installed_clicks):
- '''Create new test description
-
- A test must have either "path" or "command", the respective other value
- must be None.
-
- @name: Test name
- @path: path to the test's executable, relative to source tree
- @command: shell command for the test code
- @restrictions, @features: string lists, as in README.package-tests
- @depends: string list of test dependencies (packages)
- @clicks: path list of click packages to install for this test
- @installed_clicks: names of already installed clicks for this test
- '''
- if '/' in name:
- raise Unsupported(name, 'test name may not contain / character')
- for r in restrictions:
- if r not in known_restrictions:
- raise Unsupported(name, 'unknown restriction %s' % r)
-
- if not ((path is None) ^ (command is None)):
- raise InvalidControl(name, 'Test must have either path or command')
-
- self.name = name
- self.path = path
- self.command = command
- self.restrictions = restrictions
- self.features = features
- self.depends = depends
- self.clicks = clicks
- self.installed_clicks = installed_clicks
- # None while test hasn't run yet; True: pass, False: fail
- self.result = None
- adtlog.debug('Test defined: name %s path %s command "%s" '
- 'restrictions %s features %s depends %s clicks %s '
- 'installed clicks %s' %
- (name, path, command, restrictions, features, depends,
- clicks, installed_clicks))
-
- def passed(self):
- '''Mark test as passed'''
-
- self.result = True
- adtlog.report(self.name, 'PASS')
-
- def failed(self, reason):
- '''Mark test as failed'''
-
- self.result = False
- adtlog.report(self.name, 'FAIL ' + reason)
-
- def check_testbed_compat(self, caps):
- '''Check for restrictions incompatible with test bed capabilities.
-
- Raise Unsupported exception if there are any.
- '''
- if 'isolation-container' in self.restrictions and \
- 'isolation-container' not in caps and \
- 'isolation-machine' not in caps:
- raise Unsupported(self.name,
- 'Test requires container-level isolation but '
- 'testbed does not provide that')
-
- if 'isolation-machine' in self.restrictions and \
- 'isolation-machine' not in caps:
- raise Unsupported(self.name,
- 'Test requires machine-level isolation but '
- 'testbed does not provide that')
-
- if 'breaks-testbed' in self.restrictions and \
- 'revert-full-system' not in caps:
- raise Unsupported(self.name,
- 'Test breaks testbed but testbed does not '
- 'provide revert-full-system')
-
- if 'needs-root' in self.restrictions and \
- 'root-on-testbed' not in caps:
- raise Unsupported(self.name,
- 'Test needs root on testbed which is not '
- 'available')
-
-#
-# Parsing for Debian source packages
-#
-
-
-def parse_rfc822(path):
- '''Parse Debian-style RFC822 file
-
- Yield dictionaries with the keys/values.
- '''
- try:
- f = open(path, encoding='UTF-8')
- except (IOError, OSError) as oe:
- if oe.errno != errno.ENOENT:
- raise
- return
-
- # filter out comments, python-debian doesn't do that
- # (http://bugs.debian.org/743174)
- lines = []
- for l in f:
- # completely ignore ^# as that breaks continuation lines
- if l.startswith('#'):
- continue
- # filter out comments which don't start on first column (Debian
- # #743174); entirely remove line if all that's left is whitespace, as
- # that again breaks continuation lines
- if '#' in l:
- l = l.split('#', 1)[0]
- if not l.strip():
- continue
- lines.append(l)
- f.close()
-
- for p in debian.deb822.Deb822.iter_paragraphs(lines):
- r = {}
- for field, value in p.items():
- # un-escape continuation lines
- v = ''.join(value.split('\n')).replace(' ', ' ')
- field = string.capwords(field)
- r[field] = v
- yield r
-
-
-def _debian_check_unknown_fields(name, record):
- unknown_keys = set(record.keys()).difference(
- {'Tests', 'Test-command', 'Restrictions', 'Features',
- 'Depends', 'Tests-directory', 'Classes'})
- if unknown_keys:
- raise Unsupported(name, 'unknown field %s' % unknown_keys.pop())
-
-
-def _debian_packages_from_source(srcdir):
- packages = []
-
- for st in parse_rfc822(os.path.join(srcdir, 'debian/control')):
- if 'Package' not in st:
- # source stanza
- continue
- # filter out udebs and similar stuff which aren't "real" debs
- if st.get('Xc-package-type', 'deb') != 'deb' or \
- st.get('Package-type', 'deb') != 'deb':
- continue
- arch = st['Architecture']
- if arch in ('all', 'any'):
- packages.append('%s (>= 0~)' % st['Package'])
- else:
- packages.append('%s (>= 0~) [%s]' % (st['Package'], arch))
-
- return packages
-
-
-def _debian_build_deps_from_source(srcdir, testbed_arch):
- deps = ''
- for st in parse_rfc822(os.path.join(srcdir, 'debian/control')):
- if 'Build-depends' in st:
- deps += st['Build-depends']
- if 'Build-depends-indep' in st:
- deps += ', ' + st['Build-depends-indep']
-
- # resolve arch specific dependencies and build profiles
- perl = subprocess.Popen(['perl', '-'], stdin=subprocess.PIPE,
- stdout=subprocess.PIPE)
- code = '''use Dpkg::Deps;
- $supports_profiles = ($Dpkg::Deps::VERSION gt '1.04');
- $dep = deps_parse('%s', reduce_arch => 1,
- reduce_profiles => $supports_profiles,
- build_dep => 1, host_arch => '%s');
- $out = $dep->output();
- # fall back to ignoring build profiles
- $out =~ s/ <[^ >]+>//g if (!$supports_profiles);
- print $out, "\\n";
- ''' % (deps, testbed_arch)
- deps = perl.communicate(code.encode('UTF-8'))[0].decode('UTF-8').strip()
- if perl.returncode != 0:
- raise InvalidControl('source', 'Invalid build dependencies')
-
- deps = [d.strip() for d in deps.split(',')]
-
- # @builddeps@ should always imply build-essential
- deps.append('build-essential')
- return deps
-
-
-dep_re = re.compile(
- r'(?P<package>[a-z0-9+-.]+)(?::native)?\s*'
- r'(\((?P<relation><<|<=|>=|=|>>)\s*(?P<version>[^\)]*)\))?'
- r'(\s*\[[[a-z0-9+-.! ]+\])?$')
-
-
-def _debian_check_dep(testname, dep):
- '''Check a single Debian dependency'''
-
- dep = dep.strip()
- m = dep_re.match(dep)
- if not m:
- raise InvalidControl(testname, "Test Depends field contains an "
- "invalid dependency `%s'" % dep)
- if m.group("version"):
- try:
- debian.debian_support.NativeVersion(m.group('version'))
- except ValueError:
- raise InvalidControl(testname, "Test Depends field contains "
- "dependency `%s' with an "
- "invalid version" % dep)
- except AttributeError:
- # too old python-debian, skip the check
- pass
-
-
-def _parse_debian_depends(testname, dep_str, srcdir, testbed_arch):
- '''Parse Depends: line in a Debian package
-
- Split dependencies (comma separated), validate their syntax, and expand @
- and @builddeps at . Return a list of dependencies.
-
- This may raise an InvalidControl exception if there are invalid
- dependencies.
- '''
- deps = []
- for alt_group_str in dep_str.split(','):
- alt_group_str = alt_group_str.strip()
- if not alt_group_str:
- # happens for empty depends or trailing commas
- continue
- adtlog.debug('processing dependency %s' % alt_group_str)
- if alt_group_str == '@':
- for d in _debian_packages_from_source(srcdir):
- adtlog.debug('synthesised dependency %s' % d)
- deps.append(d)
- elif alt_group_str == '@builddeps@':
- for d in _debian_build_deps_from_source(srcdir, testbed_arch):
- adtlog.debug('synthesised dependency %s' % d)
- deps.append(d)
- else:
- for dep in alt_group_str.split('|'):
- _debian_check_dep(testname, dep)
- deps.append(alt_group_str)
-
- return deps
-
-
-def _autodep8(srcdir):
- '''Generate control file with autodep8'''
-
- f = tempfile.NamedTemporaryFile(prefix='autodep8.')
- try:
- autodep8 = subprocess.Popen(['autodep8'], cwd=srcdir, stdout=f,
- stderr=subprocess.PIPE)
- except OSError as e:
- adtlog.debug('autodep8 not available (%s)' % e)
- return None
-
- err = autodep8.communicate()[1].decode()
- if autodep8.returncode == 0:
- f.flush()
- f.seek(0)
- ctrl = f.read().decode()
- adtlog.debug('autodep8 generated control: -----\n%s\n-------' % ctrl)
- return f
-
- f.close()
- adtlog.debug('autodep8 failed to generate control (exit status %i): %s' %
- (autodep8.returncode, err))
- return None
-
-
-def parse_debian_source(srcdir, testbed_caps, testbed_arch, control_path=None,
- auto_control=True):
- '''Parse test descriptions from a Debian DEP-8 source dir
-
- You can specify an alternative path for the control file (default:
- srcdir/debian/tests/control).
-
- Return (list of Test objects, some_skipped). If this encounters any invalid
- restrictions, fields, or test restrictions which cannot be met by the given
- testbed capabilities, the test will be skipped (and reported so), and not
- be included in the result.
-
- This may raise an InvalidControl exception.
- '''
- some_skipped = False
- command_counter = 0
- tests = []
- if not control_path:
- control_path = os.path.join(srcdir, 'debian', 'tests', 'control')
-
- if not os.path.exists(control_path):
- if auto_control:
- control = _autodep8(srcdir)
- if control is None:
- return ([], False)
- control_path = control.name
- else:
- adtlog.debug('auto_control is disabled, no tests')
- return ([], False)
-
- for record in parse_rfc822(control_path):
- command = None
- try:
- restrictions = record.get('Restrictions', '').replace(
- ',', ' ').split()
- features = record.get('Features', '').replace(',', ' ').split()
-
- if 'Tests' in record:
- test_names = record['Tests'].replace(',', ' ').split()
- depends = _parse_debian_depends(test_names[0],
- record.get('Depends', '@'),
- srcdir,
- testbed_arch)
- if 'Test-command' in record:
- raise InvalidControl('*', 'Only one of "Tests" or '
- '"Test-Command" may be given')
- test_dir = record.get('Tests-directory', 'debian/tests')
-
- _debian_check_unknown_fields(test_names[0], record)
- for n in test_names:
- test = Test(n, os.path.join(test_dir, n), None,
- restrictions, features, depends, [], [])
- test.check_testbed_compat(testbed_caps)
- tests.append(test)
- elif 'Test-command' in record:
- command = record['Test-command']
- depends = _parse_debian_depends(command,
- record.get('Depends', '@'),
- srcdir,
- testbed_arch)
- command_counter += 1
- name = 'command%i' % command_counter
- _debian_check_unknown_fields(name, record)
- test = Test(name, None, command, restrictions, features,
- depends, [], [])
- test.check_testbed_compat(testbed_caps)
- tests.append(test)
- else:
- raise InvalidControl('*', 'missing "Tests" or "Test-Command"'
- ' field')
- except Unsupported as u:
- u.report()
- some_skipped = True
-
- return (tests, some_skipped)
-
-
-#
-# Parsing for click packages
-#
-
-def parse_click_manifest(manifest, testbed_caps, clickdeps, use_installed,
- srcdir=None):
- '''Parse test descriptions from a click manifest.
-
- @manifest: String with the click manifest
- @testbed_caps: List of testbed capabilities
- @clickdeps: paths of click packages that these tests need
- @use_installed: True if test expects the described click to be installed
- already
-
- Return (source_dir, list of Test objects, some_skipped). If this encounters
- any invalid restrictions, fields, or test restrictions which cannot be met
- by the given testbed capabilities, the test will be skipped (and reported
- so), and not be included in the result.
-
- If srcdir is given, use that as source for the click package, and return
- that as first return value. Otherwise, locate and download the source from
- the click's manifest into a temporary directory and use that.
-
- This may raise an InvalidControl exception.
- '''
- try:
- manifest_j = json.loads(manifest)
- test_j = manifest_j.get('x-test', {})
- except ValueError as e:
- raise InvalidControl(
- '*', 'click manifest is not valid JSON: %s' % str(e))
- if not isinstance(test_j, dict):
- raise InvalidControl(
- '*', 'click manifest x-test key must be a dictionary')
-
- installed_clicks = []
- if use_installed:
- installed_clicks.append(manifest_j.get('name'))
-
- some_skipped = False
- tests = []
-
- # It's a dictionary and thus does not have a predictable ordering; sort it
- # to get a predictable list
- for name in sorted(test_j):
- desc = test_j[name]
- adtlog.debug('parsing click manifest test %s: %s' % (name, desc))
-
- # simple string is the same as { "path": <desc> } without any
- # restrictions, or the special "autopilot" case
- if isinstance(desc, str):
- if name == 'autopilot' and re.match('^[a-z_][a-z0-9_]+$', desc):
- desc = {'autopilot_module': desc}
- else:
- desc = {'path': desc}
-
- if not isinstance(desc, dict):
- raise InvalidControl(name, 'click manifest x-test dictionary '
- 'entries must be strings or dicts')
-
- # autopilot special case: dict with extra depends
- if 'autopilot_module' in desc:
- desc['command'] = \
- 'PYTHONPATH=app/tests/autopilot:tests/autopilot:$PYTHONPATH '\
- 'python3 -m autopilot.run run -v -f subunit -o ' \
- '$ADT_ARTIFACTS/%s.subunit ' % name + os.environ.get(
- 'ADT_AUTOPILOT_MODULE', desc['autopilot_module'])
- desc.setdefault('depends', []).insert(
- 0, 'ubuntu-ui-toolkit-autopilot')
- desc['depends'].insert(0, 'autopilot-touch')
- if 'allow-stderr' not in desc.setdefault('restrictions', []):
- desc['restrictions'].append('allow-stderr')
-
- try:
- test = Test(name, desc.get('path'), desc.get('command'),
- desc.get('restrictions', []), desc.get('features', []),
- desc.get('depends', []), clickdeps, installed_clicks)
- test.check_testbed_compat(testbed_caps)
- tests.append(test)
- except Unsupported as u:
- u.report()
- some_skipped = True
-
- if srcdir is None:
- # do we have an x-source/vcs-bzr link?
- if 'x-source' in manifest_j:
- try:
- repo = manifest_j['x-source']['vcs-bzr']
- adtlog.info('checking out click source from %s' % repo)
- d = tempfile.mkdtemp(prefix='adt.clicksrc.')
- atexit.register(shutil.rmtree, d, ignore_errors=True)
- try:
- subprocess.check_call(['bzr', 'checkout', '--lightweight',
- repo, d])
- srcdir = d
- except subprocess.CalledProcessError as e:
- adtlog.error('Failed to check out click source from %s: %s'
- % (repo, str(e)))
- except KeyError:
- adtlog.error('Click source download from x-source only '
- 'supports "vcs-bzr" repositories')
- else:
- adtlog.error('cannot download click source: manifest does not '
- 'have "x-source"')
-
- return (srcdir, tests, some_skipped)
-
-
-def parse_click(clickpath, testbed_caps, srcdir=None):
- '''Parse test descriptions from a click package.
-
- Return (source_dir, list of Test objects, some_skipped). If this encounters
- any invalid restrictions, fields, or test restrictions which cannot be met
- by the given testbed capabilities, the test will be skipped (and reported
- so), and not be included in the result.
-
- If srcdir is given, use that as source for the click package, and return
- that as first return value. Otherwise, locate and download the source from
- the click's manifest into a temporary directory and use that (not yet
- implemented).
-
- This may raise an InvalidControl exception.
- '''
- pkg = debian.debfile.DebFile(clickpath)
- try:
- manifest = pkg.control.get_content('manifest').decode('UTF-8')
- finally:
- pkg.close()
-
- return parse_click_manifest(manifest, testbed_caps, [clickpath], False,
- srcdir)
diff --git a/reprotest/runner/README.running-tests.rst b/reprotest/runner/README.running-tests.rst
deleted file mode 100644
index f30629e..0000000
--- a/reprotest/runner/README.running-tests.rst
+++ /dev/null
@@ -1,279 +0,0 @@
-Autopkgtest - Running tests
-===========================
-
-This document gives an overview how to run tests with autopkgtest. It
-does not cover each detail, please consult the individual manpages like
-adt-run(1), adt-virt-schroot(1), etc. for all available options.
-
-Ingredients for Debian packages:
-
-- A source package which defines tests in ``debian/tests/``. See
- README.package-tests for how to define them.
-
- There are plenty of existing package tests in Debian/Ubuntu which you
- can use as examples and inspiration, just look for a source package
- with a ``Testsuite: autopkgtest`` header, or the automatic test
- running services `in Debian <http://ci.debian.net/>`_ and Ubuntu (e.
- g. for `14.04 LTS <https://jenkins.qa.ubuntu.com/view/Trusty/view/AutoPkgTest/>`_).
-
-- A location for the source/tests: This can be a local source tree, a
- local .dsc, or "download with apt-get source".
-
-- Optionally some pre-built binary packages which should be tested.
-
-Ingredients for Click packages:
-
-- A binary .click package (local ``*.click`` file or already installed)
- whose manifest specifies tests and their metadata. See
- README.click-tests.rst for details.
-
-- The corresponding click source package which contains the tests
- defined in the manifest.
-
-Finally you need a virtualization server, which creates the environment
-in which the test runs. Depending on how intrusive the test is this can
-provide various degrees of isolation, from "run on my local system"
-(fastest, but unsafe) to "run in a temporary virtual machine" (slowest,
-but highest possible isolation). These are described in detail below.
-
-adt-run
--------
-The ``adt-run`` program is the main program to run tests which gets all
-these ingredients as arguments, in the following form:
-
-::
-
- adt-run [options] <source package> --- <virt-server> [<virt-server options>]
-
-Specifying tests and packages
------------------------------
-
-All possible options are explained in the adt-run(1) manpage. This
-section shows the most common scenarios, with using "mysrc" as source
-package name. Note that specifying the virtualization server and its
-options is handled in the following section, and it is independent of
-specifying tests and packages, so it is merely abbreviated as
-*virt-server* here.
-
-- Run tests from the Debian source package in the distribution. This
- calls ``apt-get source mysrc`` in the virt-server, thus will use
- whichever distribution/release that ``/etc/apt/sources.list``
- configures:
-
- ``adt-run mysrc ---`` *virt-server*
-
-- Run tests from a local unbuilt source tree, using the binary packages
- from the distribution. This is useful if you are creating or fixing
- tests, but the actual binary packages are fine:
-
- ``adt-run -B --unbuilt-tree=packages/mysrc ---`` *virt-server*
-
- Note that you can abbreviate ``--unbuilt-tree=`` with just the
- directory with two(!) trailing slashes, i. e.
-
- ``adt-run -B packages/mysrc// ---`` *virt-server*
-
-- Run tests from a local built source tree, using the binary packages
- from the distribution:
-
- ``adt-run -B --built-tree=packages/mysrc ---`` *virt-server*
-
- Note that you can abbreviate ``--built-tree=`` with just the
- directory with one(!) trailing slash, i. e.
-
- ``adt-run -B packages/mysrc/ ---`` *virt-server*
-
- Built vs. unbuilt only makes a difference for tests which declare the
- ``build-needed`` restriction (see README.package-tests), in which
- case ``--built-tree`` avoids having to re-build the source in the
- virt-server.
-
-- Build a local source package in the virt-server, then run its tests
- against the built binaries. This is useful if you need to fix a bug
- in the actual packages to make the tests succeed:
-
- ``adt-run packages/mysrc// ---`` *virt-server*
-
-- Same as above, but with specifying a built source package instead of
- a source tree:
-
- ``adt-run packages/mysrc_*.dsc ---`` *virt-server*
-
-- Test new built binaries with a new source and avoid rebuilding them
- in virt-server. This is useful if you e. g. update a package to a new
- version and now want to check whether its tests still succeed:
-
- ``adt-run -B packages/*.deb packages/mysrc_*.dsc ---`` *virt-server*
-
-- The previous case can be simplified if you have a binary .changes
- from a previous build:
-
-
- ``adt-run packages/*.changes ---`` *virt-server*
-
-- Run tests for a locally built click package:
-
- ``adt-run myclickapp/ myclickapp_0.1_all.click ---`` *virt-server*
-
- Note that for this you need to specify a virt-server which has
- "click" itself and the click app's required framework already
- installed. To run this on an actual Ubuntu phone, you can use the SSH
- testbed server:
-
- ::
-
- adt-run ubuntu-calculator-app/ com.ubuntu.calculator_1.3.283_all.click --- ssh -s adb
-
- (This is using the shipped ``adb`` setup script in
- ``/usr/share/autopkgtest/ssh-setup/``.)
-
- If you aren't running the test on an Ubuntu touch device, you can
- approximate the environment in a normal schroot/LXC/QEMU testbed with
- the ``--setup-commands`` scripts that autopkgtest provides (note that
- you do not need to specify the full
- ``/usr/share/autopkgtest/setup-commands/`` path for shipped scripts):
-
- ::
-
- adt-run --setup-commands ubuntu-touch-session \
- --setup-commands ro-apt \
- myclickapp/ myclickapp_0.1_all.click --- lxc adt-utopic
-
- See the comments in the setup-commands scripts for details.
-
-- Run tests for an already installed click package:
-
- ``adt-run --click=com.example.myapp ---`` *virt-server*
-
- This will work for click apps which have an ``x-source/vcs-bzr`` entry
- in their manifest. If that's not the case, you will need to explicitly
- specify the click source directory as above.
-
-Output
-------
-
-Unless you specify some options, adt-run just writes the logging, test
-outputs, and test results to stdout/stderr and exits with code 0 on
-success, or some non-zero code if there were skipped or failed tests or
-problems with the virt-server. (See adt-run(1) for defined codes).
-
-For getting output files you have three choices:
-
-- If you just want the "testname: PASS/FAIL" results, use
-
- ``--summary-file=/path/to/summary.txt``.
-
-- If you want the complete output of adt-run in a file, use
-
- ``-l /path/to/test.log`` (or the long option ``--log-file``)
-
-- If you want the log file, the individual test stdout and stderr
- output, and built binaries (if any) in a directory, use
-
- ``-o /path/to/test-output/`` (or the long option ``--output-dir``).
-
-You can also combine these.
-
-Virtualization server
----------------------
-
-schroot
-~~~~~~~
-::
-
- adt-run ... --- schroot schroot-name
-
-Run tests in the specified schroot. You can use mk-sbuild(1) to
-conveniently create schroots, and run this as normal user if you
-configured schroot accordingly.
-
-This server is the fastest available that provides "proper" file system
-isolation and revert, but it does not provide enough isolation for tests
-that need to start services, reconfigure the network, or open TCP ports
-which are already open at the host. If your test does not need to do
-these things this is the recommended server, as schroots are also useful
-for other tasks like building packages with sbuild.
-
-See adt-virt-schroot(1) manpage.
-
-LXC
-~~~
-::
-
- adt-run ... --- lxc container-name
-
-Run tests in the specified LXC container. Containers provide full
-service and network isolation, but tests or packages cannot change the
-kernel or hardware configuration. If your test does not need that, this
-is the recommended server as it is faster than QEMU and works on all
-Linux architectures.
-
-``container-name`` will be cloned or be called with a temporary overlay
-file system if you specify the ``-e`` (``--ephemeral``) option, thus it
-will never be modified and you can run several tests in parallel safely.
-Unless your test or architecture or RAM availability doesn't work with
-overlayfs, using -e is highly recommended for better performance.
-
-If your user can get root privileges with sudo, you can call adt-run as
-your normal user and specify ``-s`` (``--sudo``) so that the container
-can be started as root.
-
-See adt-virt-lxc(1) manpage. This also explains how to build containers.
-
-QEMU
-~~~~
-::
-
- adt-run ... --- qemu path/to/image
-
-Run tests with QEMU/KVM using the specified image. The image will be run
-with a temporary overlay file system, thus it will never be modified and
-you can run several tests in parallel safely.
-
-If your test needs a full machine including kernel/hardware access, this
-is the recommended runner; it provides complete system isolation, revert
-and breaks-testbed capabilities. But it is also the one with the biggest
-overhead and only works well on architectures with KVM acceleration (i.
-e. mostly x86).
-
-See adt-virt-qemu(1) manpage. This also explains how to build suitable
-images, and the requirements of the guest.
-
-null
-~~~~
-::
-
- adt-run ... --- null
-
-This does not do any virtualization, but runs tests straight on the
-host. Beware that this will leave some clutter on your system (installed
-test or build dependency packages, configuration changes that the tests
-might make, etc.). It is not able to run tests with the "breaks-testbed"
-restriction. See adt-virt-null(1) manpage.
-
-chroot
-~~~~~~
-::
-
- adt-run ... --- chroot /path/to/chroot
-
-Run tests in the specified chroot. You need to call adt-run as root for
-this. There is no automatic cleanup or revert for the chroot, so unless
-you can provide this by some other means, don't use this.
-
-ssh
-~~~
-::
-
- adt-run ... --- ssh -l joe -h testhost.example.com
-
-This is a generic runner for an externally set up testbed which assumes
-nothing else than a working ssh connection. This can call a "setup
-script" to create/configure a testbed (such as spinning up a cloud VM
-with nova or setting up SSH on a phone through ADB). See the manpage for
-details. autopkgtest ships setup scripts for an adb host (mostly for
-Ubuntu Touch), for nova (for cloud instances) and for Ubuntu Snappy
-currently; see their comment headers in
-``/usr/share/autopkgtest/ssh-setup/``.
-
-.. vim: ft=rst tw=72
diff --git a/reprotest/runner/adt-run b/reprotest/runner/adt-run
deleted file mode 100755
index 96798aa..0000000
--- a/reprotest/runner/adt-run
+++ /dev/null
@@ -1,634 +0,0 @@
-#!/usr/bin/python3 -u
-#
-# Licensed under the GPL: https://www.gnu.org/licenses/gpl-3.0.en.html
-# For details: reprotest/debian/copyright
-
-import signal
-import tempfile
-import sys
-import subprocess
-import traceback
-import re
-import os
-import shutil
-import atexit
-import json
-import pipes
-
-from debian import deb822
-
-# support running out of git and from packaged install
-our_base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-if os.path.isdir(os.path.join(our_base, 'virt-subproc')):
- sys.path.insert(0, os.path.join(our_base, 'lib'))
- os.environ['PATH'] = os.path.join(our_base, 'virt-subproc') + ':' + os.environ.get('PATH', '')
-else:
- sys.path.insert(0, '/usr/share/autopkgtest/python')
-
-import adtlog
-import testdesc
-import adt_run_args
-import adt_testbed
-import adt_binaries
-
-# ---------- global variables
-
-tmp = None # pathstring on host
-testbed = None # Testbed
-opts = None # argparse options
-actions = None # list of (action_type, path)
-errorcode = 0 # exit status that we are going to use
-binaries = None # DebBinaries (.debs we have registered)
-blamed = []
-
-
-# ---------- convenience functions
-
-def files_from_dsc(dsc_path):
- '''Get files from a .dsc or a .changes
-
- Return list of files, including the directory of dsc_path.
- '''
- try:
- files = testdesc.parse_rfc822(dsc_path).__next__()['Files'].split()
- except (StopIteration, KeyError):
- adtlog.badpkg('%s is invalid and does not contain Files:' % dsc_path)
-
- dsc_dir = os.path.dirname(dsc_path)
-
- return [os.path.join(dsc_dir, f) for f in files if '.' in f and '_' in f]
-
-
-def blame(m):
- global blamed
- adtlog.debug('blame += %s' % m)
- blamed.append(m)
-
-
-def setup_trace():
- global tmp
-
- if opts.output_dir is not None:
- os.makedirs(opts.output_dir, exist_ok=True)
- if os.listdir(opts.output_dir):
- adtlog.bomb('--output-dir "%s" is not empty' % opts.output_dir)
- tmp = opts.output_dir
- else:
- assert(tmp is None)
- tmp = tempfile.mkdtemp(prefix='adt-run.output.')
- os.chmod(tmp, 0o755)
-
- if opts.logfile is None and opts.output_dir is not None:
- opts.logfile = opts.output_dir + '/log'
-
- if opts.logfile is not None:
- # tee stdout/err into log file
- (fd, fifo_log) = tempfile.mkstemp(prefix='adt-fifo-log.')
- os.close(fd)
- os.unlink(fifo_log)
- os.mkfifo(fifo_log)
- atexit.register(os.unlink, fifo_log)
- out_tee = subprocess.Popen(['tee', fifo_log],
- stdin=subprocess.PIPE)
- err_tee = subprocess.Popen(['tee', fifo_log, '-a', '/dev/stderr'],
- stdin=subprocess.PIPE,
- stdout=open('/dev/null', 'wb'))
- log_cat = subprocess.Popen(['cat', fifo_log], stdout=open(opts.logfile, 'wb'))
- adtlog.enable_colors = False
- os.dup2(out_tee.stdin.fileno(), sys.stdout.fileno())
- os.dup2(err_tee.stdin.fileno(), sys.stderr.fileno())
-
- def cleanup():
- os.close(sys.stdout.fileno())
- os.close(out_tee.stdin.fileno())
- out_tee.wait()
- os.close(sys.stderr.fileno())
- os.close(err_tee.stdin.fileno())
- err_tee.wait()
- log_cat.wait()
-
- atexit.register(cleanup)
-
- if opts.summary is not None:
- adtlog.summary_stream = open(opts.summary, 'w+b', 0)
- else:
- adtlog.summary_stream = open(os.path.join(tmp, 'summary'), 'w+b', 0)
-
-
-def run_tests(tests, tree):
- global errorcode, testbed
-
- if not tests:
- # if we have skipped tests, don't claim that we don't have any
- if not errorcode & 2:
- adtlog.report('*', 'SKIP no tests in this package')
- errorcode |= 8
- return
-
- for t in tests:
- # Set up clean test bed with given dependencies
- adtlog.info('test %s: preparing testbed' % t.name)
- testbed.reset(t.depends, 'needs-recommends' in t.restrictions)
- binaries.publish()
- testbed.install_deps(t.depends, 'needs-recommends' in t.restrictions)
-
- testbed.run_test(tree, t, opts.env, opts.shell_fail, opts.shell,
- opts.build_parallel)
- if not t.result:
- errorcode |= 4
- if 'breaks-testbed' in t.restrictions:
- testbed.needs_reset()
-
- testbed.needs_reset()
-
-
-def create_testinfo(vserver_args):
- global testbed
-
- info = {'virt_server': ' '.join([pipes.quote(w) for w in vserver_args])}
-
- if testbed.initial_kernel_version:
- info['kernel_version'] = testbed.initial_kernel_version
- if testbed.test_kernel_versions:
- info['test_kernel_versions'] = testbed.test_kernel_versions
- if opts.env:
- info['custom_environment'] = opts.env
- if testbed.nproc:
- info['nproc'] = testbed.nproc
- if testbed.cpu_model:
- info['cpu_model'] = testbed.cpu_model
- if testbed.cpu_flags:
- info['cpu_flags'] = testbed.cpu_flags
-
- with open(os.path.join(tmp, 'testinfo.json'), 'w') as f:
- json.dump(info, f, indent=2)
-
-
-def print_exception(ei, msgprefix=''):
- if msgprefix:
- adtlog.error(msgprefix)
- (et, e, tb) = ei
- if et is adtlog.BadPackageError:
- adtlog.preport('blame: ' + ' '.join(blamed))
- adtlog.preport('badpkg: ' + e.args[0])
- adtlog.error('erroneous package: ' + e.args[0])
- adtlog.psummary('erroneous package: ' + e.args[0])
- return 12
- elif et is adtlog.TestbedFailure:
- adtlog.error('testbed failure: ' + e.args[0])
- adtlog.psummary('testbed failure: ' + e.args[0])
- return 16
- elif et is adtlog.AutopkgtestError:
- adtlog.psummary(e.args[0])
- adtlog.error(e.args[0])
- return 20
- else:
- adtlog.error('unexpected error:')
- adtlog.psummary('quitting: unexpected error, see log')
- traceback.print_exc(None, sys.stderr)
- return 20
-
-
-def cleanup():
- try:
- if testbed is not None:
- if binaries is not None:
- binaries.reset()
- testbed.stop()
- if opts.output_dir is None and tmp is not None:
- shutil.rmtree(tmp, ignore_errors=True)
- except:
- print_exception(sys.exc_info(),
- '\nadt-run: error cleaning up:\n')
- sys.exit(20)
-
-
-def signal_handler(signum, frame):
- adtlog.error('Received signal %i, cleaning up...' % signum)
- signal.signal(signum, signal.SIG_DFL)
- try:
- # don't call cleanup() here, resetting apt takes too long
- if testbed:
- testbed.stop()
- finally:
- os.kill(os.getpid(), signum)
-
-
-# ---------- processing of sources (building)
-
-
-def deb_package_name(deb):
- '''Return package name from a .deb'''
-
- try:
- return subprocess.check_output(['dpkg-deb', '--field', deb, 'Package'],
- universal_newlines=True).strip()
- except subprocess.CalledProcessError as e:
- adtlog.badpkg('failed to parse binary package: %s' % e)
-
-
-def source_rules_command(script, which, cwd=None, results_lines=0):
- if cwd is None:
- cwd = '/'
-
- # there's no way to tell su to not reset $PATH, for install-tmp mode
- if testbed.install_tmp_env:
- for e in testbed.install_tmp_env:
- if e.startswith('PATH='):
- script = ['export ' + e] + script
- break
-
- if adtlog.verbosity > 1:
- script = ['exec 3>&1 >&2', 'set -x', 'cd ' + cwd] + script
- else:
- script = ['exec 3>&1 >&2', 'cd ' + cwd] + script
- script = '; '.join(script)
-
- # run command as user, if available
- if testbed.user and 'root-on-testbed' in testbed.caps:
- script = "su --shell=/bin/sh %s -c 'set -e; %s'" % (testbed.user, script)
-
- (rc, out, _) = testbed.execute(['sh', '-ec', script],
- stdout=subprocess.PIPE,
- xenv=opts.env,
- kind='build')
- results = out.rstrip('\n').splitlines()
- if rc:
- if opts.shell_fail:
- testbed.run_shell()
- if rc == 100:
- testbed.bomb('rules %s failed with exit code %d (apt failure)' % (which, rc))
- else:
- adtlog.badpkg('rules %s failed with exit code %d' % (which, rc))
- if results_lines is not None and len(results) != results_lines:
- adtlog.badpkg('got %d lines of results from %s where %d expected'
- % (len(results), which, results_lines))
- if results_lines == 1:
- return results[0]
- return results
-
-
-def build_source(kind, arg, built_binaries):
- '''Prepare action argument for testing
-
- This builds packages when necessary and registers their binaries, copies
- tests into the testbed, etc.
-
- Return a adt_testbed.Path to the unpacked tests tree.
- '''
- blame(arg)
- testbed.reset([], testbed.recommends_installed)
-
- def debug_b(m):
- adtlog.debug('build_source: <%s:%s> %s' % (kind, arg, m))
-
- # copy necessary source files into testbed and set create_command for final unpacking
- if kind == 'source':
- dsc = arg
- dsc_tb = os.path.join(testbed.scratch, os.path.basename(dsc))
-
- # copy .dsc file itself
- adt_testbed.Path(testbed, dsc, dsc_tb).copydown()
- # copy files from it
- for part in files_from_dsc(dsc):
- p = adt_testbed.Path(testbed, part, os.path.join(testbed.scratch, os.path.basename(part)))
- p.copydown()
-
- create_command = 'dpkg-source -x "%s"' % dsc_tb
-
- elif kind == 'unbuilt-tree':
- dsc = os.path.join(tmp, 'fake.dsc')
- with open(dsc, 'w', encoding='UTF-8') as f_dsc:
- with open(os.path.join(arg, 'debian/control'), encoding='UTF-8') as f_control:
- for l in f_control:
- if l == '\n':
- break
- f_dsc.write(l)
- f_dsc.write('Binary: none-so-this-is-not-a-package-name\n')
- atexit.register(lambda f: os.path.exists(f) and os.unlink(f), dsc)
-
- # copy unbuilt tree into testbed
- ubtree = adt_testbed.Path(testbed, arg,
- os.path.join(testbed.scratch, 'ubtree-' + os.path.basename(arg)))
- ubtree.copydown()
- create_command = 'cp -rd --preserve=timestamps -- "%s" real-tree' % ubtree.tb
-
- elif kind == 'built-tree':
- # this is a special case: we don't want to build, or even copy down
- # (and back up) the tree here for efficiency; so shortcut everything
- # below and just set the tests_tree and get the package version
- tests_tree = adt_testbed.Path(testbed, arg, os.path.join(testbed.scratch, 'tree'), is_dir=True)
-
- changelog = os.path.join(arg, 'debian', 'changelog')
- if os.path.exists(changelog):
- with open(changelog, encoding='UTF-8') as f:
- (testpkg_name, testpkg_version, _) = f.readline().split(' ', 2)
- testpkg_version = testpkg_version[1:-1] # chop off parentheses
-
- adtlog.info('testing package %s version %s' % (testpkg_name, testpkg_version))
- if opts.output_dir:
- with open(os.path.join(tmp, 'testpkg-version'), 'w') as f:
- f.write('%s %s\n' % (testpkg_name, testpkg_version))
- return tests_tree
-
- elif kind == 'apt-source':
- # determine the version for "apt-get source pkg=version" that conforms
- # to the current apt pinning, to work around the lack of
- # "apt-get source foo/release". We only consider binaries which are
- # shipped in all available versions, otherwise new binaries in pockets
- # would always win.
- # apt-get source is terribly noisy; only show what gets downloaded
- create_command = ('''pkgs=$(apt-cache showsrc %(src)s | awk "/^Package-List:/ { inlist=1; next } (/^ / && inlist == 1) { thissrc[\$1] = 1; next } { if (!inlist) next; inlist=0; if (intersect) {for (p in pkgs) { if (!(p in thissrc)) delete pkgs[p] }} else { for (p in thissrc) { pkgs[p] = 1}; intersect=1 }; delete thissrc } END {for (p in pkgs) print p}");'''
- ' for pkg in $pkgs; do'
- ' pkg_candidate=$(apt-cache policy "^$pkg\$"|sed -n "/Candidate:/ { s/^.* //; /none/d; p}") || continue;'
- ' [ -n "$pkg_candidate" ] || continue; '
- ' show=$(apt-cache show $pkg=$pkg_candidate | grep "^Source:" || true);'
- ' [ "$pkg" = "%(src)s" ] || echo "$show" | grep -q "^Source: %(src)s\\b" || continue; '
- ' srcversion=$(echo "$show" | sed -n "/^Source: .*(.*)/ { s/^.*(//; s/)\$//; p}");'
- ' ver=${srcversion:-$pkg_candidate};'
- ' dpkg --compare-versions "$ver" lt "$maxver" || maxver="$ver";'
- 'done;'
- '[ -z "$maxver" ] || maxver="=$maxver";'
- 'OUT=$(apt-get source -q --only-source %(src)s$maxver);'
- 'echo "$OUT" | grep ^Get: || true' % {'src': arg})
- elif kind == 'git-source':
- fields = arg.split()
- if len(fields) == 1:
- create_command = "git clone '%s' || { sleep 15; git clone '%s'; }" % (arg, arg)
- elif len(fields) == 2:
- create_command = "git clone --branch '%(b)s' '%(u)s' || { sleep 15; git clone --branch '%(b)s' '%(u)s'; }" \
- % {'b': fields[1], 'u': fields[0]}
- else:
- adtlog.bomb('--git-source argument must be "URL" or "URL branchname"')
-
- testbed.satisfy_dependencies_string('git, ca-certificates', 'install git for --git-source')
- else:
- adtlog.bomb('unknown action kind for build_source: ' + kind)
-
- if kind in ['source', 'apt-source']:
- testbed.install_deps([], False)
- if testbed.execute(['which', 'dpkg-source'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)[0] != 0:
- adtlog.debug('dpkg-source not available in testbed, installing dpkg-dev')
- # Install dpkg-source for unpacking .dsc
- testbed.satisfy_dependencies_string('dpkg-dev',
- 'install dpkg-dev')
-
- # run create_command
- script = [
- 'builddir=$(mktemp -d %s/build.XXX)' % testbed.scratch,
- 'cd $builddir',
- create_command,
- 'chmod -R a+rX .',
- 'cd [a-z0-9]*/.',
- 'pwd >&3',
- 'sed -n "1 {s/).*//; s/ (/\\n/; p}" debian/changelog >&3',
- 'set +e; grep -q "^Restrictions:.*\\bbuild-needed\\b" debian/tests/control 2>/dev/null; echo $? >&3'
- ]
-
- (result_pwd, testpkg_name, testpkg_version, build_needed_rc) = \
- source_rules_command(script, 'extract', results_lines=4)
-
- # record tested package version
- adtlog.info('testing package %s version %s' % (testpkg_name, testpkg_version))
- if opts.output_dir:
- with open(os.path.join(tmp, 'testpkg-version'), 'w') as f:
- f.write('%s %s\n' % (testpkg_name, testpkg_version))
-
- # For optional builds:
- #
- # We might need to build the package because:
- # - we want its binaries
- # - the test control file says so (assuming we have any tests)
-
- build_needed = False
- if built_binaries:
- adtlog.info('build needed for binaries')
- build_needed = True
- elif build_needed_rc == '0':
- adtlog.info('build needed for tests')
- build_needed = True
- else:
- adtlog.info('build not needed')
-
- if build_needed:
- testbed.needs_reset()
- if kind not in ['dsc', 'apt-source']:
- testbed.install_deps([], False)
-
- if kind in ('apt-source', 'git-source'):
- # we need to get the downloaded debian/control from the testbed, so
- # that we can avoid calling "apt-get build-dep" and thus
- # introducing a second mechanism for installing build deps
- pkg_control = adt_testbed.Path(testbed,
- os.path.join(tmp, 'apt-control'),
- os.path.join(result_pwd, 'debian/control'), False)
- pkg_control.copyup()
- dsc = pkg_control.host
-
- with open(dsc, encoding='UTF-8') as f:
- d = deb822.Deb822(sequence=f)
- bd = d.get('Build-Depends', '')
- bdi = d.get('Build-Depends-Indep', '')
-
- # determine build command and build-essential packages
- build_essential = ['build-essential']
- assert testbed.nproc
- dpkg_buildpackage = 'DEB_BUILD_OPTIONS="parallel=%s $DEB_BUILD_OPTIONS" dpkg-buildpackage -us -uc -b' % (
- opts.build_parallel or testbed.nproc)
- if opts.gainroot:
- dpkg_buildpackage += ' -r' + opts.gainroot
- else:
- if testbed.user or 'root-on-testbed' not in testbed.caps:
- build_essential += ['fakeroot']
-
- testbed.satisfy_dependencies_string(bd + ', ' + bdi + ', ' + ', '.join(build_essential), arg,
- build_dep=True, shell_on_failure=opts.shell_fail)
-
- source_rules_command([dpkg_buildpackage], 'build', cwd=result_pwd)
-
- # copy built tree from testbed to hosts
- tests_tree = adt_testbed.Path(testbed, os.path.join(tmp, 'tests-tree'), result_pwd, is_dir=True)
- atexit.register(shutil.rmtree, tests_tree.host, ignore_errors=True)
- tests_tree.copyup()
-
- if not build_needed:
- return tests_tree
-
- if built_binaries:
- debug_b('want built binaries, getting and registering built debs')
- result_debs = testbed.check_exec(['sh', '-ec', 'cd "%s"; echo *.deb' %
- os.path.dirname(result_pwd)], stdout=True).strip()
- if result_debs == '*.deb':
- debs = []
- else:
- debs = result_debs.split()
- debug_b('debs=' + repr(debs))
-
- # determine built debs and copy them from testbed
- deb_re = re.compile('^([-+.0-9a-z]+)_[^_/]+(?:_[^_/]+)\.deb$')
- for deb in debs:
- m = deb_re.match(deb)
- if not m:
- adtlog.badpkg("badly-named binary `%s'" % deb)
- pkgname = m.groups()[0]
- debug_b(' deb=%s, pkgname=%s' % (deb, pkgname))
- deb_path = adt_testbed.Path(testbed,
- os.path.join(tmp, os.path.basename(deb)),
- os.path.join(result_pwd, '..', deb),
- False)
- deb_path.copyup()
- binaries.register(deb_path.host, pkgname)
- debug_b('got all built binaries')
-
- return tests_tree
-
-
-def process_actions():
- global actions, binaries, errorcode
-
- binaries = adt_binaries.DebBinaries(testbed, tmp)
- control_override = None
- testname = None
- pending_click_source = None
- tests_tree = None
-
- for (kind, arg, built_binaries) in actions:
- # non-tests/build actions
- if kind == 'override-control':
- control_override = arg
- if not os.access(control_override, os.R_OK):
- adtlog.bomb('cannot read ' + control_override)
- continue
- if kind == 'testname':
- testname = arg
- continue
- if kind == 'binary':
- blame('arg:' + arg)
- pkg = deb_package_name(arg)
- blame('deb:' + pkg)
- binaries.register(arg, pkg)
- continue
- if kind == 'click-source':
- if pending_click_source:
- adtlog.warning('Ignoring --click-source %s, no subsequent --click argument' % pending_click_source)
- pending_click_source = arg
- continue
-
- # tests/build actions
- assert kind in ('source', 'unbuilt-tree', 'built-tree', 'apt-source',
- 'git-source', 'click')
- adtlog.info('@@@@@@@@@@@@@@@@@@@@ %s %s' % (kind, arg))
-
- # remove tests tree from previous action
- if tests_tree and tests_tree.tb:
- adtlog.debug('cleaning up previous tests tree %s on testbed' % tests_tree.tb)
- testbed.execute(['rm', '-rf', tests_tree.tb])
-
- if kind == 'click':
- if control_override:
- # locally specified manifest
- with open(control_override) as f:
- manifest = f.read()
- clicks = []
- use_installed = False
- if os.path.exists(arg):
- clicks.append(arg)
- use_installed = True
- (srcdir, tests, skipped) = testdesc.parse_click_manifest(
- manifest, testbed.caps, clicks, use_installed, pending_click_source)
-
- elif os.path.exists(arg):
- # local .click package file
- (srcdir, tests, skipped) = testdesc.parse_click(
- arg, testbed.caps, srcdir=pending_click_source)
- else:
- # already installed click package name
- if testbed.user:
- u = ['--user', testbed.user]
- else:
- u = []
- manifest = testbed.check_exec(['click', 'info'] + u + [arg], stdout=True)
- (srcdir, tests, skipped) = testdesc.parse_click_manifest(
- manifest, testbed.caps, [], True, pending_click_source)
-
- if not srcdir:
- adtlog.bomb('No click source available for %s' % arg)
-
- tests_tree = adt_testbed.Path(
- testbed, srcdir, os.path.join(testbed.scratch, 'tree'),
- is_dir=True)
- pending_click_source = None
- else:
- tests_tree = build_source(kind, arg, built_binaries)
- try:
- (tests, skipped) = testdesc.parse_debian_source(
- tests_tree.host, testbed.caps, testbed.dpkg_arch,
- control_path=control_override,
- auto_control=opts.auto_control)
- except testdesc.InvalidControl as e:
- adtlog.badpkg(str(e))
-
- if skipped:
- errorcode |= 2
-
- if testname:
- adtlog.debug('filtering testname %s for package %s %s' %
- (testname, kind, arg))
- tests = [t for t in tests if t.name == testname]
- if not tests:
- adtlog.error('%s %s has no test matching --testname %s' %
- (kind, arg, testname))
- # error code will be set later
- testname = None
-
- control_override = None
- run_tests(tests, tests_tree)
-
- adtlog.summary_stream.flush()
- if adtlog.verbosity >= 1:
- adtlog.summary_stream.seek(0)
- adtlog.info('@@@@@@@@@@@@@@@@@@@@ summary')
- sys.stderr.buffer.write(adtlog.summary_stream.read())
-
- adtlog.summary_stream.close()
- adtlog.summary_stream = None
-
-
-def main():
- global testbed, opts, actions, errorcode
- try:
- (opts, actions, vserver_args) = adt_run_args.parse_args()
- except SystemExit:
- # argparser exits with error 2 by default, but we have a different
- # meaning for that already
- sys.exit(20)
-
- # vserver can be given without "adt-virt-" prefix
- if '/' not in vserver_args[0] and not vserver_args[0].startswith('adt-virt-'):
- vserver_args[0] = 'adt-virt-' + vserver_args[0]
-
- # ensure proper cleanup on signals
- signal.signal(signal.SIGTERM, signal_handler)
- signal.signal(signal.SIGQUIT, signal_handler)
-
- try:
- setup_trace()
- testbed = adt_testbed.Testbed(vserver_argv=vserver_args,
- output_dir=tmp,
- user=opts.user,
- setup_commands=opts.setup_commands,
- add_apt_pockets=opts.apt_pocket,
- copy_files=opts.copy)
- testbed.start()
- testbed.open()
- process_actions()
- except:
- errorcode = print_exception(sys.exc_info(), '')
- if tmp:
- create_testinfo(vserver_args)
- cleanup()
- sys.exit(errorcode)
-
-main()
diff --git a/reprotest/runner/adt-run.1 b/reprotest/runner/adt-run.1
deleted file mode 100644
index 158c82a..0000000
--- a/reprotest/runner/adt-run.1
+++ /dev/null
@@ -1,511 +0,0 @@
-.TH adt\-run 1 2014 autopkgtest
-.SH NAME
-adt\-run \- test an installed binary package using the source package's tests
-.SH SYNOPSIS
-.B adt\-run
-.IR options ...
-.B \-\-\-
-.I virt\-server
-.RI [ virt\-server\-arg ...]
-.br
-.SH DESCRIPTION
-.B adt\-run
-is the program for invoking the autopkgtest package testing machinery.
-
-autopkgtest is a facility for testing binary Debian or Click packages, as
-installed on a system (such as a testbed system). The tests are those supplied
-in the source package.
-
-adt\-run runs each test supplied by a particular package and reports
-the results. It drives the specified virtualisation regime as
-appropriate, and parses the test description metadata, and arranges
-for data to be copied to and from the testbed as required.
-
-See /usr/share/doc/autopkgtest/README.running\-tests.rst.gz for an
-introduction about how to use adt\-run.
-
-.SH SPECIFYING TESTS
-
-Actions specify the source and binary packages to test, or change
-what happens with package arguments:
-
-.TP
-.BR --source " " \fIdsc\fR
-Run tests from Debian source package \fIdsc\fR. By default the package will
-also be built and the resulting binaries will be used to satisfy test
-dependencies; to disable that, specify the
-.BR -B / --no-built-binaries
-option before.
-
-The ordering is significant: each \fB--source\fR option should precede
-options whose dependencies are to be satisfied by the binaries it
-produces.
-
-.TP
-.BR --unbuilt-tree " " \fIdirectory\fR
-Specifies that tests from the unbuilt Debian source tree
-.IR directory
-should be run. This is very similar to specifying \fB\-\-source\fR
-except that a directory tree (which should be pristine) is supplied,
-instead of a source package.
-
-.TP
-.BR --built-tree " " \fIdirectory\fR
-Specifies that tests from the built Debian source tree
-.IR directory
-should be run. Note that all test dependencies are then satisfied by
-archive packages, unless you explicitly specify locally built .debs with
-.BR --binary .
-
-.TP
-.BR --apt-source " " \fIsrcpkgname\fR
-Downloads \fIsrcpkgname\fR with \fBapt\-get source\fR in the testbed and
-run its tests. This is similar to specifying
-.B \-\-source
-but avoids copying the source from the host to the testbed. Possibly built
-binaries will
-.B not
-be used to satisfy dependencies, as usually in this mode you want to test
-binaries from a real archive.
-
-.TP
-.BR --git-source " " \fIURL\fR " " \fR[\fIbranchname\fR]
-Specifies that tests from the unbuilt Debian source tree from git-cloning
-.IR URL
-should be run. If
-.I branchname
-is given, this branch will be checked out instead of the default (usually
-"master").
-
-This is very similar to specifying \fB\-\-unbuilt-tree\fR after cloning, i. e.
-this is commonly used with
-.BR \-\-no\-built\-binaries .
-The
-.B git
-package will be installed if necessary.
-
-.TP
-.BR --binary " " \fIdeb\fR
-Specifies that \fIdeb\fR should be used for tests of all following
-source packages. By default it will be used to satisfy dependencies,
-both during building and testing.
-
-The ordering is significant, as for \fB--source\fR. In particular, if a
-subsequent source package will build a binary of the same name, that will be
-used from then on, and \fIdeb\fR will be ignored.
-
-.TP
-.BR --changes " " \fIchanges\fR
-Specifies that the debs in the given .changes should be used for tests of the
-source package in that .changes. Acts as if you had specified the .debs and .dsc
-from a .changes file as explicit arguments.
-
-.TP
-.BR --click-source " " \fIclicksrc
-Path to click source tree for subsequent
-.B --click
-package.
-
-.TP
-.BR --click " " \fIclickpkg
-If
-.I clickpkg
-is a file (*.click), install given click package into testbed. If it is a click
-name (like "com.example.myapp"), assume it is already installed in the testbed
-and read the manifest from it.
-
-Run click package tests from the preceding
-.BR --click-source .
-If a click source directory is not specified explicitly, it will be downloaded
-according to the manifest's
-.B x-source
-entry. Currently the only supported schema is
-.BR vcs-bzr .
-
-
-
-.TP
-.I filename
-Bare filename arguments are processed as if
-.BR --built-tree ", " --source ", " --unbuilt-tree ", " --apt-source ", "
-.BR --binary ", " --changes ", " --click-source ", or " --click
-was specified; the nature of the argument is guessed from the form of
-the filename. In the case of \fB--built-tree\fR, either the
-option must be specified, or the filename must end in a slash; two
-slashes at the end are taken to mean \fB--unbuilt-tree\fR. If a given directory
-has a "click" subdirectory, it is interpreted as
-.BR --click-source .
-
-.SH TEST OPTIONS
-Unless stated otherwise, these affect all subsequent test arguments.
-
-.TP
-.BR -B " | " --no-built-binaries
-All built binaries from subsequent
-.B --source
-or
-.B --unbuilt-tree
-tests will not be built or ignored,
-and dependencies are satisfied with packages from the archive. Note
-that packages still get built if a test requires
-\fBbuild-needed\fR.
-
-.TP
-.B --built-binaries
-Subsequent
-.B --source
-or
-.B --unbuilt-tree
-tests will get built and their dependencies be satisfied with the built
-binaries. This is the default behaviour, so you only need this to revert a
-previously specified
-.B --no-built-binaries
-option.
-
-.TP
-.BI --override-control= PATH
-Read the test metadata from
-.I PATH
-instead of
-.B debian/tests/control
-(for Debian sources)
-or the Click manifest for the following test.
-
-.TP
-.BI --testname= TEST
-Run only the given test name (from test control file) in the following test.
-
-.SH LOGGING OPTIONS
-If you don't specify any option,
-.B adt-run
-only writes its output/results to stderr.
-
-.TP
-.BI -o " dir" " | --output-dir=" dir
-Specifies that test artifacts (stderr and stdout from the tests, the log file,
-built binary packages etc.) should be placed in the given directory.
-\fIdir\fR must not exist yet or be empty, otherwise
-.B adt-run
-will refuse to use it.
-
-.TP
-.BI -l " logfile" " | --log-file=" logfile
-Specifies that the trace log should be written to \fIlogfile\fR
-instead of to \fIoutput-dir\fR.
-
-.TP
-.BI --summary= summary
-Specifies that a summary of the outcome should be written to
-\fIsummary\fR. The events in the summary are written to the log
-in any case.
-
-.TP
-.BR -q " | " --quiet
-Do not send a copy of \fBadt-run\fR's trace logstream to stderr. This
-option does not affect the copy sent to \fIlogfile\fR or
-\fIoutput-dir\fR. Note that without the trace
-logstream it can be very hard to diagnose problems.
-
-.SH TEST BED SETUP OPTIONS
-
-.TP
-.BI \-\-setup\-commands= commands
-Run
-.I commands
-after opening the testbed. This can be used e. g. to enable additional apt
-sources, run
-.B apt-get update
-or similar.
-If
-.I commands
-is an existing file name, the commands are read from that; otherwise it
-is a string with the actual commands that gets run as-is. File names
-without directory will be searched in both the current directory and in
-.B /usr/share/autopkgtest/setup-commands/
-so you do not need to give the full path for setup scripts shipped with
-autopkgtest.
-
-This option can be specified multiple times.
-
-If
-.B \-\-user
-is given or the test bed provides a
-.B suggested-normal-user
-capability, the
-.B $ADT_NORMAL_USER
-environment variable will be set to that user.
-
-If the setup commands affect anything in boot directories (like /boot or
-/lib/systemd/system) and the testbed supports rebooting, the testbed will be
-rebooted after the setup commands. This can be suppressed by creating a file
-.BR /run/autopkgtest_no_reboot.stamp .
-
-.TP
-.BR --apt-upgrade " | " -U
-Run
-.B apt\-get update
-and
-.B apt\-get dist-upgrade -y
-in the testbed before running the tests.
-
-.TP
-.BI \-\-apt\-pocket= pocket[=pkgname,src:srcname,...]
-Add apt sources for \fIrelease\fR-\fIpocket\fR. This finds the first
-.B deb
-line in
-.B /etc/apt/sources.list
-which does not already specify a pocket and adds a deb and deb-src line with
-that pocket to
-.B /etc/apt/sources.list.d/\fIpocket\fB.list\fR.
-This also calls
-.B apt-get update
-for the new pocket (but not for anything else).
-
-If a package list is given after =, set up apt pinning to use only those
-packages from
-.I pocket\fR.
-An entry "src:srcname" expands to all binary packages built by that source.
-This can be used for minimizing dependencies taken from
-.I pocket
-so that package updates in that pocket can be tested independently from each
-other for better isolation.
-.B Attention:
-This does not currently resolve some situations where dependencies of
-the given packages can only be resolved in the given pocket. In that case the
-apt pinning will be removed and package installation will be retried with the
-entirety of
-.I pocket\fR.
-
-.TP
-.BI \-\-copy= HOSTPATH:TESTBEDPATH
-Copy file or directory from host into testbed after opening. This happens
-before
-.B \-\-setup-commands
-thus you can use these files in the setup commands.
-
-.TP
-.BI \-\-env= VAR=value
-Set arbitrary environment variable in the build and test. Can be specified
-multiple times.
-
-.SH USER/PRIVILEGE HANDLING OPTIONS
-
-.TP
-.BI -u " user" " | --user=" user
-Run builds and tests as \fIuser\fR on the testbed. This needs root on
-the testbed; if root on the testbed is not available then builds and
-tests run as whatever user is provided.
-
-.TP
-.BI --gain-root= gain-root
-Prefixes
-.B debian/rules binary
-with
-.RB gain-root .
-The default is not to use anything, except that if
-\fB--user\fR is supplied or root on the testbed is not available the
-default is \fBfakeroot\fR.
-
-.SH DEBUGGING OPTIONS
-
-.TP
-.BR --debug | -d
-Include additional debugging information in the trace log. Each
-additional \fB-d\fR increases the debugging level; the current maximum
-is \fB-ddd\fR. If you like to see what's going on, \fR-d\fB or
-\fR-dd\fB is recommended.
-
-.TP
-.BR --shell-fail | -s
-Run an interactive shell in the testbed after a failed build, test, or
-dependency installation.
-
-.TP
-.BR --shell
-Run an interactive shell in the testbed after every test.
-
-.SH TIMEOUT OPTIONS
-
-.TP
-.BR --timeout- \fIwhich\fR = \fIseconds\fR
-Use a different timeout for operations on or with the testbed. There
-are five timeouts affected by five values of \fIwhich\fR:
-.BR short :
-supposedly
-short operations like setting up the testbed's apt and checking the
-state (default: 100s);
-.BR install :
-installation of packages including dependencies
-(default: 3,000s);
-.BR test :
-test runs (default: 10,000s);
-.BR copy :
-copy files/directories between host and testbed
-(default: 300s); and
-.BR build :
-builds (default:
-100,000s). The value must be specified as an integer number of seconds.
-
-.TP
-.BR --timeout-factor =\fIdouble\fR
-Multiply all of the default timeouts by the specified factor (see
-\fB--timeout-\fR\fIwhich\fR above). Only the defaults are affected;
-explicit timeout settings are used exactly as specified.
-
-.SH LOCALE OPTIONS
-
-.TP
-.BI --set-lang= langval
-When running commands on the testbed, sets the \fBLANG\fR environment
-variable to \fIlangval\fR. The default in \fBadt-run\fR is to set it
-to \fBC.UTF-8\fR.
-
-.SH OTHER OPTIONS
-
-.TP
-.BI --no-auto-control
-Disable automatic test generation with autodep8, even if it is installed. In
-that case, packages without tests will exit with code 8 ("No tests in this
-package") just like without autodep8.
-
-
-.TP
-.BI --build-parallel N
-Set
-.I parallel=N
-DEB_BUILD_OPTION for building packages. By default this is the number of
-available processors. This is mostly useful in containers where you can
-restrict the available RAM, but not restrict the number of CPUs.
-
-.TP
-.BR \-h | \-\-help
-Show command line help and exit.
-
-
-.SH VIRTUALIZATION SERVER
-
-.TP
-\fB---\fR \fIvirt-server virt-server-arg\fR...
-Specifies the virtualisation regime server, as a command and arguments
-to invoke.
-.I virt-server
-must be an existing autopkgtest virtualization server such as
-.B adt-virt-schroot
-or
-.BR adt-virt-qemu .
-You can leave out the
-.B adt-virt-
-prefix and just specify the last part, e. g.
-.BR schroot .
-
-All the remaining arguments and options after
-.B ---
-are passed to the virtualisation server program. See the manpages of the
-individual servers for how to use them.
-
-.SH OUTPUT FORMAT
-During a normal test run, one line is printed for each test. This
-consists of a short string identifying the test, some horizontal
-whitespace, and either
-.B PASS
-or
-.BR FAIL " reason"
-or
-.BR SKIP " reason"
-where the pass/fail indication is separated by any reason by some
-horizontal whitespace.
-
-The string to identify the test consists of a short alphanumeric
-string invented by \fBadt-run\fR to distinguish different command-line
-arguments, the \fIargid\fR, followed by a hyphen and the test name.
-
-Sometimes a
-.B SKIP
-will be reported when the name of the test is not known or not
-applicable: for example, when there are no tests in the package, or a
-there is a test stanza which contains features not understood by this
-version of
-.BR adt-run .
-In this case
-.B *
-will appear where the name of the test should be.
-
-If \fBadt-run\fR detects that erroneous package(s) are involved, it
-will print the two lines
-.BR "blame: " \fIblamed-thing\fR ...
-and
-.BR "badpkg: " \fImessage\fR.
-Here each whitespace-separated \fIblamed-thing\fR is one of
-.BI arg: argument
-(representing a pathname found in a command line argument),
-.BI dsc: package
-(a source package name),
-.BI deb: package
-(a binary package name)
-or possibly other strings to be determined. This indicates which
-arguments and/or packages might have contributed to the problem; the
-ones which were processed most recently and which are therefore most
-likely to be the cause of a problem are listed last.
-
-.SH CONFIGURATION FILES
-
-If you use lots of options or nontrivial virt server arguments, you can put any
-part of the command line into a text file, with one line per option. E. g. you
-can create a file
-.I sid.cfg
-with contents like
-
-.RS
-.EX
--s
---output-dir=/tmp/testout
---apt-upgrade
----
-schroot
-sid
-.EE
-.RE
-
-and then run
-
-.RS
-.EX
-adt-run foo_1_amd64.changes @sid.cfg
-.EE
-.RE
-
-The contents of the configuration file will be expanded in-place as if you
-would have given its contents on the command line. Please ensure that you
-.B don't place spaces
-between short options and their values, they would become a part of the
-argument value.
-
-
-.SH EXIT STATUS
-0 all tests passed
-.br
-2 at least one test skipped
-.br
-4 at least one test failed
-.br
-6 at least one test failed and at least one test skipped
-.br
-8 no tests in this package
-.br
-12 erroneous package
-.br
-16 testbed failure
-.br
-20 other unexpected failures including bad usage
-
-.SH SEE ALSO
-\fB/usr/share/doc/autopkgtest/README.running-tests.rst.gz\fR
-.br
-\fB/usr/share/doc/autopkgtest/README.package-tests.rst.gz\fR
-
-.SH AUTHORS AND COPYRIGHT
-This manpage is part of autopkgtest, a tool for testing Debian binary
-packages. autopkgtest is Copyright (C) 2006-2014 Canonical Ltd.
-
-See \fB/usr/share/doc/autopkgtest/CREDITS\fR for the list of
-contributors and full copying conditions.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git
More information about the Reproducible-commits
mailing list