t_traceroute.sh revision 1.1 1 # $NetBSD: t_traceroute.sh,v 1.1 2010/12/15 00:13:52 pooka Exp $
2 #
3 # Copyright (c) 2010 The NetBSD Foundation, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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.
14 #
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.
26 #
27
28 atf_test_case basic cleanup
29 basic_head()
30 {
31
32 atf_set "descr" "Does a simple three-hop traceroute"
33 }
34
35 cfgendpt ()
36 {
37
38 sock=${1}
39 addr=${2}
40 route=${3}
41 bus=${4}
42
43 export RUMP_SERVER=${sock}
44 atf-check -s exit:0 rump.ifconfig shmif0 create
45 atf-check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
46 atf-check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00
47 atf-check -s exit:0 -o ignore rump.route add default ${route}
48 }
49
50 threeservers()
51 {
52
53 atf-check -s exit:0 rump_allserver unix://commsock1
54 atf-check -s exit:0 rump_allserver unix://commsock2
55 atf-check -s exit:0 rump_allserver unix://commsock3
56
57 # configure endpoints
58 cfgendpt unix://commsock1 1.2.3.4 1.2.3.1 bus1
59 cfgendpt unix://commsock3 2.3.4.5 2.3.4.1 bus2
60
61 # configure the router
62 export RUMP_SERVER=unix://commsock2
63 atf-check -s exit:0 rump.ifconfig shmif0 create
64 atf-check -s exit:0 rump.ifconfig shmif0 linkstr bus1
65 atf-check -s exit:0 rump.ifconfig shmif0 inet 1.2.3.1 netmask 0xffffff00
66
67 atf-check -s exit:0 rump.ifconfig shmif1 create
68 atf-check -s exit:0 rump.ifconfig shmif1 linkstr bus2
69 atf-check -s exit:0 rump.ifconfig shmif1 inet 2.3.4.1 netmask 0xffffff00
70 }
71
72 threecleanup()
73 {
74 env RUMP_SERVER=unix://commsock1 rump.halt
75 env RUMP_SERVER=unix://commsock2 rump.halt
76 env RUMP_SERVER=unix://commsock3 rump.halt
77 }
78
79 threetests()
80 {
81
82 threeservers
83 env RUMP_SERVER=unix://commsock1 atf-check -s exit:0 \
84 -o save:tmpfile -e ignore rump.traceroute ${1} -n 2.3.4.5
85 atf-check -o inline:'1.2.3.1\n2.3.4.5\n' awk '{print $2}' < tmpfile
86 env RUMP_SERVER=unix://commsock3 atf-check -s exit:0 \
87 -o save:tmpfile -e ignore rump.traceroute ${1} -n 1.2.3.4
88 atf-check -o inline:'2.3.4.1\n1.2.3.4\n' awk '{print $2}' < tmpfile
89 }
90
91 basic_body()
92 {
93 threetests
94 }
95
96 basic_cleanup()
97 {
98 threecleanup
99 }
100
101 atf_test_case basic_icmp cleanup
102 basic_icmp_head()
103 {
104
105 atf_set "descr" "Does an ICMP-based three-hop traceroute"
106 }
107
108 basic_icmp_body()
109 {
110 threetests -I
111 }
112
113 basic_icmp_cleanup()
114 {
115 threecleanup
116 }
117
118 atf_init_test_cases()
119 {
120
121 atf_add_test_case basic
122 atf_add_test_case basic_icmp
123 }
124