From 9638135a8ea91a157a68148fb1d84edec52c313b Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 22 Apr 2010 17:11:01 +0200 Subject: Nineth stage to ipset-5 Update tests. --- tests/iphash.t | 28 ++++-- tests/iphash.t.list0 | 7 +- tests/iphash.t.list1 | 7 +- tests/iphash.t.restore | 261 ++++++++++++++++++++++++------------------------ tests/ipmap.t | 78 +++++++++++---- tests/ipmap.t.list0 | 10 +- tests/ipmap.t.list1 | 10 +- tests/ipmap.t.list2 | 10 +- tests/ipmap.t.list3 | 266 ++++++++++++++++++++++++++++++++++++++++++++++++- tests/macipmap.t | 62 +++++++++++- tests/macipmap.t.list0 | 10 +- tests/macipmap.t.list1 | 11 +- tests/portmap.t | 30 ++++++ tests/portmap.t.list0 | 6 +- tests/portmap.t.list1 | 6 +- tests/runtest.sh | 36 +++++-- tests/sort.sh | 5 +- 17 files changed, 639 insertions(+), 204 deletions(-) (limited to 'tests') diff --git a/tests/iphash.t b/tests/iphash.t index 7a3ce1f..923931a 100644 --- a/tests/iphash.t +++ b/tests/iphash.t @@ -1,9 +1,9 @@ # IP: Create a set 0 ipset -N test iphash --hashsize 128 # Range: Add zero valued element -2 ipset -A test 0.0.0.0 +1 ipset -A test 0.0.0.0 # Range: Test zero valued element -2 ipset -T test 0.0.0.0 +1 ipset -T test 0.0.0.0 # IP: Add first random value 0 ipset -A test 2.0.0.1 # IP: Add second random value @@ -14,18 +14,28 @@ 0 ipset -T test 192.168.68.69 # IP: Test value not added to the set 1 ipset -T test 2.0.0.2 +# IP: Add third random value +0 ipset -A test 200.100.0.12 +# IP: Delete the same value +0 ipset -D test 200.100.0.12 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test 2>/dev/null > .foo0 && ./sort.sh .foo0 # IP: Check listing 0 diff .foo iphash.t.list0 && rm .foo # IP: Flush test set 0 ipset -F test # IP: Delete test set 0 ipset -X test +# IP: Restore values so that rehashing is triggered, old format +0 ipset -R < iphash.t.restore.old +# IP: Check that all values are restored +0 (grep add iphash.t.restore | sort > .foo.1) && (ipset -S test | grep add | sort > .foo.2) && cmp .foo.1 .foo.2 && rm .foo.* +# IP: Delete test set +0 ipset -X test # IP: Restore values so that rehashing is triggered 0 ipset -R < iphash.t.restore # IP: Check that all values are restored -0 (egrep -v '#|-N' iphash.t.restore | sort > .foo.1) && (ipset -S test | egrep -v '#|-N' | sort > .foo.2) && cmp .foo.1 .foo.2 && rm .foo.* +0 (grep add iphash.t.restore | sort > .foo.1) && (ipset -S test | grep add | sort > .foo.2) && cmp .foo.1 .foo.2 && rm .foo.* # IP: Flush test set 0 ipset -F test # IP: Delete test set @@ -33,11 +43,11 @@ # Network: Create a set 0 ipset -N test iphash --hashsize 128 --netmask 24 # Network: Add zero valued element -2 ipset -A test 0.0.0.0 +1 ipset -A test 0.0.0.0 # Network: Test zero valued element -2 ipset -T test 0.0.0.0 +1 ipset -T test 0.0.0.0 # Network: Delete zero valued element -2 ipset -D test 0.0.0.0 +1 ipset -D test 0.0.0.0 # Network: Add first random network 0 ipset -A test 2.0.0.1 # Network: Add second random network @@ -48,6 +58,10 @@ 0 ipset -T test 192.168.68.95 # Network: Test value not added to the set 1 ipset -T test 2.0.1.0 +# Network: Add third random network +0 ipset -A test 200.100.0.12 +# Network: Delete the same network +0 ipset -D test 200.100.0.12 # Network: List set 0 ipset -L test > .foo0 && ./sort.sh .foo0 # Network: Check listing diff --git a/tests/iphash.t.list0 b/tests/iphash.t.list0 index 93d51c2..3f0c2fa 100644 --- a/tests/iphash.t.list0 +++ b/tests/iphash.t.list0 @@ -1,7 +1,10 @@ Name: test -Type: iphash +Type: hash:ip +Header: hashsize 128 maxelem 65536 probes 4 resize 50 +Elements: 2 +Size in memory: 512 References: 0 -Header: hashsize: 128 probes: 8 resize: 50 Members: 192.168.68.69 2.0.0.1 + diff --git a/tests/iphash.t.list1 b/tests/iphash.t.list1 index 7f13c1c..f32655a 100644 --- a/tests/iphash.t.list1 +++ b/tests/iphash.t.list1 @@ -1,7 +1,10 @@ Name: test -Type: iphash +Type: hash:ip +Header: hashsize 128 maxelem 65536 probes 4 resize 50 netmask 24 +Elements: 2 +Size in memory: 512 References: 0 -Header: hashsize: 128 probes: 8 resize: 50 netmask: 24 Members: 192.168.68.0 2.0.0.0 + diff --git a/tests/iphash.t.restore b/tests/iphash.t.restore index fd915cc..d521c87 100644 --- a/tests/iphash.t.restore +++ b/tests/iphash.t.restore @@ -1,131 +1,130 @@ --N test iphash --hashsize 128 --A test 10.0.0.0 --A test 10.0.0.1 --A test 10.0.0.10 --A test 10.0.0.100 --A test 10.0.0.101 --A test 10.0.0.102 --A test 10.0.0.103 --A test 10.0.0.104 --A test 10.0.0.105 --A test 10.0.0.106 --A test 10.0.0.107 --A test 10.0.0.108 --A test 10.0.0.109 --A test 10.0.0.11 --A test 10.0.0.110 --A test 10.0.0.111 --A test 10.0.0.112 --A test 10.0.0.113 --A test 10.0.0.114 --A test 10.0.0.115 --A test 10.0.0.116 --A test 10.0.0.117 --A test 10.0.0.118 --A test 10.0.0.119 --A test 10.0.0.12 --A test 10.0.0.120 --A test 10.0.0.121 --A test 10.0.0.122 --A test 10.0.0.123 --A test 10.0.0.124 --A test 10.0.0.125 --A test 10.0.0.126 --A test 10.0.0.127 --A test 10.0.0.128 --A test 10.0.0.13 --A test 10.0.0.14 --A test 10.0.0.15 --A test 10.0.0.16 --A test 10.0.0.17 --A test 10.0.0.18 --A test 10.0.0.19 --A test 10.0.0.2 --A test 10.0.0.20 --A test 10.0.0.21 --A test 10.0.0.22 --A test 10.0.0.23 --A test 10.0.0.24 --A test 10.0.0.25 --A test 10.0.0.26 --A test 10.0.0.27 --A test 10.0.0.28 --A test 10.0.0.29 --A test 10.0.0.3 --A test 10.0.0.30 --A test 10.0.0.31 --A test 10.0.0.32 --A test 10.0.0.33 --A test 10.0.0.34 --A test 10.0.0.35 --A test 10.0.0.36 --A test 10.0.0.37 --A test 10.0.0.38 --A test 10.0.0.39 --A test 10.0.0.4 --A test 10.0.0.40 --A test 10.0.0.41 --A test 10.0.0.42 --A test 10.0.0.43 --A test 10.0.0.44 --A test 10.0.0.45 --A test 10.0.0.46 --A test 10.0.0.47 --A test 10.0.0.48 --A test 10.0.0.49 --A test 10.0.0.5 --A test 10.0.0.50 --A test 10.0.0.51 --A test 10.0.0.52 --A test 10.0.0.53 --A test 10.0.0.54 --A test 10.0.0.55 --A test 10.0.0.56 --A test 10.0.0.57 --A test 10.0.0.58 --A test 10.0.0.59 --A test 10.0.0.6 --A test 10.0.0.60 --A test 10.0.0.61 --A test 10.0.0.62 --A test 10.0.0.63 --A test 10.0.0.64 --A test 10.0.0.65 --A test 10.0.0.66 --A test 10.0.0.67 --A test 10.0.0.68 --A test 10.0.0.69 --A test 10.0.0.7 --A test 10.0.0.70 --A test 10.0.0.71 --A test 10.0.0.72 --A test 10.0.0.73 --A test 10.0.0.74 --A test 10.0.0.75 --A test 10.0.0.76 --A test 10.0.0.77 --A test 10.0.0.78 --A test 10.0.0.79 --A test 10.0.0.8 --A test 10.0.0.80 --A test 10.0.0.81 --A test 10.0.0.82 --A test 10.0.0.83 --A test 10.0.0.84 --A test 10.0.0.85 --A test 10.0.0.86 --A test 10.0.0.87 --A test 10.0.0.88 --A test 10.0.0.89 --A test 10.0.0.9 --A test 10.0.0.90 --A test 10.0.0.91 --A test 10.0.0.92 --A test 10.0.0.93 --A test 10.0.0.94 --A test 10.0.0.95 --A test 10.0.0.96 --A test 10.0.0.97 --A test 10.0.0.98 --A test 10.0.0.99 -COMMIT +create test hash:ip hashsize 128 +add test 10.0.0.38 +add test 10.0.0.94 +add test 10.0.0.17 +add test 10.0.0.114 +add test 10.0.0.69 +add test 10.0.0.112 +add test 10.0.0.122 +add test 10.0.0.119 +add test 10.0.0.70 +add test 10.0.0.101 +add test 10.0.0.37 +add test 10.0.0.45 +add test 10.0.0.41 +add test 10.0.0.123 +add test 10.0.0.18 +add test 10.0.0.33 +add test 10.0.0.35 +add test 10.0.0.48 +add test 10.0.0.29 +add test 10.0.0.80 +add test 10.0.0.12 +add test 10.0.0.42 +add test 10.0.0.85 +add test 10.0.0.116 +add test 10.0.0.56 +add test 10.0.0.83 +add test 10.0.0.28 +add test 10.0.0.32 +add test 10.0.0.68 +add test 10.0.0.84 +add test 10.0.0.82 +add test 10.0.0.20 +add test 10.0.0.43 +add test 10.0.0.2 +add test 10.0.0.121 +add test 10.0.0.6 +add test 10.0.0.31 +add test 10.0.0.66 +add test 10.0.0.57 +add test 10.0.0.77 +add test 10.0.0.25 +add test 10.0.0.76 +add test 10.0.0.47 +add test 10.0.0.8 +add test 10.0.0.105 +add test 10.0.0.73 +add test 10.0.0.60 +add test 10.0.0.75 +add test 10.0.0.7 +add test 10.0.0.46 +add test 10.0.0.39 +add test 10.0.0.99 +add test 10.0.0.51 +add test 10.0.0.54 +add test 10.0.0.9 +add test 10.0.0.103 +add test 10.0.0.5 +add test 10.0.0.124 +add test 10.0.0.52 +add test 10.0.0.1 +add test 10.0.0.125 +add test 10.0.0.117 +add test 10.0.0.72 +add test 10.0.0.127 +add test 10.0.0.63 +add test 10.0.0.27 +add test 10.0.0.21 +add test 10.0.0.91 +add test 10.0.0.74 +add test 10.0.0.30 +add test 10.0.0.23 +add test 10.0.0.95 +add test 10.0.0.120 +add test 10.0.0.89 +add test 10.0.0.24 +add test 10.0.0.10 +add test 10.0.0.96 +add test 10.0.0.92 +add test 10.0.0.71 +add test 10.0.0.34 +add test 10.0.0.67 +add test 10.0.0.59 +add test 10.0.0.4 +add test 10.0.0.79 +add test 10.0.0.13 +add test 10.0.0.100 +add test 10.0.0.111 +add test 10.0.0.58 +add test 10.0.0.106 +add test 10.0.0.107 +add test 10.0.0.44 +add test 10.0.0.40 +add test 10.0.0.50 +add test 10.0.0.118 +add test 10.0.0.87 +add test 10.0.0.3 +add test 10.0.0.49 +add test 10.0.0.126 +add test 10.0.0.109 +add test 10.0.0.55 +add test 10.0.0.102 +add test 10.0.0.11 +add test 10.0.0.16 +add test 10.0.0.97 +add test 10.0.0.115 +add test 10.0.0.93 +add test 10.0.0.86 +add test 10.0.0.113 +add test 10.0.0.53 +add test 10.0.0.110 +add test 10.0.0.65 +add test 10.0.0.0 +add test 10.0.0.15 +add test 10.0.0.62 +add test 10.0.0.90 +add test 10.0.0.108 +add test 10.0.0.81 +add test 10.0.0.128 +add test 10.0.0.64 +add test 10.0.0.61 +add test 10.0.0.88 +add test 10.0.0.104 +add test 10.0.0.26 +add test 10.0.0.36 +add test 10.0.0.78 +add test 10.0.0.14 +add test 10.0.0.98 +add test 10.0.0.22 +add test 10.0.0.19 diff --git a/tests/ipmap.t b/tests/ipmap.t index 239cef9..c639e0b 100644 --- a/tests/ipmap.t +++ b/tests/ipmap.t @@ -1,5 +1,5 @@ # Range: Try to create from an invalid range -2 ipset -N test ipmap --from 2.0.0.1 --to 2.1.0.1 +1 ipset -N test ipmap --from 2.0.0.1 --to 2.1.0.1 # Range: Create a set from a valid range 0 ipset -N test ipmap --from 2.0.0.1 --to 2.1.0.0 # Range: Add lower boundary @@ -10,26 +10,40 @@ 0 ipset -T test 2.0.0.1 # Range: Test upper boundary 0 ipset -T test 2.1.0.0 -# Range: Test value not added to the set +# Range: Test element not added to the set 1 ipset -T test 2.0.0.2 -# Range: Test value before lower boundary +# Range: Test element before lower boundary 1 ipset -T test 2.0.0.0 -# Range: Test value after upper boundary +# Range: Test element after upper boundary 1 ipset -T test 2.1.0.1 -# Range: Try to add value before lower boundary +# Range: Try to add element before lower boundary 1 ipset -A test 2.0.0.0 -# Range: Try to add value after upper boundary +# Range: Try to add element after upper boundary 1 ipset -A test 2.1.0.1 +# Range: Delete element not added to the set +1 ipset -D test 2.0.0.2 +# Range: Add element in the middle +0 ipset -A test 2.0.0.128 +# Range: Delete the same element +0 ipset -D test 2.0.0.128 +# Range: Add a range of elements +0 ipset -A test 2.0.0.128-2.0.0.131 # Range: List set 0 ipset -L test > .foo # Range: Check listing 0 diff .foo ipmap.t.list0 && rm .foo +# Range: Delete a range of elements +0 ipset -D test -x 2.0.0.128-2.0.0.132 +# Range: List set +0 ipset -L test > .foo +# Range: Check listing +0 diff .foo ipmap.t.list1 && rm .foo # Range: Flush test set 0 ipset -F test # Range: Delete test set 0 ipset -X test # Network: Try to create a set from an invalid network -2 ipset -N test ipmap --network 2.0.0.0/15 +1 ipset -N test ipmap --network 2.0.0.0/15 # Network: Create a set from a valid network 0 ipset -N test ipmap --network 2.0.0.0/16 # Network: Add lower boundary @@ -40,20 +54,26 @@ 0 ipset -T test 2.0.0.0 # Network: Test upper boundary 0 ipset -T test 2.0.255.255 -# Network: Test value not added to the set +# Network: Test element not added to the set 1 ipset -T test 2.0.0.1 -# Network: Test value before lower boundary +# Network: Test element before lower boundary 1 ipset -T test 1.255.255.255 -# Network: Test value after upper boundary +# Network: Test element after upper boundary 1 ipset -T test 2.1.0.0 -# Network: Try to add value before lower boundary +# Network: Try to add element before lower boundary 1 ipset -A test 1.255.255.255 -# Network: Try to add value after upper boundary +# Network: Try to add element after upper boundary 1 ipset -A test 2.1.0.0 +# Network: Delete element not added to the set +1 ipset -D test 2.0.0.2 +# Network: Add element in the middle +0 ipset -A test 2.0.0.128 +# Network: Delete the same element +0 ipset -D test 2.0.0.128 # Network: List set 0 ipset -L test > .foo # Network: Check listing -0 diff .foo ipmap.t.list1 && rm .foo +0 diff .foo ipmap.t.list2 && rm .foo # Network: Flush test set 0 ipset -F test # Network: Delete test set @@ -68,20 +88,28 @@ 0 ipset -T test 10.0.0.255 # Subnets: Test upper boundary 0 ipset -T test 10.255.255.0 -# Subnets: Test value not added to the set +# Subnets: Test element not added to the set 1 ipset -T test 10.1.0.0 -# Subnets: Test value before lower boundary +# Subnets: Test element before lower boundary 1 ipset -T test 9.255.255.255 -# Subnets: Test value after upper boundary +# Subnets: Test element after upper boundary 1 ipset -T test 11.0.0.0 -# Subnets: Try to add value before lower boundary +# Subnets: Try to add element before lower boundary 1 ipset -A test 9.255.255.255 -# Subnets: Try to add value after upper boundary +# Subnets: Try to add element after upper boundary 1 ipset -A test 11.0.0.0 +# Subnets: Try to delete element not added to the set +1 ipset -D test 10.2.0.0 +# Subnets: Add element to the set +0 ipset -A test 10.2.0.0 +# Subnets: Delete the same element from the set +0 ipset -D test 10.2.0.0 +# Subnets: Add a subnet of subnets +0 ipset -A test 10.8.0.0/16 # Subnets: List set 0 ipset -L test > .foo # Subnets: Check listing -0 diff .foo ipmap.t.list2 && rm .foo +0 diff .foo ipmap.t.list3 && rm .foo # Subnets: FLush test set 0 ipset -F test # Subnets: Delete test set @@ -89,19 +117,25 @@ # Full: Create full IPv4 space with /16 networks 0 ipset -N test ipmap --network 0.0.0.0/0 --netmask 16 # Full: Add lower boundary -0 ipset -A test 0.0.255.255 +0 ipset -A test 0.0.0.0 # Full: Add upper boundary 0 ipset -A test 255.255.0.0 # Full: Test lower boundary 0 ipset -T test 0.0.0.0 # Full: Test upper boundary 0 ipset -T test 255.255.255.255 -# Full: Test value not added to the set +# Full: Test element not added to the set 1 ipset -T test 0.1.0.0 +# Full: Delete element not added to the set +1 ipset -T test 0.1.0.0 +# Full: Add element to the set +0 ipset -A test 0.1.0.0 +# Full: Delete same element +0 ipset -D test 0.1.0.0 # Full: List set 0 ipset -L test > .foo # Full: Check listing -0 diff .foo ipmap.t.list3 && rm .foo +0 diff .foo ipmap.t.list4 && rm .foo # Full: Delete test set 0 ipset -X test # eof diff --git a/tests/ipmap.t.list0 b/tests/ipmap.t.list0 index aeaa4fb..560eed1 100644 --- a/tests/ipmap.t.list0 +++ b/tests/ipmap.t.list0 @@ -1,8 +1,14 @@ Name: test -Type: ipmap +Type: bitmap:ip +Header: range 2.0.0.1-2.1.0.0 +Elements: 6 +Size in memory: 8192 References: 0 -Header: from: 2.0.0.1 to: 2.1.0.0 Members: 2.0.0.1 +2.0.0.128 +2.0.0.129 +2.0.0.130 +2.0.0.131 2.1.0.0 diff --git a/tests/ipmap.t.list1 b/tests/ipmap.t.list1 index 53b76b6..55556a7 100644 --- a/tests/ipmap.t.list1 +++ b/tests/ipmap.t.list1 @@ -1,8 +1,10 @@ Name: test -Type: ipmap +Type: bitmap:ip +Header: range 2.0.0.1-2.1.0.0 +Elements: 2 +Size in memory: 8192 References: 0 -Header: from: 2.0.0.0 to: 2.0.255.255 Members: -2.0.0.0 -2.0.255.255 +2.0.0.1 +2.1.0.0 diff --git a/tests/ipmap.t.list2 b/tests/ipmap.t.list2 index 695254b..9e1b65d 100644 --- a/tests/ipmap.t.list2 +++ b/tests/ipmap.t.list2 @@ -1,8 +1,10 @@ Name: test -Type: ipmap +Type: bitmap:ip +Header: range 2.0.0.0-2.0.255.255 +Elements: 2 +Size in memory: 8192 References: 0 -Header: from: 10.0.0.0 to: 10.255.255.255 netmask: 24 Members: -10.0.0.0 -10.255.255.0 +2.0.0.0 +2.0.255.255 diff --git a/tests/ipmap.t.list3 b/tests/ipmap.t.list3 index 3d95091..4b2a45a 100644 --- a/tests/ipmap.t.list3 +++ b/tests/ipmap.t.list3 @@ -1,8 +1,266 @@ Name: test -Type: ipmap +Type: bitmap:ip +Header: range 10.0.0.0-10.255.255.255 netmask 24 +Elements: 258 +Size in memory: 8192 References: 0 -Header: from: 0.0.0.0 to: 255.255.255.255 netmask: 16 Members: -0.0.0.0 -255.255.0.0 +10.0.0.0 +10.8.0.0 +10.8.1.0 +10.8.2.0 +10.8.3.0 +10.8.4.0 +10.8.5.0 +10.8.6.0 +10.8.7.0 +10.8.8.0 +10.8.9.0 +10.8.10.0 +10.8.11.0 +10.8.12.0 +10.8.13.0 +10.8.14.0 +10.8.15.0 +10.8.16.0 +10.8.17.0 +10.8.18.0 +10.8.19.0 +10.8.20.0 +10.8.21.0 +10.8.22.0 +10.8.23.0 +10.8.24.0 +10.8.25.0 +10.8.26.0 +10.8.27.0 +10.8.28.0 +10.8.29.0 +10.8.30.0 +10.8.31.0 +10.8.32.0 +10.8.33.0 +10.8.34.0 +10.8.35.0 +10.8.36.0 +10.8.37.0 +10.8.38.0 +10.8.39.0 +10.8.40.0 +10.8.41.0 +10.8.42.0 +10.8.43.0 +10.8.44.0 +10.8.45.0 +10.8.46.0 +10.8.47.0 +10.8.48.0 +10.8.49.0 +10.8.50.0 +10.8.51.0 +10.8.52.0 +10.8.53.0 +10.8.54.0 +10.8.55.0 +10.8.56.0 +10.8.57.0 +10.8.58.0 +10.8.59.0 +10.8.60.0 +10.8.61.0 +10.8.62.0 +10.8.63.0 +10.8.64.0 +10.8.65.0 +10.8.66.0 +10.8.67.0 +10.8.68.0 +10.8.69.0 +10.8.70.0 +10.8.71.0 +10.8.72.0 +10.8.73.0 +10.8.74.0 +10.8.75.0 +10.8.76.0 +10.8.77.0 +10.8.78.0 +10.8.79.0 +10.8.80.0 +10.8.81.0 +10.8.82.0 +10.8.83.0 +10.8.84.0 +10.8.85.0 +10.8.86.0 +10.8.87.0 +10.8.88.0 +10.8.89.0 +10.8.90.0 +10.8.91.0 +10.8.92.0 +10.8.93.0 +10.8.94.0 +10.8.95.0 +10.8.96.0 +10.8.97.0 +10.8.98.0 +10.8.99.0 +10.8.100.0 +10.8.101.0 +10.8.102.0 +10.8.103.0 +10.8.104.0 +10.8.105.0 +10.8.106.0 +10.8.107.0 +10.8.108.0 +10.8.109.0 +10.8.110.0 +10.8.111.0 +10.8.112.0 +10.8.113.0 +10.8.114.0 +10.8.115.0 +10.8.116.0 +10.8.117.0 +10.8.118.0 +10.8.119.0 +10.8.120.0 +10.8.121.0 +10.8.122.0 +10.8.123.0 +10.8.124.0 +10.8.125.0 +10.8.126.0 +10.8.127.0 +10.8.128.0 +10.8.129.0 +10.8.130.0 +10.8.131.0 +10.8.132.0 +10.8.133.0 +10.8.134.0 +10.8.135.0 +10.8.136.0 +10.8.137.0 +10.8.138.0 +10.8.139.0 +10.8.140.0 +10.8.141.0 +10.8.142.0 +10.8.143.0 +10.8.144.0 +10.8.145.0 +10.8.146.0 +10.8.147.0 +10.8.148.0 +10.8.149.0 +10.8.150.0 +10.8.151.0 +10.8.152.0 +10.8.153.0 +10.8.154.0 +10.8.155.0 +10.8.156.0 +10.8.157.0 +10.8.158.0 +10.8.159.0 +10.8.160.0 +10.8.161.0 +10.8.162.0 +10.8.163.0 +10.8.164.0 +10.8.165.0 +10.8.166.0 +10.8.167.0 +10.8.168.0 +10.8.169.0 +10.8.170.0 +10.8.171.0 +10.8.172.0 +10.8.173.0 +10.8.174.0 +10.8.175.0 +10.8.176.0 +10.8.177.0 +10.8.178.0 +10.8.179.0 +10.8.180.0 +10.8.181.0 +10.8.182.0 +10.8.183.0 +10.8.184.0 +10.8.185.0 +10.8.186.0 +10.8.187.0 +10.8.188.0 +10.8.189.0 +10.8.190.0 +10.8.191.0 +10.8.192.0 +10.8.193.0 +10.8.194.0 +10.8.195.0 +10.8.196.0 +10.8.197.0 +10.8.198.0 +10.8.199.0 +10.8.200.0 +10.8.201.0 +10.8.202.0 +10.8.203.0 +10.8.204.0 +10.8.205.0 +10.8.206.0 +10.8.207.0 +10.8.208.0 +10.8.209.0 +10.8.210.0 +10.8.211.0 +10.8.212.0 +10.8.213.0 +10.8.214.0 +10.8.215.0 +10.8.216.0 +10.8.217.0 +10.8.218.0 +10.8.219.0 +10.8.220.0 +10.8.221.0 +10.8.222.0 +10.8.223.0 +10.8.224.0 +10.8.225.0 +10.8.226.0 +10.8.227.0 +10.8.228.0 +10.8.229.0 +10.8.230.0 +10.8.231.0 +10.8.232.0 +10.8.233.0 +10.8.234.0 +10.8.235.0 +10.8.236.0 +10.8.237.0 +10.8.238.0 +10.8.239.0 +10.8.240.0 +10.8.241.0 +10.8.242.0 +10.8.243.0 +10.8.244.0 +10.8.245.0 +10.8.246.0 +10.8.247.0 +10.8.248.0 +10.8.249.0 +10.8.250.0 +10.8.251.0 +10.8.252.0 +10.8.253.0 +10.8.254.0 +10.8.255.0 +10.255.255.0 diff --git a/tests/macipmap.t b/tests/macipmap.t index d088958..277672d 100644 --- a/tests/macipmap.t +++ b/tests/macipmap.t @@ -1,5 +1,5 @@ # Range: Try to create from an invalid range -2 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.1 +1 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.1 # Range: Create a set from a valid range 0 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.0 # Range: Add lower boundary @@ -26,6 +26,12 @@ 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: Add MAC to already added element +0 ipset -A test 2.0.0.1,00:11:22:33:44:56 +# Range: Add an element in the middle +0 ipset -A test 2.0.200.214,00:11:22:33:44:57 +# Range: Delete the same element +0 ipset -D test 2.0.200.214 # Range: List set 0 ipset -L test > .foo # Range: Check listing @@ -35,7 +41,7 @@ # Range: Delete test set 0 ipset -X test # Network: Try to create a set from an invalid network -2 ipset -N test macipmap --network 2.0.0.0/15 +1 ipset -N test macipmap --network 2.0.0.0/15 # Network: Create a set from a valid network 0 ipset -N test macipmap --network 2.0.0.0/16 # Network: Add lower boundary @@ -56,6 +62,14 @@ 1 ipset -A test 1.255.255.255 # Network: Try to add value after upper boundary 1 ipset -A test 2.1.0.0 +# Network: Try to add value with MAC +0 ipset -A test 2.0.0.2,00:11:22:33:44:55 +# Network: Test value with invalid MAC +1 ipset -T test 2.0.0.2,00:11:22:33:44:56 +# Network: Test value with valid MAC +0 ipset -T test 2.0.0.2,00:11:22:33:44:55 +# Network: Add MAC to already added element +0 ipset -A test 2.0.255.255,00:11:22:33:44:56 # Network: List set 0 ipset -L test > .foo # Network: Check listing @@ -64,4 +78,48 @@ 0 ipset -F test # Network: Delete test set 0 ipset -X test +# Range: Create a set from a valid range with timeout +0 ipset -N test macipmap --from 2.0.0.1 --to 2.1.0.0 timeout 10 +# Range: Add lower boundary +0 ipset -A test 2.0.0.1 timeout 8 +# Range: Add upper boundary +0 ipset -A test 2.1.0.0 timeout 5 +# Range: Test lower boundary +0 ipset -T test 2.0.0.1 +# Range: Test upper boundary +0 ipset -T test 2.1.0.0 +# Range: Test value not added to the set +1 ipset -T test 2.0.0.2 +# Range: Test value before lower boundary +1 ipset -T test 2.0.0.0 +# Range: Test value after upper boundary +1 ipset -T test 2.1.0.1 +# Range: Try to add value before lower boundary +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 timeout 8 +# 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: Add MAC to already added element +0 ipset -A test 2.0.0.1,00:11:22:33:44:56 +# Range: Add an element in the middle +0 ipset -A test 2.0.200.214,00:11:22:33:44:57 +# Range: Delete the same element +0 ipset -D test 2.0.200.214 +# Range: Check listing +0 ipset -L test | grep '2.0.0.2,00:11:22:33:44:55 timeout' >/dev/null +# Range: wait 10s so that elements can timeout +0 sleep 10 +# Range: List set +0 ipset -L test > .foo +# Range: Check listing +0 diff .foo macipmap.t.list2 && rm .foo +# Range: Flush test set +0 ipset -F test +# Range: Delete test set +0 ipset -X test # eof diff --git a/tests/macipmap.t.list0 b/tests/macipmap.t.list0 index 157ba53..f34c882 100644 --- a/tests/macipmap.t.list0 +++ b/tests/macipmap.t.list0 @@ -1,9 +1,11 @@ Name: test -Type: macipmap +Type: bitmap:ip,mac +Header: range 2.0.0.1-2.1.0.0 +Elements: 3 +Size in memory: 458752 References: 0 -Header: from: 2.0.0.1 to: 2.1.0.0 Members: -2.0.0.1,00:00:00:00:00:00 +2.0.0.1,00:11:22:33:44:56 2.0.0.2,00:11:22:33:44:55 -2.1.0.0,00:00:00:00:00:00 +2.1.0.0 diff --git a/tests/macipmap.t.list1 b/tests/macipmap.t.list1 index dc0dc75..cbdf127 100644 --- a/tests/macipmap.t.list1 +++ b/tests/macipmap.t.list1 @@ -1,8 +1,11 @@ Name: test -Type: macipmap +Type: bitmap:ip,mac +Header: range 2.0.0.0-2.0.255.255 +Elements: 3 +Size in memory: 458752 References: 0 -Header: from: 2.0.0.0 to: 2.0.255.255 Members: -2.0.0.0,00:00:00:00:00:00 -2.0.255.255,00:00:00:00:00:00 +2.0.0.0 +2.0.0.2,00:11:22:33:44:55 +2.0.255.255,00:11:22:33:44:56 diff --git a/tests/portmap.t b/tests/portmap.t index 12cdc1f..5e05849 100644 --- a/tests/portmap.t +++ b/tests/portmap.t @@ -18,6 +18,10 @@ 1 ipset -A test 0 # Range: Try to add value after upper boundary 1 ipset -A test 1025 +# Range: Add element in the middle +0 ipset -A test 567 +# Range: Delete the same element +0 ipset -D test 567 # Range: List set 0 ipset -L test > .foo # Range: Check listing @@ -46,4 +50,30 @@ 0 ipset -F test # Full: Delete test set 0 ipset -X test +# Full: Create a full set of ports and timeout +0 ipset -N test portmap --from 0 --to 65535 timeout 8 +# Full: Add lower boundary +0 ipset -A test 0 timeout 5 +# Full: Add upper boundary +0 ipset -A test 65535 timeout 0 +# Full: Test lower boundary +0 ipset -T test 0 +# Full: Test upper boundary +0 ipset -T test 65535 +# Full: Test value not added to the set +1 ipset -T test 1 +# Full: Add element in the middle +0 ipset -A test 567 +# Full: Delete the same element +0 ipset -D test 567 +# Full: sleep 10s so that elements can timeout +0 sleep 10 +# Full: List set +0 ipset -L test > .foo +# Full: Check listing +# 0 diff .foo portmap.t.list2 && rm .foo +# Full: Flush test set +0 ipset -F test +# Full: Delete test set +0 ipset -X test # eof diff --git a/tests/portmap.t.list0 b/tests/portmap.t.list0 index 809ffe1..ed0b7d1 100644 --- a/tests/portmap.t.list0 +++ b/tests/portmap.t.list0 @@ -1,7 +1,9 @@ Name: test -Type: portmap +Type: bitmap:port +Header: range 1-1024 +Elements: 2 +Size in memory: 128 References: 0 -Header: from: 1 to: 1024 Members: 1 1024 diff --git a/tests/portmap.t.list1 b/tests/portmap.t.list1 index 9c9b38d..f67b128 100644 --- a/tests/portmap.t.list1 +++ b/tests/portmap.t.list1 @@ -1,7 +1,9 @@ Name: test -Type: portmap +Type: bitmap:port +Header: range 0-65535 +Elements: 2 +Size in memory: 8192 References: 0 -Header: from: 0 to: 65535 Members: 0 65535 diff --git a/tests/runtest.sh b/tests/runtest.sh index d063cd7..a045905 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -1,18 +1,29 @@ #!/bin/bash tests="init" -tests="$tests ipmap macipmap portmap" -tests="$tests iphash nethash ipporthash" -tests="$tests ipportiphash ipportnethash" -tests="$tests iptree iptreemap" -tests="$tests setlist" +tests="$tests ipmap bitmap:ip macipmap portmap" +tests="$tests iphash hash:ip" +# nethash ipporthash" +# tests="$tests ipportiphash ipportnethash" +# tests="$tests iptree iptreemap" +# tests="$tests setlist" if [ "$1" ]; then tests="init $@" fi +if [ ! -x ../src/ipset ]; then + echo "Please rune `make` first and create the ipset binary." + exit 1 +fi + for types in $tests; do - ipset -X test >/dev/null 2>&1 + ../src/ipset -X test >/dev/null 2>&1 + if [ -f $types ]; then + filename=$types + else + filename=$types.t + fi while read ret cmd; do case $ret in \#) @@ -26,7 +37,8 @@ for types in $tests; do ;; esac echo -ne "$types: $what: " - eval $cmd >/dev/null 2>&1 + cmd=`echo $cmd | sed 's/ipset/..\/src\/ipset 2>.foo.err/'` + eval $cmd r=$? # echo $ret $r if [ "$ret" = "$r" ]; then @@ -34,22 +46,26 @@ for types in $tests; do else echo "FAILED" echo "Failed test: $cmd" + cat .foo.err exit 1 fi # sleep 1 - done < $types.t + done < $filename done # Remove test sets created by setlist.t -ipset -X +../src/ipset -X >/dev/null 2>&1 for x in $tests; do case $x in init) ;; *) - rmmod ip_set_$x >/dev/null 2>&1 + for x in `lsmod | grep ip_set_ | awk '{print $1}'`; do + rmmod $x >/dev/null 2>&1 + done ;; esac done rmmod ip_set >/dev/null 2>&1 +rm -f .foo.err echo "All tests are passed" diff --git a/tests/sort.sh b/tests/sort.sh index a01d066..907148a 100755 --- a/tests/sort.sh +++ b/tests/sort.sh @@ -1,5 +1,6 @@ #!/bin/sh -awk '/^[A-Za-z]+:/ { print $0 }' $1 > .foo -awk '!/^[A-Za-z]+:/ && !/inding/ { print $0 }' | sort >> .foo +head -n 7 $1 > .foo +tail -n +8 $1 | grep '[[:alnum:]]' | sort >> .foo +echo >> .foo rm $1 -- cgit v1.2.3