1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2017-2022 Petr Vorel <pvorel@suse.cz> 4f08c3bdfSopenharmony_ci# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 5f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2005 6f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ciIF_CMD='ifconfig' 9f08c3bdfSopenharmony_ciTST_CLEANUP="if_cleanup_restore" 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_citest_body() 12f08c3bdfSopenharmony_ci{ 13f08c3bdfSopenharmony_ci local cmd="$CMD" 14f08c3bdfSopenharmony_ci local iface=$(tst_iface) 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci tst_res TINFO "'$cmd' ups/downs $iface $IF_UPDOWN_TIMES times" 17f08c3bdfSopenharmony_ci tst_res TINFO "check connectivity interval is $CHECK_INTERVAL" 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_ci local cnt=1 20f08c3bdfSopenharmony_ci while [ $cnt -le $IF_UPDOWN_TIMES ]; do 21f08c3bdfSopenharmony_ci case $cmd in 22f08c3bdfSopenharmony_ci ifconfig) ifconfig $iface down ;; 23f08c3bdfSopenharmony_ci ip) ip link set $iface down ;; 24f08c3bdfSopenharmony_ci esac 25f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 26f08c3bdfSopenharmony_ci tst_res TFAIL "Failed to down $iface" 27f08c3bdfSopenharmony_ci return 28f08c3bdfSopenharmony_ci fi 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci case $cmd in 31f08c3bdfSopenharmony_ci ifconfig) ifconfig $iface up ;; 32f08c3bdfSopenharmony_ci ip) ip link set $iface up ;; 33f08c3bdfSopenharmony_ci esac 34f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 35f08c3bdfSopenharmony_ci tst_res TFAIL "Failed to up $iface" 36f08c3bdfSopenharmony_ci return 37f08c3bdfSopenharmony_ci fi 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci check_connectivity_interval $cnt restore_ip || return 40f08c3bdfSopenharmony_ci 41f08c3bdfSopenharmony_ci cnt=$(($cnt + 1)) 42f08c3bdfSopenharmony_ci done 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci tst_res TPASS "Test is finished correctly" 45f08c3bdfSopenharmony_ci} 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci. if-lib.sh 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ciCHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))} 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_citst_run 52