Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565564lkm; Mon, 20 Sep 2021 18:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1vF/T17t+/CeoSQgRlZopZgNmrvH/yDSpcAA7FF9IzRiIR3ojHuRmM46HCl4YOfmCimtN X-Received: by 2002:a05:6e02:1caf:: with SMTP id x15mr11188332ill.150.1632189016148; Mon, 20 Sep 2021 18:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189016; cv=none; d=google.com; s=arc-20160816; b=HKpGIwAYDx5XoC/nlmvNznsh93YB6JNwZk9a8GM3UfPApuDkwQ2lrNsoGXhVpr7Dax He6oeYJ/tpmR5CZTXU37VumaVhue9dyGPVfr2Upawc8q+WwDe/ni5PPLEdGlwMx5Jr+K fLEPjpmHB2K7DRzA46Rz2OJiZhl4WeZEBq3WQDXl60YbyiV974tV28BPeYp1kLHvcnX6 yPaweuIcos+2LbMFCezBQU8BF6091R/Bz+84mwx243q/DD53SnJloElnwipxew33SVoI SQfwJknYH7jRy1RFJQMOgHkGQ6JZLTc5uaUtYaySH4WpVAmyKdHiYEIAN6dOEeJ+fyKj vXaw== 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=IDR8y5Utj0Fa6hFB887rRVJ0c1Vy/fNRF+sxhzm5E9Q=; b=YzvgvD0xdqurzZ5xjtGiRPnCfOrLJqvNmqmZ498piHPjdvyjIXoODhXBo07+4j2/7i Ci7K5QESO6KuNlgkCYrEzz/XW2swq8HmBvcI5u0XBTvmJi3K734k/otlV6F0iQL0MmM2 xpHxVpHbd07nWP8DSRw5BoVH2D9Ue5YyPL4mFI0M0jMj8ea5KoM4QVW2X4HrFAaof7IL Z1XYFQseEc/Cgx3in4OzIrpZUFcb5UfEUlSgFJkCBULv73D4MjXSchNdn3HXYWuXpqYp M7CLwSmqjZw0myKvIokbOCWzxpTDkubCCvi0ziJ2PVTr6UK/2ilvC04f7FVVFZENKq3v mVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gFJoYvUC; 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 b8si15676005ios.12.2021.09.20.18.50.05; Mon, 20 Sep 2021 18:50:16 -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=gFJoYvUC; 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 S1355238AbhITRy0 (ORCPT + 99 others); Mon, 20 Sep 2021 13:54:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:52568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349514AbhITRs1 (ORCPT ); Mon, 20 Sep 2021 13:48:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 064E261BB3; Mon, 20 Sep 2021 17:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157868; bh=AJpXbpPOr7yKBsBlNIWWsMTSvBZzIz7cDKjO3sAlSOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFJoYvUC/2qGAJEFgzNF1HL721UrjscGSyFxeS6LO0PY/zGHVlHAfVRPbA1n2/0MJ cdW26j17XzrMYHIYsi5i/mjPQqRbq0WwHHfKkLNkj2wo/FUoTngfduYiLBopY9CfeI lDmecPbfdlbhe9RZf6UXwTMIAkg9TXJ6Df7JJu2Q= 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 4.19 189/293] bpf/tests: Do not PASS tests without actually testing the result Date: Mon, 20 Sep 2021 18:42:31 +0200 Message-Id: <20210920163939.738221715@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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 98074a3bc161..49d79079e8b3 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6687,7 +6687,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