aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-08-10 18:49:28 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-08-10 18:49:28 +0000
commitfd381bc26fd4393d2456ed9bcc466f5159828a1a (patch)
treef5777cd37224ec5b4c80b52cc4877a8c02028189
parentReverted r3181, accomplish the same thing via a special case (diff)
downloadopenvpn-fd381bc26fd4393d2456ed9bcc466f5159828a1a.tar.xz
Updated openvpn/t_cltsrv.sh (used by "make check") to conform to new
--script-security rules. Also adds retrying if the addresses are in use (Matthias Andree). git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3217 e7ae566f-a301-0410-adde-c780ea21d3b5
-rwxr-xr-xt_cltsrv-down.sh2
-rwxr-xr-xt_cltsrv.sh56
2 files changed, 44 insertions, 14 deletions
diff --git a/t_cltsrv-down.sh b/t_cltsrv-down.sh
new file mode 100755
index 0000000..2ef852a
--- /dev/null
+++ b/t_cltsrv-down.sh
@@ -0,0 +1,2 @@
+#! /bin/sh
+echo "${role}:${signal}" >&3
diff --git a/t_cltsrv.sh b/t_cltsrv.sh
index b72d1ee..808d719 100755
--- a/t_cltsrv.sh
+++ b/t_cltsrv.sh
@@ -1,7 +1,7 @@
#! /bin/sh
#
# t_cltsrv.sh - script to test OpenVPN's crypto loopback
-# Copyright (C) 2005,2006 Matthias Andree
+# Copyright (C) 2005, 2006, 2008 Matthias Andree
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -38,22 +38,50 @@ case `uname -s` in
fi
;;
esac
-echo "the following test will take about two minutes..." >&2
-set +e
-(
-./openvpn --cd "${srcdir}" ${addopts} --down 'echo "srv:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
-./openvpn --cd "${srcdir}" ${addopts} --down 'echo "clt:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
-) 3>log.$$.signal >log.$$ 2>&1
-e1=$?
-wait $!
-e2=$?
-grep -v ":inactive$" log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
+
+# make sure that the --down script is executable -- fail (rather than
+# skip) test if it isn't.
+downscript="t_cltsrv-down.sh"
+test -x "${srcdir}"/$downscript || chmod +x "${srcdir}"/$downscript || { echo >&2 "$downscript is not executable, failing." ; exit 1 ; }
+echo "The following test will take about two minutes." >&2
+echo "If the addresses are in use, this test will retry up to two times." >&2
+
+# go
+success=0
+for i in 1 2 3 ; do
+ set +e
+ (
+ ./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role srv --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
+ ./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role clt --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
+ ) 3>log.$$.signal >log.$$ 2>&1
+ e1=$?
+ wait $!
+ e2=$?
+ grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
+ echo 'address in use, retrying in 150 s'
+ sleep 150
+ continue
+ }
+ grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
+ success=1
+ break
+done
set -e
-if [ $e1 != 0 ] || [ $e2 != 0 ] ; then
- cat log.$$
- exit 1
+# exit code - defaults to 0, PASS
+ec=0
+
+if [ $success != 1 ] ; then
+ # couldn't run test -- addresses in use, skip test
+ cat log.$$
+ ec=77
+elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
+ # failure -- fail test
+ cat log.$$
+ ec=1
fi
+
rm log.$$ log.$$.signal
trap 0
+exit $ec