• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2017-2018 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. if-lib.sh
11
12CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))}
13
14test_body()
15{
16	local cmd="$CMD"
17	local iface=$(tst_iface)
18
19	tst_res TINFO "'$cmd' ups/downs $iface $IF_UPDOWN_TIMES times"
20	tst_res TINFO "check connectivity interval is $CHECK_INTERVAL"
21
22	local cnt=1
23	while [ $cnt -le $IF_UPDOWN_TIMES ]; do
24		case $cmd in
25		ifconfig) ifconfig $iface down ;;
26		ip) ip link set $iface down ;;
27		esac
28		if [ $? -ne 0 ]; then
29			tst_res TFAIL "Failed to down $iface"
30			return
31		fi
32
33		case $cmd in
34		ifconfig) ifconfig $iface up ;;
35		ip) ip link set $iface up ;;
36		esac
37		if [ $? -ne 0 ]; then
38			tst_res TFAIL "Failed to up $iface"
39			return
40		fi
41
42		check_connectivity_interval $cnt restore_ip || return
43
44		cnt=$(($cnt + 1))
45	done
46
47	tst_res TPASS "Test is finished correctly"
48}
49
50tst_run
51