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 10# workaround to disable netns initialization 11RHOST="foo" 12 13. tst_net.sh 14 15IPV4_DATA=" 160 0|10.23.0.0 170 1|10.23.0.1 181 0|10.23.1.0 191 1|10.23.1.1 201 2|10.23.1.2 212 2|10.23.2.2 221 3|10.23.1.3 233 3|10.23.3.3 241 128|10.23.1.128 25128 128|10.23.128.128 261 254|10.23.1.254 27254 254|10.23.254.254 281 255|10.23.1.255 29255 255|10.23.255.255 301 256|10.23.1.0 31256 256|10.23.0.0 321 257|10.23.1.1 33257 257|10.23.1.1 34 35-c 0|10.23.0.2 36-c 0 lhost|10.23.0.2 37-c 0 rhost|10.23.0.1 38 39-c 1|10.23.0.2 40-c 1 rhost|10.23.0.1 41-c 2|10.23.0.4 42-c 2 rhost|10.23.0.3 43-c 127|10.23.0.254 44-c 127 rhost|10.23.0.253 45-c 128|10.23.1.2 46-c 128 rhost|10.23.1.1 47-c 254|10.23.1.254 48-c 254 rhost|10.23.1.253 49-c 255|10.23.2.2 50-c 255 rhost|10.23.2.1 51 52-c 0 -h1,255|10.23.0.2 53-c 0 -h1,255 rhost|10.23.0.1 54-c 1 -h1,255|10.23.0.2 55-c 1 -h1,255 rhost|10.23.0.1 56-c 127 -h1,255|10.23.0.254 57-c 127 -h1,255 rhost|10.23.0.253 58-c 128 -h1,255|10.23.1.1 59-c 128 -h1,255 rhost|10.23.0.255 60-c 255 -h1,255|10.23.1.255 61-c 255 -h1,255 rhost|10.23.1.254 62-c 256 -h1,255|10.23.2.2 63-c 256 -h1,255 rhost|10.23.2.1 64 65-c1 -h 2,8 -n 2,8|10.23.2.3 66-c1 -h 2,8 -n 2,8 rhost|10.23.2.2 67-c2 -h 2,8 -n 2,8|10.23.2.5 68-c2 -h 2,8 -n 2,8 rhost|10.23.2.4 69 70-c1 -n 22,44|10.23.22.2 71-c1 -n 22,44 rhost|10.23.22.1 72-c2 -n 22,44|10.23.22.4 73-c2 -n 22,44 rhost|10.23.22.3 74" 75 76IPV6_DATA=" 770 0|fd00:23:: 780 1|fd00:23::1 791 0|fd00:23:1:: 801 1|fd00:23:1::1 811 2|fd00:23:1::2 822 2|fd00:23:2::2 831 3|fd00:23:1::3 843 3|fd00:23:3::3 851 32767|fd00:23:1::7fff 8632767 32767|fd00:23:7fff::7fff 871 65534|fd00:23:1::fffe 8865534 65534|fd00:23:fffe::fffe 891 65535|fd00:23:1::ffff 9065535 65535|fd00:23:ffff::ffff 911 65536|fd00:23:1:: 9265536 65536|fd00:23:: 931 65537|fd00:23:1::1 9465537 65537|fd00:23:1::1 95 96-c 0|fd00:23::2 97-c 0 lhost|fd00:23::2 98-c 0 rhost|fd00:23::1 99 100-c 1|fd00:23::2 101-c 1 rhost|fd00:23::1 102-c 2|fd00:23::4 103-c 2 rhost|fd00:23::3 104-c 32767|fd00:23::fffe 105-c 32767 rhost|fd00:23::fffd 106-c 32768|fd00:23:1::2 107-c 32768 rhost|fd00:23:1::1 108-c 65534|fd00:23:1::fffe 109-c 65534 rhost|fd00:23:1::fffd 110-c 65535|fd00:23:2::2 111-c 65535 rhost|fd00:23:2::1 112 113-c 0 -h1,65535|fd00:23::2 114-c 0 -h1,65535 rhost|fd00:23::1 115-c 1 -h1,65535|fd00:23::2 116-c 1 -h1,65535 rhost|fd00:23::1 117-c 32767 -h1,65535|fd00:23::fffe 118-c 32767 -h1,65535 rhost|fd00:23::fffd 119-c 32768 -h1,65535|fd00:23:1::1 120-c 32768 -h1,65535 rhost|fd00:23::ffff 121-c 65535 -h1,65535|fd00:23:1::ffff 122-c 65535 -h1,65535 rhost|fd00:23:1::fffe 123-c 65536 -h1,65535|fd00:23:2::2 124-c 65536 -h1,65535 rhost|fd00:23:2::1 125 126-c1 -h 2,8 -n 2,8|fd00:23:2::3 127-c1 -h 2,8 -n 2,8 rhost|fd00:23:2::2 128-c2 -h 2,8 -n 2,8|fd00:23:2::5 129-c2 -h 2,8 -n 2,8 rhost|fd00:23:2::4 130 131-c1 -n 22,44|fd00:23:16::2 132-c1 -n 22,44 rhost|fd00:23:16::1 133-c2 -n 22,44|fd00:23:16::4 134-c2 -n 22,44 rhost|fd00:23:16::3 135" 136 137test_tst_ipaddr_un() 138{ 139 local data cmd i result 140 local var="$1" 141 142 tst_res TINFO "Testing for IPv${TST_IPVER}, data: \$$var" 143 144 eval data="\$$var" 145 IFS=" 146" 147 for i in $data; do 148 cmd="tst_ipaddr_un $(echo $i | cut -d'|' -f 1)" 149 result="$(echo $i | cut -d'|' -f 2)" 150 tst_res TINFO "testing $cmd" 151 EXPECT_PASS "[ '$(eval $cmd)' = '$result' ]" 152 done 153} 154 155do_test2() 156{ 157 test_tst_ipaddr_un "IPV${TST_IPVER}_DATA" 158} 159 160do_test() 161{ 162 case $1 in 163 1) TST_IPV6= TST_IPVER=4 do_test2;; 164 2) TST_IPV6=6 TST_IPVER=6 do_test2;; 165 esac 166} 167 168tst_run 169