Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0247C43219 for ; Thu, 16 Dec 2021 19:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241109AbhLPTvN (ORCPT ); Thu, 16 Dec 2021 14:51:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241088AbhLPTvM (ORCPT ); Thu, 16 Dec 2021 14:51:12 -0500 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06EC9C061574 for ; Thu, 16 Dec 2021 11:51:12 -0800 (PST) Received: by mail-ot1-x332.google.com with SMTP id a23-20020a9d4717000000b0056c15d6d0caso165675otf.12 for ; Thu, 16 Dec 2021 11:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TSyw+5NE57grmXEvJooaI5xtGgoQMSQLuPJVw3Fnbz0=; b=Tpyf7pdfSIzTQJ5ddM2RQ/4ufoSTi693T/ZvMrPXpEsrX+dek4KH9zcyfyqnda/mpV oK8+bQs73J8jGLrrMPKmsDYnHYixb1TrYcFvGpRuIqaon/M3jsb2/0QY1AmETvx7rJBu 65BPv3eRq6Z+Nfi0Wbajl/LtknopCWZwg07gM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TSyw+5NE57grmXEvJooaI5xtGgoQMSQLuPJVw3Fnbz0=; b=2qis132M0rkxsL9AUPNvuek41ePeedLBavskavHGTlOKiyZZcgByknDtjTqJVhOYTs 1jDM0kGpO1RaHuv+lexu8SK2ax2K+YLUklayv7n2o/+hmaqGWpZkD+crH7zSfPibWRpx Z7BuxlDEdOG9pWoYtnv8NSaUgXuWXAHZ5y0no/D02OUCKeLgU4F9cevLHxlx/qlaR9WQ Qq2BZAOyeLfpEjP/nyOfxoqsxhbwkkph3R54VfWk2aXSAOq7X/WXOQ347J+qcMPaeoF2 /6u2d1fvlokiN6+BDGNooTb6d4kB2/rzJbRYJYpXge+NvVdqnhwP+B5om1bQsoNnpM8P 43Bw== X-Gm-Message-State: AOAM530zkSYLFiRcpivODM8B0ARzNWPJM+G/fdV2O/IZVEUKIXmBUiRx Mz6bV9jPRBeIoIcEIBAg1GOgu54PiaXVhw== X-Google-Smtp-Source: ABdhPJzkPk7UAaVmdoip7gq4iwOC5yGm+pzaLqDeNMEUG5lPY0sMchwnWFV03x5CAd8cbbCPLNJxXg== X-Received: by 2002:a9d:798d:: with SMTP id h13mr13577040otm.132.1639684270667; Thu, 16 Dec 2021 11:51:10 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id 52sm534911oth.52.2021.12.16.11.51.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 11:51:10 -0800 (PST) Subject: Re: [PATCH] selftests/bpf: remove ARRAY_SIZE defines from tests To: Andrii Nakryiko Cc: Alexei Starovoitov , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "open list:KERNEL SELFTEST FRAMEWORK" , Network Development , bpf , LKML , Shuah Khan References: <20211210173433.13247-1-skhan@linuxfoundation.org> From: Shuah Khan Message-ID: <53490dba-b7fd-a3f8-6574-5736c83aa90d@linuxfoundation.org> Date: Thu, 16 Dec 2021 12:51:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/16/21 12:30 PM, Andrii Nakryiko wrote: > On Thu, Dec 16, 2021 at 6:42 AM Shuah Khan wrote: >> >> On 12/15/21 9:04 PM, Andrii Nakryiko wrote: >>> On Tue, Dec 14, 2021 at 12:27 PM Shuah Khan wrote: >>>> >>>> On 12/11/21 6:53 PM, Alexei Starovoitov wrote: >>>>> On Fri, Dec 10, 2021 at 9:34 AM Shuah Khan wrote: >>>>>> >>>>>> ARRAY_SIZE is defined in multiple test files. Remove the definitions >>>>>> and include header file for the define instead. >>>>>> >>>>>> Remove ARRAY_SIZE define and add include bpf_util.h to bring in the >>>>>> define. >>>>>> >>>>>> Signed-off-by: Shuah Khan >>>>>> --- >>>>>> tools/testing/selftests/bpf/progs/netif_receive_skb.c | 5 +---- >>>>>> tools/testing/selftests/bpf/progs/profiler.inc.h | 5 +---- >>>>>> tools/testing/selftests/bpf/progs/test_sysctl_loop1.c | 5 +---- >>>>>> tools/testing/selftests/bpf/progs/test_sysctl_loop2.c | 4 +--- >>>>>> tools/testing/selftests/bpf/progs/test_sysctl_prog.c | 5 +---- >>>>>> 5 files changed, 5 insertions(+), 19 deletions(-) >>>>>> >>>>>> diff --git a/tools/testing/selftests/bpf/progs/netif_receive_skb.c b/tools/testing/selftests/bpf/progs/netif_receive_skb.c >>>>>> index 1d8918dfbd3f..7a5ebd330689 100644 >>>>>> --- a/tools/testing/selftests/bpf/progs/netif_receive_skb.c >>>>>> +++ b/tools/testing/selftests/bpf/progs/netif_receive_skb.c >>>>>> @@ -5,6 +5,7 @@ >>>>>> #include >>>>>> #include >>>>>> #include >>>>>> +#include >>>>> >>>>> It doesn't look like you've built it. >>>>> >>>>> progs/test_sysctl_prog.c:11:10: fatal error: 'bpf/bpf_util.h' file not found >>>>> #include >>>>> ^~~~~~~~~~~~~~~~ >>>>> CLNG-BPF [test_maps] socket_cookie_prog.o >>>>> progs/test_sysctl_loop2.c:11:10: fatal error: 'bpf/bpf_util.h' file not found >>>>> #include >>>>> ^~~~~~~~~~~~~~~~ >>>>> 1 error generated. >>>>> In file included from progs/profiler2.c:6: >>>>> progs/profiler.inc.h:7:10: fatal error: 'bpf/bpf_util.h' file not found >>>>> #include >>>>> ^~~~~~~~~~~~~~~~ >>>>> >>>> >>>> Sorry about that. I built it - I think something is wrong in my env. Build >>>> fails complaining about not finding vmlinux - I overlooked that the failure >>>> happened before it got to progs. >>>> >>>> Error: failed to load BTF from .../vmlinux: No such file or directory >>> >>> Please make sure that you build vmlinux before you build selftests, >>> BPF selftests use vmlinux to generate vmlinux.h with all kernel types >>> (among other things). So please also make sure that all the setting in >>> selftests/bpf/config were used in your Kconfig. >>> >>>> >> >> The problem in my env. is that I don't have CONFIG_DEBUG_INFO_BTF in >> my config and then don't have the dwarves and llvm-strip on my system. >> Pains of upgrading. >> >> I am all set now. On the other hand the vmlinux.h is a mess. It has >> no guards for defines and including stdio.h and this generated >> vmlinux.h causes all sorts of problems. > > It does have > > #ifndef __VMLINUX_H__ > #define __VMLINUX_H__ > > Are we talking about the same vmlinux.h here? > Yes we are. The guard it has works when vmlinux.h is included twice. It defines a lot of common defines which are the problem. Unless you add guards around each one of them, including vmlinux.h is problematic if you also include other standard includes. You can try to include bpf_util.h for example from one of the test in progs to see the problem. thanks, -- Shuah