From: Samuli Seppänen Date: Mon, 3 Oct 2016 10:51:27 +0000 (+0300) Subject: Automatically cache expected IPs for t_client.sh on the first run X-Git-Tag: v2.4_alpha1~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df0b00c25;p=thirdparty%2Fopenvpn.git Automatically cache expected IPs for t_client.sh on the first run Previously one had to manually define correct values for the EXPECT_IFCONFIG* variables based on what IPv4 and IPv6 addresses the test VPN server handed out. This was a tedious process especially with large number of tests, as the IPs changed for every test client and for every test. With this patch t_client.sh figures out the correct IP addresses using an --up script and caches them to a separate file for later use. Signed-off-by: Samuli Seppänen Acked-by: Arne Schwabe Message-Id: <1475491887-740-1-git-send-email-samuli@openvpn.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12587.html Signed-off-by: Gert Doering --- diff --git a/.gitignore b/.gitignore index 0eea06e01..fc1e223ae 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ distro/rpm/openvpn.spec tests/t_client.sh tests/t_client-*-20??????-??????/ t_client.rc +t_client_ips.rc src/openvpn/openvpn include/openvpn-plugin.h diff --git a/tests/t_client.rc-sample b/tests/t_client.rc-sample index 6e6660774..fb2abfae2 100644 --- a/tests/t_client.rc-sample +++ b/tests/t_client.rc-sample @@ -11,6 +11,14 @@ top_srcdir="${top_srcdir:-..}" CA_CERT="${top_srcdir}/sample/sample-keys/ca.crt" CLIENT_KEY="${top_srcdir}/sample/sample-keys/client.key" CLIENT_CERT="${top_srcdir}/sample/sample-keys/client.crt" + +# Load EXPECT_IFCONFIG* parameters from cache +if [ -r "${top_srcdir}/t_client_ips.rc" ]; then + . "${top_srcdir}/t_client_ips.rc" +else + echo "NOTICE: missing t_client_ips.rc will be auto-generated" +fi + # # remote host (used as macro below) # @@ -58,8 +66,6 @@ OPENVPN_BASE_P2P="..." # RUN_TITLE_1="testing tun/udp/ipv4+ipv6" OPENVPN_CONF_1="$OPENVPN_BASE_P2MP --dev tun --proto udp --remote $REMOTE --port 51194" -EXPECT_IFCONFIG4_1="10.100.50.6" -EXPECT_IFCONFIG6_1="2001:db8:a050::1:0" PING4_HOSTS_1="10.100.50.1 10.100.0.1" PING6_HOSTS_1="2001:db8::1 2001:db8:a050::1" @@ -67,8 +73,6 @@ PING6_HOSTS_1="2001:db8::1 2001:db8:a050::1" # RUN_TITLE_2="testing tun/tcp/ipv4+ipv6" OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" -EXPECT_IFCONFIG4_2="10.100.51.6" -EXPECT_IFCONFIG6_2="2001:db8:a051::1:0" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in index 2b9bacf58..d1c5d8737 100755 --- a/tests/t_client.sh.in +++ b/tests/t_client.sh.in @@ -271,6 +271,12 @@ do eval ping4_hosts=\"\$PING4_HOSTS_$SUF\" eval ping6_hosts=\"\$PING6_HOSTS_$SUF\" + # If EXCEPT_IFCONFIG* variables for this test are missing, run an --up + # script to generate them dynamically. + if [ -z "$expect_ifconfig4" ] || [ -z "$expect_ifconfig6" ]; then + up="--setenv TESTNUM $SUF --setenv TOP_BUILDDIR ${top_builddir} --script-security 2 --up ${top_builddir}/tests/update_t_client_ips.sh" + fi + echo -e "\n### test run $SUF: '$test_run_title' ###\n" fail_count=0 @@ -294,7 +300,7 @@ do fi pidfile="${top_builddir}/tests/$LOGDIR/openvpn-$SUF.pid" - openvpn_conf="$openvpn_conf --writepid $pidfile" + openvpn_conf="$openvpn_conf --writepid $pidfile $up" echo " run openvpn $openvpn_conf" echo "# src/openvpn/openvpn $openvpn_conf" >$LOGDIR/$SUF:openvpn.log umask 022 diff --git a/tests/update_t_client_ips.sh b/tests/update_t_client_ips.sh new file mode 100755 index 000000000..e7b58ba2a --- /dev/null +++ b/tests/update_t_client_ips.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +# This --up script caches the IPs handed out by the test VPN server to a file +# for later use. + +echo "EXPECT_IFCONFIG4_$TESTNUM=$ifconfig_local" >> $TOP_BUILDDIR/t_client_ips.rc +echo "EXPECT_IFCONFIG6_$TESTNUM=$ifconfig_ipv6_local" >> $TOP_BUILDDIR/t_client_ips.rc