Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2339727pxb; Mon, 20 Sep 2021 19:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7croLvmafx3s0ohJlhYEbsWu4Uzxhrg+2r+XFpHuKJMHp7aJnY7b6m5Do0XV4eUZYc1fZ X-Received: by 2002:a17:906:1fc1:: with SMTP id e1mr8007445ejt.515.1632190955381; Mon, 20 Sep 2021 19:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632190955; cv=none; d=google.com; s=arc-20160816; b=bAlsKiztUCIKVdZjd07P7uoUDvGVpa7rNvL61XGrRWds/T5Hfdn2Y/YtB4VhrkFhLC pya/swHJ+BxtuBBzGzrEtn3SXahA0mv6Xqj7RMjMGgaQA6LMEndLPtV4I6tP6V4FXZPv sQB030AmZJ1Wv4ihe5sbdFBA+ys/c7fEvctf9IaenYSRUisQGg6vRfK41MysnGfOMfcY LxP3ZsdWsAf64NdTts+BYQfX2eDBMjZ7qCSNbTd+ym5sBatzs3fzW0qvrr8UScETP/cP j3PPRjE1QpmFGCb/tY7JEl5M2v6Nh+M3tXGmKrxTMDsAmJ/Q4qoZubLNAbb3sJBL5i+L g3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/g1+2DIBRyeodv32pVs1DL2ryin8ODSQGhkzoPlub8k=; b=e8es/wXB7OZ5mgpX/aHcNU0MzX4a5vQTLnBUKjclPkd17rRkOBd7+HinsPnG8xI9Tc 4R/pLmx4NJIUBGeTds/jO/KTAI4zuCTc+axKmFAbyaQGa8lXhMWdf2dSG5aQsSuETnlQ YLv4R0Zzqz3DMT4n6BScB+x9BzhckGR88DZWi2LCQp2mYKt0Ar0xlUeAhv6mixNiikU5 ClAGEGGqvroljhom5Bolz8ieH260j0b7il9ESv2KPsz8IRywJjFTK3IaQ3U7Ef7pBKOk X5APAfl1fDQGgrxQ1+BMivJjuuyVBsEevIOADyjQ8x3Z/Rs6o2I/QsJ8Ab34RSnR+/R+ Tmqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WanllQqx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds17si2734365ejc.213.2021.09.20.19.22.10; Mon, 20 Sep 2021 19:22:35 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WanllQqx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351168AbhITSNU (ORCPT + 99 others); Mon, 20 Sep 2021 14:13:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:33076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358690AbhITSH0 (ORCPT ); Mon, 20 Sep 2021 14:07:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6B2863253; Mon, 20 Sep 2021 17:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158308; bh=uTNrrX/S4t6/ZBcUg0zRYdoMNiMsoigv8fWLoQZC3gE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WanllQqxp2UOdFys7Fv2+Y37W0MG2CstTp2QmlXXsPWtY00/NIc7Ha8E5nNXfyGWd D7gLkl4WN7Laou3aa0aL0v2op8TtKht28LWYsmQDTXmNv1hUYypwEcXrgTJ+MFbqb2 7OF0tjqzBi5qc2KpL5oP3tiLFVVljWZZ8fBQnDM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Almbladh , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.4 097/260] bpf/tests: Do not PASS tests without actually testing the result Date: Mon, 20 Sep 2021 18:41:55 +0200 Message-Id: <20210920163934.430780943@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Almbladh [ Upstream commit 2b7e9f25e590726cca76700ebdb10e92a7a72ca1 ] Each test case can have a set of sub-tests, where each sub-test can run the cBPF/eBPF test snippet with its own data_size and expected result. Before, the end of the sub-test array was indicated by both data_size and result being zero. However, most or all of the internal eBPF tests has a data_size of zero already. When such a test also had an expected value of zero, the test was never run but reported as PASS anyway. Now the test runner always runs the first sub-test, regardless of the data_size and result values. The sub-test array zero-termination only applies for any additional sub-tests. There are other ways fix it of course, but this solution at least removes the surprise of eBPF tests with a zero result always succeeding. Signed-off-by: Johan Almbladh Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210721103822.3755111-1-johan.almbladh@anyfinetworks.com Signed-off-by: Sasha Levin --- lib/test_bpf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 5e985ed68b2a..3ae002ced4c7 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6684,7 +6684,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test) u64 duration; u32 ret; - if (test->test[i].data_size == 0 && + /* + * NOTE: Several sub-tests may be present, in which case + * a zero {data_size, result} tuple indicates the end of + * the sub-test array. The first test is always run, + * even if both data_size and result happen to be zero. + */ + if (i > 0 && + test->test[i].data_size == 0 && test->test[i].result == 0) break; -- 2.30.2