Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1557054pxb; Thu, 16 Sep 2021 09:51:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIDKYAMg+lMM9GROy9QL10La0lXz/luxRXLlQftyaYmRLmCQLJLN4ioeHZ4a0JsA6IEA1U X-Received: by 2002:a17:906:1319:: with SMTP id w25mr7599949ejb.552.1631811099657; Thu, 16 Sep 2021 09:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631811099; cv=none; d=google.com; s=arc-20160816; b=uwQLtC9ysg7F6M9FgddN25ZVPgAzFr6eoLWywiH33na9eyyQSgJu21VcWQ8zwbDdEe Rs0VDxNpqZMllcfNBRmLfeWltzWO5uemEutRSCZfso+aaVgIfZ3/SRoeTMsCZtO/ujvQ rLS1FCK/lTwbIQbb5N/cdwx9bJPjW4+Gcj8hYQZTxlP1QIpBn27C8sI0l1f/+lAtESjA 06fWkT8N3YBqpPvGvJ8Xit3o0Er0x6OR+eLWQ35xYaGzi46D/ajoql45iwxK9y1xXkbX ywTQHgN7v3okjjhCs91tYZ2d6gTBTGefBUTHJXA9mZ0DTM7wfv49dHkpPnHTil0ePc2r 8oVw== 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=uLU2ARnvEQQm8NM2LvnkICU2xUAytcKUIWAd4joayiI=; b=fqq+27DGQoyLvVSWSbYNABYLlKbsRJuffy1eTziukNGojvUTH1ba4hF4BJyJiFHCTI +TFjwZKZ55o78GEoJ08Hl8l+jvlcO5D3lPvpjoxQipOZeSP0ccQMBnM3Pqz+Rk64/oR5 lnJtByYilSVO7KN10HmwZermphidtiMRedVfMLPujYPeRnjTrl1J5AJi2U4Q/MtRCwBc DZOiXJdECUPslsRZdDLOSZUiO4/JEiHt9FKyI6PuYMBtiKX3YvhndjwCtygDpV7BUKhx GKQLP5JtNdAb5aSBnMxBzlFpBQ8qHV9jY+JpMYWTZZmFZzjFEw3c5EjYyPHjJJZ+6b9O mjHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=01HSS28u; 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 h12si5156990edb.310.2021.09.16.09.51.14; Thu, 16 Sep 2021 09:51:39 -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=01HSS28u; 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 S1345099AbhIPQth (ORCPT + 99 others); Thu, 16 Sep 2021 12:49:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:57410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344060AbhIPQoa (ORCPT ); Thu, 16 Sep 2021 12:44:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0688F613D5; Thu, 16 Sep 2021 16:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809540; bh=qAjnl9fZBFF30EAQJawikxCXtJtytrTUzqXnRJgkWZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=01HSS28ut5NIuJ3u+KxbSba82sC9Q0IUBbn5cO095D+ff4aYLLsmOnP33n+GPn4Hb hB+JFr6WoZ5pG54Q9IeUBYPD++XAUjx0c1CU2rzTaRbn6E51qNxJ5CaiWD6SMQ7aUk ZCrj1HRG5tIzipXA0oSVgc+o3LzcHOxahdQxthWA= 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.13 192/380] bpf/tests: Do not PASS tests without actually testing the result Date: Thu, 16 Sep 2021 17:59:09 +0200 Message-Id: <20210916155810.602255331@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 f826df50355b..acf825d81671 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6659,7 +6659,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