From patchwork Wed Aug 12 12:08:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1343632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BRT4k0nTfz9sTv; Wed, 12 Aug 2020 22:08:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1k5pYY-0008A4-KX; Wed, 12 Aug 2020 12:08:34 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k5pYS-00086p-H1 for kernel-team@lists.ubuntu.com; Wed, 12 Aug 2020 12:08:28 +0000 Received: from mail-pg1-f197.google.com ([209.85.215.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k5pYS-0000il-4q for kernel-team@lists.ubuntu.com; Wed, 12 Aug 2020 12:08:28 +0000 Received: by mail-pg1-f197.google.com with SMTP id n32so1373084pgb.22 for ; Wed, 12 Aug 2020 05:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BTg+xd3V0P9TBNLj+tgRk3Zk7X4ZISlorGWH9/2bw+k=; b=Ep9qIUhYKRHrgnYV+HcK9zanOlYcr4vc1f6JsZtRyyN7GOEInAccIvA6Ms869wTjZK SaneUh25pnDp03NBgsVw2jgze8COwShxaaEO1OjJmxg3gUQ8aLm6UQJPfqkYVMpxdThR aaDwq0PKYIyATdT/idIlNjEA/mr8ColtdmArYYRGnGyDvnq+g9sLoSajaJnCVAJnSxE2 qLeGMQ3wiFKlIYD6P1BrSFEW79tR9N4iIa0RTCyh7TLhZn5ZzoI7475A6yKn/ei6ta3z tIyk59Ohp2+IsOfymkrcExHhbEAJT75HF5cAFBmD582dd7pxYVXgUpAEyz/V7Gd/tW0v sBqw== X-Gm-Message-State: AOAM531uV0ivecbjfePZ2lttxnUbnoPyDbxUUGSSo5le60/iPotrA+yX HHuq29c0AvpoevZrGou5pKD5HbdFV/9NYzCT1DTvU8lCq+k+uDkPC1zOEUXAvFF5upFodbeQj8m T7rZYNLiH4UkMNHMwG7Fm8WMUCdX82TL1BGYIPwBf X-Received: by 2002:a62:1a49:: with SMTP id a70mr11135980pfa.297.1597234106326; Wed, 12 Aug 2020 05:08:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5yxgzkMWhRQ/HE2XnmNJWIJ8NE2mY/WKbg5w2cuG7wHxBfRMgzP+C7JK1aTejDgfbxSWw8g== X-Received: by 2002:a62:1a49:: with SMTP id a70mr11135954pfa.297.1597234106012; Wed, 12 Aug 2020 05:08:26 -0700 (PDT) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id e4sm2320658pfd.204.2020.08.12.05.08.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 05:08:25 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [B][PATCH 1/2][SRU] selftests: rtnetlink: correct the final return value for the test Date: Wed, 12 Aug 2020 20:08:13 +0800 Message-Id: <20200812120815.8499-3-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812120815.8499-1-po-hsu.lin@canonical.com> References: <20200812120815.8499-1-po-hsu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1890136 The return value "ret" will be reset to 0 from the beginning of each sub-test in rtnetlink.sh, therefore this test will always pass if the last sub-test has passed: $ sudo ./rtnetlink.sh PASS: policy routing PASS: route get PASS: preferred_lft addresses have expired PASS: promote_secondaries complete PASS: tc htb hierarchy PASS: gre tunnel endpoint PASS: gretap PASS: ip6gretap PASS: erspan PASS: ip6erspan PASS: bridge setup PASS: ipv6 addrlabel PASS: set ifalias a39ee707-e36b-41d3-802f-63179ed4d580 for test-dummy0 PASS: vrf PASS: vxlan FAIL: can't add fou port 7777, skipping test PASS: macsec PASS: ipsec 3,7c3,7 < sa[0] spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1 < sa[0] key=0x31323334 35363738 39303132 33343536 < sa[1] rx ipaddr=0x00000000 00000000 00000000 c0a87b03 < sa[1] spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1 < sa[1] key=0x31323334 35363738 39303132 33343536 --- > sa[0] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1 > sa[0] key=0x34333231 38373635 32313039 36353433 > sa[1] rx ipaddr=0x00000000 00000000 00000000 037ba8c0 > sa[1] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1 > sa[1] key=0x34333231 38373635 32313039 36353433 FAIL: ipsec_offload incorrect driver data FAIL: ipsec_offload PASS: bridge fdb get PASS: neigh get $ echo $? 0 Make "ret" become a local variable for all sub-tests. Also, check the sub-test results in kci_test_rtnl() and return the final result for this test. Signed-off-by: Po-Hsu Lin Signed-off-by: David S. Miller (backported from commit c2a4d2747996ee6a1397e2064d44a4f57ac442e6) [PHLin: ignore multiple non-existing test cases] Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/rtnetlink.sh | 40 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 5affdd1..7cc3b3e 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -5,7 +5,6 @@ # set -e devdummy="test-dummy0" -ret=0 # set global exit status, but never reset nonzero one. check_err() @@ -63,7 +62,7 @@ kci_test_bridge() devbr="test-br0" vlandev="testbr-vlan1" - ret=0 + local ret=0 ip link add name "$devbr" type bridge check_err $? @@ -110,7 +109,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 @@ -146,7 +145,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 $? @@ -181,7 +180,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 @@ -202,7 +201,7 @@ kci_test_polrouting() kci_test_route_get() { - ret=0 + local ret=0 ip route get 127.0.0.1 > /dev/null check_err $? @@ -253,7 +252,7 @@ kci_test_addrlft() kci_test_addrlabel() { - ret=0 + local ret=0 ip addrlabel add prefix dead::/64 dev lo label 1 check_err $? @@ -293,7 +292,7 @@ kci_test_addrlabel() kci_test_ifalias() { - ret=0 + local ret=0 namewant=$(uuidgen) syspathname="/sys/class/net/$devdummy/ifalias" @@ -348,7 +347,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 @@ -388,7 +387,7 @@ kci_test_vrf() kci_test_encap_vxlan() { - ret=0 + local ret=0 vxlan="test-vxlan0" vlan="test-vlan0" testns="$1" @@ -422,7 +421,7 @@ kci_test_encap_vxlan() kci_test_encap_fou() { - ret=0 + local ret=0 name="test-fou" testns="$1" @@ -459,7 +458,7 @@ kci_test_encap_fou() kci_test_encap() { testns="testns" - ret=0 + local ret=0 ip netns add "$testns" if [ $? -ne 0 ]; then @@ -484,7 +483,7 @@ kci_test_encap() 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 @@ -524,6 +523,7 @@ kci_test_macsec() kci_test_rtnl() { + local ret=0 kci_add_dummy if [ $ret -ne 0 ];then echo "FAIL: cannot add dummy interface" @@ -531,18 +531,30 @@ kci_test_rtnl() fi kci_test_polrouting + check_err $? kci_test_route_get + check_err $? kci_test_addrlft + check_err $? kci_test_tc + check_err $? kci_test_gre + 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_del_dummy + return $ret } #check for needed privileges @@ -561,4 +573,4 @@ done kci_test_rtnl -exit $ret +exit $?