diff options
author | Reto Buerki <reet@codelabs.ch> | 2012-12-10 16:16:56 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-01-17 16:54:55 +0100 |
commit | 76ccd25a050a543e9dfc5fd23d5ebe976660fccb (patch) | |
tree | b1bc8cd79b24138e9c1603e18a2b61366b6d4363 /testing/hosts/default/usr/local | |
parent | 44e83859e0819c86d10007380da19829e3112f51 (diff) | |
download | strongswan-76ccd25a050a543e9dfc5fd23d5ebe976660fccb.tar.bz2 strongswan-76ccd25a050a543e9dfc5fd23d5ebe976660fccb.tar.xz |
Add expect-connection guest image script
This script can be used in pretest.dat files to wait until an IPsec
connection becomes available. This avoids unconditional sleeps and
improves test performance.
The ipv6 tests have been updated to use the expect-connection script.
Diffstat (limited to 'testing/hosts/default/usr/local')
-rwxr-xr-x | testing/hosts/default/usr/local/bin/expect-connection | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/hosts/default/usr/local/bin/expect-connection b/testing/hosts/default/usr/local/bin/expect-connection new file mode 100755 index 000000000..10a709255 --- /dev/null +++ b/testing/hosts/default/usr/local/bin/expect-connection @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Wait until a given IPsec connection becomes available +# +# Params: +# $1 - connection name +# $2 - maximum time to wait in seconds, default is 5 seconds + +if [[ $# -lt 1 || $# -gt 2 ]] +then + echo "invalid arguments" + exit 1 +fi + +secs=$2 +[ ! $secs ] && secs=5 + +let steps=$secs*10 +for i in `seq 1 $steps` +do + ipsec statusall 2>&1 | grep ^[[:space:]]*$1: >/dev/null + [ $? -eq 0 ] && exit 0 + sleep 0.1 +done + +echo "Connection '$1' not available after $secs second(s)" +exit 1 |