ipset: Pass IPSET_BIN to test scripts to change binary location
PATCH 1/1 ipset: Pass IPSET_BIN to test scripts to change binary location
In the "as-installed" package testing situation, the test scripts should invokes the system installed "ipset" binary.
Therefore, the IPSET_BIN could be passed to change the binary location.
IPSET_BIN=/sbin/ipset ./runtest.sh
The test scripts run fine in build source tree without IPSET_BIN.
--- tests/check_cidrs.sh | 18 +++++++++--------- tests/check_counters | 4 +++- tests/check_extensions | 4 +++- tests/check_sendip_packets | 0 tests/iptables.sh | 40 +++++++++++++++++++++------------------- tests/resize.sh | 8 +++++--- tests/resizec.sh | 2 +- tests/resizen.sh | 2 +- tests/resizet.sh | 2 +- tests/runtest.sh | 8 +++++--- tests/setlist_resize.sh | 8 +++++--- 11 files changed, 54 insertions(+), 42 deletions(-) mode change 100644 => 100755 tests/check_counters mode change 100644 => 100755 tests/check_extensions mode change 100644 => 100755 tests/check_sendip_packets mode change 100644 => 100755 tests/resizec.sh mode change 100644 => 100755 tests/resizen.sh mode change 100644 => 100755 tests/resizet.sh
tests/check_cidrs.sh +9 -9
@@ -2,22 +2,22 @@ set -e -cmd=../src/ipset +ipset=${IPSET_BIN:-../src/ipset} -$cmd f -$cmd x -$cmd n test hash:net +$ipset f +$ipset x +$ipset 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` + $ipset a test 10.0.0.0/$x + n=`$ipset 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` + $ipset d test 10.0.0.0/$x + n=`$ipset l test | wc -l` # We deleted one element n=$((n - 7 + 1)) test $n -eq $x || exit 1 done -$cmd x test +$ipset x test
tests/check_counters +3 -1
@@ -1,6 +1,8 @@ #!/bin/bash -read ip p packets b bytes <<< $(../src/ipset l $1 | grep ^$2) +ipset=${IPSET_BIN:-../src/ipset} + +read ip p packets b bytes <<< $($ipset l $1 | grep ^$2) test -z "$packets" -o -z "$bytes" && exit 1 test $packets -ne $3 -o $bytes -ne $4 && exit 1 exit 0
tests/check_extensions +3 -1
@@ -1,6 +1,8 @@ #!/bin/bash -read ip t timeout p packets b bytes <<< $(../src/ipset l $1 | grep ^$2) +ipset=${IPSET_BIN:-../src/ipset} + +read ip t timeout p packets b bytes <<< $($ipset l $1 | grep ^$2) test -z "$timeout" -o -z "$packets" -o -z "$bytes" && exit 1 test $timeout -gt $3 -o $timeout -lt $(($3 - 10)) && exit 1 test $packets -ne $4 -o $bytes -ne $5 && exit 1
tests/check_sendip_packets +0 -0
tests/iptables.sh +21 -19
@@ -3,6 +3,8 @@ # set -x set -e +ipset=${IPSET_BIN:-../src/ipset} + # We play with the following networks: # inet: 10.255.255.0/24 # 10.255.255.0-31 in ip1
@@ -37,14 +39,14 @@ esac case "$2" in start) - ../src/ipset n ip1 hash:ip $family 2>/dev/null - ../src/ipset a ip1 $IP1 2>/dev/null - ../src/ipset n ip2 hash:ip $family 2>/dev/null - ../src/ipset a ip2 $IP2 2>/dev/null - ../src/ipset n ipport hash:ip,port $family 2>/dev/null - ../src/ipset n list list:set 2>/dev/null - ../src/ipset a list ipport 2>/dev/null - ../src/ipset a list ip1 2>/dev/null + $ipset n ip1 hash:ip $family 2>/dev/null + $ipset a ip1 $IP1 2>/dev/null + $ipset n ip2 hash:ip $family 2>/dev/null + $ipset a ip2 $IP2 2>/dev/null + $ipset n ipport hash:ip,port $family 2>/dev/null + $ipset n list list:set 2>/dev/null + $ipset a list ipport 2>/dev/null + $ipset a list ip1 2>/dev/null $cmd -A INPUT ! -s $NET -j ACCEPT $cmd -A INPUT -m set ! --match-set ip1 src \ -m set ! --match-set ip2 src \
@@ -62,10 +64,10 @@ start) cat /dev/null > /var/log/kern.log ;; start_flags) - ../src/ipset n test hash:net $family 2>/dev/null - ../src/ipset a test 10.0.0.0/16 2>/dev/null - ../src/ipset a test 10.0.0.0/24 nomatch 2>/dev/null - ../src/ipset a test 10.0.0.1 2>/dev/null + $ipset n test hash:net $family 2>/dev/null + $ipset a test 10.0.0.0/16 2>/dev/null + $ipset a test 10.0.0.0/24 nomatch 2>/dev/null + $ipset a test 10.0.0.1 2>/dev/null $cmd -A INPUT ! -s 10.0.0.0/16 -j ACCEPT $cmd -A INPUT -m set --match-set test src \ -j LOG --log-prefix "in set test: "
@@ -76,10 +78,10 @@ start_flags) cat /dev/null > /var/log/kern.log ;; start_flags_reversed) - ../src/ipset n test hash:net $family 2>/dev/null - ../src/ipset a test 10.0.0.0/16 2>/dev/null - ../src/ipset a test 10.0.0.0/24 nomatch 2>/dev/null - ../src/ipset a test 10.0.0.1 2>/dev/null + $ipset n test hash:net $family 2>/dev/null + $ipset a test 10.0.0.0/16 2>/dev/null + $ipset a test 10.0.0.0/24 nomatch 2>/dev/null + $ipset a test 10.0.0.1 2>/dev/null $cmd -A INPUT ! -s 10.0.0.0/16 -j ACCEPT $cmd -A INPUT -m set --match-set test src --return-nomatch \ -j LOG --log-prefix "in set test-nomatch: "
@@ -94,14 +96,14 @@ del) $cmd -A INPUT -j SET --del-set ipport src,src ;; timeout) - ../src/ipset n test hash:ip,port timeout 2 + $ipset n test hash:ip,port timeout 2 $cmd -A INPUT -j SET --add-set test src,src --timeout 10 --exist ;; stop) $cmd -F $cmd -X - ../src/ipset -F 2>/dev/null - ../src/ipset -X 2>/dev/null + $ipset -F 2>/dev/null + $ipset -X 2>/dev/null ;; *) echo "Usage: $0 start|stop"
tests/resize.sh +5 -3
@@ -1,12 +1,14 @@ #!/bin/bash -../src/ipset x resize-test 2>/dev/null +ipset=${IPSET_BIN:-../src/ipset} + +$ipset x resize-test 2>/dev/null set -e -../src/ipset n resize-test hash:ip hashsize 64 +$ipset n resize-test hash:ip hashsize 64 for x in `seq 1 32`; do for y in `seq 1 255`; do - ../src/ipset a resize-test 192.168.$x.$y + $ipset a resize-test 192.168.$x.$y done done
tests/resizec.sh +1 -1
@@ -3,7 +3,7 @@ # set -x set -e -ipset=../src/ipset +ipset=${IPSET_BIN:-../src/ipset} case "$1" in -4)
tests/resizen.sh +1 -1
@@ -3,7 +3,7 @@ # set -x set -e -ipset=../src/ipset +ipset=${IPSET_BIN:-../src/ipset} case "$1" in -4)
tests/resizet.sh +1 -1
@@ -3,7 +3,7 @@ # set -x set -e -ipset=../src/ipset +ipset=${IPSET_BIN:-../src/ipset} case "$1" in -4)
tests/runtest.sh +5 -3
@@ -2,6 +2,8 @@ # set -x +ipset=${IPSET_BIN:-../src/ipset} + tests="init" tests="$tests ipmap bitmap:ip" tests="$tests macipmap portmap"
@@ -65,7 +67,7 @@ fi chmod a+x check_* *.sh for types in $tests; do - ../src/ipset -X test >/dev/null 2>&1 + $ipset -X test >/dev/null 2>&1 if [ -f $types ]; then filename=$types else
@@ -92,7 +94,7 @@ for types in $tests; do ;; esac echo -ne "$types: $what: " - cmd=`echo $cmd | sed 's/ipset/..\/src\/ipset 2>.foo.err/'` + cmd=`echo $cmd | sed "s|ipset|$ipset 2>.foo.err|"` eval $cmd r=$? # echo $ret $r
@@ -108,7 +110,7 @@ for types in $tests; do done < $filename done # Remove test sets created by setlist.t -../src/ipset -X >/dev/null 2>&1 +$ipset -X >/dev/null 2>&1 for x in $tests; do case $x in init)
tests/setlist_resize.sh +5 -3
@@ -2,6 +2,8 @@ # set -x +ipset=${IPSET_BIN:-../src/ipset} + loop=8 for x in ip_set_list_set ip_set_hash_netiface ip_set_hash_ipportnet \
@@ -16,7 +18,7 @@ done create() { n=$1 while [ $n -le 1024 ]; do - ../src/ipset c test$n hash:ip + $ipset c test$n hash:ip n=$((n+2)) done }
@@ -26,8 +28,8 @@ for x in `seq 1 $loop`; do create 1 & create 2 & wait - test `../src/ipset l -n | wc -l` -eq 1024 || exit 1 - ../src/ipset x + 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 rmmod ip_set_hash_ip rmmod ip_set
Signature · 1 line
1.9.1
Quoted 7 lines · Neutron Soutmun
In the "as-installed" package testing situation, the test scripts should invokes the system installed "ipset" binary.
Therefore, theIPSET_BINcould be passed to change the binary location.IPSET_BIN=/sbin/ipset ./runtest.sh
The test scripts run fine in build source tree without
IPSET_BIN.
This patch is also applied, thanks.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary