From 816c51c7d218c69d375dc0cf8c07542486381bcc Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 8 Dec 2013 13:27:54 +0100 Subject: [PATCH] reduced fragility of the tests --- tests/test-cert | 7 ++++--- tests/test-iroute | 14 +++++++++----- tests/test-iroute.config | 4 ++-- tests/test-multi-cookie | 28 +++++++++++++++++----------- tests/test-multi-cookie.config | 4 ++-- tests/test-pass | 7 ++++--- tests/test-pass-cert | 7 ++++--- tests/test-pass-script | 7 ++++--- 8 files changed, 46 insertions(+), 32 deletions(-) diff --git a/tests/test-cert b/tests/test-cert index c4912fe6..8af74e02 100755 --- a/tests/test-cert +++ b/tests/test-cert @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Nikos Mavrogiannopoulos # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,6 +19,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" +srcdir=${srcdir:-.} PORT=4446 . `dirname $0`/common.sh diff --git a/tests/test-iroute b/tests/test-iroute index 98e8a812..5317c6f3 100755 --- a/tests/test-iroute +++ b/tests/test-iroute @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Nikos Mavrogiannopoulos # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,13 +19,16 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" -PORT=4447 +srcdir=${srcdir:-.} +PORT=4501 . `dirname $0`/common.sh echo "Testing ocserv and user route application... " -launch_server -d -f -c test-iroute.config & PID=$! +rm -f ${srcdir}/test-iroute.tmp + +launch_server -d -f -c ${srcdir}/test-iroute.config & PID=$! wait_server $PID echo -n "Connecting to obtain cookie (with certificate)... " @@ -34,6 +37,7 @@ echo -n "Connecting to obtain cookie (with certificate)... " echo ok +sleep 1 echo -n "Checking if routes have been applied... " if [ ! -f ${srcdir}/test-iroute.tmp ];then diff --git a/tests/test-iroute.config b/tests/test-iroute.config index 7a6ecf06..a23b5a60 100644 --- a/tests/test-iroute.config +++ b/tests/test-iroute.config @@ -24,8 +24,8 @@ max-clients = 16 max-same-clients = 2 # TCP and UDP port number -tcp-port = 4447 -udp-port = 4447 +tcp-port = 4501 +udp-port = 4501 # Keepalive in seconds keepalive = 32400 diff --git a/tests/test-multi-cookie b/tests/test-multi-cookie index 49f19530..6c5fdca6 100755 --- a/tests/test-multi-cookie +++ b/tests/test-multi-cookie @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Red Hat # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,13 +19,15 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" -PORT=4449 +srcdir=${srcdir:-.} +PORT=4500 . `dirname $0`/common.sh echo "Testing whether cookies are being re-used... " +rm -f ${srcdir}/pid1 ${srcdir}/pid2 -launch_server -d -f -c test-multi-cookie.config & PID=$! +launch_server -d -f -c ${srcdir}/test-multi-cookie.config & PID=$! wait_server $PID echo "Connecting to obtain cookie... " @@ -38,29 +40,33 @@ fi #echo "Cookie: $COOKIE" echo "Connecting with cookie... " -echo "test" | openconnect -q localhost:$PORT -u test -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true >/dev/null 2>&1 & +echo "test" | openconnect -q localhost:$PORT -u test -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose --pid-file ${srcdir}/pid1 & CPID=$! echo "Connecting again with same cookie... " #( echo "test" | openconnect -q localhost:$PORT -u test -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1 ) || # fail $PID "Could not connect to server" -echo "test" | openconnect -q localhost:$PORT -u test -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose >/dev/null 2>&1 & +rm -f ${srcdir}/ok +echo "test" | openconnect -q localhost:$PORT -u test -C "$COOKIE" --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --script=/bin/true --verbose --pid-file ${srcdir}/pid2 & C2PID=$! sleep 4 -kill $C2PID >/dev/null 2>&1 -if [ $? != 0 ];then +if [ !-f ${srcdir}/pid2 ];then fail $PID "It was not possible to establish session!" fi # checking whether server has already terminated $CPID sleep 1 -kill $CPID >/dev/null 2>&1 -if [ $? == 0 ];then + +if [ -f ${srcdir}/pid1 ];then fail $PID "Initial connection was still running!" fi +rm -f ${srcdir}/pid1 ${srcdir}/pid2 + +kill $C2PID >/dev/null 2>&1 +kill $CPID >/dev/null 2>&1 kill $PID wait diff --git a/tests/test-multi-cookie.config b/tests/test-multi-cookie.config index 5ae610ba..88ceba80 100644 --- a/tests/test-multi-cookie.config +++ b/tests/test-multi-cookie.config @@ -24,8 +24,8 @@ max-clients = 16 max-same-clients = 2 # TCP and UDP port number -tcp-port = 4449 -udp-port = 4449 +tcp-port = 4500 +udp-port = 4500 # Keepalive in seconds keepalive = 32400 diff --git a/tests/test-pass b/tests/test-pass index dc2a9422..789d0ce0 100755 --- a/tests/test-pass +++ b/tests/test-pass @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Nikos Mavrogiannopoulos # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,6 +19,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" +srcdir=${srcdir:-.} PORT=4444 . `dirname $0`/common.sh diff --git a/tests/test-pass-cert b/tests/test-pass-cert index 75e55ac6..da28e513 100755 --- a/tests/test-pass-cert +++ b/tests/test-pass-cert @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Nikos Mavrogiannopoulos # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,6 +19,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" +srcdir=${srcdir:-.} PORT=4445 . `dirname $0`/common.sh diff --git a/tests/test-pass-script b/tests/test-pass-script index c5386126..63511e5b 100755 --- a/tests/test-pass-script +++ b/tests/test-pass-script @@ -2,14 +2,14 @@ # # Copyright (C) 2013 Nikos Mavrogiannopoulos # -# This file is part of GnuTLS. +# This file is part of ocserv. # -# GnuTLS is free software; you can redistribute it and/or modify it +# ocserv 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. # -# GnuTLS is distributed in the hope that it will be useful, but +# ocserv 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. @@ -19,6 +19,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SERV="${SERV:-../src/ocserv}" +srcdir=${srcdir:-.} PORT=4448 . `dirname $0`/common.sh