summaryrefslogtreecommitdiff
path: root/debian/tests/regress
diff options
context:
space:
mode:
Diffstat (limited to 'debian/tests/regress')
-rwxr-xr-xdebian/tests/regress67
1 files changed, 67 insertions, 0 deletions
diff --git a/debian/tests/regress b/debian/tests/regress
new file mode 100755
index 000000000..418bf55a6
--- /dev/null
+++ b/debian/tests/regress
@@ -0,0 +1,67 @@
1#! /bin/sh
2set -e
3
4if [ "$(id -un)" != openssh-tests ]; then
5 TMP="$AUTOPKGTEST_TMP/user"
6 CREATED_RUN_SSHD=false
7 STARTED_HAVEGED=false
8
9 cleanup () {
10 if $STARTED_HAVEGED; then
11 if [ -d /run/systemd/system ] && \
12 which systemctl >/dev/null 2>&1; then
13 systemctl disable haveged || true
14 systemctl stop haveged || true
15 else
16 start-stop-daemon --stop --quiet \
17 --retry=TERM/30/KILL/5 \
18 --pidfile "$AUTOPKGTEST_TMP/haveged.pid" \
19 --name haveged
20 fi
21 fi
22 rm -f /etc/sudoers.d/openssh-tests
23 if id openssh-tests >/dev/null 2>&1; then
24 deluser --remove-home openssh-tests
25 fi
26
27 if $CREATED_RUN_SSHD; then
28 rm -rf /run/sshd
29 fi
30 }
31 trap cleanup EXIT
32
33 adduser --disabled-password --gecos 'OpenSSH tests' openssh-tests
34 cat >/etc/sudoers.d/openssh-tests <<EOF
35openssh-tests ALL = (ALL:ALL) NOPASSWD: ALL
36EOF
37 chmod 440 /etc/sudoers.d/openssh-tests
38 mkdir -p "$TMP"
39 chown -R openssh-tests:openssh-tests "$TMP"
40
41 # Depending on how the environment is configured, our test
42 # dependency on openssh-server may not actually started sshd and
43 # thus may not have caused /run/sshd to be created.
44 if [ ! -d /run/sshd ]; then
45 mkdir -m755 /run/sshd
46 CREATED_RUN_SSHD=:
47 fi
48
49 # If we're running in a container, haveged may not have started
50 # automatically.
51 if [ -d /run/systemd/system ] && which systemctl >/dev/null 2>&1; then
52 systemctl enable haveged || true
53 systemctl start haveged || true
54 STARTED_HAVEGED=:
55 elif ! pidof haveged >/dev/null; then
56 start-stop-daemon --start --quiet \
57 --pidfile "$AUTOPKGTEST_TMP/haveged.pid" \
58 --exec /usr/sbin/haveged -- \
59 -p "$AUTOPKGTEST_TMP/haveged.pid"
60 STARTED_HAVEGED=:
61 fi
62
63 sudo -u openssh-tests env TMP="$TMP" "$0" "$@"
64 exit "$?"
65fi
66
67annotate-output +%H:%M:%S.%N /usr/lib/openssh/regress/run-tests "$TMP"