Debian Packaging: From Source to Repository

Package Testing and Quality

A practical Debian packaging course lesson covering package testing and quality.

Package Testing and Quality

A successful package build proves that the build process completed. It does not prove that the application behaves correctly, installs cleanly, or follows Debian packaging conventions.

In this lesson, we will add basic tests, inspect package quality with Lintian, and introduce autopkgtest.

Learning Objectives

  • Distinguish build success from package quality.
  • Run basic application smoke tests.
  • Use Lintian to inspect package issues.
  • Understand Debian’s autopkgtest framework.
  • Test installation and removal behavior.

1. Build the Package Again

From the project directory:

1
2
cd ~/packaging-lab/syspeek
dpkg-buildpackage -us -uc -b

Move to the parent directory:

1
cd ..

2. Run Lintian

Lintian checks Debian source and binary packages for common policy and packaging issues.

Run:

1
lintian syspeek_*.deb

Lintian may report errors, warnings, or informational tags. Review each finding rather than trying to suppress every message blindly.

Some tags may be context-dependent. Read the explanation for a tag before deciding how to address it.

3. Test the Application

Install the package in a disposable Debian environment or virtual machine:

1
sudo apt install ./syspeek_*.deb

Check the version:

1
syspeek --version

Check that normal execution returns output:

1
syspeek

Check the executable location:

1
command -v syspeek

Expected location:

1
/usr/bin/syspeek

4. Add a Simple Test Script

Create a test script in the project:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mkdir -p tests
cat > tests/smoke-test.sh <<'EOF'
#!/bin/sh
set -eu

output="$(./syspeek)"
printf '%s\n' "$output" | grep -q 'Syspeek - System Overview'

version="$(./syspeek --version)"
printf '%s\n' "$version" | grep -q '^syspeek '

echo "Syspeek smoke tests passed."
EOF

chmod +x tests/smoke-test.sh

Build the executable and run the test:

1
2
go build -o syspeek .
./tests/smoke-test.sh

This is a simple smoke test, not a comprehensive test suite. More tests should be added as the application grows.

5. Introduce autopkgtest

Debian’s autopkgtest framework runs tests against installed packages in a test environment.

A package can provide tests under:

1
debian/tests/

Create a simple test:

1
2
3
4
5
6
mkdir -p debian/tests
cat > debian/tests/control <<'EOF'
Tests: command-line
Depends: @
Restrictions: superficial
EOF

Create the test program:

1
2
3
4
5
6
7
8
9
cat > debian/tests/command-line <<'EOF'
#!/bin/sh
set -eu

syspeek --version
syspeek
EOF

chmod +x debian/tests/command-line

The @ dependency means the test depends on the package being tested.

The superficial restriction is appropriate only for a very basic smoke test that does not provide meaningful deep coverage. Remove it when writing tests that genuinely exercise package behavior.

6. Run autopkgtest

Install the tool:

1
sudo apt install autopkgtest

A typical local invocation using a suitable testbed is:

1
autopkgtest ../syspeek_*.changes -- null

The null runner uses the current environment and is not equivalent to a clean virtual-machine testbed. For stronger testing, configure a supported runner such as schroot or lxd, depending on your system.

Consult autopkgtest --help and the Debian autopkgtest documentation for runner configuration.

7. Test Removal

Also verify that the package can be removed cleanly:

1
sudo apt remove syspeek

For packages that install services, users, configuration, or persistent data, removal and purge behavior require additional tests.

8. What We Learned

We used Lintian to inspect package quality, wrote a smoke test, introduced autopkgtest, and considered installation and removal behavior.

Testing should be part of the package workflow, not an afterthought.

Exercises

  1. Run Lintian and investigate every reported tag.
  2. Break the smoke test temporarily and confirm that it fails.
  3. Run the package test in an isolated testbed.
  4. Add a test for the expected executable path.

What’s Next?

Next, we will build source packages and discuss signing. This is the step that prepares our work for distribution beyond a local binary package.

Next: Source Packages and Signing