Skip to content

Commit

Permalink
Merge branch 'selftests-rtnetlink-Fix-for-false-negative-return-values'
Browse files Browse the repository at this point in the history
Po-Hsu Lin says:

====================
selftests: rtnetlink: Fix for false-negative return values

This patchset will address the false-negative return value issue
caused by the following:
  1. The return value "ret" in this script will be reset to 0 from
     the beginning of each sub-test in rtnetlink.sh, therefore this
     rtnetlink test will always pass if the last sub-test has passed.
  2. The test result from two sub-tests in kci_test_encap() were not
     being processed, thus they will not affect the final test result
     of this test.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Aug 5, 2020
2 parents 0b0e299 + 72f70c1 commit 889579d
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions tools/testing/selftests/net/rtnetlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# set -e

devdummy="test-dummy0"
ret=0

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
Expand Down Expand Up @@ -66,7 +65,7 @@ kci_test_bridge()
devbr="test-br0"
vlandev="testbr-vlan1"

ret=0
local ret=0
ip link add name "$devbr" type bridge
check_err $?

Expand Down Expand Up @@ -113,7 +112,7 @@ kci_test_gre()
rem=10.42.42.1
loc=10.0.0.1

ret=0
local ret=0
ip tunnel add $gredev mode gre remote $rem local $loc ttl 1
check_err $?
ip link set $gredev up
Expand Down Expand Up @@ -149,7 +148,7 @@ kci_test_gre()
kci_test_tc()
{
dev=lo
ret=0
local ret=0

tc qdisc add dev "$dev" root handle 1: htb
check_err $?
Expand Down Expand Up @@ -184,7 +183,7 @@ kci_test_tc()

kci_test_polrouting()
{
ret=0
local ret=0
ip rule add fwmark 1 lookup 100
check_err $?
ip route add local 0.0.0.0/0 dev lo table 100
Expand All @@ -207,7 +206,7 @@ kci_test_route_get()
{
local hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)

ret=0
local ret=0

ip route get 127.0.0.1 > /dev/null
check_err $?
Expand Down Expand Up @@ -290,7 +289,7 @@ kci_test_promote_secondaries()

kci_test_addrlabel()
{
ret=0
local ret=0

ip addrlabel add prefix dead::/64 dev lo label 1
check_err $?
Expand Down Expand Up @@ -330,7 +329,7 @@ kci_test_addrlabel()

kci_test_ifalias()
{
ret=0
local ret=0
namewant=$(uuidgen)
syspathname="/sys/class/net/$devdummy/ifalias"

Expand Down Expand Up @@ -385,7 +384,7 @@ kci_test_ifalias()
kci_test_vrf()
{
vrfname="test-vrf"
ret=0
local ret=0

ip link show type vrf 2>/dev/null
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -425,7 +424,7 @@ kci_test_vrf()

kci_test_encap_vxlan()
{
ret=0
local ret=0
vxlan="test-vxlan0"
vlan="test-vlan0"
testns="$1"
Expand Down Expand Up @@ -511,7 +510,7 @@ kci_test_encap_vxlan()

kci_test_encap_fou()
{
ret=0
local ret=0
name="test-fou"
testns="$1"

Expand Down Expand Up @@ -548,7 +547,7 @@ kci_test_encap_fou()
kci_test_encap()
{
testns="testns"
ret=0
local ret=0

ip netns add "$testns"
if [ $? -ne 0 ]; then
Expand All @@ -565,15 +564,18 @@ kci_test_encap()
check_err $?

kci_test_encap_vxlan "$testns"
check_err $?
kci_test_encap_fou "$testns"
check_err $?

ip netns del "$testns"
return $ret
}

kci_test_macsec()
{
msname="test_macsec0"
ret=0
local ret=0

ip macsec help 2>&1 | grep -q "^Usage: ip macsec"
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -631,7 +633,7 @@ kci_test_macsec()
#-------------------------------------------------------------------
kci_test_ipsec()
{
ret=0
local ret=0
algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
srcip=192.168.123.1
dstip=192.168.123.2
Expand Down Expand Up @@ -731,7 +733,7 @@ kci_test_ipsec()
#-------------------------------------------------------------------
kci_test_ipsec_offload()
{
ret=0
local ret=0
algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
srcip=192.168.123.3
dstip=192.168.123.4
Expand Down Expand Up @@ -841,7 +843,7 @@ kci_test_gretap()
{
testns="testns"
DEV_NS=gretap00
ret=0
local ret=0

ip netns add "$testns"
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -891,7 +893,7 @@ kci_test_ip6gretap()
{
testns="testns"
DEV_NS=ip6gretap00
ret=0
local ret=0

ip netns add "$testns"
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -941,7 +943,7 @@ kci_test_erspan()
{
testns="testns"
DEV_NS=erspan00
ret=0
local ret=0

ip link help erspan 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then
Expand Down Expand Up @@ -1006,7 +1008,7 @@ kci_test_ip6erspan()
{
testns="testns"
DEV_NS=ip6erspan00
ret=0
local ret=0

ip link help ip6erspan 2>&1 | grep -q "^Usage:"
if [ $? -ne 0 ];then
Expand Down Expand Up @@ -1077,7 +1079,7 @@ kci_test_fdb_get()
test_mac=de:ad:be:ef:13:37
localip="10.0.2.2"
dstip="10.0.2.3"
ret=0
local ret=0

bridge fdb help 2>&1 |grep -q 'bridge fdb get'
if [ $? -ne 0 ];then
Expand Down Expand Up @@ -1125,7 +1127,7 @@ kci_test_neigh_get()
dstmac=de:ad:be:ef:13:37
dstip=10.0.2.4
dstip6=dead::2
ret=0
local ret=0

ip neigh help 2>&1 |grep -q 'ip neigh get'
if [ $? -ne 0 ];then
Expand Down Expand Up @@ -1175,34 +1177,56 @@ kci_test_neigh_get()

kci_test_rtnl()
{
local ret=0
kci_add_dummy
if [ $ret -ne 0 ];then
echo "FAIL: cannot add dummy interface"
return 1
fi

kci_test_polrouting
check_err $?
kci_test_route_get
check_err $?
kci_test_addrlft
check_err $?
kci_test_promote_secondaries
check_err $?
kci_test_tc
check_err $?
kci_test_gre
check_err $?
kci_test_gretap
check_err $?
kci_test_ip6gretap
check_err $?
kci_test_erspan
check_err $?
kci_test_ip6erspan
check_err $?
kci_test_bridge
check_err $?
kci_test_addrlabel
check_err $?
kci_test_ifalias
check_err $?
kci_test_vrf
check_err $?
kci_test_encap
check_err $?
kci_test_macsec
check_err $?
kci_test_ipsec
check_err $?
kci_test_ipsec_offload
check_err $?
kci_test_fdb_get
check_err $?
kci_test_neigh_get
check_err $?

kci_del_dummy
return $ret
}

#check for needed privileges
Expand All @@ -1221,4 +1245,4 @@ done

kci_test_rtnl

exit $ret
exit $?

0 comments on commit 889579d

Please sign in to comment.