]> git.ipfire.org Git - people/ms/network.git/blob - test/functions/ip/ip_split_prefix
b8da3d4341393a354ff66ed989d40fe6e8d5c0ed
[people/ms/network.git] / test / functions / ip / ip_split_prefix
1 #!/bin/bash
2
3 . ${networkdir}/functions
4
5 . ${testdir}/constants.sh
6
7 failed=0
8
9
10 SPLIT_PREFIX_TEST_VALID_NETWORKS=(
11 127.0.0.1/32
12 192.168.106.0/23
13 2001:470:1f09:1249::/64
14 2001:470:6ef3::/48
15 127.0.0.1
16 )
17
18 SPLIT_PREFIX_TEST_VALID_ADRESSES=(
19 127.0.0.1
20 192.168.106.0
21 2001:470:1f09:1249::
22 2001:470:6ef3::
23 127.0.0.1
24 )
25
26 i=0
27
28 for network in ${SPLIT_PREFIX_TEST_VALID_NETWORKS[@]}; do
29 address=$(ip_split_prefix ${network})
30 if [[ $? == 0 ]] && [[ "${address}" == "${SPLIT_PREFIX_TEST_VALID_ADRESSES[$i]}" ]]; then
31 echo "OK: Split prefix of network ${network} was successful [${address}]"
32 else
33 echo "ERROR: Split prefix of network ${network} was not successful [${address}]"
34 failed=1
35 fi
36 i=$(( i+1 ))
37 done
38
39 exit ${failed}