Module Name: src Committed By: ozaki-r Date: Thu Nov 24 11:54:57 UTC 2016
Modified Files: src/tests/net: net_common.sh src/tests/net/net: t_forwarding.sh t_mtudisc.sh t_mtudisc6.sh Log Message: Share httpd start/stop code To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/net/net_common.sh cvs rdiff -u -r1.16 -r1.17 src/tests/net/net/t_forwarding.sh cvs rdiff -u -r1.5 -r1.6 src/tests/net/net/t_mtudisc.sh cvs rdiff -u -r1.3 -r1.4 src/tests/net/net/t_mtudisc6.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/net/net_common.sh diff -u src/tests/net/net_common.sh:1.5 src/tests/net/net_common.sh:1.6 --- src/tests/net/net_common.sh:1.5 Thu Nov 24 09:07:09 2016 +++ src/tests/net/net_common.sh Thu Nov 24 11:54:57 2016 @@ -1,4 +1,4 @@ -# $NetBSD: net_common.sh,v 1.5 2016/11/24 09:07:09 ozaki-r Exp $ +# $NetBSD: net_common.sh,v 1.6 2016/11/24 11:54:57 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -103,3 +103,31 @@ get_macaddr() env RUMP_SERVER=${1} \ rump.ifconfig ${2} |awk '/address/ {print $2;}' } + +HTTPD_PID=./.__httpd.pid +start_httpd() +{ + local sock=$1 + local ip=$2 + local backup=$RUMP_SERVER + + export RUMP_SERVER=$sock + + # start httpd in daemon mode + atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ + /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) + + export RUMP_SERVER=$backup + + sleep 3 +} + +stop_httpd() +{ + + if [ -f $HTTPD_PID ]; then + kill -9 $(cat $HTTPD_PID) + rm -f $HTTPD_PID + sleep 1 + fi +} Index: src/tests/net/net/t_forwarding.sh diff -u src/tests/net/net/t_forwarding.sh:1.16 src/tests/net/net/t_forwarding.sh:1.17 --- src/tests/net/net/t_forwarding.sh:1.16 Mon Nov 7 05:25:37 2016 +++ src/tests/net/net/t_forwarding.sh Thu Nov 24 11:54:57 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_forwarding.sh,v 1.16 2016/11/07 05:25:37 ozaki-r Exp $ +# $NetBSD: t_forwarding.sh,v 1.17 2016/11/24 11:54:57 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -40,7 +40,6 @@ IP6SRC=fc00:0:0:1::2 IP6SRCGW=fc00:0:0:1::1 IP6DSTGW=fc00:0:0:2::1 IP6DST=fc00:0:0:2::2 -HTTPD_PID=httpd.pid HTML_FILE=index.html DEBUG=${DEBUG:-false} @@ -166,20 +165,6 @@ setup6() setup_forwarder ipv6 } -setup_bozo() -{ - local ip=$1 - - export RUMP_SERVER=$SOCKDST - - touch $HTML_FILE - # start bozo in daemon mode - atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ - /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) - - $DEBUG && rump.netstat -a -} - test_http_get() { local ip=$1 @@ -314,16 +299,6 @@ cleanup() env RUMP_SERVER=$SOCKDST rump.halt } -cleanup_bozo() -{ - - if [ -f $HTTPD_PID ]; then - kill -9 "$(cat $HTTPD_PID)" - rm -f $HTTPD_PID - fi - rm -f $HTML_FILE -} - dump() { env RUMP_SERVER=$SOCKSRC rump.netstat -nr @@ -481,7 +456,10 @@ ipforwarding_fastforward_v4_body() setup_forwarding test_setup_forwarding - setup_bozo $IP4DST + touch $HTML_FILE + start_httpd $SOCKDST $IP4DST + $DEBUG && rump.netstat -a + test_http_get $IP4DST teardown_interfaces @@ -495,7 +473,10 @@ ipforwarding_fastforward_v6_body() setup_forwarding6 test_setup_forwarding6 - setup_bozo $IP6DST + touch $HTML_FILE + start_httpd $SOCKDST $IP6DST + $DEBUG && rump.netstat -a + test_http_get "[$IP6DST]" teardown_interfaces @@ -513,7 +494,10 @@ ipforwarding_misc_body() test_directed_broadcast - setup_bozo $IP4DST + touch $HTML_FILE + start_httpd $SOCKDST $IP4DST + $DEBUG && rump.netstat -a + test_sysctl_ttl $IP4DST teardown_interfaces @@ -535,21 +519,21 @@ ipforwarding_v6_cleanup() ipforwarding_fastforward_v4_cleanup() { dump - cleanup_bozo + stop_httpd cleanup } ipforwarding_fastforward_v6_cleanup() { dump - cleanup_bozo + stop_httpd cleanup } ipforwarding_misc_cleanup() { dump - cleanup_bozo + stop_httpd cleanup } Index: src/tests/net/net/t_mtudisc.sh diff -u src/tests/net/net/t_mtudisc.sh:1.5 src/tests/net/net/t_mtudisc.sh:1.6 --- src/tests/net/net/t_mtudisc.sh:1.5 Thu Nov 24 09:03:53 2016 +++ src/tests/net/net/t_mtudisc.sh Thu Nov 24 11:54:57 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_mtudisc.sh,v 1.5 2016/11/24 09:03:53 ozaki-r Exp $ +# $NetBSD: t_mtudisc.sh,v 1.6 2016/11/24 11:54:57 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -32,7 +32,6 @@ inetserver="$inetserver -lrumpdev" SOCKLOCAL=unix://commsock1 SOCKGATEWAY=unix://commsock2 SOCKREMOTE=unix://commsock3 -HTTPD_PID=httpd.pid HTML_FILE=index.html DEBUG=${DEBUG:-false} @@ -63,27 +62,16 @@ setup_server() $DEBUG && rump.ifconfig $if } -setup_httpd() +prepare_download_file() { - local sock=$1 - local ip=$2 + local file=$1 local data="0123456789" - export RUMP_SERVER=$sock - - touch $HTML_FILE + touch $file for i in `seq 1 512` do - echo $data >> $HTML_FILE + echo $data >> $file done - - # start httpd in daemon mode - atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ - /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) - - $DEBUG && rump.netstat -a - - sleep 5 } do_http_get() @@ -141,7 +129,9 @@ mtudisc_basic_body() atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet.ip.mtudisc # Start httpd daemon - setup_httpd $SOCKREMOTE $remote_ip + prepare_download_file $HTML_FILE + start_httpd $SOCKREMOTE $remote_ip + $DEBUG && rump.netstat -a # Teach the peer thar 10.0.0.2(local serer) is behind 10.0.1.1(gateway server) atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip @@ -224,7 +214,7 @@ dump() mtudisc_basic_cleanup() { $DEBUG && dump - kill "$(cat ${HTTPD_PID})" + stop_httpd env RUMP_SERVER=$SOCKLOCAL rump.halt env RUMP_SERVER=$SOCKGATEWAY rump.halt env RUMP_SERVER=$SOCKREMOTE rump.halt Index: src/tests/net/net/t_mtudisc6.sh diff -u src/tests/net/net/t_mtudisc6.sh:1.3 src/tests/net/net/t_mtudisc6.sh:1.4 --- src/tests/net/net/t_mtudisc6.sh:1.3 Thu Nov 24 09:03:53 2016 +++ src/tests/net/net/t_mtudisc6.sh Thu Nov 24 11:54:57 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_mtudisc6.sh,v 1.3 2016/11/24 09:03:53 ozaki-r Exp $ +# $NetBSD: t_mtudisc6.sh,v 1.4 2016/11/24 11:54:57 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -32,7 +32,6 @@ inetserver="$inetserver -lrumpdev" SOCKLOCAL=unix://commsock1 SOCKGATEWAY=unix://commsock2 SOCKREMOTE=unix://commsock3 -HTTPD_PID=httpd.pid HTML_FILE=index.html DEBUG=${DEBUG:-false} @@ -64,27 +63,16 @@ setup_server() $DEBUG && rump.ifconfig $if } -setup_httpd() +prepare_download_file() { - local sock=$1 - local ip=$2 + local file=$1 local data="0123456789" - export RUMP_SERVER=$sock - - touch $HTML_FILE + touch $file for i in `seq 1 512` do - echo $data >> $HTML_FILE + echo $data >> $file done - - # start httpd in daemon mode - atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ - /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) - - $DEBUG && rump.netstat -a - - sleep 5 } do_http_get() @@ -139,7 +127,9 @@ mtudisc6_basic_body() export RUMP_SERVER=$SOCKREMOTE # Start httpd daemon - setup_httpd $SOCKREMOTE $remote_ip + prepare_download_file $HTML_FILE + start_httpd $SOCKREMOTE $remote_ip + $DEBUG && rump.netstat -a # Teach the peer that local serer is behind gateway server atf_check -s exit:0 -o ignore \ @@ -202,7 +192,7 @@ mtudisc6_basic_cleanup() { $DEBUG && dump - kill "$(cat ${HTTPD_PID})" + stop_httpd env RUMP_SERVER=$SOCKLOCAL rump.halt env RUMP_SERVER=$SOCKGATEWAY rump.halt env RUMP_SERVER=$SOCKREMOTE rump.halt