1 # $NetBSD: t_pppoe.sh,v 1.2 2016/08/07 23:34:31 pgoyette Exp $
3 # Copyright (c) 2016 Internet Initiative Japan Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 server="rump_server -lrump -lrumpnet -lrumpnet_net -lrumpnet_netinet \
29 -lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev \
31 HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so"
33 SERVER=unix://commsock1
34 CLIENT=unix://commsock2
38 AUTHNAME=foobar@baz.com
45 atf_test_case pap cleanup
49 atf_check -s exit:0 ${server} $SERVER
50 atf_check -s exit:0 ${server} $CLIENT
52 export RUMP_SERVER=$SERVER
53 atf_check -s exit:0 rump.ifconfig shmif0 create
54 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
55 atf_check -s exit:0 rump.ifconfig shmif0 up
57 atf_check -s exit:0 rump.ifconfig pppoe0 create
58 atf_check -s exit:0 rump.ifconfig pppoe0 inet $SERVER_IP $CLIENT_IP down
59 atf_check -s exit:0 rump.ifconfig pppoe0 link0
61 $DEBUG && rump.ifconfig
62 $DEBUG && $HIJACKING pppoectl -d pppoe0
64 atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
67 export RUMP_SERVER=$CLIENT
68 atf_check -s exit:0 rump.ifconfig shmif0 create
69 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
70 atf_check -s exit:0 rump.ifconfig shmif0 up
72 atf_check -s exit:0 rump.ifconfig pppoe0 create
73 atf_check -s exit:0 rump.ifconfig pppoe0 inet 0.0.0.0 0.0.0.1 down
75 atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
80 env RUMP_SERVER=$SERVER rump.halt
81 env RUMP_SERVER=$CLIENT rump.halt
86 atf_set "descr" "Does simple pap tests"
87 atf_set "require.progs" "rump_server pppoectl"
90 wait_for_session_established()
95 for i in $(seq $n); do
96 $HIJACKING pppoectl -d pppoe0 |grep -q "state = session"
101 if [ $dontfail != "dontfail" ]; then
102 atf_fail "Couldn't connect to the server for $n seconds."
111 export RUMP_SERVER=$SERVER
112 local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
113 'hisauthname=$AUTHNAME' \
114 'hisauthsecret=$SECRET' \
116 atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
117 atf_check -s exit:0 rump.ifconfig pppoe0 up
120 export RUMP_SERVER=$CLIENT
121 local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
122 'myauthname=$AUTHNAME' \
123 'myauthsecret=$SECRET' \
125 atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
126 atf_check -s exit:0 rump.ifconfig pppoe0 up
127 $DEBUG && rump.ifconfig
128 wait_for_session_established
129 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
132 # test for disconnection from server
133 atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 down"
134 export RUMP_SERVER=$CLIENT
135 atf_check -s not-exit:0 -o ignore -e ignore \
136 rump.ping -c 1 -w $TIMEOUT $SERVER_IP
137 atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0"
140 # test for recoonecting
141 atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 up"
142 export RUMP_SERVER=$CLIENT
143 wait_for_session_established
144 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP
147 # test for disconnection from client
148 atf_check -s exit:0 -x "env RUMP_SERVER=$CLIENT rump.ifconfig pppoe0 down"
149 export RUMP_SERVER=$SERVER
150 $DEBUG && $HIJACKING pppoectl -d pppoe0
151 atf_check -s not-exit:0 -o ignore -e ignore \
152 rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
153 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
156 # test for recconecting
157 export RUMP_SERVER=$CLIENT
158 atf_check -s exit:0 -x rump.ifconfig pppoe0 up
159 wait_for_session_established
160 $DEBUG && rump.ifconfig pppoe0
161 $DEBUG && $HIJACKING pppoectl -d pppoe0
164 export RUMP_SERVER=$SERVER
165 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
166 atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
167 $DEBUG && HIJACKING pppoectl -d pppoe0
170 # test for invalid password
171 export RUMP_SERVER=$CLIENT
172 atf_check -s exit:0 rump.ifconfig pppoe0 down
173 local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
174 'myauthname=$AUTHNAME' \
175 'myauthsecret=invalidsecret' \
177 atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
178 atf_check -s exit:0 rump.ifconfig pppoe0 up
179 wait_for_session_established dontfail
180 atf_check -s not-exit:0 -o ignore -e ignore \
181 rump.ping -c 1 -w $TIMEOUT $SERVER_IP
182 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
190 atf_init_test_cases()
192 atf_add_test_case pap