Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2320250pxb; Mon, 20 Sep 2021 18:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHZs/vjTKOAioqNlAr6GxLMOdys74dWG5/s1eEFZkWnqNKTAx0UdHALuSbmXEv3Z9Ua1aF X-Received: by 2002:a92:6c0c:: with SMTP id h12mr19060095ilc.32.1632188633062; Mon, 20 Sep 2021 18:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188633; cv=none; d=google.com; s=arc-20160816; b=VPeBQ8Tf8VkjZo4OtpqEX04hfUKY/CX4R7Le/J+xe2kvmSmCei1BhLyHyyiYBkAMwU OJMWFoVXk2VfYll2v0ioTSdq6E13ivQ3P8of+nNvslCmK1HpuRNF0BQFq0/Nz1p2fp01 ROm6/5Aa/rVAhFicpk8bmyCphBAhN/SlMG0z806iAmSRT0WYZo+z59nT9Q5zyqfes7iy z3xxfz5nJBGqvAutDZLPfWN2fn9G1gyuXsyRMt2w2KgGDdLkjkg7dvRt0M0HGm9jkgCa E3k0gPPb6mTKec02Q7NJWCnA/eapqrkyN8i292mfYhjlsqPVuKwV42RQI9hQUXBAgoGR J3gQ== 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=cK0Z+EZFRBpm0kSRZB1+oV/xW2qIsdqloY2vLeQjtNQ=; b=p5vRsPLapKLdyPmUDDycLgs1mSxMX3GDYwFDh8Ke40ml2o45fD1Ja4X8vmoYwNpE+K H8ZdcIZayx4kcoIwJMGvXKtQof72wpraqoSp2Peej45tfkVu82vyi8vBIu42jQ1tPByj QbwB/080zzouxYsai6K71Qs5PL6685Te4juJ4baeoPTCKicf90jkDryHTLKBnIaqus9c OKSOBCzJnd+X08UHbS5nPrphSJegMq4wT1KNJF/qQt9IxQ639aVUyX0/89haP7WSEIh3 UgmjP4sIfprzWDJ6yO16xyvU6bzAAcIHIx6aN38uLu0lBx3fzflm06YiMLI8JJtsGNkY Y21w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="bSkaB/RZ"; 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 f8si4650296ilu.129.2021.09.20.18.43.41; Mon, 20 Sep 2021 18:43:53 -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="bSkaB/RZ"; 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 S244291AbhITQ4K (ORCPT + 99 others); Mon, 20 Sep 2021 12:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243396AbhITQw2 (ORCPT ); Mon, 20 Sep 2021 12:52:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BB8396135E; Mon, 20 Sep 2021 16:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156589; bh=dzAigAepBsLS1JtEPhZgzE3+YL6NfLUinqhExcTXxbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSkaB/RZvIQfPuZEhNkfVGImvjxWFsCRBuwQr0bt4XWcywthJLl2eWVFDwPxZf+0w hGOHB/zz7vsMs/Jk4/X7k9sfDid6qLIOCvNavadKMcrkVLlbUQYUFfrJY3ZDDCWsuS wWRxAOeQRP/mGL2489zXKM9g0S+nMhngOamy2QW8= 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.4 095/133] bpf/tests: Do not PASS tests without actually testing the result Date: Mon, 20 Sep 2021 18:42:53 +0200 Message-Id: <20210920163915.744092346@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 7db8d06006d8..cf2880d2ce3f 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -5399,7 +5399,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