#!/bin/bash## This test is for checking rtnetlink callpaths, and get as much coverage as possible.## set -eALL_TESTS=" kci_test_polrouting kci_test_route_get kci_test_addrlft kci_test_promote_secondaries kci_test_tc kci_test_gre kci_test_gretap kci_test_ip6gretap kci_test_erspan kci_test_ip6erspan kci_test_bridge kci_test_addrlabel kci_test_ifalias kci_test_vrf kci_test_encap kci_test_macsec kci_test_macsec_offload kci_test_ipsec kci_test_ipsec_offload kci_test_fdb_get kci_test_neigh_get kci_test_bridge_parent_id kci_test_address_proto kci_test_enslave_bonding"devdummy="test-dummy0"VERBOSE=0PAUSE=no
PAUSE_ON_FAIL=no
source lib.sh
# set global exit status, but never reset nonzero one.
check_err(){if[$ret -eq 0];thenret=$1fi}# same but inverted -- used when command must fail for test to pass
check_fail(){if[$1 -eq 0];thenret=1fi}
run_cmd_common(){localcmd="$*"local out
if["$VERBOSE"="1"];thenecho"COMMAND: ${cmd}"fiout=$($cmd2>&1)rc=$?if["$VERBOSE"="1" -a -n "$out"];thenecho" $out"fireturn$rc}
run_cmd(){
run_cmd_common "$@"rc=$?
check_err $rcreturn$rc}
run_cmd_fail(){
run_cmd_common "$@"rc=$?
check_fail $rcreturn$rc}
run_cmd_grep_common(){localfind="$1";shiftlocalcmd="$*"local out
if["$VERBOSE"="1"];thenecho"COMMAND: ${cmd} 2>&1 | grep -q '${find}'"fiout=$($cmd2>&1| grep -q "${find}"2>&1)return$?}
run_cmd_grep(){
run_cmd_grep_common "$@"rc=$?
check_err $rcreturn$rc}
run_cmd_grep_fail(){
run_cmd_grep_common "$@"rc=$?
check_fail $rcreturn$rc}
end_test(){echo"$*"["${VERBOSE}"="1"]&&echoif[[$ret -ne 0]]&&[["${PAUSE_ON_FAIL}"="yes"]];thenecho"Hit enter to continue"read a
fi;if["${PAUSE}"="yes"];thenecho"Hit enter to continue"read a
fi}
kci_add_dummy(){
run_cmd ip link add name "$devdummy"type dummy
run_cmd ip link set"$devdummy" up
}
kci_del_dummy(){
run_cmd ip link del dev "$devdummy"}
kci_test_netconf(){dev="$1"r=$ret
run_cmd ip netconf show dev "$dev"for f in 46;do
run_cmd ip -$f netconf show dev "$dev"doneif[$ret -ne 0]