From owner-svn-src-projects@FreeBSD.ORG Thu Jul 26 14:03:30 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98A881065670; Thu, 26 Jul 2012 14:03:30 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7930A8FC12; Thu, 26 Jul 2012 14:03:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6QE3UXf091389; Thu, 26 Jul 2012 14:03:30 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6QE3UAt091388; Thu, 26 Jul 2012 14:03:30 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201207261403.q6QE3UAt091388@svn.freebsd.org> From: Monthadar Al Jaberi Date: Thu, 26 Jul 2012 14:03:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238807 - projects/net80211_testsuite/wtap/008 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jul 2012 14:03:30 -0000 Author: monthadar Date: Thu Jul 26 14:03:29 2012 New Revision: 238807 URL: http://svn.freebsd.org/changeset/base/238807 Log: Added test 008 - mesh should be empty when peer goes down. Added: projects/net80211_testsuite/wtap/008/ projects/net80211_testsuite/wtap/008/test.sh (contents, props changed) Added: projects/net80211_testsuite/wtap/008/test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/net80211_testsuite/wtap/008/test.sh Thu Jul 26 14:03:29 2012 (r238807) @@ -0,0 +1,205 @@ +#!/bin/sh + +# This program requires: +# + wtap - to create/destroy the wtap instances +# + vis_map - to setup the visibility map between wtap instances +# + vimage - to configure/destroy vtap nodes + +# The name of the test that will be printed in the begining +TEST_NBR="008" +TEST_NAME="mesh should be empty when peer goes down" + +# Return value from this test, 0 success failure otherwise +TEST_RESULT=127 + +# The number of nodes to test +NBR_NODES=3 + +# The subnet prefix +IP_SUBNET="192.168.2." + +cmd() +{ + echo "***${TEST_NBR}*** " $* + $* +} + +info() +{ + echo "***${TEST_NBR}*** " $* +} + +descr() +{ + cat < B <-> C + +* node B goes down after 5 seconds +* node A should not have any mesh path to B and C + +EOL +} + +setup() +{ + # Initialize output file + info "TEST: ${TEST_NAME}" + info `date` + + # Create wtap/vimage nodes + for i in `seq 1 ${NBR_NODES}`; do + wtap_if="`expr $i - 1`" + info "Setup: vimage $i - wtap$wtap_if" + cmd vimage -c $i + cmd wtap c $wtap_if + done + + # Set visibility for each node to see the + # next node. + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + j="`expr ${i} + 1`" + cmd vis_map a $i $j + cmd vis_map a $j $i + done + + # Makes the visibility map plugin deliver packets to resp. dest. + cmd vis_map o + + # Create each wlan subinterface, place into the correct vnet + for i in `seq 0 ${n}`; do + vnet="`expr ${i} + 1`" + cmd ifconfig wlan${i} create wlandev wtap${i} wlanmode mesh + cmd ifconfig wlan${i} meshid mymesh + cmd wlandebug -i wlan${i} hwmp+mesh + cmd ifconfig wlan${i} vnet ${vnet} + cmd jexec ${vnet} ifconfig wlan${i} up + cmd jexec ${vnet} ifconfig wlan${i} inet ${IP_SUBNET}${vnet} + done +} + +run() +{ + NBR_TESTS=4 NBR_FAIL=0 + + cmd sleep 5 + + cmd jexec 1 ping -q -t 5 -c 5 -o ${IP_SUBNET}3 + + TMP=`jexec 1 ifconfig wlan0 list mesh | grep "00:98:9a:98:96:98" | wc -l` + if [ $TMP != "2" ]; then # Node C jumps through node B + info "Node B is not in A's 'list mesh' table" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" + fi + TMP=`jexec 1 ifconfig wlan0 list mesh | grep "00:98:9a:98:96:99" | wc -l` + if [ $TMP != "1" ]; then + info "Node C is not in A's 'list mesh' table" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" + fi + + # take node B down + cmd jexec 2 ifconfig wlan1 down + + cmd sleep 1 + + TMP=`jexec 1 ifconfig wlan0 list mesh | grep "00:98:9a:98:96:98" | wc -l` + if [ $TMP != "0" ]; then + info "Node B still in A's 'list mesh' table" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" + fi + TMP=`jexec 1 ifconfig wlan0 list mesh | grep "00:98:9a:98:96:99" | wc -l` + if [ $TMP != "0" ]; then + info "Node C still in A's 'list mesh' table" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" + fi + + if [ $NBR_FAIL = 0 ]; then + info "ALL TESTS PASSED" + TEST_RESULT=0 + else + info "FAILED ${NBR_FAIL} of ${NBR_TESTS} TESTS" + fi +} + +teardown() +{ + cmd vis_map c + # Unlink all links + # XXX: this is a limitation of the current plugin, + # no way to reset vis_map without unload wtap. + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + j="`expr ${i} + 1`" + cmd vis_map d $i $j + cmd vis_map d $j $i + done + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + vnet="`expr ${i} + 1`" + cmd cat /dev/wtap${i} > wtap${i}.debug + cmd jexec ${vnet} ifconfig wlan${i} destroy + done + for i in `seq 1 ${NBR_NODES}`; do + wtap_if="`expr $i - 1`" + cmd wtap d ${wtap_if} + cmd vimage -d ${i} + done + exit ${TEST_RESULT} +} + +EXEC_SETUP=0 +EXEC_RUN=0 +EXEC_TEARDOWN=0 +while [ "$#" -gt "0" ] +do + case $1 in + 'all') + EXEC_SETUP=1 + EXEC_RUN=1 + EXEC_TEARDOWN=1 + ;; + 'setup') + EXEC_SETUP=1 + ;; + 'run') + EXEC_RUN=1 + ;; + 'teardown') + EXEC_TEARDOWN=1 + ;; + 'descr') + descr + exit 0 + ;; + *) + echo "$0 {all | setup | run | teardown | descr}" + exit 127 + ;; + esac + shift +done + +if [ $EXEC_SETUP = 1 ]; then + setup +fi +if [ $EXEC_RUN = 1 ]; then + run +fi +if [ $EXEC_TEARDOWN = 1 ]; then + teardown +fi + +exit 0 +