From owner-svn-src-projects@FreeBSD.ORG Sat Apr 14 00:40:33 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 8F1C81065675; Sat, 14 Apr 2012 00:40:33 +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 7A79C8FC0C; Sat, 14 Apr 2012 00:40:33 +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 q3E0eXRk005315; Sat, 14 Apr 2012 00:40:33 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3E0eXX9005312; Sat, 14 Apr 2012 00:40:33 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201204140040.q3E0eXX9005312@svn.freebsd.org> From: Monthadar Al Jaberi Date: Sat, 14 Apr 2012 00:40:33 +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: r234259 - projects/net80211_testsuite/wtap/001 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: Sat, 14 Apr 2012 00:40:33 -0000 Author: monthadar Date: Sat Apr 14 00:40:32 2012 New Revision: 234259 URL: http://svn.freebsd.org/changeset/base/234259 Log: * Modified so that the test script returns 0 on success otherwise failure, which is returned in teardown(); * Added info() routine that should be used instead of calling echo directly; * Modified loggin format to print the number of the test on each log line; * Modified loggin output to print the name of the test and date of running the test; * Modified run() so that it print either "ALL TEST PASSED" or how many test failed with which ones; * Modified teardown() to explicitly unlink the wtap simulator visibility between the nodes; * Changed how the script parses the command line arguments, and add 'all' flag that equals to 'setup run teardown'; Approved by: adrian (mentor) Modified: projects/net80211_testsuite/wtap/001/test.sh Modified: projects/net80211_testsuite/wtap/001/test.sh ============================================================================== --- projects/net80211_testsuite/wtap/001/test.sh Sat Apr 14 00:40:13 2012 (r234258) +++ projects/net80211_testsuite/wtap/001/test.sh Sat Apr 14 00:40:32 2012 (r234259) @@ -5,8 +5,14 @@ # + vis_map - to setup the visibility map between wtap instances # + vimage - to configure/destroy vtap nodes -# The number of nodes to test +# The name of the test that will be printed in the begining +TEST_NBR="001" +TEST_NAME="4 nodes in a line topology" + +# Return value from this test, 0 success failure otherwise +TEST_RESULT=127 +# The number of nodes to test NBR_NODES=4 # The subnet prefix @@ -14,10 +20,15 @@ IP_SUBNET="192.168.2." cmd() { - echo "*** " $* + echo "***${TEST_NBR}*** " $* $* } +info() +{ + echo "***${TEST_NBR}*** " $* +} + descr() { cat < ${j}.." + info "Checking ${i} -> ${j}.." + NBR_TESTS="`expr ${NBR_TESTS} + 1`" # Return after a single successful packet cmd jexec $i ping -q -t 5 -c 5 \ -o ${IP_SUBNET}${j} if [ "$?" = "0" ]; then - echo "CHECK: ${i} -> ${j}: SUCCESS" + info "CHECK: ${i} -> ${j}: SUCCESS" else - echo "CHECK: ${i} -> ${j}: FAILURE" + info "CHECK: ${i} -> ${j}: FAILURE" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" fi fi done done + 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`" @@ -114,30 +149,50 @@ teardown() cmd wtap d ${wtap_if} cmd vimage -d ${i} done + exit ${TEST_RESULT} } -case $1 in - 'setup') - setup - exit 0 - ;; - 'run') - run - exit 0 - ;; - 'teardown') - teardown - exit 0 - ;; - 'descr') - descr - exit 0 - ;; - *) - echo "$0 {setup | run | teardown | descr}" - exit 127 - ;; -esac +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