diff options
-rw-r--r-- | tests/setlist.t | 2 | ||||
-rwxr-xr-x | tests/setlist_ns.sh | 22 | ||||
-rwxr-xr-x | tests/setlist_resize.sh | 39 |
3 files changed, 55 insertions, 8 deletions
diff --git a/tests/setlist.t b/tests/setlist.t index 316daf8..a2780d7 100644 --- a/tests/setlist.t +++ b/tests/setlist.t @@ -211,4 +211,6 @@ skip which sendip >/dev/null 0 ipset f # Counters and timeout: destroy sets 0 ipset x +# Use namespace and test list:set with comments (takes longer) +0 ./setlist_ns.sh # eof diff --git a/tests/setlist_ns.sh b/tests/setlist_ns.sh new file mode 100755 index 0000000..9e47d65 --- /dev/null +++ b/tests/setlist_ns.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +CMD=$(cat <<EOF +for x in \$(seq 0 127); do + echo "create h\$x hash:ip" + echo "create l\$x list:set timeout 10 comment" +done | ipset restore +for x in \$(seq 0 127); do + for y in \$(seq 0 127); do + echo "add l\$x h\$y timeout 1000 comment \"l\$x h\$y\"" + done +done | ipset restore +# Wait for GC +sleep 15 +EOF +) + +for x in seq 0 123; do + unshare -Urn bash -c "$CMD" +done diff --git a/tests/setlist_resize.sh b/tests/setlist_resize.sh index 848f1d1..1c2be32 100755 --- a/tests/setlist_resize.sh +++ b/tests/setlist_resize.sh @@ -1,19 +1,26 @@ #!/bin/sh +set -e # set -x +# exec > setlist.res +# exec 2>&1 ipset=${IPSET_BIN:-../src/ipset} loop=8 -for x in ip_set_list_set ip_set_hash_netiface ip_set_hash_ipportnet \ - ip_set_hash_netport ip_set_hash_net ip_set_hash_ipportip \ - ip_set_hash_ipport ip_set_hash_ip ip_set_hash_netnet \ - ip_set_hash_netportnet ip_set_hash_ipmark ip_set_hash_mac \ - ip_set_bitmap_port ip_set_bitmap_ipmac \ - ip_set_bitmap_ip xt_set ip_set; do - rmmod $x >/dev/null 2>&1 +n=0 +while [ $n -le 9 ]; do + egrep '^(ip_set_|xt_set)' /proc/modules | while read x y; do + rmmod $x >/dev/null 2>&1 + done + if [ "`egrep '^(ip_set_|xt_set)' /proc/modules`" ]; then + sleep 1s + else + n=10 + fi done +rmmod ip_set >/dev/null 2>&1 create() { n=$1 @@ -30,7 +37,23 @@ for x in `seq 1 $loop`; do wait test `$ipset l -n | wc -l` -eq 1024 || exit 1 $ipset x - test `lsmod|grep -w ^ip_set_hash_ip | awk '{print $3}'` -eq 0 || exit 1 + # Wait for destroy to be finished and reference counts releases + n=0 + ref=0 + while [ $n -le 9 ]; do + ref=`lsmod|grep -w ^ip_set_hash_ip | awk '{print $3}'` + if [ $ref -eq 0 ]; then + n=10; + else + sleep 1s + n=$((n+1)) + fi + done + if [ "$ref" -ne 0 ]; then + lsmod + echo $ref + fi + test "$ref" -eq 0 || exit 1 rmmod ip_set_hash_ip >/dev/null 2>&1 rmmod ip_set >/dev/null 2>&1 done |