1 AUTOPKGTEST - DEFINING TESTS FOR PACKAGES
2 =========================================
4 This document describes how the autopkgtest tester core (the program
5 `adt-run') interprets and executes tests found in source packages.
9 The source package provides a test metadata file
10 debian/tests/control. This is a file containing zero or more
11 RFC822-style stanzas, along these lines:
13 Tests: fred bill bongo
14 Restrictions: needs-root breaks-computer
16 This example defines three tests, called `fred', `bill' and `bongo'.
17 The tests will be performed by executing debian/tests/fred,
18 debian/tests/bill, etc. Each test program should, on success, exit
19 with status 0 and print nothing to stderr; if a test exits nonzero, or
20 prints to stderr, it is considered to have failed.
22 The cwd of each test is guaranteed to be the root of the source
23 package which will have been built. HOWEVER note that the tests must
24 test the INSTALLED version of the program. Tests may not modify the
25 source tree (and may not have write access to it).
27 If the file to be executed has no execute bits set, chmod a+x is
28 applied to it (this means that tests can be added in patches without
29 the need for additional chmod; contrast this with debian/rules).
31 During execution of the test, the environment variable TMPDIR will
32 point to a directory for the execution of this particular test, which
33 starts empty and will be deleted afterwards (so there is no need for
34 the test to clean up files left there).
36 Tests must declare all applicable Restrictions - see below.
39 The fields which may appear in the RFC822-style stanza are:
41 Tests: <name-of-test> [<name-of-another-test> ...]
43 This field is mandatory. It names the tests which are defined by
44 this stanza. All of the other fields in the same stanza apply to
45 all of the named tests.
47 Test names are separated by whitespace and should contain only
48 characters which are legal in package names, plus `/'.
50 Restrictions: <restriction-name> [<another-restriction-name> ...]
52 Declares some restrictions or problems with the tests defined in
53 this stanza. Depending on the test environment capabilities, user
54 requests, and so on, restrictions can cause tests to be skipped or
55 can cause the test to be run in a different manner. Tests which
56 declare unknown restrictions will be skipped. See below for the
59 Features: <feature-name> [<another-feature-name> ...]
61 Declares some additional capabilities or good properties of the
62 tests defined in this stanza. Any unknown features declared will
63 be completely ignored. See below for the defined features.
65 Depends: <dpkg dependcy field syntax>
67 Declares that the specified packages must be installed for the
68 test to go ahead. `@' stands for the package(s) generated by the
69 source package containing the tests; each dependency (strictly,
70 or-clause, which may contain `|'s but not commas) containing `@'
71 is replicated once for each such binary package, with the binary
72 package name substituted for each `@' (but normally `@' should
73 occur only once and without a version restriction).
75 If no Depends field is present, `Depends: @' is assumed. Note
76 that the source tree's Build-Dependencies are _not_ necessarily
77 installed, and if you specify any Depends, no binary packages from
78 the source are installed unless explicitly requested.
80 Tests-Directory: <path>
82 Replaces the path segment `debian/tests' in the filenames of the
83 test programs with <path>. Ie, the tests are run by executing
84 /path/to/built/source/tree/<path>/<name-of-test>. <path> must be
85 a relative path and is interpreted starting from the root of the
88 This allows tests to live outside the debian/ metadata area, so
89 that they can more palatably be shared with non-Debian
92 Any unknown fields will cause the whole stanza to be skipped.
95 The defined Restrictions are:
99 The test(s) needs write access to the built source tree (so it may
100 need to be copied first). Even with this restriction, the test is
101 not allowed to make any change to the built source tree which (i)
102 isn't cleaned up by debian/rules clean, (ii) affects the future
103 results of any test, or (iii) affects binary packages produced by
104 the build tree in the future.
108 The test, when run, is liable to break the testbed system. This
109 includes causing data loss, causing services that the machine is
110 running to malfunction, or permanently disabling services; it does
111 not include causing services on the machine to temporarily fail.
113 When this restriction is present the test will usually be skipped
114 unless the testbed's virtualisation arrangements are sufficiently
115 powerful, or alternatively if the user explicitly requests.
119 The test script must be run as root.
122 The currently defined Features are:
126 The tests can run in an unbuilt tree.