From: Jozsef Kadlecsik Date: Sat, 22 Sep 2012 16:10:43 +0000 (+0200) Subject: Add simple test to check cidr book-keeping X-Git-Tag: v6.15~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05391af5055b8886866d1002269f808ac0844f1f;p=thirdparty%2Fipset.git Add simple test to check cidr book-keeping --- diff --git a/tests/check_cidrs.sh b/tests/check_cidrs.sh new file mode 100644 index 00000000..ee89e379 --- /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 14eed430..78efe3df 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