diff mbox

ipset: Pass IPSET_BIN to test scripts to change binary location

Message ID 20140404032422.GA5954@nitrogen.neutroncom.local
State Accepted
Delegated to: Jozsef Kadlecsik
Headers show

Commit Message

Neutron Soutmun April 4, 2014, 3:24 a.m. UTC
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>
---
 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

Comments

Jozsef Kadlecsik April 7, 2014, 7:57 p.m. UTC | #1
On Fri, 4 Apr 2014, Neutron Soutmun wrote:

> 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.

This patch is also applied, thanks.

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
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
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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
old mode 100644
new mode 100755
index 0099f23..912067a
--- 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
old mode 100644
new mode 100755
index 5848b38..77e7c2c
--- 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
old mode 100644
new mode 100755
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
old mode 100644
new mode 100755
index c9b0c41..28d6747
--- 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
old mode 100644
new mode 100755
index 9ceee88..9322bd2
--- 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
old mode 100644
new mode 100755
index 753c08e..b5f7fdc
--- 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