diff options
Diffstat (limited to 'debian/tests')
-rw-r--r-- | debian/tests/control | 10 | ||||
-rwxr-xr-x | debian/tests/regress | 66 |
2 files changed, 76 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 000000000..8bc480a74 --- /dev/null +++ b/debian/tests/control | |||
@@ -0,0 +1,10 @@ | |||
1 | Tests: regress | ||
2 | Restrictions: needs-root allow-stderr | ||
3 | Depends: devscripts, | ||
4 | haveged, | ||
5 | openssh-tests, | ||
6 | openssl, | ||
7 | putty-tools, | ||
8 | python3-twisted, | ||
9 | sudo, | ||
10 | sysvinit-utils, | ||
diff --git a/debian/tests/regress b/debian/tests/regress new file mode 100755 index 000000000..8bb73ee95 --- /dev/null +++ b/debian/tests/regress | |||
@@ -0,0 +1,66 @@ | |||
1 | #! /bin/sh | ||
2 | set -e | ||
3 | |||
4 | if [ "$(id -un)" != openssh-tests ]; then | ||
5 | TMP="$ADTTMP/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 "$ADTTMP/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 | ||
35 | openssh-tests ALL = (ALL:ALL) NOPASSWD: ALL | ||
36 | EOF | ||
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 "$ADTTMP/haveged.pid" \ | ||
58 | --exec /usr/sbin/haveged -- -p "$ADTTMP/haveged.pid" | ||
59 | STARTED_HAVEGED=: | ||
60 | fi | ||
61 | |||
62 | sudo -u openssh-tests env TMP="$TMP" "$0" "$@" | ||
63 | exit "$?" | ||
64 | fi | ||
65 | |||
66 | annotate-output +%H:%M:%S.%N /usr/lib/openssh/regress/run-tests "$TMP" | ||