Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1684815pxb; Thu, 16 Sep 2021 12:56:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9w0TY/I9IHVTLOxPGOOSA/lzowNeEv1KBfHLyTd8kUkBlwwz8p5JeRs2wV+uWJwJaCrk9 X-Received: by 2002:a05:6e02:1bc2:: with SMTP id x2mr5213248ilv.98.1631822211969; Thu, 16 Sep 2021 12:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631822211; cv=none; d=google.com; s=arc-20160816; b=CRrt4F/0QZa1h8Cvo6p6GRG8uJE04Z9gj1vmlXpQnBAM73hoXFTDRSXR+l+AzoCSOm nvt6fK6O0bviDIdUwW6wfBaMnS7qWUuqEcyyGaxOgimw3f7Gv1CkkeYtR6aSQJoGpaus RsH8iFyOsCwgo32JrC5BarFuF8QJZmzeDb/SONjVQXDAJ+/WQc31wJ2VDmIqERD7Af8c yucZcMBe+RN4fvJGgNUAApEunk1RmxY929ukyX5WJzlrCmNcmpzF1u085n1XErVt0D9w XfVF5WDI4VdePpBAe8EnxJFqrjBsDb0nWvEh1d9xtRpZOJt6rakoflW5Ndt6LyK5+gq6 LC/g== 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=uOQMrAbrSE6GyN6Kq92mQfg8BQfAQU+d0R7eVWRkiks=; b=IniNdY4S9KesMkBQuZ0Bj3lZTHVmcIG8G36NEMMnSCjXmnZuhtZjLyA6UUI9pVDI8O U+1WN1G9mtqQw+bYD0eG+5uvWy8qLxLuMOugRSKrILXFJOmugInLLCLpDOacVivL83KJ FktgcM0C3DdXI0LSiepwRH1KLfgTSHFdP3+gRaw3kA0zf6lCLhJJbW/a+d7T30Jivfn6 +8jZQYG4RLi5iOM7pSNP5rZ+0EmZTmfgoM2R5j5IY/GvdXv3Rl8SHT9sczkmqoQtG0Er T9CjPzcrsI4V1qSrSXPbP4ZyirykIQhDraF+vBfKam+B0oklyPAfrgSemCBJFkQXGvZ6 LFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gDRIWji/"; 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 j2si3622528ilr.113.2021.09.16.12.56.38; Thu, 16 Sep 2021 12:56:51 -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="gDRIWji/"; 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 S235405AbhIPQXS (ORCPT + 99 others); Thu, 16 Sep 2021 12:23:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:48902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239484AbhIPQNU (ORCPT ); Thu, 16 Sep 2021 12:13:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4889A611F2; Thu, 16 Sep 2021 16:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808594; bh=zFSR/y0zf3mMjO+hWHcjRXVdXR3DnvExAtTzipWi3QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDRIWji/E/tBhVlTElMnrXUeeC8fonrd5YS5Mak4FUZtv/M6MuycUlUdfkkwtcSfC +yGI+sx0fvjQfx9uDMu8Pv9XbosLzt6m8kQCypLQue/dh3a+v3QhX8/L5Ku7CfGPRt dhsfKC59sDEOsrrxQoNG5Ed30UZy6fAKG8uzci9g= 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.10 151/306] bpf/tests: Do not PASS tests without actually testing the result Date: Thu, 16 Sep 2021 17:58:16 +0200 Message-Id: <20210916155759.222323968@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 ca8eef2f6442..4a9137c8551a 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6664,7 +6664,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