From 9779ee47871217df935261f6931eeb285198da51 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 8 Oct 2014 22:33:32 +0100 Subject: Run a subset of the upstream regression test suite at package build time, and the rest of it under autopkgtest. --- .gitignore | 8 ++++---- debian/changelog | 2 ++ debian/control | 1 + debian/keygen-test/Makefile | 12 ++++++++++++ debian/keygen-test/getpid.c | 39 +++++++++++++++++++++++++++++++++++++++ debian/keygen-test/keygen-test | 12 ++++++++++++ debian/rules | 13 +++++++++++-- debian/tests/Makefile | 12 ------------ debian/tests/control | 3 +++ debian/tests/getpid.c | 39 --------------------------------------- debian/tests/keygen-test | 12 ------------ debian/tests/regress | 38 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 122 insertions(+), 69 deletions(-) create mode 100644 debian/keygen-test/Makefile create mode 100644 debian/keygen-test/getpid.c create mode 100755 debian/keygen-test/keygen-test delete mode 100644 debian/tests/Makefile create mode 100644 debian/tests/control delete mode 100644 debian/tests/getpid.c delete mode 100755 debian/tests/keygen-test create mode 100644 debian/tests/regress diff --git a/.gitignore b/.gitignore index 2c0b0d839..b9953edd3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,10 @@ debian/*.debhelper* debian/*substvars debian/copyright debian/files +debian/keygen-test/key1 +debian/keygen-test/key1.pub +debian/keygen-test/key2 +debian/keygen-test/key2.pub debian/openssh-client debian/openssh-client-udeb debian/openssh-server @@ -42,8 +46,4 @@ debian/openssh-server-udeb debian/ssh debian/ssh-askpass-gnome debian/ssh-krb5 -debian/tests/key1 -debian/tests/key1.pub -debian/tests/key2 -debian/tests/key2.pub debian/tmp diff --git a/debian/changelog b/debian/changelog index e89bee3b7..9842e0f7e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -46,6 +46,8 @@ openssh (1:6.7p1-1) UNRELEASED; urgency=medium * Simplify debian/rules using /usr/share/dpkg/buildflags.mk. * Use Package-Type rather than XC-Package-Type, now that it is an official field. + * Run a subset of the upstream regression test suite at package build + time, and the rest of it under autopkgtest. -- Colin Watson Mon, 06 Oct 2014 13:42:36 +0100 diff --git a/debian/control b/debian/control index bafe4307d..c513f4ee4 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,7 @@ Section: net Priority: standard Maintainer: Debian OpenSSH Maintainers Build-Depends: libwrap0-dev | libwrap-dev, zlib1g-dev (>= 1:1.2.3), libssl-dev (>= 0.9.8g), libpam0g-dev | libpam-dev, libgtk2.0-dev, libedit-dev, debhelper (>= 9~), dh-exec, libselinux1-dev [linux-any], libkrb5-dev | heimdal-dev, dpkg-dev (>= 1.16.1~), libck-connector-dev, dh-autoreconf, autotools-dev, dh-systemd (>= 1.4) +XS-Testsuite: autopkgtest Standards-Version: 3.9.6 Uploaders: Colin Watson , Matthew Vernon Homepage: http://www.openssh.org/ diff --git a/debian/keygen-test/Makefile b/debian/keygen-test/Makefile new file mode 100644 index 000000000..666ed8227 --- /dev/null +++ b/debian/keygen-test/Makefile @@ -0,0 +1,12 @@ +test: getpid.so + chmod +x keygen-test + ./keygen-test + +getpid.o: getpid.c + gcc -fPIC -c $< -o $@ + +getpid.so: getpid.o + gcc -shared -o $@ $< + +clean: + rm -f getpid.o getpid.so key1 key1.pub key2 key2.pub diff --git a/debian/keygen-test/getpid.c b/debian/keygen-test/getpid.c new file mode 100644 index 000000000..c9e35b87e --- /dev/null +++ b/debian/keygen-test/getpid.c @@ -0,0 +1,39 @@ +/* + * Compile: + +gcc -fPIC -c getpid.c -o getpid.o +gcc -shared -o getpid.so getpid.o + + * Use: + +FORCE_PID=1234 LD_PRELOAD=./getpid.so bash + +# +# Copyright (C) 2001-2008 Kees Cook +# kees@outflux.net, http://outflux.net/ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# http://www.gnu.org/copyleft/gpl.html + +*/ + +#include +#include +#include + +pid_t getpid(void) +{ + return atoi(getenv("FORCE_PID")); +} diff --git a/debian/keygen-test/keygen-test b/debian/keygen-test/keygen-test new file mode 100755 index 000000000..02b7c761a --- /dev/null +++ b/debian/keygen-test/keygen-test @@ -0,0 +1,12 @@ +#! /bin/sh + +rm -f key1 key1.pub key2 key2.pub +LD_PRELOAD="$(pwd)/getpid.so" FORCE_PID=1234 \ + ../../build-deb/ssh-keygen -N '' -f key1 >/dev/null +LD_PRELOAD="$(pwd)/getpid.so" FORCE_PID=1234 \ + ../../build-deb/ssh-keygen -N '' -f key2 >/dev/null +if cmp -s key1 key2; then + echo "Generated two identical keys!" >&2 + exit 1 +fi +exit 0 diff --git a/debian/rules b/debian/rules index bf4115fc4..570e6519f 100755 --- a/debian/rules +++ b/debian/rules @@ -145,13 +145,22 @@ override_dh_auto_build: override_dh_auto_test: ifeq ($(RUN_TESTS),yes) - $(MAKE) -C debian/tests + $(MAKE) -C build-deb regress-prep + $(MAKE) -C build-deb $(PARALLEL) \ + regress/unittests/sshbuf/test_sshbuf \ + regress/unittests/sshkey/test_sshkey + $(MAKE) -C build-deb/regress \ + .OBJDIR="$(CURDIR)/build-deb/regress" \ + .CURDIR="$(CURDIR)/regress" \ + unit + $(MAKE) -C build-deb compat-tests + $(MAKE) -C debian/keygen-test endif override_dh_auto_clean: rm -rf build-deb build-udeb ifeq ($(RUN_TESTS),yes) - $(MAKE) -C debian/tests clean + $(MAKE) -C debian/keygen-test clean endif $(MAKE) -C contrib clean (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \ diff --git a/debian/tests/Makefile b/debian/tests/Makefile deleted file mode 100644 index 666ed8227..000000000 --- a/debian/tests/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -test: getpid.so - chmod +x keygen-test - ./keygen-test - -getpid.o: getpid.c - gcc -fPIC -c $< -o $@ - -getpid.so: getpid.o - gcc -shared -o $@ $< - -clean: - rm -f getpid.o getpid.so key1 key1.pub key2 key2.pub diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 000000000..77b515bf8 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: regress +Restrictions: needs-root allow-stderr isolation-container +Depends: @builddeps@, openssh-client, openssh-server, openssh-sftp-server, sudo, putty-tools, python-twisted-conch diff --git a/debian/tests/getpid.c b/debian/tests/getpid.c deleted file mode 100644 index c9e35b87e..000000000 --- a/debian/tests/getpid.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Compile: - -gcc -fPIC -c getpid.c -o getpid.o -gcc -shared -o getpid.so getpid.o - - * Use: - -FORCE_PID=1234 LD_PRELOAD=./getpid.so bash - -# -# Copyright (C) 2001-2008 Kees Cook -# kees@outflux.net, http://outflux.net/ -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# http://www.gnu.org/copyleft/gpl.html - -*/ - -#include -#include -#include - -pid_t getpid(void) -{ - return atoi(getenv("FORCE_PID")); -} diff --git a/debian/tests/keygen-test b/debian/tests/keygen-test deleted file mode 100755 index 02b7c761a..000000000 --- a/debian/tests/keygen-test +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -rm -f key1 key1.pub key2 key2.pub -LD_PRELOAD="$(pwd)/getpid.so" FORCE_PID=1234 \ - ../../build-deb/ssh-keygen -N '' -f key1 >/dev/null -LD_PRELOAD="$(pwd)/getpid.so" FORCE_PID=1234 \ - ../../build-deb/ssh-keygen -N '' -f key2 >/dev/null -if cmp -s key1 key2; then - echo "Generated two identical keys!" >&2 - exit 1 -fi -exit 0 diff --git a/debian/tests/regress b/debian/tests/regress new file mode 100644 index 000000000..0e3fbc4ae --- /dev/null +++ b/debian/tests/regress @@ -0,0 +1,38 @@ +#! /bin/sh +set -e + +# Don't use "make tests"; we want to test the installed version. + +cp -a . "$ADTTMP/tree" +cd "$ADTTMP/tree" + +# We aren't actually going to use most of this build, but we need a basic +# build tree in place in order to be able to build the regression tests. +autoreconf -f -i +cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./ +./configure +make + +# The defaults for TEST_SSH_* in regress/test-exec.sh use the system +# versions, but the top-level Makefile sets things up to test the just-built +# versions, so we must bypass the latter in order to work correctly under +# autopkgtest. +make regress-prep +make regress/modpipe \ + regress/setuid-allowed \ + regress/unittests/sshbuf/test_sshbuf \ + regress/unittests/sshkey/test_sshkey + +SRCDIR="$(pwd)" +BUILDDIR="$SRCDIR" +make -C regress \ + .OBJDIR="$BUILDDIR/regress" \ + .CURDIR="$SRCDIR/regress" \ + BUILDDIR="$BUILDDIR" \ + OBJ="$BUILDDIR/regress" \ + SUDO=sudo \ + TEST_SHELL=sh \ + TEST_SSH_SFTPSERVER=/usr/lib/openssh/sftp-server \ + TEST_SSH_IPV6=yes \ + TEST_SSH_ECC=yes \ + tests interop-tests -- cgit v1.2.3