Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion t_server/original/client_vm/bin/ping8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# Ping the peer. Used by tests 8 and 8a.
#
( sleep 2 ; ping -6 -c 2 fd00:abcd:204:8::1 >/dev/null) &
( sleep 2 ; ping6 -c 2 fd00:abcd:204:8::1 >/dev/null) &
158 changes: 70 additions & 88 deletions t_server/original/client_vm/bin/t_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,18 @@ openvpn="${openvpn:-${top_builddir}/src/openvpn/openvpn}"
t_client_ips_rc="${t_client_ips_rc:-${top_builddir}/t_client_ips.rc}"
update_t_client_ips="${update_t_client_ips:-${srcdir}/update_t_client_ips.sh}"

# HACK for t_server support
# Argument 1 is BRANCH (23, 24, master)
# export as $BRANCH to t_client.rc
if [ x"$t_server" != "x" ]; then
export BRANCH="$1"

if [ -z "$BRANCH" ] ; then
echo "$0: branch missing (23/24/master)" >&2 ; exit 1
if [ -z "${t_client_rc}" ]; then
if [ -r "${top_builddir}"/t_client.rc ] ; then
t_client_rc="${top_builddir}"/t_client.rc
elif [ -r "${srcdir}"/t_client.rc ] ; then
t_client_rc="${srcdir}"/t_client.rc
else
echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
echo "$0: or source directory ('${srcdir}'). SKIPPING TEST." >&2
exit "${TCLIENT_SKIP_RC}"
fi
fi

if [ -r "${top_builddir}"/t_client.rc ] ; then
. "${top_builddir}"/t_client.rc
elif [ -r "${srcdir}"/t_client.rc ] ; then
. "${srcdir}"/t_client.rc
else
echo "$0: cannot find 't_client.rc' in build dir ('${top_builddir}')" >&2
echo "$0: or source directory ('${srcdir}'). SKIPPING TEST." >&2
exit "${TCLIENT_SKIP_RC}"
fi

# Check for external dependencies
FPING="fping"
FPING6="fping6"
Expand Down Expand Up @@ -76,21 +67,16 @@ then
exit 1
fi

echoout=`echo -e "foo\cbar"`
if [ "$echoout" = "foo" ]; then
ECHO_E="-e"
elif [ "$echoout" = "-e foo" ]; then
# echo doesn't interpret -e but supports escape sequences
ECHO_E=
else
echo "something is wrong with your 'echo' command. FAIL." >&2
exit 1
fi
openvpn_version=`${openvpn} --version | head -n 1 | cut -f2 -d" " | sed -e 's/^2\.\([0123456789]\+\).*$/2\1/'`

if [ -z "$CA_CERT" ] ; then
echo "CA_CERT not defined in 't_client.rc'. SKIP test." >&2
exit "${TCLIENT_SKIP_RC}"
fi
needs_openvpn() {
needs_version=$1

[ "$openvpn_version" -ge "$needs_version" ]
return $?
}

. "${t_client_rc}"

if [ -z "$TEST_RUN_LIST" ] ; then
echo "TEST_RUN_LIST empty, no tests defined. SKIP test." >&2
Expand Down Expand Up @@ -140,6 +126,7 @@ else
fi

LOGDIR=t_client-`hostname`-`date +%Y%m%d-%H%M%S`
LOGDIR_ABS="$PWD/$LOGDIR"
if mkdir $LOGDIR
then :
else
Expand All @@ -162,21 +149,20 @@ output_start()
{
case $V in
0) outbuf="" ;; # no per-test output at all
1) echo $ECHO_E "$@" # compact, details only on failure
1) printf "$@\n" # compact, details only on failure
outbuf="\n" ;;
*) echo $ECHO_E "\n$@\n" ;; # print all, with a bit formatting
*) printf "\n$@\n" ;; # print all, with a bit formatting
esac
}

output()
{
NO_NL=''; if [ "X$1" = "X-n" ] ; then NO_NL=$1 ; shift ; fi
END_NL="\n"; if [ "X$1" = "X-n" ] ; then END_NL="" ; shift ; fi
case $V in
0) ;; # no per-test output at all
1) outbuf="$outbuf$@" # print details only on failure
test -z "$NO_NL" && outbuf="$outbuf\n"
1) outbuf="$outbuf$@${END_NL}" # print details only on failure
;;
*) echo $ECHO_E $NO_NL "$@" ;; # print everything
*) printf "$@${END_NL}" ;; # print everything
esac
}

Expand All @@ -195,12 +181,12 @@ get_ifconfig_route()
case $UNAME in
Linux)
# linux / iproute2? (-> if configure got a path)
if [ -n "/usr/sbin/ip" ]
if [ -n "/sbin/ip" ]
then
echo "-- linux iproute2 --"
/usr/sbin/ip addr show | grep -v valid_lft
/usr/sbin/ip route show
/usr/sbin/ip -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
/sbin/ip addr show | grep -v valid_lft
/sbin/ip route show
/sbin/ip -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar) [0-9]+ms//g'
else
echo "-- linux / ifconfig --"
LANG=C /usr/sbin/ifconfig -a |egrep "( addr:|encap:)"
Expand Down Expand Up @@ -362,12 +348,10 @@ do
up=""
fi


output_start "### test run $SUF: '$test_run_title' ###"
if [ -n "$expect_fail" ] ; then
echo "### expect failure: '$expect_fail'";
output "### expect failure: '$expect_fail'";
fi
echo ""
fail_count=0

if [ -n "$test_check_skip" ]; then
Expand All @@ -376,7 +360,7 @@ do
else
output "skip check failed, SKIP test $SUF."
SUMMARY_SKIP="$SUMMARY_SKIP $SUF"
echo $ECHO_E "$outbuf" ; continue
printf "$outbuf" ; continue
fi
fi

Expand All @@ -397,11 +381,10 @@ do
fail "make sure that ping hosts are ONLY reachable via VPN, SKIP test $SUF."
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=31
echo $ECHO_E "$outbuf" ; continue
printf "$outbuf" ; continue
fi

#pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid"
pidfile="$LOGDIR/openvpn-$SUF.pid"
pidfile="$LOGDIR_ABS/openvpn-$SUF.pid"
openvpn_conf="$openvpn_conf --writepid $pidfile $up"
output " run openvpn $openvpn_conf"
echo "# ${openvpn} $openvpn_conf" >$LOGDIR/$SUF:openvpn.log
Expand All @@ -415,54 +398,53 @@ do
ovpn_init_success=0
while [ $ovpn_init_check -gt 0 ];
do
sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
if [ -n "$expect_fail" ]
then
grep "$expect_fail" $LOGDIR/$SUF:openvpn.log # >/dev/null
if [ $? -eq 0 ]; then
ovpn_init_check=0
ovpn_init_success=1
sleep 5 # give openvpn time to quit
fi
else
grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
if [ $? -eq 0 ]; then
ovpn_init_check=0
ovpn_init_success=1
fi
fi
ovpn_init_check=$(( $ovpn_init_check - 1 ))
sleep 1 # Wait for OpenVPN to initialize and have had time to write the pid file
if [ -n "$expect_fail" ]
then
grep "$expect_fail" $LOGDIR/$SUF:openvpn.log # >/dev/null
if [ $? -eq 0 ]; then
ovpn_init_check=0
ovpn_init_success=1
sleep 5 # give openvpn time to quit
fi
else
grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log >/dev/null
if [ $? -eq 0 ]; then
ovpn_init_check=0
ovpn_init_success=1
fi
fi
ovpn_init_check=$(( $ovpn_init_check - 1 ))
done

opid=`cat $pidfile`
opid=`[ -e $pidfile ] && cat $pidfile`
if [ -n "$opid" ]; then
output " OpenVPN running with PID $opid"
else
if [ -z "$expect_fail" ] # print this only if unexpected
then
echo " Could not read OpenVPN PID file" >&2
output " Could not read OpenVPN PID file"
fi
output " Could not read OpenVPN PID file"
fi

# did we expect a failure?
if [ -n "$expect_fail" ]
then
if [ -n "$opid" ] # OpenVPN did start!
then
echo "$0: OpenVPN did start up, expected failure" >&2
$RUN_SUDO $KILL_EXEC $opid $sudopid
echo "tail -5 $SUF:openvpn.log" >&2
tail -5 $LOGDIR/$SUF:openvpn.log >&2
echo $ECHO_E "\nFAIL. skip rest of sub-tests for test run $SUF.\n" >&2
trap - 0 1 2 3 15
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=32
continue
else
echo $ECHO_E "test run $SUF: all tests OK (saw expected failure).\n"
SUMMARY_OK="$SUMMARY_OK $SUF"
continue
if [ -n "$opid" ] # OpenVPN did start!
then
output "$0: OpenVPN did start up, expected failure"
$RUN_SUDO $KILL_EXEC $opid $sudopid
output "tail -5 $SUF:openvpn.log"
output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
fail "skip rest of sub-tests for test run $SUF."
trap - 0 1 2 3 15
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=32
printf "$outbuf" ; continue
else
output "test run $SUF: all tests OK (saw expected failure)."
SUMMARY_OK="$SUMMARY_OK $SUF"
continue
fi
fi

Expand All @@ -479,7 +461,7 @@ do
trap - 0 1 2 3 15
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=30
echo $ECHO_E "$outbuf" ; continue
printf "$outbuf" ; continue
fi

# make sure openvpn client is terminated in case shell exits
Expand Down Expand Up @@ -542,15 +524,15 @@ do
SUMMARY_OK="$SUMMARY_OK $SUF"
else
if [ "$V" -gt 0 ] ; then
echo $ECHO_E -n "$outbuf"
echo $ECHO_E "test run $SUF: $fail_count test failures. FAIL.\n"
printf "$outbuf"
echo "test run $SUF: $fail_count test failures. FAIL."
fi
SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
exit_code=30
fi

if [ -n "$test_cleanup" ]; then
echo $ECHO_E "cleaning up: '$test_cleanup'"
echo "cleaning up: '$test_cleanup'"
eval $test_cleanup
fi

Expand Down
Loading