~ubuntu-branches/ubuntu/oneiric/openvpn/oneiric

« back to all changes in this revision

Viewing changes to t_cltsrv.sh

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2008-10-07 16:30:44 UTC
  • mfrom: (1.1.11 upstream) (10.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081007163044-ixx04wg588z1972e
Tags: 2.1~rc11-1ubuntu1
* Merge with Debian (LP: #279655), remaining diffs:
  - debian/openvpn.init.d: Added 'status' action to init script, show
    per-VPN result messages and add "--script-security 2" by default for
    backwards compatibility
  - debian/control: Added lsb-base>=3.2-14 depend to allow status_of_proc()
* Fixes regression when calling commands with arguments (LP: #277447)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
#
3
3
# t_cltsrv.sh - script to test OpenVPN's crypto loopback
4
 
# Copyright (C) 2005,2006  Matthias Andree
 
4
# Copyright (C) 2005, 2006, 2008  Matthias Andree
5
5
#
6
6
# This program is free software; you can redistribute it and/or
7
7
# modify it under the terms of the GNU General Public License
38
38
    fi
39
39
    ;;
40
40
esac
41
 
echo "the following test will take about two minutes..." >&2
42
 
set +e
43
 
(
44
 
./openvpn --cd "${srcdir}" ${addopts} --down 'echo "srv:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
45
 
./openvpn --cd "${srcdir}" ${addopts} --down 'echo "clt:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
46
 
) 3>log.$$.signal >log.$$ 2>&1
47
 
e1=$?
48
 
wait $!
49
 
e2=$?
50
 
grep -v ":inactive$" log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
 
41
 
 
42
# make sure that the --down script is executable -- fail (rather than
 
43
# skip) test if it isn't.
 
44
downscript="t_cltsrv-down.sh"
 
45
test -x "${srcdir}"/$downscript || chmod +x "${srcdir}"/$downscript || { echo >&2 "$downscript is not executable, failing." ; exit 1 ; }
 
46
echo "The following test will take about two minutes." >&2
 
47
echo "If the addresses are in use, this test will retry up to two times." >&2
 
48
 
 
49
# go
 
50
success=0
 
51
for i in 1 2 3 ; do
 
52
  set +e
 
53
  (
 
54
  ./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role srv --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
 
55
  ./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role clt --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
 
56
  ) 3>log.$$.signal >log.$$ 2>&1
 
57
  e1=$?
 
58
  wait $!
 
59
  e2=$?
 
60
  grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
 
61
    echo 'address in use, retrying in 150 s'
 
62
    sleep 150
 
63
    continue
 
64
  }
 
65
  grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
 
66
  success=1
 
67
  break
 
68
done
51
69
 
52
70
set -e
53
71
 
54
 
if [ $e1 != 0 ] || [ $e2 != 0 ] ; then
55
 
    cat log.$$
56
 
    exit 1
 
72
# exit code - defaults to 0, PASS
 
73
ec=0
 
74
 
 
75
if [ $success != 1 ] ; then
 
76
  # couldn't run test -- addresses in use, skip test
 
77
  cat log.$$
 
78
  ec=77
 
79
elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
 
80
  # failure -- fail test
 
81
  cat log.$$
 
82
  ec=1
57
83
fi
 
84
 
58
85
rm log.$$ log.$$.signal
59
86
trap 0
 
87
exit $ec