• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
4
5TST_TESTFUNC=do_test
6TST_CNT=2
7
8PATH="$(dirname $0)/../../../../testcases/lib/:$PATH"
9
10TST_NET_SKIP_VARIABLE_INIT=1
11
12# from tst_net_vars.c
13IPV4_NET16_UNUSED="10.23"
14IPV6_NET32_UNUSED="fd00:23"
15
16. tst_net.sh
17
18IPV4_DATA="
190 0|10.23.0.0
200 1|10.23.0.1
211 0|10.23.1.0
221 1|10.23.1.1
231 2|10.23.1.2
242 2|10.23.2.2
251 3|10.23.1.3
263 3|10.23.3.3
271 128|10.23.1.128
28128 128|10.23.128.128
291 254|10.23.1.254
30254 254|10.23.254.254
311 255|10.23.1.255
32255 255|10.23.255.255
331 256|10.23.1.0
34256 256|10.23.0.0
351 257|10.23.1.1
36257 257|10.23.1.1
37
38-c 0|10.23.0.2
39-c 0 lhost|10.23.0.2
40-c 0 rhost|10.23.0.1
41
42-c 1|10.23.0.2
43-c 1 rhost|10.23.0.1
44-c 2|10.23.0.4
45-c 2 rhost|10.23.0.3
46-c 127|10.23.0.254
47-c 127 rhost|10.23.0.253
48-c 128|10.23.1.2
49-c 128 rhost|10.23.1.1
50-c 254|10.23.1.254
51-c 254 rhost|10.23.1.253
52-c 255|10.23.2.2
53-c 255 rhost|10.23.2.1
54
55-c 0 -h1,255|10.23.0.2
56-c 0 -h1,255 rhost|10.23.0.1
57-c 1 -h1,255|10.23.0.2
58-c 1 -h1,255 rhost|10.23.0.1
59-c 127 -h1,255|10.23.0.254
60-c 127 -h1,255 rhost|10.23.0.253
61-c 128 -h1,255|10.23.1.1
62-c 128 -h1,255 rhost|10.23.0.255
63-c 255 -h1,255|10.23.1.255
64-c 255 -h1,255 rhost|10.23.1.254
65-c 256 -h1,255|10.23.2.2
66-c 256 -h1,255 rhost|10.23.2.1
67
68-c1 -h 2,8 -n 2,8|10.23.2.3
69-c1 -h 2,8 -n 2,8 rhost|10.23.2.2
70-c2 -h 2,8 -n 2,8|10.23.2.5
71-c2 -h 2,8 -n 2,8 rhost|10.23.2.4
72
73-c1 -n 22,44|10.23.22.2
74-c1 -n 22,44 rhost|10.23.22.1
75-c2 -n 22,44|10.23.22.4
76-c2 -n 22,44 rhost|10.23.22.3
77"
78
79IPV6_DATA="
800 0|fd00:23::
810 1|fd00:23::1
821 0|fd00:23:1::
831 1|fd00:23:1::1
841 2|fd00:23:1::2
852 2|fd00:23:2::2
861 3|fd00:23:1::3
873 3|fd00:23:3::3
881 32767|fd00:23:1::7fff
8932767 32767|fd00:23:7fff::7fff
901 65534|fd00:23:1::fffe
9165534 65534|fd00:23:fffe::fffe
921 65535|fd00:23:1::ffff
9365535 65535|fd00:23:ffff::ffff
941 65536|fd00:23:1::
9565536 65536|fd00:23::
961 65537|fd00:23:1::1
9765537 65537|fd00:23:1::1
98
99-c 0|fd00:23::2
100-c 0 lhost|fd00:23::2
101-c 0 rhost|fd00:23::1
102
103-c 1|fd00:23::2
104-c 1 rhost|fd00:23::1
105-c 2|fd00:23::4
106-c 2 rhost|fd00:23::3
107-c 32767|fd00:23::fffe
108-c 32767 rhost|fd00:23::fffd
109-c 32768|fd00:23:1::2
110-c 32768 rhost|fd00:23:1::1
111-c 65534|fd00:23:1::fffe
112-c 65534 rhost|fd00:23:1::fffd
113-c 65535|fd00:23:2::2
114-c 65535 rhost|fd00:23:2::1
115
116-c 0 -h1,65535|fd00:23::2
117-c 0 -h1,65535 rhost|fd00:23::1
118-c 1 -h1,65535|fd00:23::2
119-c 1 -h1,65535 rhost|fd00:23::1
120-c 32767 -h1,65535|fd00:23::fffe
121-c 32767 -h1,65535 rhost|fd00:23::fffd
122-c 32768 -h1,65535|fd00:23:1::1
123-c 32768 -h1,65535 rhost|fd00:23::ffff
124-c 65535 -h1,65535|fd00:23:1::ffff
125-c 65535 -h1,65535 rhost|fd00:23:1::fffe
126-c 65536 -h1,65535|fd00:23:2::2
127-c 65536 -h1,65535 rhost|fd00:23:2::1
128
129-c1 -h 2,8 -n 2,8|fd00:23:2::3
130-c1 -h 2,8 -n 2,8 rhost|fd00:23:2::2
131-c2 -h 2,8 -n 2,8|fd00:23:2::5
132-c2 -h 2,8 -n 2,8 rhost|fd00:23:2::4
133
134-c1 -n 22,44|fd00:23:16::2
135-c1 -n 22,44 rhost|fd00:23:16::1
136-c2 -n 22,44|fd00:23:16::4
137-c2 -n 22,44 rhost|fd00:23:16::3
138"
139
140test_tst_ipaddr_un()
141{
142	local data cmd i result
143	local var="$1"
144
145	tst_res TINFO "Testing for IPv${TST_IPVER}, data: \$$var"
146
147	eval data="\$$var"
148	IFS="
149"
150	for i in $data; do
151		cmd="tst_ipaddr_un $(echo $i | cut -d'|' -f 1)"
152		result="$(echo $i | cut -d'|' -f 2)"
153		tst_res TINFO "testing $cmd"
154		EXPECT_PASS "[ '$(eval $cmd)' = '$result' ]"
155	done
156}
157
158do_test2()
159{
160	test_tst_ipaddr_un "IPV${TST_IPVER}_DATA"
161}
162
163do_test()
164{
165	case $1 in
166	 1) TST_IPV6= TST_IPVER=4 do_test2;;
167	 2) TST_IPV6=6 TST_IPVER=6 do_test2;;
168	esac
169}
170
171tst_run
172