diff options
-rw-r--r-- | tests/check_cidrs.sh | 23 | ||||
-rw-r--r-- | tests/hash:net.t | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/check_cidrs.sh b/tests/check_cidrs.sh new file mode 100644 index 0000000..ee89e37 --- /dev/null +++ b/tests/check_cidrs.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +cmd=../src/ipset + +$cmd f +$cmd x +$cmd n test hash:net +for x in `seq 1 32`; do + $cmd a test 10.0.0.0/$x + n=`$cmd l test | wc -l` + n=$((n - 7)) + test $n -eq $x || exit 1 +done +for x in `seq 32 -1 1`; do + $cmd d test 10.0.0.0/$x + n=`$cmd l test | wc -l` + # We deleted one element + n=$((n - 7 + 1)) + test $n -eq $x || exit 1 +done +$cmd x test diff --git a/tests/hash:net.t b/tests/hash:net.t index 14eed43..78efe3d 100644 --- a/tests/hash:net.t +++ b/tests/hash:net.t @@ -100,4 +100,6 @@ 0 ipset -T test 1.1.1.3 # Delete test set 0 ipset destroy test +# Check CIDR book-keeping +0 ./check_cidrs.sh # eof |