Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp446335pxb; Thu, 9 Sep 2021 04:47:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvejc3x4gybDL9TfHTII/3QrZWPrQJ+RGRnf8jTbuGthtDtaKls/d1yy9TX/3NHx1bAjeb X-Received: by 2002:a05:6638:bcf:: with SMTP id g15mr2480763jad.1.1631188051023; Thu, 09 Sep 2021 04:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188051; cv=none; d=google.com; s=arc-20160816; b=ZbkVcwy+eCPVRZ1ckP/1C0QAEXeix2Zu+8O9LIiPPBeY6yGwzf2CknysuPMhd+yLOn +Rsc28jBGa53mAwilRIWAUWtC2Glq9hQPbHKB3t6BvLh9pqoQ14N1MEEkHxKDj2YBIe8 aFrO9ulC0sd4z79tg97V+UKDsJ1tPX10EvsC1ShFsa2zQJuTciNi7+cXcagFP5pgyA+j FhNUOBJ5EfhjXGzJtzvmYlXufJJi1lQZznhPrfAMUzK31yQV9FOEQmNY26SQauiDI/Y3 9TJEDQ3/+EMkuodPYN+D0BJYAB6+6c3mDxFduORaFOEv5xLguIzSmFJPsGtWeMRH8GO6 kugQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a3Q0AqMFGOM2XZ3BLZYyjn0pXHnHX7QSksM9jbWXbJs=; b=dmuXe/kwRh36271Fe+QFo7Wzm4zQgF0s/gGxmobK0qiB3/qvPKFebt8ZMzRZpKXgLd +uAFSYRekuG/6Hh8DFSBFv/SK25//MqpH+DDlOmCRXv/p6u5/jqD4qjNzfNZf4GPrCoE eYITyu2y6hGAQqhKIJ7aLQ06aHv0c3cIko0GXWxfrm6v30utMHJ07YBxX9fiPJ4qfIyy egzyNPwumQ4hWBUU+NFPWNHDuGlDw5cI+GkcymA6X+mx1pMx0G3B/+JX1NOlIZEv5oMv 0nEe07wDRlz4tezHtn0AkOihJ0vh4jJd6vw9qbyFCxrOZACccvKhVg6xm/PQxlynegx+ uMNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MQVag7DS; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si1377721ioj.7.2021.09.09.04.47.18; Thu, 09 Sep 2021 04:47:31 -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=@kernel.org header.s=k20201202 header.b=MQVag7DS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238416AbhIILrI (ORCPT + 99 others); Thu, 9 Sep 2021 07:47:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:46380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240077AbhIILo2 (ORCPT ); Thu, 9 Sep 2021 07:44:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB601600AA; Thu, 9 Sep 2021 11:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187750; bh=qg26jiuTtdoiJ3RenuggGw8K55QTJlmz12NTT/iEnWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MQVag7DSFgDOVewDnYIpcSg5RDz4wZib9MnpkPggSlFySxmZRS649H/2Bl/LXilAz 06ygaiSIhvBCu+WmK7HqKfTIDEQeZgaaTp+M/C1NvYsuzOx/yH7U6N/cfWyML9JdFQ L9TM6jbA2Dm8r0O+sNmstFsHi45iEmUFKb0IWfMP7qpLNS8f3phiOIelopLZGq1pHp 4nse6uTVBL7jRIgpP10HYB1WegW06Y4mqmQYHxRNEP9hsZxYPa7UdJDAiYS/uxSIuc PzbcG7cSxAcI3KECi1mHg7Wv3fedejb61ZnIX0+r5ixEfqCBvNmIVDE35ado6owUda FlBo+hNaJ/3mA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johan Almbladh , Andrii Nakryiko , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 065/252] bpf/tests: Do not PASS tests without actually testing the result Date: Thu, 9 Sep 2021 07:37:59 -0400 Message-Id: <20210909114106.141462-65-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 1c5299cb3f19..f6d5d30d01bf 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