LinuxCommandLibrary

autopkgtest

Run package tests in a clean environment

TLDR

Build the package in the current directory and run all tests directly on the system

$ autopkgtest -- [null]
copy

Run a specific test for the package in the current directory
$ autopkgtest --test-name=[test_name] -- [null]
copy

Download and build a specific package with apt-get, then run all tests
$ autopkgtest [package] -- [null]
copy

Test the package in the current directory using a new root directory
$ autopkgtest -- [chroot] [path/to/new_root]
copy

Test the package in the current directory without rebuilding it
$ autopkgtest [[-B|--no-built-binaries]] -- [null]
copy

SYNOPSIS

autopkgtest [options] [--] package.dsc|package.deb [=version] [testname [args...]]

PARAMETERS

-h, --help
    Show help message and exit

--version
    Print version information

-d, --debug
    Enable debug output

-q, --quiet
    Reduce output verbosity

-v, --verbose
    Increase output verbosity

--shell-fail
    Fail if shell command returns non-zero

--timeout=SECONDS
    Abort test after timeout

--apt-pocket=POCKET
    Add PPA-like pocket to apt sources

--apt-upgrade
    Upgrade packages before testing

--setup-commands=CMD
    Run commands before test setup

--env=VAR=VALUE
    Set environment variable in testbed

--ssh=HOSTNAME
    Use SSH testbed (user@host)

--qemu=/path/to/image
    Use QEMU VM testbed

--lxd
    Use LXD container testbed

--chroot=/path/to/chroot
    Use local chroot testbed

--null
    Null testbed (dry-run simulation)

-s, --source=SOURCE
    Path to source package directory

--build-deps=...
    Build-dependency inclusion list

--no-build-deps
    Skip building from source

--testbed-overlay=DIR
    Overlay directory for testbed

--allow-stderr
    Passed to tests allowing stderr

--immediate
    Run tests immediately without setup

--schedule
    Output schedule for queueing

DESCRIPTION

autopkgtest is a versatile tool for running automatic tests on Debian and Ubuntu packages. It executes tests defined in the debian/tests directory of source packages or associated with binary packages. Tests can run in diverse environments like chroots, LXD containers, QEMU VMs, SSH hosts, or physical machines, simulating various deployment scenarios.

It supports .dsc source packages, binary .deb/.udeb/.ipk files, and integrates with CI systems such as Debian's ci.debian.net or Ubuntu's autopkgtest cloud. Tests are declared via simple control files specifying dependencies, restrictions (e.g., <allow-stderr>), and actions (e.g., apt install). autopkgtest handles package installation, dependency resolution via apt, and reports pass/fail outcomes with logs.

Common uses include developer testing during build cycles, release team validation, and migration testing between suites. It ensures packages work correctly post-install, under resource limits, and in isolation, catching regressions early.

CAVEATS

Requires debian/tests/control files in packages; testbeds like schroot/LXD must be pre-configured; resource-intensive for VMs; network access limited by default; fails if dependencies unmet.

TEST CONTROL FILE

Tests defined in debian/tests/control: Tests: test1 test2
Restrictions: needs-root, allow-stderr
Depends: @, @builddeps@

CLOUD INTEGRATION

Supports AWS/GCE/Azure via autopkgtest-cloud; used in Ubuntu Proposer for migration testing.

OUTPUT FORMAT

Produces .log, .html reports; exit codes: 0=pass, 2=fail, 4=setup-fail, 8=internal-error.

HISTORY

Originated as Debian's autopkgtest (formerly 'adt-run') around 2011 for QA automation, replacing older piuparts. Merged into autopkgtest project in 2013; actively maintained by Debian/Ubuntu Release Teams for CI/CD pipelines like ci.debian.net. Supports modern testbeds since Ubuntu 14.04+.

SEE ALSO

schroot(1), lxd(1), qemu(1), debuild(1), piuparts(1), dpkg-buildpackage(1)

Copied to clipboard