Home | History | Annotate | Download | only in interface
      1 #!/bin/sh
      2 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
      3 # Copyright (c) International Business Machines  Corp., 2005
      4 #
      5 # This program is free software; you can redistribute it and/or
      6 # modify it under the terms of the GNU General Public License as
      7 # published by the Free Software Foundation; either version 2 of
      8 # the License, or (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it would be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     17 #
     18 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com>
     19 
     20 TST_TOTAL=2
     21 
     22 TST_CLEANUP="netstress_cleanup"
     23 
     24 . test_net_stress.sh
     25 
     26 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))}
     27 
     28 test_body()
     29 {
     30 	local cmd_type=$1
     31 
     32 	case $cmd_type in
     33 	if_cmd) local cmd_name='ifconfig' ;;
     34 	ip_cmd) local cmd_name='ip' ;;
     35 	*) tst_brkm TBROK "Unknown test parameter '$cmd_type'"
     36 	esac
     37 
     38 	local iface=$(tst_iface)
     39 
     40 	tst_resm TINFO "'$cmd_name ups/downs $iface $IF_UPDOWN_TIMES times"
     41 	tst_resm TINFO "check connectivity interval is $CHECK_INTERVAL"
     42 
     43 	local cnt=1
     44 	while [ $cnt -le $IF_UPDOWN_TIMES ]; do
     45 		case $cmd_type in
     46 		if_cmd) ifconfig $iface down ;;
     47 		ip_cmd) ip link set $iface down ;;
     48 		esac
     49 		if [ $? -ne 0 ]; then
     50 			tst_resm TFAIL "Failed to down $iface"
     51 			return
     52 		fi
     53 
     54 		case $cmd_type in
     55 		if_cmd) ifconfig $iface up ;;
     56 		ip_cmd) ip link set $iface up ;;
     57 		esac
     58 		if [ $? -ne 0 ]; then
     59 			tst_resm TFAIL "Failed to up $iface"
     60 			return
     61 		fi
     62 
     63 		check_connectivity_interval $cnt restore_ip || return
     64 
     65 		cnt=$(($cnt + 1))
     66 	done
     67 
     68 	tst_resm TPASS "Test is finished correctly"
     69 }
     70 
     71 netstress_setup
     72 
     73 tst_check_cmds ifconfig
     74 
     75 test_body 'if_cmd'
     76 test_body 'ip_cmd'
     77 
     78 tst_exit
     79