Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp517539pxb; Thu, 9 Sep 2021 06:17:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcytl78O0V/atI1bVxBJhU9wKqevTO2yYS4SxHtDWE24koABO1OOu9VieGiw+e/LTuYQxe X-Received: by 2002:a5d:9bd3:: with SMTP id d19mr2662861ion.202.1631193440227; Thu, 09 Sep 2021 06:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193440; cv=none; d=google.com; s=arc-20160816; b=kdVQJU3/sCDCFijp9zAlvHy6V54K6VnVX7IFizRo7+oM03viKFGV7Q/ThBtYz0K3sp ltY32UthpkGVSRGai3En0n3EIjV1e0CbmLvg04vqj6E/RvViS6MvPEcIhVW7r6zWitd1 I7Xo5aD02RK9Ewzi4sDSxjJBdI3EHCc9kZMDXtGxsbACRHZZBlyMzpx9mRiO3rSUIR0X 5NeD5XijTncB0LYZzFop9UYBIr0aNVZtIyBVDgUdyEZIPL0/0MCtje+Ksx42Bz8kEGmx VFLrov3Dvs0F23bnHQPUJi3NtfyOtxYhK3efi8q99Y562xdZuuHCRmjgl7H8ZMmjtFaO DRQA== 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=lweAN1Fded4fwbohd+7hsY3waG7F5lApnOXhZah6Yt0=; b=OXmvRSYIhkEm09trMdJK/7BYemlGQFLTgdbOfJkwQbbn0LlHw/WWC9B3Ku2W6mGrZN 0UiSecSjcMbu9dKFHNzsDp4fzh5Z/TbBPKwX+5MX8xFNGHZApEgZ3lUqTEnU/E7E9RJW duCpewX/yNA8LHzXhygk5k0YuHwKwGff3RBcDSFcI+Zae//+sPRSJlXNqrFDkuDufCB6 yS5UsCj2QQufSPKuYBUOHzcANJx7SyNZqX06pas2URocRfpeiaQy0WIVU/0zzHwzc+3L gU4eb8rXmvAzpXKkPFqDrkwnz14pgV35Cslms1tS7vq7Gv/WId8HRmGjDAnMvM1F2HvY h5RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tPpFxxfD; 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 g14si2148083jat.122.2021.09.09.06.17.03; Thu, 09 Sep 2021 06:17:20 -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=tPpFxxfD; 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 S1359298AbhIINQr (ORCPT + 99 others); Thu, 9 Sep 2021 09:16:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357496AbhIINBD (ORCPT ); Thu, 9 Sep 2021 09:01:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F269C6326E; Thu, 9 Sep 2021 11:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188761; bh=sD6Zjz4XgFnTkzsdkW1tFoWkAVvIfgF0vNhuksybvbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPpFxxfD6hgdwsJV/WqZVWVVXeV1K0i3QjyYhkVL67Xj3FVVIH4KmTVw9G/C/ylWI T8Us8E2fob6iZII07yAXSpIGpqoRAFcKkzHbVrrnk0GjwJoSQ87mwcFE7pbnTMU+rB 2K6FaPGc5PaOTPahccEO/Gq/GLB2vKoT0myWkdiS5mV91n0bn68O4sFQcX6B41aK1V B5BFRjJPBfVp3J4rXk41NhrFNa4l/HHOLfwU5RXdKiwm6TrINyqXa2KAJd1RUSiUlv wHGsQAWcmwA1HoI3RyMMc+5j3TwsG7JEFjm2WkwFzZ1jN/Cha1Z8gEaFcXQyzBayq7 PHVGTHwaYYuBw== 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 4.14 16/59] bpf/tests: Do not PASS tests without actually testing the result Date: Thu, 9 Sep 2021 07:58:17 -0400 Message-Id: <20210909115900.149795-16-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 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