]> git.ipfire.org Git - people/ms/network.git/blob - test/functions/ip/ip_detect_protocol
Make "make distcheck" happy and allow builddir != srcdir
[people/ms/network.git] / test / functions / ip / ip_detect_protocol
1 #!/bin/bash
2
3 . ${functions}
4
5 . ${testdir}/constants.sh
6
7 failed=0
8
9 for address in ${VALID_IPv4_ADDRESSES[@]}; do
10 proto=$(ip_detect_protocol ${address})
11 if [[ $? == 0 ]] && [[ "${proto}" == "ipv4" ]]; then
12 echo "OK: Detection of ip protocol for ${address} was successful [${proto}]"
13 else
14 echo "ERROR: Detection of ip protocol for ${address} was not successful"
15 failed=1
16 fi
17 done
18
19 # Here we have to use a extra array because ::1 is an invalid IPv4 address but we can find a protocol for it [ipv6], so ip_detect_protocol is successful
20 INVALID_IPv4_ADDRESSES=(
21 1.2.3.X/abc
22 a.b.c.d/24
23 a.b.c.d/e
24 1.2.3.500
25 )
26
27 for address in ${INVALID_IPv4_ADDRESSES[@]}; do
28 proto=$(ip_detect_protocol ${address})
29 if [[ $? == 1 ]] && [[ "${proto}" != "ipv4" ]]; then
30 echo "OK: Detection of ip protocol for ${address} was not successful"
31 else
32 echo "ERROR: Detection of ip protocol for ${address} was successful [${proto}]"
33 failed=1
34 fi
35 done
36
37 exit ${failed}