systemd/debian/tests/upstream
Dan Streetman 1d407ce943 d/t/upstream: change BLACKLIST env var into per-test file that upstream can control
Currently, the 'upstream' test runs all upstream-provided tests at tests/TEST-*,
except for any that are in a hardcoded list contained in this test.

Any change to the hardcoded blacklist involves patching the debian repo, which is
not an ideal way for upstream systemd to manage a hopefully temporary blacklist of
problematic tests.

There was discussion around making the blacklist entirely provided by an upstream
env var, configured in the upstream webhooks that control the Ubuntu CI tests,
but that results in 2 problems; 1) Debian would no longer be able to easily
control its own blacklist, and 2) upstream would only have an all-or-none control
over the blacklist, meaning that it could only enable or disable any specific
test for all PRs; it could not enable a test for only a specific PR that was
attempting to fix the flaky test (for example).

This approach moves blacklist control into the systemd tests themselves, by changing
the 'upstream' test to look for a file in the test directory, and skipping the test
if such file is found.  This way, Debian (and Ubuntu and other Debian derivatives)
can continue to manage their own blacklist, but also upstream can control
the blacklist for individual tests on a per-PR basis.

For example, if upstream has the file 'tests/TEST-01-BASIC/blacklist-ubuntu-ci'
in its repo, Ubuntu CI will skip this test for all PRs opened.  Then, a PR can
be opened that both fixes the test, as well as removes this file.  The Ubuntu CI
will then run the test, but only for the PR that attempts to fix it.  Once that
PR is merged, all future tests will then run the fixed test.

The specific naming of the per-test blacklist file, for tests run from the
upstream repo, is either "blacklist-ubuntu-ci" to completely blacklist the test
on all archs, or "blacklist-ubuntu-ci-$DPKGARCH" to blacklist the test only
for a specific arch, for example "blacklist-ubuntu-ci-amd64".  For tests run
from Debian (or Ubuntu), which are run without the TEST_UPSTREAM param set,
the blacklist filename is 'blacklist-upstream-ci[-$DPKGARCH]'.

Note that the $DPKGARCH is specified as the value returned by
'dpkg --print-architecture', not the value returned from 'uname -m' (e.g.
to blacklist a test for intel 64-bit, 'amd64' should be used, not 'x86_64').
This naming matches the title of the ubuntu tests, such as 'bionic-amd64',
'bionic-arm64', etc.
2019-10-17 06:00:36 -04:00

61 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# run upstream system integration tests
# Author: Martin Pitt <martin.pitt@ubuntu.com>
set -e
DPKGARCH=$(dpkg --print-architecture)
# quiesce Makefile.guess; not really relevant as systemd/nspawn run from
# installed packages
export BUILD_DIR=.
# modify the image build scripts to install systemd from the debs instead of
# from a "make/ninja install" as we don't have a built tree here. Also call
# systemd-nspawn from the system.
sed -i '/DESTDIR.* install/ s%^.*$% for p in `grep ^Package: '`pwd`'/debian/control | cut -f2 -d\\ |grep -Ev -- "-(udeb|dev)"`; do (cd /tmp; apt-get download $p \&\& dpkg-deb --fsys-tarfile ${p}[._]*deb | tar -C $initdir --dereference -x); done%; s_[^" ]*/systemd-nspawn_systemd-nspawn_g; s/\(_ninja_bin=\).*/\1dummy-ninja/' test/test-functions
# adjust path
sed -i 's_/usr/libexec/selinux/hll/pp_/usr/lib/selinux/hll/pp_' test/TEST-06-SELINUX/test.sh
FAILED=""
# Because this test is used both by upstream and by Debian, we use different blacklist filenames.
# For more details see https://salsa.debian.org/systemd-team/systemd/merge_requests/52
if [ -n "$TEST_UPSTREAM" ]; then
BLACKLIST="blacklist-ubuntu-ci"
else
BLACKLIST="blacklist-upstream-ci"
fi
for t in test/TEST*; do
testname=$(basename $t)
if [ -f "$t/$BLACKLIST" ]; then
echo "========== BLACKLISTED: $testname =========="
continue
elif [ -f "$t/$BLACKLIST-$DPKGARCH" ]; then
echo "========== BLACKLISTED (for arch $DPKGARCH): $testname =========="
continue
fi
echo "========== START: $testname =========="
rm -rf /var/tmp/systemd-test.*
if ! make -C $t clean setup run; then
for j in /var/tmp/systemd-test.*/journal/*; do
[ -e "$j" ] || continue
# keep the entire journal in artifacts, in case one needs the debug messages
cp -r "$j" "$AUTOPKGTEST_ARTIFACTS/${testname}-$(basename $j)"
echo "---- $j ----"
journalctl --priority=warning --directory=$j
done
FAILED="$FAILED $testname"
fi
echo
# always cleanup each test run
make -C $t clean-again
echo "========== END: $testname =========="
done
if [ -n "$FAILED" ]; then
echo FAILED TESTS: "$FAILED"
exit 1
fi