lib.sh (cdd5b5a9761fd66d17586e4f4ba6588c70e640ea) lib.sh (25ae948b447881bf689d459cd5bd4629d9c04b20)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4##############################################################################
5# Defines
6
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4##############################################################################
5# Defines
6
7# Kselftest framework requirement - SKIP code is 4.
8ksft_skip=4
9
10# Can be overridden by the configuration file.
11PING=${PING:=ping}
12PING6=${PING6:=ping6}
13MZ=${MZ:=mausezahn}
14ARPING=${ARPING:=arping}
15TEAMD=${TEAMD:=teamd}
16WAIT_TIME=${WAIT_TIME:=5}
17PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}

--- 18 unchanged lines hidden (view full) ---

36if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
37 relative_path="."
38fi
39
40if [[ -f $relative_path/forwarding.config ]]; then
41 source "$relative_path/forwarding.config"
42fi
43
7# Can be overridden by the configuration file.
8PING=${PING:=ping}
9PING6=${PING6:=ping6}
10MZ=${MZ:=mausezahn}
11ARPING=${ARPING:=arping}
12TEAMD=${TEAMD:=teamd}
13WAIT_TIME=${WAIT_TIME:=5}
14PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}

--- 18 unchanged lines hidden (view full) ---

33if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
34 relative_path="."
35fi
36
37if [[ -f $relative_path/forwarding.config ]]; then
38 source "$relative_path/forwarding.config"
39fi
40
41source ../lib.sh
44##############################################################################
45# Sanity checks
46
47check_tc_version()
48{
49 tc -j &> /dev/null
50 if [[ $? -ne 0 ]]; then
51 echo "SKIP: iproute2 too old; tc is missing JSON support"

--- 338 unchanged lines hidden (view full) ---

390
391log_info()
392{
393 local msg=$1
394
395 echo "INFO: $msg"
396}
397
42##############################################################################
43# Sanity checks
44
45check_tc_version()
46{
47 tc -j &> /dev/null
48 if [[ $? -ne 0 ]]; then
49 echo "SKIP: iproute2 too old; tc is missing JSON support"

--- 338 unchanged lines hidden (view full) ---

388
389log_info()
390{
391 local msg=$1
392
393 echo "INFO: $msg"
394}
395
398busywait()
399{
400 local timeout=$1; shift
401
402 local start_time="$(date -u +%s%3N)"
403 while true
404 do
405 local out
406 out=$("$@")
407 local ret=$?
408 if ((!ret)); then
409 echo -n "$out"
410 return 0
411 fi
412
413 local current_time="$(date -u +%s%3N)"
414 if ((current_time - start_time > timeout)); then
415 echo -n "$out"
416 return 1
417 fi
418 done
419}
420
421not()
422{
423 "$@"
424 [[ $? != 0 ]]
425}
426
427get_max()
428{

--- 798 unchanged lines hidden (view full) ---

1227{
1228 RET=0
1229
1230 ping_do $1 $2
1231 check_err $?
1232 log_test "ping$3"
1233}
1234
396not()
397{
398 "$@"
399 [[ $? != 0 ]]
400}
401
402get_max()
403{

--- 798 unchanged lines hidden (view full) ---

1202{
1203 RET=0
1204
1205 ping_do $1 $2
1206 check_err $?
1207 log_test "ping$3"
1208}
1209
1210ping_test_fails()
1211{
1212 RET=0
1213
1214 ping_do $1 $2
1215 check_fail $?
1216 log_test "ping fails$3"
1217}
1218
1235ping6_do()
1236{
1237 local if_name=$1
1238 local dip=$2
1239 local args=$3
1240 local vrf_name
1241
1242 vrf_name=$(master_name_get $if_name)

--- 6 unchanged lines hidden (view full) ---

1249{
1250 RET=0
1251
1252 ping6_do $1 $2
1253 check_err $?
1254 log_test "ping6$3"
1255}
1256
1219ping6_do()
1220{
1221 local if_name=$1
1222 local dip=$2
1223 local args=$3
1224 local vrf_name
1225
1226 vrf_name=$(master_name_get $if_name)

--- 6 unchanged lines hidden (view full) ---

1233{
1234 RET=0
1235
1236 ping6_do $1 $2
1237 check_err $?
1238 log_test "ping6$3"
1239}
1240
1241ping6_test_fails()
1242{
1243 RET=0
1244
1245 ping6_do $1 $2
1246 check_fail $?
1247 log_test "ping6 fails$3"
1248}
1249
1257learning_test()
1258{
1259 local bridge=$1
1260 local br_port1=$2 # Connected to `host1_if`.
1261 local host1_if=$3
1262 local host2_if=$4
1263 local mac=de:ad:be:ef:13:37
1264 local ageing_time

--- 703 unchanged lines hidden ---
1250learning_test()
1251{
1252 local bridge=$1
1253 local br_port1=$2 # Connected to `host1_if`.
1254 local host1_if=$3
1255 local host2_if=$4
1256 local mac=de:ad:be:ef:13:37
1257 local ageing_time

--- 703 unchanged lines hidden ---