diff options
Diffstat (limited to 'debian/tests/regress')
-rwxr-xr-x | debian/tests/regress | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/debian/tests/regress b/debian/tests/regress new file mode 100755 index 000000000..e89e1940a --- /dev/null +++ b/debian/tests/regress | |||
@@ -0,0 +1,97 @@ | |||
1 | #! /bin/sh | ||
2 | set -ex | ||
3 | |||
4 | if [ "$(id -un)" != openssh-tests ]; then | ||
5 | TMP="$ADTTMP/user" | ||
6 | STARTED_HAVEGED=false | ||
7 | |||
8 | cleanup () { | ||
9 | if $STARTED_HAVEGED; then | ||
10 | if [ -d /run/systemd/system ] && \ | ||
11 | which systemctl >/dev/null 2>&1; then | ||
12 | systemctl disable haveged || true | ||
13 | systemctl stop haveged || true | ||
14 | else | ||
15 | start-stop-daemon --stop --quiet \ | ||
16 | --retry=TERM/30/KILL/5 \ | ||
17 | --pidfile "$TMP/haveged.pid" \ | ||
18 | --name haveged | ||
19 | fi | ||
20 | fi | ||
21 | rm -rf "$TMP" | ||
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 | trap cleanup EXIT | ||
28 | |||
29 | adduser --disabled-password --gecos 'OpenSSH tests' openssh-tests | ||
30 | cat >/etc/sudoers.d/openssh-tests <<EOF | ||
31 | openssh-tests ALL = (ALL:ALL) NOPASSWD: ALL | ||
32 | EOF | ||
33 | chmod 440 /etc/sudoers.d/openssh-tests | ||
34 | mkdir -p "$TMP" | ||
35 | cp -a . "$TMP/tree" | ||
36 | chown -R openssh-tests:openssh-tests "$TMP" | ||
37 | |||
38 | # If we're running in a container, haveged may not have started | ||
39 | # automatically. | ||
40 | if [ -d /run/systemd/system ] && which systemctl >/dev/null 2>&1; then | ||
41 | systemctl enable haveged || true | ||
42 | systemctl start haveged || true | ||
43 | STARTED_HAVEGED=: | ||
44 | elif ! pidof haveged >/dev/null; then | ||
45 | start-stop-daemon --start --quiet \ | ||
46 | --pidfile "$TMP/haveged.pid" \ | ||
47 | --exec /usr/sbin/haveged -- -p "$TMP/haveged.pid" | ||
48 | STARTED_HAVEGED=: | ||
49 | fi | ||
50 | |||
51 | sudo -u openssh-tests env TMP="$TMP" "$0" "$@" | ||
52 | exit "$?" | ||
53 | fi | ||
54 | |||
55 | # Don't use "make tests"; we want to test the installed version. | ||
56 | |||
57 | cd "$TMP/tree" | ||
58 | |||
59 | # We aren't actually going to use most of this build, but we need a basic | ||
60 | # build tree in place in order to be able to build the regression tests. | ||
61 | autoreconf -f -i | ||
62 | cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./ | ||
63 | ./configure | ||
64 | make | ||
65 | |||
66 | # The defaults for TEST_SSH_* in regress/test-exec.sh use the system | ||
67 | # versions, but the top-level Makefile sets things up to test the just-built | ||
68 | # versions, so we must bypass the latter in order to work correctly under | ||
69 | # autopkgtest. | ||
70 | make regress-prep | ||
71 | make regress-binaries | ||
72 | |||
73 | SRCDIR="$(pwd)" | ||
74 | BUILDDIR="$SRCDIR" | ||
75 | ret=0 | ||
76 | annotate-output +%H:%M:%S.%N make -C regress \ | ||
77 | .OBJDIR="$BUILDDIR/regress" \ | ||
78 | .CURDIR="$SRCDIR/regress" \ | ||
79 | BUILDDIR="$BUILDDIR" \ | ||
80 | OBJ="$BUILDDIR/regress" \ | ||
81 | SUDO=sudo \ | ||
82 | TEST_SHELL='sh -x' \ | ||
83 | TEST_SSH_SFTPSERVER=/usr/lib/openssh/sftp-server \ | ||
84 | TEST_SSH_PLINK=plink \ | ||
85 | TEST_SSH_PUTTYGEN=puttygen \ | ||
86 | TEST_SSH_CONCH=conch \ | ||
87 | TEST_SSH_IPV6=yes \ | ||
88 | TEST_SSH_ECC=yes \ | ||
89 | tests interop-tests </dev/zero || ret="$?" | ||
90 | if [ "$ret" -ne 0 ]; then | ||
91 | for log in failed-regress.log failed-ssh.log failed-sshd.log; do | ||
92 | if [ -e "$BUILDDIR/regress/$log" ]; then | ||
93 | tail -v -n+0 "$BUILDDIR/regress/$log" | ||
94 | fi | ||
95 | done | ||
96 | fi | ||
97 | exit "$ret" | ||