Cleanup test_ip.sh to give more consistent output

Minor changes to give more consistent output; no functional changes to
tests.

Change-Id: I6c4ef74587c59b786761735c7bd528f3d7f94905
This commit is contained in:
Ian Wienand 2015-05-25 11:50:32 +10:00
parent d986c59d6b
commit dd363a182f

View File

@ -48,60 +48,44 @@ function test_cidr2netmask {
test_cidr2netmask
if [[ $(maskip 169.254.169.254 240.0.0.0) == 160.0.0.0 ]]; then
passed "maskip(): /4...OK"
else
failed "maskip(): /4...failed"
fi
if [[ $(maskip 169.254.169.254 255.0.0.0) == 169.0.0.0 ]]; then
passed "maskip(): /8...OK"
else
failed "maskip(): /8...failed"
fi
if [[ $(maskip 169.254.169.254 255.240.0.0) == 169.240.0.0 ]]; then
passed "maskip(): /12...OK"
else
failed "maskip(): /12...failed"
fi
if [[ $(maskip 169.254.169.254 255.255.0.0) == 169.254.0.0 ]]; then
passed "maskip(): /16...OK"
else
failed "maskip(): /16...failed"
fi
if [[ $(maskip 169.254.169.254 255.255.240.0) == 169.254.160.0 ]]; then
passed "maskip(): /20...OK"
else
failed "maskip(): /20...failed"
fi
if [[ $(maskip 169.254.169.254 255.255.255.0) == 169.254.169.0 ]]; then
passed "maskip(): /24...OK"
else
failed "maskip(): /24...failed"
fi
if [[ $(maskip 169.254.169.254 255.255.255.240) == 169.254.169.240 ]]; then
passed "maskip(): /28...OK"
else
failed "maskip(): /28...failed"
fi
if [[ $(maskip 169.254.169.254 255.255.255.255) == 169.254.169.254 ]]; then
passed "maskip(): /32...OK"
else
failed "maskip(): /32...failed"
fi
msg="maskip(169.254.169.254 240.0.0.0) == 160.0.0.0"
assert_equal $(maskip 169.254.169.254 240.0.0.0) 160.0.0.0 "$msg"
msg="maskip(169.254.169.254 255.0.0.0) == 169.0.0.0"
assert_equal $(maskip 169.254.169.254 255.0.0.0) 169.0.0.0 "$msg"
msg="maskip(169.254.169.254 255.240.0.0) == 169.240.0.0"
assert_equal $(maskip 169.254.169.254 255.240.0.0) 169.240.0.0 "$msg"
msg="maskip(169.254.169.254 255.255.0.0) == 169.254.0.0"
assert_equal $(maskip 169.254.169.254 255.255.0.0) 169.254.0.0 "$msg"
msg="maskip(169.254.169.254 255.255.240.0) == 169.254.160.0"
assert_equal $(maskip 169.254.169.254 255.255.240.0) 169.254.160.0 "$msg"
msg="maskip(169.254.169.254 255.255.255.0) == 169.254.169.0"
assert_equal $(maskip 169.254.169.254 255.255.255.0) 169.254.169.0 "$msg"
msg="maskip(169.254.169.254 255.255.255.240) == 169.254.169.240"
assert_equal $(maskip 169.254.169.254 255.255.255.240) 169.254.169.240 "$msg"
msg="maskip(169.254.169.254 255.255.255.255) == 169.254.169.254"
assert_equal $(maskip 169.254.169.254 255.255.255.255) 169.254.169.254 "$msg"
for mask in 8 12 16 20 24 26 28; do
echo -n "address_in_net(): in /$mask..."
msg="address_in_net($10.10.10.1 10.10.10.0/$mask)"
if address_in_net 10.10.10.1 10.10.10.0/$mask; then
passed "OK"
passed "$msg"
else
failed "address_in_net() failed on /$mask"
failed "$msg"
fi
echo -n "address_in_net(): not in /$mask..."
msg="! address_in_net($10.10.10.1 11.11.11.0/$mask)"
if ! address_in_net 10.10.10.1 11.11.11.0/$mask; then
passed "OK"
passed "$msg"
else
failed "address_in_net() failed on /$mask"
failed "$msg"
fi
done