Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6809399rwd; Tue, 6 Jun 2023 02:09:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RCuI0+DzTu6I4aG6SrXVuPyr5npbPcrrC3q45JWaTcISxCKzP7tzg72JB9SxfLFOv0kXC X-Received: by 2002:a05:6214:1945:b0:623:8309:7e04 with SMTP id q5-20020a056214194500b0062383097e04mr1948327qvk.1.1686042547512; Tue, 06 Jun 2023 02:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686042547; cv=none; d=google.com; s=arc-20160816; b=YOtoKMLdgP47e0+9WcLRlJ0wIhULp3hhvVSBaENeZCJqsrHWzhWQTY/cKRrjugQmd9 XQM43vLPgWJYU8rdv4qsa8r91p+s7pX5LFvxlfAFq7ueo+QL/g9QDehgvh7NxswF96+g hOjfbNMmyY7l7GLtxgTQjWEkpB/TwE5/jNp0akL0LqVfS8FxtlRgQZOAvSJbGSJlu15o HjdMS26NvC6UVIV7l0TLpERYrXbBED5w5JZwEy7PSKnMqJAfguNafZOih8BNVKCdwEVR avne89D1/u6rvolO+Zm2+O1C2Kd/kRDhNNJ2NSlGLwYAp3ylyJwRA3ILqc24Nu+CKATN UsSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=sxNFbQ5oVo/tRY1hL4X83NGkQfKGWsYX11uH89KCmM4=; b=w5vBof6liQUe2VD+pTJLnxo+P/qI5Ra5lZfrUqlEksn7vF91AiNy3812GfVhLwANpG FqXnYNgaVnUoewSYggFmKDwGFk/a1Yz8aOyHTE/Eri9c3zXcE0Tet/oppVPokEkPTEny iQ+mRlfakWjd58Fnow3gSEMJbwjcTjxpLGv4FZLKv/D4BwyA9DOjWeJg4co1hbuV7jML QK6pPpcXGWPuVk10hLpFRWaALQJ376gSl1fs49Z+c5MZZmGQ48ycACwZ6baF3yaKU0fV pJW2razpfCOzbx4ALinL1XuSmHdzxVPa4doAZqFSXb+GwGCxwK43Zzt4MFzspPMEGoe0 rkvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kVLKlUef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kc28-20020a056214411c00b00626168c1029si5914576qvb.56.2023.06.06.02.08.53; Tue, 06 Jun 2023 02:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kVLKlUef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236273AbjFFIAq (ORCPT + 99 others); Tue, 6 Jun 2023 04:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237191AbjFFIAU (ORCPT ); Tue, 6 Jun 2023 04:00:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312A82D71; Tue, 6 Jun 2023 00:57:54 -0700 (PDT) Received: from [192.168.10.48] (unknown [119.152.150.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 33DCF6606E98; Tue, 6 Jun 2023 08:57:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686038272; bh=3mvikzsrZ6UUqHFtYoJSndS+MYKtof2+48NtxLq92KI=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=kVLKlUef7fSpaZPOn+iXxXPHzOr7Ff+dAj1OX0Cvym0iDwVQDV0rpmtNtBrWndlRN l0EZlowVKOe00KX1u6LUgu0igsYeckNmUCH2YqzzLO4HikM5PbAxwUOKQiJueOT2WX IlLUinbeLUTDgsi/XZzvTyAQk2wqa+lFppzCh9gaTO6HlHhhyPKvWFGqxGiAvUpW74 fUZx7f6aU54I/53kB+dve3V/wFBKZuqKnFIbA76XvHVK0LSW3RkX6SE66+TrfD11b8 P7je2uYEnUVoNTHVrLP5G85A6n/GqrF4AtICxmt/0yyOQp5fxLmVLDEC2PmSU6pdZR fofv2mkKzzLlw== Message-ID: <59b157ac-d6ee-c122-802c-a44b0f9463a5@collabora.com> Date: Tue, 6 Jun 2023 12:57:46 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: Muhammad Usama Anjum , David Hildenbrand , Peter Xu , Shuah Khan , Nathan Chancellor , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, LKML , Jonathan Corbet , linux-doc@vger.kernel.org Subject: Re: [PATCH v3 11/11] selftests: error out if kernel header files are not yet built Content-Language: en-US To: John Hubbard , Andrew Morton References: <20230606071637.267103-1-jhubbard@nvidia.com> <20230606071637.267103-12-jhubbard@nvidia.com> From: Muhammad Usama Anjum In-Reply-To: <20230606071637.267103-12-jhubbard@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/6/23 12:16 PM, John Hubbard wrote: > As per a discussion with Muhammad Usama Anjum [1], the following is how > one is supposed to build selftests: > > make headers && make -C tools/testing/selftests/mm > > Change the selftest build system's lib.mk to fail out with a helpful > message if that prerequisite "make headers" has not been done yet. > > [1] https://lore.kernel.org/all/bf910fa5-0c96-3707-cce4-5bcc656b6274@collabora.com/ > > Cc: David Hildenbrand > Cc: Peter Xu > Cc: Muhammad Usama Anjum > Cc: Jonathan Corbet > Cc: linux-doc@vger.kernel.org > Signed-off-by: John Hubbard Reviewed-by: Muhammad Usama Anjum > --- > tools/testing/selftests/lib.mk | 36 +++++++++++++++++++++++++++++++--- > 1 file changed, 33 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index 05400462c779..b8ea03b9a015 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -44,10 +44,22 @@ endif > selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) > top_srcdir = $(selfdir)/../../.. > > -ifeq ($(KHDR_INCLUDES),) > -KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include > +ifneq ($(KBUILD_OUTPUT),) > + # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot > + # expand a shell special character '~'. We use a somewhat tedious way here. > + abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) > + $(if $(abs_objtree),, \ > + $(error failed to create output directory "$(KBUILD_OUTPUT)")) > + # $(realpath ...) resolves symlinks > + abs_objtree := $(realpath $(abs_objtree)) > + KHDR_DIR := ${abs_objtree}/usr/include > +else > + abs_srctree := $(shell cd $(top_srcdir) && pwd) > + KHDR_DIR := ${abs_srctree}/usr/include > endif > > +KHDR_INCLUDES := -isystem $(KHDR_DIR) > + > # The following are built by lib.mk common compile rules. > # TEST_CUSTOM_PROGS should be used by tests that require > # custom build rule and prevent common build rule use. > @@ -58,7 +70,25 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) > TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) > TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) > > -all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) > +all: kernel_header_files $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) \ > + $(TEST_GEN_FILES) > + > +kernel_header_files: > + @ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \ > + if [ $$? -ne 0 ]; then \ > + RED='\033[1;31m'; \ > + NOCOLOR='\033[0m'; \ > + echo; \ > + echo -e "$${RED}error$${NOCOLOR}: missing kernel header files."; \ > + echo "Please run this and try again:"; \ > + echo; \ > + echo " cd $(top_srcdir)"; \ > + echo " make headers"; \ > + echo; \ > + exit 1; \ > + fi > + > +.PHONY: kernel_header_files > > define RUN_TESTS > BASE_DIR="$(selfdir)"; \ -- BR, Muhammad Usama Anjum