Debian Codegraph @

debian/tests/boot-smoke

raw
1 #!/bin/sh
2 # test $TEST_REBOOTS successful reboots in a row
3 # Author: Martin Pitt <[email protected]>
4 # For bisecting/testing you can replace individual binaries in /lib/systemd
5 # with --copy /host/path/systemd-foo:/tmp/systemd-replace/systemd-foo
6 set -e
7
8 IS_SYSTEM_RUNNING_TIMEOUT=300
9 TEST_REBOOTS=5
10
11 . `dirname $0`/assert.sh
12
13 fail() {
14 [ -n "$1" ] && echo "$1"
15 set +e
16 journalctl --sync
17 journalctl -a > "$AUTOPKGTEST_ARTIFACTS/boot-smoke-journal.txt"
18 systemctl --no-pager --no-legend list-jobs > "$AUTOPKGTEST_ARTIFACTS/boot-smoke-running-jobs.txt"
19 udevadm info --export-db > "$AUTOPKGTEST_ARTIFACTS/boot-smoke-udevdb.txt"
20 exit 1
21 }
22
23 if [ -z "$AUTOPKGTEST_REBOOT_MARK" ]; then
24 # enable persistent journal
25 mkdir -p /var/log/journal
26 # allow X to start even on headless machines
27 mkdir -p /etc/X11/xorg.conf.d/
28 cat << EOF > /etc/X11/xorg.conf.d/dummy.conf
29 Section "Device"
30 Identifier "test"
31 Driver "dummy"
32 EndSection
33 EOF
34
35 # This test installs network-manager, which seems to cause
36 # systemd-networkd-wait-online to be stuck as they conflict,
37 # so systemctl start network-online.target ran by autopkgtest
38 # gets stuck, at least in Debian Bullseye images.
39 # https://salsa.debian.org/ci-team/autopkgtest/-/blob/debian/5.21/virt/autopkgtest-virt-lxc#L131
40 systemctl disable systemd-networkd.service
41
42 AUTOPKGTEST_REBOOT_MARK=0
43 if [ -d /tmp/systemd-replace/ ]; then
44 for f in /tmp/systemd-replace/*; do
45 echo "Installing $f..."
46 rm -f /lib/systemd/$(basename $f)
47 cp $f /lib/systemd/
48 done
49 fi
50 else
51 echo "waiting to boot..."
52 TIMEOUT=${IS_SYSTEM_RUNNING_TIMEOUT}
53 while [ $TIMEOUT -ge 0 ]; do
54 state="$(systemctl is-system-running || true)"
55 case $state in
56 running|degraded)
57 break
58 ;;
59 *)
60 sleep 1
61 TIMEOUT=$((TIMEOUT - 1))
62 ;;
63 esac
64 done
65
66 echo "checking for running system"
67 if [ "$state" = "degraded" ]; then
68 systemctl --no-pager --no-legend --failed list-units > "$AUTOPKGTEST_ARTIFACTS/boot-smoke-failed-units.txt" || true
69 echo "systemctl is-system-running: degraded (non-fatal)"
70 elif [ "$state" != "running" ]; then
71 fail "system not running after timeout $IS_SYSTEM_RUNNING_TIMEOUT, state: $state"
72 fi
73
74 echo "checking for failed unmounts for user systemd"
75 # grep complete journal to catch shutdown messages
76 if journalctl | grep -E "systemd\[([2-9]|[1-9][0-9]+)\].*Failed unmounting"; then
77 fail "found failed unmount in journal"
78 fi
79
80 # grep only this boot's journal, earlier ones complain about missing "render" group
81 echo "checking for connection timeouts"
82 if journalctl -b | grep "Connection timed out"; then
83 fail "found connection timeout in journal for this boot"
84 fi
85
86 echo "checking that NetworkManager runs"
87 pidof NetworkManager || fail "NetworkManager was not running"
88 fi
89
90 if [ "$AUTOPKGTEST_REBOOT_MARK" -ge "$TEST_REBOOTS" ]; then
91 exit 0
92 fi
93
94 echo "reboot #$AUTOPKGTEST_REBOOT_MARK"
95 /tmp/autopkgtest-reboot $(($AUTOPKGTEST_REBOOT_MARK + 1))