summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeutron Soutmun <neo.neutron@gmail.com>2014-04-04 10:24:22 +0700
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2014-04-07 21:56:45 +0200
commitf7cafd65feda94b6f21c6b6e36e2bf258e2563d3 (patch)
tree8e470a67c40a97c012ccb737a9e9d878060e05a4 /tests
parent485b3a2d8f46354ebde6017c9bab528108742268 (diff)
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. Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/check_cidrs.sh18
-rwxr-xr-x[-rw-r--r--]tests/check_counters4
-rwxr-xr-x[-rw-r--r--]tests/check_extensions4
-rwxr-xr-x[-rw-r--r--]tests/check_sendip_packets0
-rwxr-xr-xtests/iptables.sh40
-rwxr-xr-xtests/resize.sh8
-rwxr-xr-x[-rw-r--r--]tests/resizec.sh2
-rwxr-xr-x[-rw-r--r--]tests/resizen.sh2
-rwxr-xr-x[-rw-r--r--]tests/resizet.sh2
-rwxr-xr-xtests/runtest.sh8
-rwxr-xr-xtests/setlist_resize.sh8
11 files changed, 54 insertions, 42 deletions
diff --git a/tests/check_cidrs.sh b/tests/check_cidrs.sh
index ee89e37..38f735f 100755
--- a/tests/check_cidrs.sh
+++ b/tests/check_cidrs.sh
@@ -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
diff --git a/tests/check_counters b/tests/check_counters
index 0099f23..912067a 100644..100755
--- a/tests/check_counters
+++ b/tests/check_counters
@@ -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
diff --git a/tests/check_extensions b/tests/check_extensions
index 5848b38..77e7c2c 100644..100755
--- a/tests/check_extensions
+++ b/tests/check_extensions
@@ -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
diff --git a/tests/check_sendip_packets b/tests/check_sendip_packets
index 0dad3d0..0dad3d0 100644..100755
--- a/tests/check_sendip_packets
+++ b/tests/check_sendip_packets
diff --git a/tests/iptables.sh b/tests/iptables.sh
index 63b0b92..03d2e09 100755
--- a/tests/iptables.sh
+++ b/tests/iptables.sh
@@ -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"
diff --git a/tests/resize.sh b/tests/resize.sh
index 008c607..19b93fb 100755
--- a/tests/resize.sh
+++ b/tests/resize.sh
@@ -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
diff --git a/tests/resizec.sh b/tests/resizec.sh
index c9b0c41..28d6747 100644..100755
--- a/tests/resizec.sh
+++ b/tests/resizec.sh
@@ -3,7 +3,7 @@
# set -x
set -e
-ipset=../src/ipset
+ipset=${IPSET_BIN:-../src/ipset}
case "$1" in
-4)
diff --git a/tests/resizen.sh b/tests/resizen.sh
index 9ceee88..9322bd2 100644..100755
--- a/tests/resizen.sh
+++ b/tests/resizen.sh
@@ -3,7 +3,7 @@
# set -x
set -e
-ipset=../src/ipset
+ipset=${IPSET_BIN:-../src/ipset}
case "$1" in
-4)
diff --git a/tests/resizet.sh b/tests/resizet.sh
index 753c08e..b5f7fdc 100644..100755
--- a/tests/resizet.sh
+++ b/tests/resizet.sh
@@ -3,7 +3,7 @@
# set -x
set -e
-ipset=../src/ipset
+ipset=${IPSET_BIN:-../src/ipset}
case "$1" in
-4)
diff --git a/tests/runtest.sh b/tests/runtest.sh
index 99e5e6c..fbfa154 100755
--- a/tests/runtest.sh
+++ b/tests/runtest.sh
@@ -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)
diff --git a/tests/setlist_resize.sh b/tests/setlist_resize.sh
index 7e7ad24..01d1cfc 100755
--- a/tests/setlist_resize.sh
+++ b/tests/setlist_resize.sh
@@ -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