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