Merge "Cleanup test_ip.sh to give more consistent output"

This commit is contained in:
Jenkins 2015-05-28 20:29:48 +00:00 committed by Gerrit Code Review
commit 588ea5b5ab

View File

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