diff --git a/test/Makefile.am b/test/Makefile.am index 952d5a5..a59aa0f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = adv.sh basic.sh batch.sh bridge.sh dyn.sh expire.sh gre.sh ipv6.sh EXTRA_DIST += include.sh isolated.sh join.sh joinlen.sh lib.sh lost.sh -EXTRA_DIST += multi.sh mem.sh mrcache.sh mrcache6.sh mrdisc.sh poison.sh +EXTRA_DIST += multi.sh mem.sh mrcache.sh mrdisc.sh poison.sh EXTRA_DIST += reload.sh reload6.sh vlan.sh vrfy.sh CLEANFILES = *~ *.trs *.log TEST_EXTENSIONS = .sh @@ -21,7 +21,6 @@ TESTS += joinlen.sh TESTS += lost.sh TESTS += mem.sh TESTS += mrcache.sh -TESTS += mrcache6.sh TESTS += mrdisc.sh TESTS += multi.sh TESTS += poison.sh diff --git a/test/lib.sh b/test/lib.sh index 6e77ed2..901446c 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -23,6 +23,11 @@ FAIL() exit 99 } +CHECK() +{ + [ "$@" ] || FAIL "$*" +} + OK() { print "TEST: OK" diff --git a/test/mrcache.sh b/test/mrcache.sh index 105ab7a..24a67bb 100755 --- a/test/mrcache.sh +++ b/test/mrcache.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Verifies IPv4 (S,G) add and remove route via IPC bites in kernel. -# Twist: uses only one interface, inteded to mimic Debian test. +# Verifies both IPv4 and IPv6 (S,G) add, including remove route via IPC bites in kernel. +# Twist: uses only one interface, inteded to mimic Debian tests. #set -x # shellcheck source=/dev/null @@ -8,15 +8,68 @@ debug() { + echo "/proc/net/ip_mr_cache -------------------------------------------------------DEBUG-" cat /proc/net/ip_mr_cache + echo "ip mroute -------------------------------------------------------------------DEBUG-" ip mroute - echo "-----------------------------------------------------------------------------------" + echo "smcroutectl -----------------------------------------------------------------DEBUG-" ../src/smcroutectl -pd -u "/tmp/$NM/sock" + echo "-----------------------------------------------------------------------------DEBUG/" +} + +check_add() +{ + s=$1 + g=$2 + input=$3 + output=$4 + + print "Adding IPC route ($s,$g) inbound $input outbound $output ..." + ../src/smcroutectl -u "/tmp/$NM/sock" add "$input" "$s" "$g" "$output" + # sleep 1 + + print "Verifying kernel route ($s,$g) Iif: $input Oif: $output ..." +# debug + ip mroute > "/tmp/$NM/routes" + ip -6 mroute >> "/tmp/$NM/routes" + sg=$(awk "/$s,$g/{print \$1}" "/tmp/$NM/routes") + iif=$(awk "/$s,$g/{print \$3}" "/tmp/$NM/routes") + oif=$(awk "/$s,$g/{print \$5}" "/tmp/$NM/routes") + state=$(awk "/$s,$g/{print \$7}" "/tmp/$NM/routes") + CHECK "$sg" = "($s,$g)" + CHECK "$iif" = "$input" + CHECK "$oif" = "$output" + CHECK "$state" = "resolved" +} + +check_del() +{ + s=$1 + g=$2 + input=$3 + output=$4 + + print "Removing IPC route ($s,$g) inbound $input outbound $output ..." + ../src/smcroutectl -u "/tmp/$NM/sock" del "$input" "$s" "$g" +# sleep 1 + + print "Verifying kernel route for ($s,$g) has been removed ..." + #debug + ip mroute > "/tmp/$NM/routes2" + sg=$(awk "/$s,$g/{print \$1}" "/tmp/$NM/routes2") + CHECK -z "$sg" +} + +test_one() +{ + check_add $1 $2 $3 $4 + check_del $1 $2 $3 $4 } print "Creating world ..." topo basic ip addr add 10.0.0.1/24 dev a1 +ip addr add fc01::1/64 dev a1 ip -br a print "Creating config ..." @@ -29,24 +82,6 @@ print "Starting smcrouted ..." ../src/smcrouted -f "/tmp/$NM/conf" -n -P "/tmp/$NM/pid" -l debug -u "/tmp/$NM/sock" & sleep 1 -print "Adding IPC route ..." -../src/smcroutectl -u "/tmp/$NM/sock" add a1 10.0.0.1 224.0.1.20 a1 -sleep 1 - -print "Verifying kernel route ..." -debug -if ! grep "140100E0 0100000A 2 0 0 0 2:1" /proc/net/ip_mr_cache; then - FAIL -fi - -print "Removing IPC route ..." -../src/smcroutectl -u "/tmp/$NM/sock" del a1 10.0.0.1 224.0.1.20 -sleep 1 - -print "Verifying kernel route ..." -debug -if grep "140100E0 0100000A" /proc/net/ip_mr_cache; then - FAIL -fi - +test_one 10.0.0.1 224.0.1.20 a1 a1 +test_one fc01::1 ff01::114 a1 a1 OK diff --git a/test/mrcache6.sh b/test/mrcache6.sh deleted file mode 100755 index 76aa474..0000000 --- a/test/mrcache6.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Verifies IPv6 (S,G) add and remove route via IPC bites in kernel. -# Twist: uses only one interface, inteded to mimic Debian test. -#set -x - -# shellcheck source=/dev/null -. "$(dirname "$0")/lib.sh" - -debug() -{ - cat /proc/net/ip6_mr_cache - ip -6 mroute - echo "-----------------------------------------------------------------------------------" - ../src/smcroutectl -pd -u "/tmp/$NM/sock" -} - -print "Creating world ..." -topo basic -ip addr add fc01::1/64 dev a1 -ip -br a - -print "Creating config ..." -cat < "/tmp/$NM/conf" -# empty -EOF -cat "/tmp/$NM/conf" - -print "Starting smcrouted ..." -../src/smcrouted -f "/tmp/$NM/conf" -n -P "/tmp/$NM/pid" -l debug -u "/tmp/$NM/sock" & -sleep 1 - -print "Adding IPC route ..." -../src/smcroutectl -u "/tmp/$NM/sock" add a1 fc01::1 ff01:0:0:0:0:0:0:114 a1 -sleep 1 - -print "Verifying kernel route ..." -debug -if ! grep "ff01:0000:0000:0000:0000:0000:0000:0114 fc01:0000:0000:0000:0000:0000:0000:0001 2 0 0 0 2:1" /proc/net/ip6_mr_cache; then - FAIL -fi - -print "Removing IPC route ..." -../src/smcroutectl -u "/tmp/$NM/sock" del a1 fc01::1 ff01:0:0:0:0:0:0:114 -sleep 1 - -print "Verifying kernel route ..." -debug -if grep "ff01:0000:0000:0000:0000:0000:0000:0114 fc01:0000:0000:0000:0000:0000:0000:0001" /proc/net/ip_mr_cache; then - FAIL -fi - -OK