Message ID | 20230606071637.267103-12-jhubbard@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3213872vqr; Tue, 6 Jun 2023 00:42:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67Nod6NjzW+gSKITXSWOIrTo1/uTvdqquuT7WfWxl+0/Ehi8YOAcLtTGaNVxrUEjt1Zmwi X-Received: by 2002:a05:6870:b285:b0:19a:1331:9d4d with SMTP id c5-20020a056870b28500b0019a13319d4dmr1530340oao.23.1686037350346; Tue, 06 Jun 2023 00:42:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686037350; cv=pass; d=google.com; s=arc-20160816; b=s+siKD0Tvsx6h/G1+iAGz16ofDgy1BWFNonBAB3wbwQab2X6A5g1Beo4MjaB69Tw3L kvWp6eNlVjFmUG1xz1rbfCSp7dk+hreU2jeuUut2c5u+v/m4s4g+abY45nxSKkNYdlI5 x5Ezsks2Sj5/0Slx9h0wwND+bmNz3f2bHHJF/BLfpEisV30nnhNqjPjzY64W67Pavq4R UqvGm7vU/YHSOHPFMp0OH1ilwhmBV/VbaYnESyXokDrokuiYk55rEzmJ/dmjkUbNzDHL wDHgYvBnEZP7AuE+wPJ4JF9DexDa+aRyd1ngdjAXIXjmOe8FYKmFkzN/V30a4RKnZq/h TWDA== ARC-Message-Signature: i=2; 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=4Fine+ULcirLmEqNWkiHf+fbRUQNrgpAQqF8Q8I9Jv8=; b=hiiZtTOeG3vuPWrW0YMhuissdVBFchLjVAurihwZyOG9909o+eBH9lkHSLM2xkbOaz hJRrNjFHlrcbNsTP3pk6Zcm8q2uQ/RFDJUHWcfL+Ba3vrJY1M9wgKO4FU6aFkJITfTma fv8+irofm2H3kVDuxKk1YIpX2/YV3SQXnmbySG3xKQIxzuQgC9frx12atEvEEYxZnS4F eB1MMqjCsgDwmsP1XgAQoJY7MK4xKnwsoM/IPXYK1YgF5h3cUl0IP5SELUnrY9X63yQM Z5lQzMSBTtRxgyKSvK24jei35CogSHyTAgM6PzMfgEw1rwI0X5gsOPAo3YlEU8jNGLeI F4AA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=btuvmAMY; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m65-20020a633f44000000b00502f4be647fsi7006711pga.641.2023.06.06.00.42.16; Tue, 06 Jun 2023 00:42:30 -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=@Nvidia.com header.s=selector2 header.b=btuvmAMY; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236165AbjFFHSG (ORCPT <rfc822;xxoosimple@gmail.com> + 99 others); Tue, 6 Jun 2023 03:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235069AbjFFHRa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 6 Jun 2023 03:17:30 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C448FF7; Tue, 6 Jun 2023 00:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJooluIYCXO7Bo4oxRmnm+GE/+bdE/UI1gt/CmdnnvMrBX0JsqYKBWYF60hKDg9SUBYK1RDw3lfUzoxa6DT6Nxx4B4WMBV7+9Yv5pGCRbNts4Komh8dkw5gl2veFrVBneR1HYX3Y6dwGDOdK85VdIxWW0YbdO68+lmHjZ1uatf/6YTW5WludfTyA/N3FYuKjhtPFHXwG8raXVVraynSGOkRlHDUUsEeRSYgCJDDe1eKptB8jWYEix64DLfBsRBQLZYathBmFr0nWDtrARJO9ldOSGUN7LXbu30E5lCtztrdKR42rWpgrEzCldIBGMbNtIl4WSk6LbRwjRDx2nesqbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4Fine+ULcirLmEqNWkiHf+fbRUQNrgpAQqF8Q8I9Jv8=; b=EEnTF4VoOkwRqJnksL6DXhjUeRtUi46wf/CqhXZ57IwCWPqgoqKovyJzzKgmXazjL/YUbp6J5qp56AAulDq7dN9G5lwP66asBPjdFsYzvImNbA8cHqSv0aOEdlW+zJgaNtC76vAiKGFLi7izQ8UMHdzu6GkyonSZ+ytbE15ULPTEREFbDbG3pIzvTxRnSTtxGuiOODqk36HnZBAPXzzYtIb4IShg74hCzMvRo5QlObK8MuyeqkMP9GzBH3BQfpo+UHz8GbuMXAoUGOiYDsYTDRl+xYbu2FLUcp5ZcPYUkZiC+a1gobpeL8yoZd8T+DlJBHuPvt0k2rl7Rb7DqfFHTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Fine+ULcirLmEqNWkiHf+fbRUQNrgpAQqF8Q8I9Jv8=; b=btuvmAMYyzE27ABu7VBwlvAcjEci5vRX18QHREurNcFKmdPNUJtoqvLPH7Qr0qriZG8Bd0KJRYZd5wsIC5oUNI+ahY9cgMOvxHaQK0RgkczQFMgMJuqZF0AjFU2M/9fvRYG2YfJci/3oiE5TwVy72u9VKEbFYkiwfRlK6IMBsfgsEhcgbg61sTSpECqlwvzd/raMzw0GenEVcO8pyCGX6exsbzuvSZTcrwAps3Frxy58hYJZG2R4TZQ7sUCSUJW1rZ7vcFfak4fAawhAq34SndraL1KBO03Lh7sOTEFpOu/LxGogBpHakT96hSxYE+RIbswVG1c7/wPA7HKW/cOM0g== Received: from DS7PR03CA0284.namprd03.prod.outlook.com (2603:10b6:5:3ad::19) by PH7PR12MB5830.namprd12.prod.outlook.com (2603:10b6:510:1d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 07:17:26 +0000 Received: from DM6NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::da) by DS7PR03CA0284.outlook.office365.com (2603:10b6:5:3ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 07:17:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT086.mail.protection.outlook.com (10.13.173.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 07:17:26 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 6 Jun 2023 00:17:13 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 6 Jun 2023 00:17:12 -0700 Received: from sandstorm.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 6 Jun 2023 00:17:12 -0700 From: John Hubbard <jhubbard@nvidia.com> To: Andrew Morton <akpm@linux-foundation.org> CC: David Hildenbrand <david@redhat.com>, Peter Xu <peterx@redhat.com>, "Shuah Khan" <shuah@kernel.org>, Nathan Chancellor <nathan@kernel.org>, <linux-mm@kvack.org>, <linux-kselftest@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, John Hubbard <jhubbard@nvidia.com>, "Muhammad Usama Anjum" <usama.anjum@collabora.com>, Jonathan Corbet <corbet@lwn.net>, <linux-doc@vger.kernel.org> Subject: [PATCH v3 11/11] selftests: error out if kernel header files are not yet built Date: Tue, 6 Jun 2023 00:16:37 -0700 Message-ID: <20230606071637.267103-12-jhubbard@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606071637.267103-1-jhubbard@nvidia.com> References: <20230606071637.267103-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT086:EE_|PH7PR12MB5830:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ee2a593-f893-404f-6ef1-08db665e14a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D6JyrV7UKBSncKCDQBDtupx10E0cen55WxHrGHi1nSH0HXH1Sg17VGW7XRQvJhO49sgPrX5cgXy3yK/rtw90NG9gScesFqMLSV1t4Cjl/SfLJhFRtrs1AJjuDXtqQXLNXEEBWwbus2XCzOSpVQ62eFjccCm8mJl4VG8ddsPoebDb3kWvrFtC7e6540rEvNshxVUBkGXC4KiombXlO2QkvftKNtuFsxzcqNKSbsU6Q8Y+xIHEzBCKDFCD9WL0kUvFjX8x7QK85ZpyCAOl6gvmIoYcWhgCwO9bzoEbvPjGHW8PjPsgffdEKguA0iX1A7cW61ANo0vWhguxJ5ibwGilo1oM6OE82Kjmh/buiiizjjj6idBDD+Nt7bpJ3DuCIRci14K+WQ5krZEm3votMvzu0eKGCQ/G2jPeaqX+goSWz7UV6TpCTwbFDLONi+rIt93g2brxk2KyrYfQrYsx6WM7jqvEb9DdYSLzZVMVcSEive/SQxdGHIGgl4RYgFGyrOlWhrBcOzVKaRQVWo7SlFB0DowwPyk/23tygD/S1rq7/cVLPIlmTaLwxmAIveQXPj8yCSyvUSh6kB386wP03hQGT9Zd2/wcD8ls6bSgRotOPYzv3gov/NjtdbvSYaMedLkkIdCBGDHOtD5n2HCsA6ckYbhaUJkmBegdu+D3L+O/DWPQjwv2CQ2nO7ou0htHizgMPnCP5eLJzGDKk6umHgthTJ/8jgvz7SLXi2u4GQ0nBNmWu3WCYVqh72G+HO/CSNgvcBmMlKBSPUyxZFUagD2aLg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(39860400002)(136003)(346002)(451199021)(46966006)(36840700001)(40470700004)(47076005)(83380400001)(966005)(336012)(426003)(40480700001)(54906003)(82740400003)(4326008)(478600001)(8676002)(8936002)(70586007)(70206006)(356005)(7636003)(316002)(40460700003)(5660300002)(41300700001)(6916009)(86362001)(6666004)(36756003)(7696005)(2906002)(82310400005)(36860700001)(7416002)(186003)(26005)(1076003)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 07:17:26.1192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ee2a593-f893-404f-6ef1-08db665e14a8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5830 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767938300473279951?= X-GMAIL-MSGID: =?utf-8?q?1767938300473279951?= |
Series |
A minor flurry of selftest/mm fixes
|
|
Commit Message
John Hubbard
June 6, 2023, 7:16 a.m. UTC
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 <david@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
tools/testing/selftests/lib.mk | 36 +++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
Comments
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 <david@redhat.com> > Cc: Peter Xu <peterx@redhat.com> > Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> > Cc: Jonathan Corbet <corbet@lwn.net> > Cc: linux-doc@vger.kernel.org > Signed-off-by: John Hubbard <jhubbard@nvidia.com> > --- > 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 Thank you for adding this. This is outputting error for every selftest directory. We should try to make it even better by just aborting the Make-ing process the first time headers aren't detected. We can do this now or later, fine by me. make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline/tools/testing/selftests/futex' -e error: missing kernel header files. Please run this and try again: cd /home/usama/repos/kernel/linux_mainline/tools/testing/selftests/../../.. make headers make[1]: *** [../lib.mk:77: kernel_header_files] Error 1 make[1]: Leaving directory '/home/usama/repos/kernel/linux_mainline/tools/testing/selftests/futex' make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline/tools/testing/selftests/gpio' -e error: missing kernel header files. Please run this and try again: cd /home/usama/repos/kernel/linux_mainline/tools/testing/selftests/../../.. make headers make[1]: *** [../lib.mk:77: kernel_header_files] Error 1 make[1]: Leaving directory '/home/usama/repos/kernel/linux_mainline/tools/testing/selftests/gpio' m Complete error log file is attached. > + > +.PHONY: kernel_header_files > > define RUN_TESTS > BASE_DIR="$(selfdir)"; \
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 <david@redhat.com> > Cc: Peter Xu <peterx@redhat.com> > Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> > Cc: Jonathan Corbet <corbet@lwn.net> > Cc: linux-doc@vger.kernel.org > Signed-off-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com> > --- > 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)"; \
On 6/6/23 00:38, Muhammad Usama Anjum wrote: ... >> +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 > Thank you for adding this. This is outputting error for every selftest > directory. We should try to make it even better by just aborting the > Make-ing process the first time headers aren't detected. We can do this now > or later, fine by me. > OK, I see. Yes, this can be improved by adding the same mechanism to the selftests/Makefile, that is in selftests/mm/Makefile. I'd like to keep both, because as I mentioned earlier, mm folks like to run just that one Makefile, sometimes, and selftests/mm/Makefile is not invoking the top level Makefile. Rather, it includes lib.mk--which the top level Makefile does *not* include. Arguably, using includes instead of recursive Make, would improve this framework: reduce duplication such as the above. But that's a larger project and just food for thought at this point. Anyway, this works nicely on my system, and I'll attach it as a patch also in case you want to try it out. What do you think of this: diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 90a62cf75008..bdca160063d8 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -144,10 +144,12 @@ ifneq ($(KBUILD_OUTPUT),) abs_objtree := $(realpath $(abs_objtree)) BUILD := $(abs_objtree)/kselftest KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include + KHDR_DIR := ${abs_objtree}/usr/include else BUILD := $(CURDIR) abs_srctree := $(shell cd $(top_srcdir) && pwd) KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include + KHDR_DIR := ${abs_srctree}/usr/include DEFAULT_INSTALL_HDR_PATH := 1 endif @@ -161,7 +163,7 @@ export KHDR_INCLUDES # all isn't the first target in the file. .DEFAULT_GOAL := all -all: +all: kernel_header_files @ret=1; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ @@ -172,6 +174,23 @@ all: ret=$$((ret * $$?)); \ done; exit $$ret; +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 + run_tests: all @for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ thanks,
On 6/7/23 1:10 AM, John Hubbard wrote: > On 6/6/23 00:38, Muhammad Usama Anjum wrote: > ... >>> +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 >> Thank you for adding this. This is outputting error for every selftest >> directory. We should try to make it even better by just aborting the >> Make-ing process the first time headers aren't detected. We can do this now >> or later, fine by me. >> > OK, I see. Yes, this can be improved by adding the same mechanism to the > selftests/Makefile, that is in selftests/mm/Makefile. > > I'd like to keep both, because as I mentioned earlier, mm folks like to > run just that one Makefile, sometimes, and selftests/mm/Makefile is not > invoking the top level Makefile. Rather, it includes lib.mk--which the > top level Makefile does *not* include. > > Arguably, using includes instead of recursive Make, would improve this > framework: reduce duplication such as the above. But that's a larger > project and just food for thought at this point. > > Anyway, this works nicely on my system, and I'll attach it as a patch > also in case you want to try it out. What do you think of this: Nice patch. Thanks. Lets add this patch as well. Please add the tag for this new patch: Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com> > > diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile > index 90a62cf75008..bdca160063d8 100644 > --- a/tools/testing/selftests/Makefile > +++ b/tools/testing/selftests/Makefile > @@ -144,10 +144,12 @@ ifneq ($(KBUILD_OUTPUT),) > abs_objtree := $(realpath $(abs_objtree)) > BUILD := $(abs_objtree)/kselftest > KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include > + KHDR_DIR := ${abs_objtree}/usr/include > else > BUILD := $(CURDIR) > abs_srctree := $(shell cd $(top_srcdir) && pwd) > KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include > + KHDR_DIR := ${abs_srctree}/usr/include > DEFAULT_INSTALL_HDR_PATH := 1 > endif > > @@ -161,7 +163,7 @@ export KHDR_INCLUDES > # all isn't the first target in the file. > .DEFAULT_GOAL := all > > -all: > +all: kernel_header_files > @ret=1; \ > for TARGET in $(TARGETS); do \ > BUILD_TARGET=$$BUILD/$$TARGET; \ > @@ -172,6 +174,23 @@ all: > ret=$$((ret * $$?)); \ > done; exit $$ret; > > +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 > + > run_tests: all > @for TARGET in $(TARGETS); do \ > BUILD_TARGET=$$BUILD/$$TARGET; \ > > > > thanks,
On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. > NAK NAK NAK This now means I can no longer run selftests, I thank you very much! :-/ root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' *** *** The source tree is not clean, please run 'make mrproper' *** in /usr/src/linux-2.6 I've always done: cd tools/testing/selftests/x86; make and that has always worked Now I can't bloody well build *any* selftest or risk not being able to do builds.
On 03.11.23 13:16, Peter Zijlstra wrote: > On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. >> > > NAK NAK NAK > > This now means I can no longer run selftests, I thank you very much! :-/ > > root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 > make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' > *** > *** The source tree is not clean, please run 'make mrproper' > *** in /usr/src/linux-2.6 > > > I've always done: > > cd tools/testing/selftests/x86; make > > and that has always worked > > Now I can't bloody well build *any* selftest or risk not being able to > do builds. This change landed in 6.5, no? And 6.6 was just released. Just curious why you notice that now.
On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: > On 03.11.23 13:16, Peter Zijlstra wrote: > > On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. > > > > > > > NAK NAK NAK > > > > This now means I can no longer run selftests, I thank you very much! :-/ > > > > root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 > > make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' > > *** > > *** The source tree is not clean, please run 'make mrproper' > > *** in /usr/src/linux-2.6 > > > > > > I've always done: > > > > cd tools/testing/selftests/x86; make > > > > and that has always worked > > > > Now I can't bloody well build *any* selftest or risk not being able to > > do builds. > > This change landed in 6.5, no? And 6.6 was just released. Just curious why > you notice that now. Dunno, last time I edited the selftests and needed to recompile was a few weeks ago.
On 03.11.23 13:46, Peter Zijlstra wrote: > On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: >> On 03.11.23 13:16, Peter Zijlstra wrote: >>> On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. >>>> >>> >>> NAK NAK NAK >>> >>> This now means I can no longer run selftests, I thank you very much! :-/ >>> >>> root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 >>> make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' >>> *** >>> *** The source tree is not clean, please run 'make mrproper' >>> *** in /usr/src/linux-2.6 >>> >>> >>> I've always done: >>> >>> cd tools/testing/selftests/x86; make >>> >>> and that has always worked >>> >>> Now I can't bloody well build *any* selftest or risk not being able to >>> do builds. >> >> This change landed in 6.5, no? And 6.6 was just released. Just curious why >> you notice that now. > > Dunno, last time I edited the selftests and needed to recompile was a > few weeks ago. Okay. the question is if your workflow can be easily adjusted, or if we can improve that header handling as a whole. The problem I had with this recently: just because we did a "make headers" once in a git tree doesn't mean that it is still up-to-date. So once some selftest changes showed up that require newer headers, building the selftests again fails without a hint that another round of "make headers" would be required.
On 03.11.23 13:59, David Hildenbrand wrote: > On 03.11.23 13:46, Peter Zijlstra wrote: >> On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: >>> On 03.11.23 13:16, Peter Zijlstra wrote: >>>> On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. >>>>> >>>> >>>> NAK NAK NAK >>>> >>>> This now means I can no longer run selftests, I thank you very much! :-/ >>>> >>>> root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 >>>> make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' >>>> *** >>>> *** The source tree is not clean, please run 'make mrproper' >>>> *** in /usr/src/linux-2.6 >>>> >>>> >>>> I've always done: >>>> >>>> cd tools/testing/selftests/x86; make >>>> >>>> and that has always worked >>>> >>>> Now I can't bloody well build *any* selftest or risk not being able to >>>> do builds. >>> >>> This change landed in 6.5, no? And 6.6 was just released. Just curious why >>> you notice that now. >> >> Dunno, last time I edited the selftests and needed to recompile was a >> few weeks ago. > > Okay. the question is if your workflow can be easily adjusted, or if we > can improve that header handling as a whole. > > The problem I had with this recently: just because we did a "make > headers" once in a git tree doesn't mean that it is still up-to-date. > > So once some selftest changes showed up that require newer headers, > building the selftests again fails without a hint that another round of > "make headers" would be required. To clarify: maybe some kind of a warning would be better, ideally that the headers might be outdated and that another "make headers" would be required in case there are any build errors.
On Fri, Nov 03, 2023 at 01:59:28PM +0100, David Hildenbrand wrote: > Okay. the question is if your workflow can be easily adjusted, or if we can > improve that header handling as a whole. So on IRC the following was suggested: make O=defconfig-build headers ; make O=defconfig-build -C tools/testing/selftests/x86 But that makes absolutely no sense to me; because the headers and selftests are not .config dependent. Furthermore I don't want them in a kernel build dir. > The problem I had with this recently: just because we did a "make headers" > once in a git tree doesn't mean that it is still up-to-date. > > So once some selftest changes showed up that require newer headers, building > the selftests again fails without a hint that another round of "make > headers" would be required. Yeah, so I've been adding #ifndef guards all over the place for decades and that just works. You need it in normal userspace too. This super reliance on the very latestesetst headers is just a total pain.
Hi John, Muhammad, On Tue, 6 Jun 2023, 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/ could you, please, elaborate more on that one is supposed to build selftests with 'make headers'? Yes, Documentation/dev-tools/kselftest.rst mentions that because you might need headers but... The common way how we test the kernel is to build the kernel, install it somewhere and run selftests on top. The sequence basically being "make rpm-pkg; rpm -ivh; cd tools/testing/selftest/livepatch/ in source tree; sudo make run_tests" (or a similar variation of the procedure). The point is that we want to test the running kernel with its respective environment installed in /lib/modules/`uname -r`/ (if needed). This way we can run newer selftests from the current mainline tree on older kernels among others. The commit breaks the use case which worked for a long long time. It also breaks what Marcos proposed for livepatch selftests in https://lore.kernel.org/all/20231031-send-lp-kselftests-v3-0-2b1655c2605f@suse.com/ I guess we can always work around it by letting subsystem selftests to override KHDR_DIR but I am not comfortable with the behaviour that your commit introduced in the first place to be honest. Thank you, Miroslav
On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: > On 03.11.23 13:16, Peter Zijlstra wrote: > > On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. > > > > > > > NAK NAK NAK > > > > This now means I can no longer run selftests, I thank you very much! :-/ > > > > root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 > > make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' > > *** > > *** The source tree is not clean, please run 'make mrproper' > > *** in /usr/src/linux-2.6 > > > > > > I've always done: > > > > cd tools/testing/selftests/x86; make > > > > and that has always worked > > > > Now I can't bloody well build *any* selftest or risk not being able to > > do builds. > > This change landed in 6.5, no? And 6.6 was just released. Just curious why > you notice that now. And I hit it again (different box etc..) Can we please get this garbage fixed already?
On 08.12.23 16:14, Peter Zijlstra wrote: > On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: >> On 03.11.23 13:16, Peter Zijlstra wrote: >>> On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. >>>> >>> >>> NAK NAK NAK >>> >>> This now means I can no longer run selftests, I thank you very much! :-/ >>> >>> root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 >>> make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' >>> *** >>> *** The source tree is not clean, please run 'make mrproper' >>> *** in /usr/src/linux-2.6 >>> >>> >>> I've always done: >>> >>> cd tools/testing/selftests/x86; make >>> >>> and that has always worked >>> >>> Now I can't bloody well build *any* selftest or risk not being able to >>> do builds. >> >> This change landed in 6.5, no? And 6.6 was just released. Just curious why >> you notice that now. > > And I hit it again (different box etc..) > > Can we please get this garbage fixed already? I'd suggest to either revert or turn into a warning. @John?
On 12/8/23 07:21, David Hildenbrand wrote: > On 08.12.23 16:14, Peter Zijlstra wrote: >> On Fri, Nov 03, 2023 at 01:22:54PM +0100, David Hildenbrand wrote: >>> On 03.11.23 13:16, Peter Zijlstra wrote: >>>> On Tue, Jun 06, 2023 at 12:16:37AM -0700, 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. >>>>> >>>> >>>> NAK NAK NAK >>>> >>>> This now means I can no longer run selftests, I thank you very much! >>>> :-/ >>>> >>>> root@spr:/usr/src/linux-2.6# make O=defconfig-build/ -j64 >>>> make[1]: Entering directory '/usr/src/linux-2.6/defconfig-build' >>>> *** >>>> *** The source tree is not clean, please run 'make mrproper' >>>> *** in /usr/src/linux-2.6 >>>> >>>> >>>> I've always done: >>>> >>>> cd tools/testing/selftests/x86; make >>>> >>>> and that has always worked >>>> >>>> Now I can't bloody well build *any* selftest or risk not being able to >>>> do builds. >>> >>> This change landed in 6.5, no? And 6.6 was just released. Just >>> curious why >>> you notice that now. >> >> And I hit it again (different box etc..) >> >> Can we please get this garbage fixed already? > > I'd suggest to either revert or turn into a warning. That would put us back into a half-broken sort of situation, though... see below. > > @John? > I don't have a strong opinion about how this should be done, and in fact I believed at the time that I was bringing the system into compliance with what everyone wanted here. :) There seem to be two conflicting visions: a) The way it was (much) earlier: use ifdefs and defines to get by without the latest kernel headers, or b) Requiring recent kernel headers to build the various selftests. Shuah, Peter, others: can we choose a direction please? Either way will work, and I personally don't care which one we choose. thanks,
On Fri, Dec 08, 2023 at 12:29:37PM -0800, John Hubbard wrote: > I don't have a strong opinion about how this should be done, and in > fact I believed at the time that I was bringing the system into > compliance with what everyone wanted here. :) > > There seem to be two conflicting visions: > > a) The way it was (much) earlier: use ifdefs and defines to get by > without the latest kernel headers, or > > b) Requiring recent kernel headers to build the various selftests. > > Shuah, Peter, others: can we choose a direction please? Either > way will work, and I personally don't care which one we choose. So as David already argued, the current thing does not in fact help with b. You just have to install once and the error goes away, then carry that tree for a year and you're running old crap again. My biggest beef with the whole thing is that I simply do not want to use 'make headers', it doesn't work for me. I have a ton of output directories and I don't care to build tools into the output dirs, in fact some of them flat out refuse to work that way (bpf comes to mind).
On 12/8/23 14:10, Peter Zijlstra wrote: > So as David already argued, the current thing does not in fact help with > b. You just have to install once and the error goes away, then carry > that tree for a year and you're running old crap again. > > My biggest beef with the whole thing is that I simply do not want to use > 'make headers', it doesn't work for me. > > I have a ton of output directories and I don't care to build tools into > the output dirs, in fact some of them flat out refuse to work that way > (bpf comes to mind). Going with that, then, I believe it is best to simply revert commit 9fc96c7c19df ("selftests: error out if kernel header files are not yet built"). And then follow up with a series of (many) changes to wean the various selftests off of the kernel headers. I'll post the revert shortly. thanks,
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)"; \