Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp665151rdd; Tue, 9 Jan 2024 16:25:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCBVjoulO76mGft9GfMKlcaeG0e+QHxTSpRHH5xTaWoEzkbOHuNA4wEgn+wfDATa+BuExI X-Received: by 2002:a05:6a00:80d1:b0:6d9:ff12:c428 with SMTP id ei17-20020a056a0080d100b006d9ff12c428mr270405pfb.36.1704846328335; Tue, 09 Jan 2024 16:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704846328; cv=none; d=google.com; s=arc-20160816; b=F5kCEgSuq4P2p5LXAvULHpgOV8MTQtPuPPKyLhSADgceBE5uRJYNumQW9zRKgRpEeo MYOGKo+fqLS9pLGTQkkQu/Mxdkunps4RVf7BarShrRJfZwsi40C+k/cfNtl6b9OCu7jo NkZGXvkUeZSnCuC23aRtHksgzb6GqJlnSUQjKV6Jukepq/2EYZE17/OZQG99Vj/i/bnS njecIIAmqNH7Ljj84M149IJm/DLdHuLEdZtr/L0gXoP4qGZrBYexxdo2UyPOTnwDnquZ NhWqhLzg10AK9iYXwVLMnnsXzQdVLxW3qDu7cMYNjHxNqbF3LCmHUmb9RkVpILKxK81g k/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature; bh=4QzBlWWfwboCn7QByVKvAtD0FlCJirOWNu502Jtpu2Y=; fh=Mq58102248fM07I0WalrZ/nXtmtKWhasuGO5B/rfF9E=; b=b/pfjPLfAqjEZ8KGpfoTygPwMvemo5MsBXZil+dD6rRyMbglXe65L1R9eSsnGLOPMT CpxINcGcW4X+2YoUKnz4x6BbQHf+AidOLRbfYuKNX77YfGWvfq7k8Bk49ADChuH3sYAS k6vdPUPK1AJcftBI4BLVQkBSSzJaFXB4td3RvEgsKkxAs62iM9B42d0sgcnB/0SHQF2N X15LLKlpT9oL1yJAL2+/2mvAjfiaYqYpTRIPMVPu2hy+Lj5RvvshHfBes24aNBR8W3oc 1F9spZ7etvPeXh8VkJn8iU1Cx9uCSecr//ov5fsJVEn9O/NfD0HQ4aarjDE/KiCaE44G 0FYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QXFTqkJ3; dkim=pass header.i=@suse.com header.s=susede1 header.b=QXFTqkJ3; spf=pass (google.com: domain of linux-kernel+bounces-21568-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21568-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i129-20020a639d87000000b005ceb4a70213si2485787pgd.385.2024.01.09.16.25.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 16:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21568-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QXFTqkJ3; dkim=pass header.i=@suse.com header.s=susede1 header.b=QXFTqkJ3; spf=pass (google.com: domain of linux-kernel+bounces-21568-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21568-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 00A88288F29 for ; Wed, 10 Jan 2024 00:25:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 624001109; Wed, 10 Jan 2024 00:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="QXFTqkJ3"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="QXFTqkJ3" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5676C39F; Wed, 10 Jan 2024 00:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 321231F838; Wed, 10 Jan 2024 00:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704846301; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4QzBlWWfwboCn7QByVKvAtD0FlCJirOWNu502Jtpu2Y=; b=QXFTqkJ330mdm4dxdD8YZUMEMmyIRvVznMawSU+2vlnJYwCzyTjXVJIwd0nXlc9TgIWydk OmTASikMeVDuRK369RHBZmMRFYZ9gZvNNRt3qRUWfNCEJZvQjHK5BULavin5w5A4tonJQ1 FCqq3pOpQ7ASqkZX2ar0w/KWbbav62A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704846301; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4QzBlWWfwboCn7QByVKvAtD0FlCJirOWNu502Jtpu2Y=; b=QXFTqkJ330mdm4dxdD8YZUMEMmyIRvVznMawSU+2vlnJYwCzyTjXVJIwd0nXlc9TgIWydk OmTASikMeVDuRK369RHBZmMRFYZ9gZvNNRt3qRUWfNCEJZvQjHK5BULavin5w5A4tonJQ1 FCqq3pOpQ7ASqkZX2ar0w/KWbbav62A= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B0A3613786; Wed, 10 Jan 2024 00:25:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0fNvHdzjnWUyWwAAD6G6ig (envelope-from ); Wed, 10 Jan 2024 00:25:00 +0000 From: Marcos Paulo de Souza Date: Tue, 09 Jan 2024 21:24:54 -0300 Subject: [PATCH v5 1/3] kselftests: lib.mk: Add TEST_GEN_MODS_DIR variable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240109-send-lp-kselftests-v5-1-364d59a69f12@suse.com> References: <20240109-send-lp-kselftests-v5-0-364d59a69f12@suse.com> In-Reply-To: <20240109-send-lp-kselftests-v5-0-364d59a69f12@suse.com> To: Shuah Khan , Jonathan Corbet , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence Cc: linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, live-patching@vger.kernel.org, Marcos Paulo de Souza X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704846294; l=5552; i=mpdesouza@suse.com; s=20231031; h=from:subject:message-id; bh=mSClHVx7GS9z/JPMcrHBkeiVi2JrX1/vNnl454UqiKQ=; b=oJdBwUj8DOWIcoQ0LqF1iJoayYzRVEXpt8BiwTlxZJab/ZKB9ydEyapDTmK3gwWwYpMNvUZJO yspGo9K99ilBZGQ16vKO+Ho0NpUlWY/T+aWNSiufHRW45FtwJoHbAVa X-Developer-Key: i=mpdesouza@suse.com; a=ed25519; pk=/Ni/TsKkr69EOmdZXkp1Q/BlzDonbOBRsfPa18ySIwU= X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-0.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWELVE(0.00)[18]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -0.20 Add TEST_GEN_MODS_DIR variable for kselftests. It can point to a directory containing kernel modules that will be used by selftest scripts. The modules are built as external modules for the running kernel. As a result they are always binary compatible and the same tests can be used for older or newer kernels. The build requires "kernel-devel" package to be installed. For example, in the upstream sources, the rpm devel package is produced by "make rpm-pkg" The modules can be built independently by make -C tools/testing/selftests/livepatch/ or they will be automatically built before running the tests via make -C tools/testing/selftests/livepatch/ run_tests Note that they are _not_ built when running the standalone tests by calling, for example, ./test-state.sh. Along with TEST_GEN_MODS_DIR, it was necessary to create a new install rule. INSTALL_MODS_RULE is needed because INSTALL_SINGLE_RULE would copy the entire TEST_GEN_MODS_DIR directory to the destination, even the files created by Kbuild to compile the modules. The new install rule copies only the .ko files, as we would expect the gen_tar to work. Reviewed-by: Joe Lawrence Signed-off-by: Marcos Paulo de Souza --- Documentation/dev-tools/kselftest.rst | 4 ++++ tools/testing/selftests/lib.mk | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst index ab376b316c36..7f3582a67318 100644 --- a/Documentation/dev-tools/kselftest.rst +++ b/Documentation/dev-tools/kselftest.rst @@ -245,6 +245,10 @@ Contributing new tests (details) TEST_PROGS, TEST_GEN_PROGS mean it is the executable tested by default. + TEST_GEN_MODS_DIR should be used by tests that require modules to be built + before the test starts. The variable will contain the name of the directory + containing the modules. + TEST_CUSTOM_PROGS should be used by tests that require custom build rules and prevent common build rule use. diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 118e0964bda9..d77dda59f6a2 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -70,12 +70,15 @@ KHDR_INCLUDES := -isystem $(KHDR_DIR) # TEST_PROGS are for test shell scripts. # TEST_CUSTOM_PROGS and TEST_PROGS will be run by common run_tests # and install targets. Common clean doesn't touch them. +# TEST_GEN_MODS_DIR is used to specify a directory with modules to be built +# before the test executes. These modules are cleaned on the clean target as well. 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)) +TEST_GEN_MODS_DIR := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_MODS_DIR)) all: kernel_header_files $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) \ - $(TEST_GEN_FILES) + $(TEST_GEN_FILES) $(if $(TEST_GEN_MODS_DIR),gen_mods_dir) kernel_header_files: @ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \ @@ -105,8 +108,8 @@ endef run_tests: all ifdef building_out_of_srctree - @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ - rsync -aq --copy-unsafe-links $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT); \ + @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)$(TEST_GEN_MODS_DIR)" != "X" ]; then \ + rsync -aq --copy-unsafe-links $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(TEST_GEN_MODS_DIR) $(OUTPUT); \ fi @if [ "X$(TEST_PROGS)" != "X" ]; then \ $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) \ @@ -118,11 +121,22 @@ else @$(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS)) endif +gen_mods_dir: + $(Q)$(MAKE) -C $(TEST_GEN_MODS_DIR) + +clean_mods_dir: + $(Q)$(MAKE) -C $(TEST_GEN_MODS_DIR) clean + define INSTALL_SINGLE_RULE $(if $(INSTALL_LIST),@mkdir -p $(INSTALL_PATH)) $(if $(INSTALL_LIST),rsync -a --copy-unsafe-links $(INSTALL_LIST) $(INSTALL_PATH)/) endef +define INSTALL_MODS_RULE + $(if $(INSTALL_LIST),@mkdir -p $(INSTALL_PATH)/$(INSTALL_LIST)) + $(if $(INSTALL_LIST),rsync -a --copy-unsafe-links $(INSTALL_LIST)/*.ko $(INSTALL_PATH)/$(INSTALL_LIST)) +endef + define INSTALL_RULE $(eval INSTALL_LIST = $(TEST_PROGS)) $(INSTALL_SINGLE_RULE) $(eval INSTALL_LIST = $(TEST_PROGS_EXTENDED)) $(INSTALL_SINGLE_RULE) @@ -131,6 +145,7 @@ define INSTALL_RULE $(eval INSTALL_LIST = $(TEST_CUSTOM_PROGS)) $(INSTALL_SINGLE_RULE) $(eval INSTALL_LIST = $(TEST_GEN_PROGS_EXTENDED)) $(INSTALL_SINGLE_RULE) $(eval INSTALL_LIST = $(TEST_GEN_FILES)) $(INSTALL_SINGLE_RULE) + $(eval INSTALL_LIST = $(notdir $(TEST_GEN_MODS_DIR))) $(INSTALL_MODS_RULE) $(eval INSTALL_LIST = $(wildcard config settings)) $(INSTALL_SINGLE_RULE) endef @@ -156,7 +171,7 @@ define CLEAN $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN) endef -clean: +clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir) $(CLEAN) # Enables to extend CFLAGS and LDFLAGS from command line, e.g. @@ -187,4 +202,4 @@ $(OUTPUT)/%:%.S $(LINK.S) $^ $(LDLIBS) -o $@ endif -.PHONY: run_tests all clean install emit_tests +.PHONY: run_tests all clean install emit_tests gen_mods_dir clean_mods_dir -- 2.42.1