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