From: <sk...@li...> - 2008-08-29 13:09:46
|
The coming patch stack fixes some of the testcases sent earlier on the list by Veerendra and adds new testcases for testing network namespace. The patches provides infrastructure for tcp testcass and add one testcase for ping command test. Content-Disposition: inline; filename=add-ping-test-in-tcp-cmds.patch This patch adds the ping command testcase for the network namespace containers. The patch applies on top of the patchset sent for other netns testcases. Original copyright and history included. Signed-off-by: Sudhir Kumar <sk...@li...> Index: containers/netns/tcp/ping/ns_ping01.sh =================================================================== --- /dev/null +++ containers/netns/tcp/ping/ns_ping01.sh @@ -0,0 +1,106 @@ +#! /bin/sh +#*********************************************************************** +# +# Copyright (c) International Business Machines Corp., 2008 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this pronram; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# +# FILE : ping +# +# PURPOSE: To test the basic functionality of the `ping` command. +# +# SETUP: Assumes the child namespcae veth device address is defined in file +# initialize.sh as IP1 +# +# HISTORY: +# 06/06/03 Manoj Iyer ma...@ma... +# - Modified testcase to use test APIs and also fixed minor bugs +# 03/01 Robbie Williamson (ro...@us...) +# -Ported +# 21/08/08 Sudhir Kumar <sk...@li...> +# - Modified the testcase for testing into the containers environment +# +# +#*********************************************************************** +# Uncomment line below for debug output +#trace_logic=${trace_logic:-"set -x"} +$trace_logic + +source initialize.sh ; +TC=ping + +RHOST=$IP1 +COUNT=${COUNT:-2} +SLEEPTIME=${SLEEPTIME:-0} +PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"} + +# FUNCTION: exists +# Checks whether a command exist on system or not +exists() +{ + for cmd in $1 + do + which $cmd 2>&1 1>/dev/null + if [ $? -ne 0 ] ;then + tst_resm TBROK "Test broke: command $cmd not found" + exit 1 + fi + done +} + + +# FUNCTION: run_test +# PURPOSE: Executes the testcases. + +run_test() +{ + $trace_logic + tst_resm TINFO "ping with different size ICMP packets" + for packetsize in $PACKETSIZES + do + tst_resm TINFO "calling ping with packet size = $packetsize" + ping -R -c $COUNT -s $packetsize $RHOST 2>&1 1>/dev/null + [ $? -eq 0 ] || end_test "failed: ping -c $COUNT + -s $packetsize $RHOST" + sleep $SLEEPTIME + done +} + +# FUNCTION NAME: end_test (does cleanup) +# PARAMETERS: pass string to be printed if the testcase fails + +end_test() +{ + $trace_logic + + if [ $# -eq 0 ]; then + tst_resm TPASS "Test Successful"; + exit 0; + else + tst_resm TFAIL "Test Failed: $@" + exit 1 + fi +} + +# FUNCTION: MAIN + +export TCID="ping01" +export TST_TOTAL=1 +export TST_COUNT=1 +exists "ping" +run_test +end_test -- Regards Sudhir Kumar Linux Technology Center IBM, India. |