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 TCID=if-updown 22 23 . if-lib.sh 24 25 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))} 26 27 test_body() 28 { 29 local cmd_type=$1 30 31 case $cmd_type in 32 if_cmd) local cmd_name='ifconfig' ;; 33 ip_cmd) local cmd_name='ip' ;; 34 *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" 35 esac 36 37 local iface=$(tst_iface) 38 39 tst_resm TINFO "'$cmd_name ups/downs $iface $IF_UPDOWN_TIMES times" 40 tst_resm TINFO "check connectivity interval is $CHECK_INTERVAL" 41 42 local cnt=1 43 while [ $cnt -le $IF_UPDOWN_TIMES ]; do 44 case $cmd_type in 45 if_cmd) ifconfig $iface down ;; 46 ip_cmd) ip link set $iface down ;; 47 esac 48 if [ $? -ne 0 ]; then 49 tst_resm TFAIL "Failed to down $iface" 50 return 51 fi 52 53 case $cmd_type in 54 if_cmd) ifconfig $iface up ;; 55 ip_cmd) ip link set $iface up ;; 56 esac 57 if [ $? -ne 0 ]; then 58 tst_resm TFAIL "Failed to up $iface" 59 return 60 fi 61 62 check_connectivity $cnt restore_ip || return 63 64 cnt=$(($cnt + 1)) 65 done 66 67 tst_resm TPASS "Test is finished correctly" 68 } 69 70 setup 71 72 tst_check_cmds ifconfig 73 74 test_body 'if_cmd' 75 test_body 'ip_cmd' 76 77 tst_exit 78