Merge lp:~dholbach/ubuntu-packaging-guide/autopkgtest into lp:ubuntu-packaging-guide

Proposed by Daniel Holbach on 2012-10-10
Status: Merged
Merged at revision: 171
Proposed branch: lp:~dholbach/ubuntu-packaging-guide/autopkgtest
Merge into: lp:ubuntu-packaging-guide
Diff against target: 141 lines (+126/-0)
2 files modified
ubuntu-packaging-guide/auto-pkg-test.rst (+125/-0)
ubuntu-packaging-guide/index.rst (+1/-0)
To merge this branch: bzr merge lp:~dholbach/ubuntu-packaging-guide/autopkgtest
Reviewer Review Type Date Requested Status
Martin Pitt 2012-10-10 Approve on 2012-10-10
Ubuntu Packaging Guide Team 2012-10-10 Pending
Review via email: mp+128905@code.launchpad.net
To post a comment you must log in.
Martin Pitt (pitti) wrote :

Thanks so much for adding this!

One issue:

+* The `gtk+3.0 tests`_ do two things: firstly they run the upstream
+ test-suite as part of ``autopkgtest``. Secondly they execute a python
+ program using ``xvfb`` to emulate a running X session.

That's not quite true, the upstream tests are currently only run during package build. Somethign like this:

 * The `gtk+3.0 tests`_ also do a compile/link/run check in the "build" test. There is an additional "python3-gi" test which verifies that the GTK library can also be used through introspection.

+While Debian does not have an automatic testing infrastructure set up yet, it
+makes a lot of sense to forward ``autopkgtest`` changes to Debian as well.

Perhaps "... yet, they should still be submitted to Debian, as DEP-8 is a Debian specification and Debian developers or users can still manually run the tests."

171. By Daniel Holbach on 2012-10-10

factored in feedback from Martin Pitt: fixed statements about gtk+3.0 tests, added link to ubiquity tests, rephrased comment about sharing tests with Debian

Martin Pitt (pitti) wrote :

Nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'ubuntu-packaging-guide/auto-pkg-test.rst'
2--- ubuntu-packaging-guide/auto-pkg-test.rst 1970-01-01 00:00:00 +0000
3+++ ubuntu-packaging-guide/auto-pkg-test.rst 2012-10-10 12:05:24 +0000
4@@ -0,0 +1,125 @@
5+===========================================
6+autopkgtest: Automatic testing for packages
7+===========================================
8+
9+The `DEP 8 specification`_ defines how automatic testing can very easily be
10+integrated into packages. To integrate a test into a package, all you need to
11+do is:
12+
13+* add the following to the Source section in ``debian/control``::
14+
15+ XS-Testsuite: autopkgtest
16+
17+* add a file called ``debian/tests/control`` which specifies the requirements
18+ for the testbed,
19+* add the tests in ``debian/tests/``.
20+
21+
22+Testbed requirements
23+====================
24+
25+In ``debian/tests/control`` you specify what to expect from the testbed. So
26+for example you list all the required packages for the tests, if the testbed
27+gets broken during the build or if ``root`` permissions are required. The
28+`DEP 8 specification`_ lists all available options.
29+
30+In a very simple case the file would look like this::
31+
32+ Tests: build
33+ Depends: libglib2.0-dev, build-essential
34+
35+For the test in ``debian/tests/build`` this would ensure that the packages
36+``libglib2.0-dev`` and ``build-essential`` are installed.
37+
38+.. note:: You can use ``@`` in the ``Depends`` line to indicate that you want
39+ all the packages installed which are built by the source package in
40+ question.
41+
42+
43+The actual tests
44+================
45+
46+The accompanying test for the example above might be::
47+
48+ #!/bin/sh
49+ # autopkgtest check: Build and run a program against glib, to verify that the
50+ # headers and pkg-config file are installed correctly
51+ # (C) 2012 Canonical Ltd.
52+ # Author: Martin Pitt <martin.pitt@ubuntu.com>
53+
54+ set -e
55+
56+ WORKDIR=$(mktemp -d)
57+ trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
58+ cd $WORKDIR
59+ cat <<EOF > glibtest.c
60+ #include <glib.h>
61+
62+ int main()
63+ {
64+ g_assert_cmpint (g_strcmp0 (NULL, "hello"), ==, -1);
65+ g_assert_cmpstr (g_find_program_in_path ("bash"), ==, "/bin/bash");
66+ return 0;
67+ }
68+ EOF
69+
70+ gcc -o glibtest glibtest.c `pkg-config --cflags --libs glib-2.0`
71+ echo "build: OK"
72+ [ -x glibtest ]
73+ ./glibtest
74+ echo "run: OK"
75+
76+Here a very simple piece of C code is written to a temporary directory. Then
77+this is compiled with system libraries (using flags and library paths as
78+provided by `pkg-config`. Then the compiled binary, which just exercises some
79+parts of core glib functionality, is run.
80+
81+While this test is very small and basic, it tests quite a number of core
82+components on a system, so is very important to have as it might uncover a big
83+number of problems.
84+
85+Executing the test
86+==================
87+
88+The test script can be easily executed on its own, but if you want to make
89+sure that the testbed is properly set up, you might want to use ``adt-run``
90+from the ``autopkgtest`` package to execute the test. Simply run this
91+command in the source tree::
92+
93+ sudo adt-run --no-built-binaries --built-tree=. --- adt-virt-null
94+
95+
96+Further examples
97+================
98+
99+This list is not comprehensive, but might help you get a better idea of how
100+automated tests are implemented and used in Ubuntu.
101+
102+* The `libxml2 tests`_ are very similar. They also run a test-build of a
103+ simple piece of C code and execute it.
104+* The `gtk+3.0 tests`_ also do a compile/link/run check in the "build" test.
105+ There is an additional "python3-gi" test which verifies that the GTK
106+ library can also be used through introspection.
107+* In the `ubiquity tests`_ the upstream test-suite is executed.
108+* The `gvfs tests`_ have comprehensive testing of their functionality and
109+ are very interesting because they emulate usage of CDs, Samba, DAV and
110+ other bits.
111+
112+Ubuntu infrastructure
113+=====================
114+
115+Packages which have ``autopkgtest`` enabled will have their tests run whenever
116+they get uploaded or any of their reverse-dependencies change. The output of
117+`automatically run autopkgtest tests`_ can be viewed on the web and is
118+regularly updated.
119+
120+While Debian does not have an automatic testing infrastructure set up yet,
121+they should still be submitted to Debian, as DEP-8 is a Debian specification
122+and Debian developers or users can still manually run the tests.
123+
124+.. _`DEP 8 Specification`: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD
125+.. _`libxml2 tests`: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/libxml2/quantal/files/head:/debian/tests/
126+.. _`gvfs tests`: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/gvfs/quantal/files/head:/debian/tests/
127+.. _`gtk+3.0 tests`: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/gtk+3.0/quantal/files/head:/debian/tests/
128+.. _`ubiquity tests`: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/ubiquity/quantal/files/head:/debian/tests/
129+.. _`automatically run autopkgtest tests`: https://jenkins.qa.ubuntu.com/view/Quantal/view/AutoPkg%20Test/
130
131=== modified file 'ubuntu-packaging-guide/index.rst'
132--- ubuntu-packaging-guide/index.rst 2012-09-03 16:43:14 +0000
133+++ ubuntu-packaging-guide/index.rst 2012-10-10 12:05:24 +0000
134@@ -54,6 +54,7 @@
135
136 communication
137 debian-dir-overview
138+ auto-pkg-test
139 udd-getting-the-source
140 udd-working
141 udd-sponsorship

Subscribers

People subscribed via source and target branches