diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2012-09-22 18:10:43 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2012-09-22 18:10:43 +0200 |
commit | 05391af5055b8886866d1002269f808ac0844f1f (patch) | |
tree | 3ff2f6c848e2c6144fd6e5f5ee088ed2796d1bec /tests | |
parent | 74a3033ab9cd5235409ac38a45014951eccb02f0 (diff) |
Add simple test to check cidr book-keeping
Diffstat (limited to 'tests')
-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 |