Tags: patch Hello!
In Ubuntu we have created a very very simple sanity testing autopkgtest (in version 3.5-2ubuntu2) for needrestart, checking for very basic functionality as we wanted to have at least a quick smoke test to identify any obvious breakages. It creates a dummy service file, causes an artificial refresh of a dependent library, runs needrestart in batch mode, checks if it succeeds, checks if the dummy service is marked for restart and - if possible - checks if the kernel checks are performed. Forwarding it here in case it's of any use! And I'd love to get rid of the delta in Ubuntu - either by getting this accepted, or having someone prepare something much better! Thank you! On Sun, 10 Jan 2016 12:51:58 +0800 Paul Wise <p...@debian.org> wrote: > Package: needrestart > Severity: wishlist > > It would be nice for needrestart to have a test suite that could verify > that it is working. At the moment it appears to produce different > results to checkrestart so I'm worried it isn't working, but I don't > have time to write a proper bug report about this. A DEP-8 test would > mean that users don't have to file bugs as the CI system would > automatically and continuously test the package. > > http://dep.debian.net/deps/dep8/ > https://ci.debian.net/ > > -- > bye, > pabs > > https://wiki.debian.org/PaulWise > >
diff -Nru needrestart-3.5/debian/tests/control needrestart-3.5/debian/tests/control --- needrestart-3.5/debian/tests/control 1970-01-01 01:00:00.000000000 +0100 +++ needrestart-3.5/debian/tests/control 2021-03-05 18:01:10.000000000 +0100 @@ -0,0 +1,3 @@ +Tests: sanity-test.sh +Restrictions: needs-root +Depends: needrestart, dpkg-dev diff -Nru needrestart-3.5/debian/tests/sanity-test.sh needrestart-3.5/debian/tests/sanity-test.sh --- needrestart-3.5/debian/tests/sanity-test.sh 1970-01-01 01:00:00.000000000 +0100 +++ needrestart-3.5/debian/tests/sanity-test.sh 2021-03-23 12:47:33.000000000 +0100 @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +# Create a dummy service file and emulate library change in the background +systemd-run -u dummy-background sleep infinity 2>/dev/null +ARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null) +LIBC=$(realpath /lib/$ARCH/libc.so.6) +cp "$LIBC" "${LIBC}.new" +mv -f "${LIBC}.new" "$LIBC" + +OUTPUT=$(needrestart -b) + +echo "Check if the mandatory version number is printed" +echo "$OUTPUT" | grep -q "^NEEDRESTART-VER:" + +# Kernel checks are disabled when running in a container +if ! /usr/bin/systemd-detect-virt --container --quiet; then + echo "Check if the correct kernel was detected" + echo "$OUTPUT" | grep -q "^NEEDRESTART-KCUR: $(uname -r)$" + + echo "Check if the kernel status value is present as well" + echo "$OUTPUT" | grep -q "^NEEDRESTART-KSTA: [0-3]$" +fi + +echo "Check if outdated library was detected and dummy marked for restart" +echo "$OUTPUT" | grep -q "^NEEDRESTART-SVC: dummy-background.service$"