Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/if_bridge Add tests for brconfig maxaddr



details:   https://anonhg.NetBSD.org/src/rev/7c55f95d0d41
branches:  trunk
changeset: 805614:7c55f95d0d41
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Jan 08 06:33:11 2015 +0000

description:
Add tests for brconfig maxaddr

diffstat:

 tests/net/if_bridge/t_bridge.sh |  65 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 1 deletions(-)

diffs (87 lines):

diff -r ec593b4c6e42 -r 7c55f95d0d41 tests/net/if_bridge/t_bridge.sh
--- a/tests/net/if_bridge/t_bridge.sh   Thu Jan 08 04:00:31 2015 +0000
+++ b/tests/net/if_bridge/t_bridge.sh   Thu Jan 08 06:33:11 2015 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/atf-sh
-#      $NetBSD: t_bridge.sh,v 1.2 2015/01/07 08:55:01 ozaki-r Exp $
+#      $NetBSD: t_bridge.sh,v 1.3 2015/01/08 06:33:11 ozaki-r Exp $
 #
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -268,6 +268,66 @@
        rump.ifconfig -v shmif0
 }
 
+get_number_of_caches()
+{
+       export RUMP_SERVER=$SOCK2
+       export LD_PRELOAD=/usr/lib/librumphijack.so
+       echo $(($(/sbin/brconfig bridge0 |grep -A 100 "Address cache" |wc -l) - 1))
+       unset LD_PRELOAD
+}
+
+test_brconfig_maxaddr()
+{
+       addr1= addr3= n=
+
+       # Get MAC addresses of the endpoints.
+       export RUMP_SERVER=$SOCK1
+       addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+       export RUMP_SERVER=$SOCK3
+       addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
+       unset RUMP_SERVER
+
+       # Refill the MAC addresses of the endpoints.
+       export RUMP_SERVER=$SOCK1
+       atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+       export RUMP_SERVER=$SOCK2
+       export LD_PRELOAD=/usr/lib/librumphijack.so
+       /sbin/brconfig bridge0
+       atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
+       atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
+
+       # Check the default # of caches is 100
+       atf_check -s exit:0 -o match:"max cache: 100" /sbin/brconfig bridge0
+
+       # Test two MAC addresses are cached
+       n=$(get_number_of_caches)
+       atf_check_equal $n 2
+
+       # Limit # of caches to one
+       atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 1
+       atf_check -s exit:0 -o match:"max cache: 1" /sbin/brconfig bridge0
+       /sbin/brconfig bridge0
+
+       # Test just one address is cached
+       n=$(get_number_of_caches)
+       atf_check_equal $n 1
+
+       # Increase # of caches to two
+       atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 maxaddr 2
+       atf_check -s exit:0 -o match:"max cache: 2" /sbin/brconfig bridge0
+       unset LD_PRELOAD
+
+       # Test we can cache two addresses again
+       export RUMP_SERVER=$SOCK1
+       atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP2
+       export RUMP_SERVER=$SOCK2
+       export LD_PRELOAD=/usr/lib/librumphijack.so
+       /sbin/brconfig bridge0
+       atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
+       atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
+       unset LD_PRELOAD
+}
+
 basic_body()
 {
        setup
@@ -365,6 +425,9 @@
        atf_check -s exit:0 -o match:"timeout: 10" /sbin/brconfig bridge0
        unset LD_PRELOAD
 
+       # Tests brconfig maxaddr.
+       test_brconfig_maxaddr
+
        # TODO: brconfig static/flushall/discover/learn
        # TODO: cache expiration; it takes 5 minutes at least and we want to
        #       wait here so long. Should we have a sysctl to change the period?



Home | Main Index | Thread Index | Old Index