Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566809lkm; Mon, 20 Sep 2021 18:53:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy+TUI7Q/9UfY7Hep12KxfK6w4nhw4YoAOl1+8sFvCl894q6bhNnMf+KhLqJedJan3TSif X-Received: by 2002:a05:6e02:1beb:: with SMTP id y11mr19310982ilv.134.1632188828623; Mon, 20 Sep 2021 18:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188828; cv=none; d=google.com; s=arc-20160816; b=medlJPBJ9bWLJxppqTF1d7OeUBUWsow0+BYObVPXQr+N8ftGlr8cb18/5DxTKWfLhF BL1nsyvdJAsrEHj+uAJw+WFeV6sP0FIFNnJ6IzLFPLvktLDdnLGmELCXb+xjDR33QWY3 mPDFxIUL42+atRn2yfM2+JVoIvzUUgsl4nOIBmf+waIjJZDACLFcpBfh6+BhKyXWlXRs jfn78V1CbQ28Ht4SvW9YYtLp6vSGGzGwoh406HjE8rraHt8FtIfWAWs7Vgfyhh0DwNIN MOjU+5jpKqdLYQVmIa8bsFQz+1JG4f0vonjyYdScrKbmUPUgTVBNeHO3WgcdezRxLyOo 4hQA== 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=lweAN1Fded4fwbohd+7hsY3waG7F5lApnOXhZah6Yt0=; b=DvHCSkArScyO1dlpo8/SLjHIT8QjA5O+sey+kWUgCuCI77YGkOdtMbYE8LDMKavvD9 GnZnHQT/EE5qdigDw60ZlxhvvaRW/xwLWZ5UDSYzyzNuPgyMgR1TdHs58iJntfs6zHsM cHhOfAI6eGpmKYRZNC/oIFOceMLIX2Gli1vVnkBpZatvesKxOnqykenPxOz9SNGo8GZm q8NqXU3CeBldiynTpH2J4DutgjHiYxim4tOHrbkOpqQTGZHV6fkjH8HtmHKv6kRE2Viw GccGe5gDvkecvmpBupmJeEClk4z/ZorkrqMISwhwo8GKz3dC0YDMZIyWzXJKge4EjcIi iRig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="y/Ai9vK+"; 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 l20si579149jad.72.2021.09.20.18.46.57; Mon, 20 Sep 2021 18:47:08 -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="y/Ai9vK+"; 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 S1350450AbhITR2r (ORCPT + 99 others); Mon, 20 Sep 2021 13:28:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:54322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350114AbhITR0i (ORCPT ); Mon, 20 Sep 2021 13:26:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82D5261425; Mon, 20 Sep 2021 17:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157370; bh=sD6Zjz4XgFnTkzsdkW1tFoWkAVvIfgF0vNhuksybvbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y/Ai9vK+0DE2OLim/AHJTpDTiSPpg1c0z02u5pntjNI5mqM3djoQFReNdrtDbcL2k VrRbmpX4/h/ZwRvGsUQENI8qo8d+gBu2gnMbxBNuZFrMtlKDQ0RFzlKQheJ3p/XboO 2y1fCOMc4Yp6y0FVJUOWBpg1NcQDbMymqpOSUfbY= 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.14 145/217] bpf/tests: Do not PASS tests without actually testing the result Date: Mon, 20 Sep 2021 18:42:46 +0200 Message-Id: <20210920163929.553597446@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163924.591371269@linuxfoundation.org> References: <20210920163924.591371269@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 4aa88ba8238c..9a8f957ad86e 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6306,7 +6306,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