summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-20 10:00:26 +0000
committer/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-20 10:00:26 +0000
commita96e4fca10506462df4ee4035f0f86f09bd9dc34 (patch)
tree103bed0a7ae3608675f371d2ac91f3fa7f3a58cc /tests
parentbc2ddd2d8da1252e78a1f25bd91c1e3cd8016ead (diff)
ipset 2.4 release
userspace changes: - Added KBUILD_OUTPUT support (Sven Wegener) - Fix memory leak in ipset_iptreemap (Sven Wegener) - Fix multiple compiler warnings (Sven Wegener) - ipportiphash, ipportnethash and setlist types added - binding marked as deprecated functionality - element separator token changed to ',' in anticipating IPv6 addresses, old separator tokens are still supported - unnecessary includes removed - ipset does not try to resolve IP addresses when listing the content of sets (default changed) - manpage updated - ChangeLog forked for kernel part kernel part changes: - ipportiphash, ipportnethash and setlist types added - set type modules reworked to avoid code duplication as much as possible, code unification macros - expand_macros Makefile target added to help debugging code unification macros - ip_set_addip_kernel and ip_set_delip_kernel changed from void to int, __ip_set_get_byname and __ip_set_put_byid added for the sake of setlist type - unnecessary includes removed - compatibility fix for kernels >= 2.6.27: semaphore.h was moved from asm/ to linux/ (James King) - ChangeLog forked for kernel part
Diffstat (limited to 'tests')
-rw-r--r--tests/ipporthash.t40
-rw-r--r--tests/ipportiphash.t55
-rw-r--r--tests/ipportnethash.t55
-rw-r--r--tests/iptree.t8
-rw-r--r--tests/iptreemap.t10
-rw-r--r--tests/macipmap.t6
-rw-r--r--tests/nethash.t2
-rwxr-xr-xtests/runtest.sh14
-rw-r--r--tests/setlist.t31
9 files changed, 196 insertions, 25 deletions
diff --git a/tests/ipporthash.t b/tests/ipporthash.t
index fc0a7d5..edbbb0c 100644
--- a/tests/ipporthash.t
+++ b/tests/ipporthash.t
@@ -3,25 +3,25 @@
# Range: Create a set from a valid range
0 ipset -N test ipporthash --from 2.0.0.1 --to 2.1.0.0
# Range: Add lower boundary
-0 ipset -A test 2.0.0.1:5
+0 ipset -A test 2.0.0.1,5
# Range: Add upper boundary
-0 ipset -A test 2.1.0.0:128
+0 ipset -A test 2.1.0.0,128
# Range: Test lower boundary
-0 ipset -T test 2.0.0.1:5
+0 ipset -T test 2.0.0.1,5
# Range: Test upper boundary
-0 ipset -T test 2.1.0.0:128
+0 ipset -T test 2.1.0.0,128
# Range: Test value not added to the set
-1 ipset -T test 2.0.0.1:4
+1 ipset -T test 2.0.0.1,4
# Range: Test value not added to the set
-1 ipset -T test 2.0.0.1:6
+1 ipset -T test 2.0.0.1,6
# Range: Test value before lower boundary
-1 ipset -T test 2.0.0.0:5
+1 ipset -T test 2.0.0.0,5
# Range: Test value after upper boundary
-1 ipset -T test 2.1.0.1:128
+1 ipset -T test 2.1.0.1,128
# Range: Try to add value before lower boundary
-1 ipset -A test 2.0.0.0:5
+1 ipset -A test 2.0.0.0,5
# Range: Try to add value after upper boundary
-1 ipset -A test 2.1.0.1:128
+1 ipset -A test 2.1.0.1,128
# Range: Delete test test
0 ipset -X test
# Network: Try to create a set from an invalid network
@@ -29,25 +29,25 @@
# Network: Create a set from a valid network
0 ipset -N test ipporthash --network 2.0.0.0/16
# Network: Add lower boundary
-0 ipset -A test 2.0.0.0:5
+0 ipset -A test 2.0.0.0,5
# Network: Add upper boundary
-0 ipset -A test 2.0.255.255:128
+0 ipset -A test 2.0.255.255,128
# Network: Test lower boundary
-0 ipset -T test 2.0.0.0:5
+0 ipset -T test 2.0.0.0,5
# Network: Test upper boundary
-0 ipset -T test 2.0.255.255:128
+0 ipset -T test 2.0.255.255,128
# Network: Test value not added to the set
-1 ipset -T test 2.0.0.0:4
+1 ipset -T test 2.0.0.0,4
# Network: Test value not added to the set
-1 ipset -T test 2.0.0.0:6
+1 ipset -T test 2.0.0.0,6
# Network: Test value before lower boundary
-1 ipset -T test 1.255.255.255:5
+1 ipset -T test 1.255.255.255,5
# Network: Test value after upper boundary
-1 ipset -T test 2.1.0.0:128
+1 ipset -T test 2.1.0.0,128
# Network: Try to add value before lower boundary
-1 ipset -A test 1.255.255.255:5
+1 ipset -A test 1.255.255.255,5
# Network: Try to add value after upper boundary
-1 ipset -A test 2.1.0.0:128
+1 ipset -A test 2.1.0.0,128
# Network: Delete test set
0 ipset -X test
# eof
diff --git a/tests/ipportiphash.t b/tests/ipportiphash.t
new file mode 100644
index 0000000..5ffd08a
--- /dev/null
+++ b/tests/ipportiphash.t
@@ -0,0 +1,55 @@
+# Range: Try to create from an invalid range
+2 ipset -N test ipportiphash --from 2.0.0.1 --to 2.1.0.1
+# Range: Create a set from a valid range
+0 ipset -N test ipportiphash --from 2.0.0.1 --to 2.1.0.0
+# Range: Add lower boundary
+0 ipset -A test 2.0.0.1,5,1.1.1.1
+# Range: Add upper boundary
+0 ipset -A test 2.1.0.0,128,2.2.2.2
+# Range: Test lower boundary
+0 ipset -T test 2.0.0.1,5,1.1.1.1
+# Range: Test upper boundary
+0 ipset -T test 2.1.0.0,128,2.2.2.2
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1,5,1.1.1.2
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1,6,1.1.1.1
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.2,6,1.1.1.1
+# Range: Test value before lower boundary
+1 ipset -T test 2.0.0.0,5,1.1.1.1
+# Range: Test value after upper boundary
+1 ipset -T test 2.1.0.1,128,2.2.2.2
+# Range: Try to add value before lower boundary
+1 ipset -A test 2.0.0.0,5,1.1.1.1
+# Range: Try to add value after upper boundary
+1 ipset -A test 2.1.0.1,128,2.2.2.2
+# Range: Delete test test
+0 ipset -X test
+# Network: Try to create a set from an invalid network
+2 ipset -N test ipportiphash --network 2.0.0.0/15
+# Network: Create a set from a valid network
+0 ipset -N test ipportiphash --network 2.0.0.0/16
+# Network: Add lower boundary
+0 ipset -A test 2.0.0.0,5,1.1.1.1
+# Network: Add upper boundary
+0 ipset -A test 2.0.255.255,128,2.2.2.2
+# Network: Test lower boundary
+0 ipset -T test 2.0.0.0,5,1.1.1.1
+# Network: Test upper boundary
+0 ipset -T test 2.0.255.255,128,2.2.2.2
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0,5,1.1.1.2
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0,6,1.1.1.1
+# Network: Test value before lower boundary
+1 ipset -T test 1.255.255.255,5,1.1.1.1
+# Network: Test value after upper boundary
+1 ipset -T test 2.1.0.0,128,2.2.2.2
+# Network: Try to add value before lower boundary
+1 ipset -A test 1.255.255.255,5,1.1.1.1
+# Network: Try to add value after upper boundary
+1 ipset -A test 2.1.0.0,128,2.2.2.2
+# Network: Delete test set
+0 ipset -X test
+# eof
diff --git a/tests/ipportnethash.t b/tests/ipportnethash.t
new file mode 100644
index 0000000..b7d64ff
--- /dev/null
+++ b/tests/ipportnethash.t
@@ -0,0 +1,55 @@
+# Range: Try to create from an invalid range
+2 ipset -N test ipportnethash --from 2.0.0.1 --to 2.1.0.1
+# Range: Create a set from a valid range
+0 ipset -N test ipportnethash --from 2.0.0.1 --to 2.1.0.0
+# Range: Add lower boundary
+0 ipset -A test 2.0.0.1,5,1.1.1.1/24
+# Range: Add upper boundary
+0 ipset -A test 2.1.0.0,128,2.2.2.2/12
+# Range: Test lower boundary
+0 ipset -T test 2.0.0.1,5,1.1.1.2
+# Range: Test upper boundary
+0 ipset -T test 2.1.0.0,128,2.2.2.0
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1,5,1.1.0.255
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.1,6,1.1.1.1
+# Range: Test value not added to the set
+1 ipset -T test 2.0.0.2,6,1.1.1.1
+# Range: Test value before lower boundary
+1 ipset -T test 2.0.0.0,5,1.1.1.1
+# Range: Test value after upper boundary
+1 ipset -T test 2.1.0.1,128,2.2.2.2
+# Range: Try to add value before lower boundary
+1 ipset -A test 2.0.0.0,5,1.1.1.1/24
+# Range: Try to add value after upper boundary
+1 ipset -A test 2.1.0.1,128,2.2.2.2/12
+# Range: Delete test test
+0 ipset -X test
+# Network: Try to create a set from an invalid network
+2 ipset -N test ipportnethash --network 2.0.0.0/15
+# Network: Create a set from a valid network
+0 ipset -N test ipportnethash --network 2.0.0.0/16
+# Network: Add lower boundary
+0 ipset -A test 2.0.0.0,5,1.1.1.1/24
+# Network: Add upper boundary
+0 ipset -A test 2.0.255.255,128,2.2.2.2/12
+# Network: Test lower boundary
+0 ipset -T test 2.0.0.0,5,1.1.1.2
+# Network: Test upper boundary
+0 ipset -T test 2.0.255.255,128,2.2.2.0
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0,5,1.1.0.255
+# Network: Test value not added to the set
+1 ipset -T test 2.0.0.0,6,1.1.1.1
+# Network: Test value before lower boundary
+1 ipset -T test 1.255.255.255,5,1.1.1.1
+# Network: Test value after upper boundary
+1 ipset -T test 2.1.0.0,128,2.2.2.2
+# Network: Try to add value before lower boundary
+1 ipset -A test 1.255.255.255,5,1.1.1.1/24
+# Network: Try to add value after upper boundary
+1 ipset -A test 2.1.0.0,128,2.2.2.2/12
+# Network: Delete test set
+0 ipset -X test
+# eof
diff --git a/tests/iptree.t b/tests/iptree.t
index 76cac54..0e661ce 100644
--- a/tests/iptree.t
+++ b/tests/iptree.t
@@ -38,6 +38,14 @@
1 ipset -T test 2.0.0.2
# Timeout: Test value not added to the set
1 ipset -T test 192.168.68.70
+# Timeout: Add entry with 3s timeout value
+0 ipset -A test 2.0.0.2,3
+# Timeout: Test entry added with 3s timeout
+0 ipset -T test 2.0.0.2
+# Timeout: Sleep 4s so that entry can time out
+0 sleep 4
+# Timeout: Test entry added with 3s timeout
+1 ipset -T test 2.0.0.2
# Timeout: Delete test set
0 ipset -X test
# eof
diff --git a/tests/iptreemap.t b/tests/iptreemap.t
index b8aeef2..66ee325 100644
--- a/tests/iptreemap.t
+++ b/tests/iptreemap.t
@@ -13,7 +13,7 @@
# Test value not added to the set
1 ipset -T test 192.168.68.70
# Add IP range
-0 ipset -A test 3.0.0.0:3.0.0.2
+0 ipset -A test 3.0.0.0-3.0.0.2
# Test the three members of the range: first
0 ipset -T test 3.0.0.0
# Test the three members of the range: second
@@ -38,8 +38,14 @@
0 ipset -T test 192.168.68.71
# Delete a network from the middle
0 ipset -D test 192.168.68.70/30
-# Test element from the middle
+# Test lower bound of deleted network
+1 ipset -T test 192.168.68.68
+# Test upper bound of deleted network
1 ipset -T test 192.168.68.71
+# Test element before lower bound of deleted network
+0 ipset -T test 192.168.68.67
+# Test element after upper bound of deleted network
+0 ipset -T test 192.168.68.72
# Delete test set
0 ipset -X test
# eof
diff --git a/tests/macipmap.t b/tests/macipmap.t
index 035160a..049eaee 100644
--- a/tests/macipmap.t
+++ b/tests/macipmap.t
@@ -20,6 +20,12 @@
1 ipset -A test 2.0.0.0
# Range: Try to add value after upper boundary
1 ipset -A test 2.1.0.1
+# Range: Try to add value with MAC
+0 ipset -A test 2.0.0.2,00:11:22:33:44:55
+# Range: Test value with invalid MAC
+1 ipset -T test 2.0.0.2,00:11:22:33:44:56
+# Range: Test value with valid MAC
+0 ipset -T test 2.0.0.2,00:11:22:33:44:55
# Range: Delete test test
0 ipset -X test
# Network: Try to create a set from an invalid network
diff --git a/tests/nethash.t b/tests/nethash.t
index 4cd5867..ef213f9 100644
--- a/tests/nethash.t
+++ b/tests/nethash.t
@@ -10,6 +10,8 @@
0 ipset -T test 192.168.68.95
# Test value not added to the set
1 ipset -T test 2.0.1.0
+# Try to add IP address
+2 ipset -A test 2.0.0.1
# Delete test set
0 ipset -X test
# eof
diff --git a/tests/runtest.sh b/tests/runtest.sh
index 028e968..4f2a2d2 100755
--- a/tests/runtest.sh
+++ b/tests/runtest.sh
@@ -1,9 +1,15 @@
-#!/bin/sh
+#!/bin/bash
tests="init"
tests+=" ipmap macipmap portmap"
tests+=" iphash nethash ipporthash"
+tests+=" ipportiphash ipportnethash"
tests+=" iptree iptreemap"
+tests+=" setlist"
+
+if [ "$1" ]; then
+ tests="init $@"
+fi
for types in $tests; do
ipset -X test >/dev/null 2>&1
@@ -24,7 +30,7 @@ for types in $tests; do
r=$?
# echo $ret $r
if [ "$ret" = "$r" ]; then
- echo "OK"
+ echo "passed"
else
echo "FAILED"
echo "Failed test: $cmd"
@@ -33,6 +39,8 @@ for types in $tests; do
# sleep 1
done < $types.t
done
+# Remove test sets created by setlist.t
+ipset -X
for x in $tests; do
case $x in
init)
@@ -43,5 +51,5 @@ for x in $tests; do
esac
done
rmmod ip_set >/dev/null 2>&1
-echo "All tests are OK"
+echo "All tests are passed"
diff --git a/tests/setlist.t b/tests/setlist.t
new file mode 100644
index 0000000..785dc13
--- /dev/null
+++ b/tests/setlist.t
@@ -0,0 +1,31 @@
+# Setlist: Create base set foo
+0 ipset -N foo ipmap --from 2.0.0.1 --to 2.1.0.0
+# Setlist: Create base set bar
+0 ipset -N bar iphash
+# Setlist: Create setlist kind of set
+0 ipset -N test setlist
+# Setlist: Add foo set to setlist
+0 ipset -A test foo
+# Setlist: Test foo set in setlist
+0 ipset -T test foo
+# Setlist: Try to delete foo set
+1 ipset -X foo
+# Setlist: Add bar set to setlist, after foo
+0 ipset -A test bar
+# Setlist: Test bar,after,foo
+0 ipset -T test bar,after,foo
+# Setlist: Test foo,before,bar
+0 ipset -T test foo,before,bar
+# Setlist: Test bar,before,foo
+1 ipset -T test bar,before,foo
+# Setlist: Test foo,after,bar
+1 ipset -T test foo,after,bar
+# Setlist: Delete bar,before,foo
+1 ipset -D test bar,before,foo
+# Setlist: Delete foo,after,bar
+1 ipset -D test foo,after,bar
+# Setlist: Delete bar,after,foo
+0 ipset -D test bar,after,foo
+# Setlist: Delete test test
+0 ipset -X test
+# eof