Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10415234pxu; Wed, 30 Dec 2020 01:54:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1OfHhs2pf2JVRLJEbrx2WXaziQYtp2vQA2lsId1lRKyO/z9oTsns+TRhf6VosdZHMLco2 X-Received: by 2002:a50:c315:: with SMTP id a21mr49958701edb.50.1609322081612; Wed, 30 Dec 2020 01:54:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609322081; cv=none; d=google.com; s=arc-20160816; b=QJkxD7gROiu47CeRPUJkimZkdJDfVmURXPGriJNWDzXVjj4zMbq5mv2cbFYk1ZZPAG Fi5/eA0EClPWy1ZtxVMRbkw/fSxP8h7SurfeFCU/yq5FRs2n0PuKJD+mLlfyM95FZJQ7 l9VuA/VOckSxOssRs6OtZZbcJ1sv8khp2/MU8aY/UTcDNhy+CLkn/Fk3aymlCYy3fnsg H381lWR1ucdm0CGP45ZAfAmwKgfe0FZhZm/zIjExRbCESw5O/YSvfs2MuoG7LPmLlXOx 6RslmvPf1tp5zfW0syqbWR9d2qHow+ArGi5Bk75vxsEG1h5ZUsnC1MaFhbRbQ/7HXfud lBdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=i+QpbOc8ony+XYCIFM3o157TRlJnFXAk3ZOK7FKW9BI=; b=Vj7IrLW+az7vyKD4aZ/3E57Hxe6ZnZ43VdwtyCJ0yahz36IP1Hgulys9LSayBzIDVd +Z2QTsCZZxZv/Igw7zlc65t9WWCZUh67amRVxA9JUhzquOA3wAruxqJcQKqObSMFSHct fnXEPA5dEcgs3xAr7d2p4Qq5YJLydlqNsgHalVQTV/MWSKB5PiHaoFGb6ApZtaT+qIK8 y48s5H1VokquKI6MhDu9xTab8R3GYTXb06+P7IORwGvdz6ZfpoUbio7XSmEKkv6RONi0 nw1Tybi30Erth6cEBDm6Xbr6h/Q/7jwumtWZyYN9OpQGr8EeqqI/Gi+0j+6blLm+P8oY P4rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp24si23304134ejb.323.2020.12.30.01.54.18; Wed, 30 Dec 2020 01:54:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgL3Jw5 (ORCPT + 99 others); Wed, 30 Dec 2020 04:52:57 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:59571 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbgL3Jw4 (ORCPT ); Wed, 30 Dec 2020 04:52:56 -0500 Received: from mail-pg1-f199.google.com ([209.85.215.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kuY9N-00083r-NB for linux-kernel@vger.kernel.org; Wed, 30 Dec 2020 09:52:13 +0000 Received: by mail-pg1-f199.google.com with SMTP id 139so11997739pgd.11 for ; Wed, 30 Dec 2020 01:52:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=i+QpbOc8ony+XYCIFM3o157TRlJnFXAk3ZOK7FKW9BI=; b=RK28FGIzNhOX2BONeD14pqu2FvodF1ehvugKlymIjgJEkTcgQJEvCA6UVzlxIqA2gJ wD7ygkXiozCCrL3ajSyK/iFI0Au7qUNuDp69ZslpwsdLFpdwpH9sKKEcqDL4Vsu0Rbf3 UxbJPOAJbyH70cx57Qw4GqnJCC5c8/66v7hWWlpM2hu8P0fH7Ji2hsgnkPgn05u9QJco AsGIpuz9LmWl6cFWCMi9rQ4xmsl5s5XGRXGHmjNYJqMEzje0qo0yktOtQ05bPPDE5OL4 pf36rxDs5sfRGD/djUpBIcN8yR/CBISIm0rhd2e7xeGdwSWxg/nFnscGABHmnHge0AmU z9wQ== X-Gm-Message-State: AOAM531X16faZUBfuloWYtP0lZsy52CY3pnGY/H5he3dWmAHmpWNi8N7 G7TSFU8oUTQWFfiFfX2tIn38tJcyXjmxWV7gnFPoPmnbpoIr+i2/jfhRbSMzpH0rKwiWBbWRv/s WPqh2eTm1T5vkYhAbF41uyH9hC+UV7pZ7+pcqGeSo X-Received: by 2002:aa7:9a86:0:b029:1a6:d998:922a with SMTP id w6-20020aa79a860000b02901a6d998922amr48132013pfi.80.1609321932207; Wed, 30 Dec 2020 01:52:12 -0800 (PST) X-Received: by 2002:aa7:9a86:0:b029:1a6:d998:922a with SMTP id w6-20020aa79a860000b02901a6d998922amr48132008pfi.80.1609321931953; Wed, 30 Dec 2020 01:52:11 -0800 (PST) Received: from Leggiero.taipei.internal (61-220-137-38.HINET-IP.hinet.net. [61.220.137.38]) by smtp.gmail.com with ESMTPSA id m13sm41214530pff.21.2020.12.30.01.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 01:52:11 -0800 (PST) From: Po-Hsu Lin To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, shuah@kernel.org, steffen.klassert@secunet.com, fw@strlen.de Subject: [PATCH] selftests: xfrm: fix test return value override issue in xfrm_policy.sh Date: Wed, 30 Dec 2020 17:52:04 +0800 Message-Id: <20201230095204.21467-1-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running this xfrm_policy.sh test script, even with some cases marked as FAIL, the overall test result will still be PASS: $ sudo ./xfrm_policy.sh PASS: policy before exception matches FAIL: expected ping to .254 to fail (exceptions) PASS: direct policy matches (exceptions) PASS: policy matches (exceptions) FAIL: expected ping to .254 to fail (exceptions and block policies) PASS: direct policy matches (exceptions and block policies) PASS: policy matches (exceptions and block policies) FAIL: expected ping to .254 to fail (exceptions and block policies after hresh changes) PASS: direct policy matches (exceptions and block policies after hresh changes) PASS: policy matches (exceptions and block policies after hresh changes) FAIL: expected ping to .254 to fail (exceptions and block policies after hthresh change in ns3) PASS: direct policy matches (exceptions and block policies after hthresh change in ns3) PASS: policy matches (exceptions and block policies after hthresh change in ns3) FAIL: expected ping to .254 to fail (exceptions and block policies after htresh change to normal) PASS: direct policy matches (exceptions and block policies after htresh change to normal) PASS: policy matches (exceptions and block policies after htresh change to normal) PASS: policies with repeated htresh change $ echo $? 0 This is because the $lret in check_xfrm() is not a local variable. Therefore when a test failed in check_exceptions(), the non-zero $lret will later get reset to 0 when the next test calls check_xfrm(). With this fix, the final return value will be 1. Make it easier for testers to spot this failure. Fixes: 39aa6928d462d0 ("xfrm: policy: fix netlink/pf_key policy lookups") Signed-off-by: Po-Hsu Lin --- tools/testing/selftests/net/xfrm_policy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh index 7a1bf94..5922941 100755 --- a/tools/testing/selftests/net/xfrm_policy.sh +++ b/tools/testing/selftests/net/xfrm_policy.sh @@ -202,7 +202,7 @@ check_xfrm() { # 1: iptables -m policy rule count != 0 rval=$1 ip=$2 - lret=0 + local lret=0 ip netns exec ns1 ping -q -c 1 10.0.2.$ip > /dev/null -- 2.7.4