From patchwork Wed Feb 21 17:17:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcos Paulo de Souza X-Patchwork-Id: 204330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1177996dyc; Wed, 21 Feb 2024 09:18:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWGAC1IihsVBaenRvUwUsxFwxpsCTuO+KzvxJ7+u4tR2wRjBwh+NhHQYB8WCtnkjVhqSvezNL4aRg3JudiMXqJfD61SPA== X-Google-Smtp-Source: AGHT+IEXwshL6X9uuMmJw2rnV8e9lKXCmfpbsS8SoESRSvnZp42MPKXRtM7wI2AqBJK3ffmlcdHW X-Received: by 2002:a05:620a:d96:b0:787:80ca:99e7 with SMTP id q22-20020a05620a0d9600b0078780ca99e7mr182856qkl.23.1708535925046; Wed, 21 Feb 2024 09:18:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708535925; cv=pass; d=google.com; s=arc-20160816; b=mRZORK63X989R5eHj1hDmNb/Y5tVmK0PQ6UoB0IEupYiagG934aEOiivH+e66TDzAH 7Pht89SWJPFSCT0JWzklk2wNQOHtdnTRgkSQy1WyLOZqGKfLVUHXZUj7eY0TVEJDNPk1 zfl5eB3L+L3VX2UPnR80PtuqKehRYYyM3cDdnXg6+mwfnuDTz15dX6oE6mrTDfKjrO/w H7yL8ybutgd9Bg5EtS1pBz824FztuMxRHWZ92POG3GA2IGrU9Gm1SHWGgKfa2jbuIJYm 4i8U5CD/BB7gRht0lbIXaVkj7fI8douScdCCE5D791Be4UWXVqjsJjpkBu2fVms8TkzP a8cg== ARC-Message-Signature: i=2; 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; bh=7zBQ+jKKrfO9O4qvfQeA67+cejMB/pzT9h3QKVIFtZI=; fh=wq/8FRvx9rcFgVCe3ZmzYS1pgimebarJ6aWkDgUl4KA=; b=gr2aAQqW70RC1K8HJD8YFHrFckCUJwbsRzIewMtO9nvjrAeyRucKAvo4CgYNDhVjoC IIRdtVPhuBcq7XHLSG2Hn6syJdjRSOYOIdzYDHVmNlVgXuP/L48NBfEKTjTHyIvqG1b5 W5J2dSWGc6FpiNRKftT8Lw0W8agR/wTxFdXctnkm+a3s854yX6bNejozZ3LjsaOx2NOL RWKUMcKvivip5KmM/RoFU4iN5efbO4uDLIs1rAbrm42+4YQSLxSxX923QYehU0WwuuMg ElC8t4g5LYpxX3mPrwtAybnZSbsbC2hCwl2axfwU65YHd19m5ccru+Mf63sczto5VrhN euuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-75183-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75183-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l22-20020ac84596000000b0042e2aa110easi3434773qtn.691.2024.02.21.09.18.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 09:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75183-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-75183-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75183-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D2BAB1C22C74 for ; Wed, 21 Feb 2024 17:18:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A53985941; Wed, 21 Feb 2024 17:17:25 +0000 (UTC) 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 ECDC985920; Wed, 21 Feb 2024 17:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535843; cv=none; b=Q8SyVRcTUknVlnkHzdgVQZ3bn130UW0A1K8EQZy4yuhRxC4Pu2HvzzXMgkpwlF7yEfnMgPgzrr8Fr33o5jx/o4GGf7tMNgQhDVek25xuSxaJ9myuOKb4feEcPCoLyQxJRwD1AsaBILDoqXQ2/3hLVFUxKlLeimEvuyxG9Wzq9OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535843; c=relaxed/simple; bh=3poRLsl87I5LGoGOxmZJk8+3nZWuoc4lJ1AqHOCLYZI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M8e6BeU+VK3kio6ZrhSufFhW6IFTcav8l92ulW4Hl+FUn+0P9MlmThr5bjuR9ub0Go9ZHYeWou0+rFgAS6O7agYkyKk9g7m2xJ6j8MZ5LGUnT3Rcj/MZJqgIDhb1zVL5GfV3uYABsNck7YGN8JH8W0Llvk6kTXN6YuznoFzM8TE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; arc=none smtp.client-ip=195.135.223.131 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 imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 26CBA1FD5F; Wed, 21 Feb 2024 17:17:20 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id A574613A25; Wed, 21 Feb 2024 17:17:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id p5sFGx8w1mUWcQAAn2gu4w (envelope-from ); Wed, 21 Feb 2024 17:17:19 +0000 From: Marcos Paulo de Souza Date: Wed, 21 Feb 2024 14:17:04 -0300 Subject: [PATCH v2 2/4] selftests: livepatch: Avoid running the tests if kernel-devel is missing Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-lp-selftests-fixes-v2-2-a19be1e029a7@suse.com> References: <20240221-lp-selftests-fixes-v2-0-a19be1e029a7@suse.com> In-Reply-To: <20240221-lp-selftests-fixes-v2-0-a19be1e029a7@suse.com> To: Shuah Khan , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Marcos Paulo de Souza , kernel test robot X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1708535830; l=2202; i=mpdesouza@suse.com; s=20231031; h=from:subject:message-id; bh=3poRLsl87I5LGoGOxmZJk8+3nZWuoc4lJ1AqHOCLYZI=; b=MPj10FsveNXGa7hnAV7q6dARSYDTiOPFpQ0FKKtUWcm02p+ZxFSnUtUCDdOKV+Lc8bIZVQQ01 lD49kFKIBw0DvbKQOi5JcJK70lMbtNnNcbCyAYxscWflPw45s/FjXY5 X-Developer-Key: i=mpdesouza@suse.com; a=ed25519; pk=/Ni/TsKkr69EOmdZXkp1Q/BlzDonbOBRsfPa18ySIwU= Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 26CBA1FD5F X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791529766202031169 X-GMAIL-MSGID: 1791529766202031169 By checking if KDIR is a valid directory we can safely skip the tests if kernel-devel isn't installed (default value of KDIR), or if KDIR variable passed doesn't exists. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202402191417.XULH88Ct-lkp@intel.com/ Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/livepatch/functions.sh | 13 +++++++++++++ tools/testing/selftests/livepatch/test_modules/Makefile | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh index e60cf09491a6..f0ed148d3c51 100644 --- a/tools/testing/selftests/livepatch/functions.sh +++ b/tools/testing/selftests/livepatch/functions.sh @@ -34,6 +34,18 @@ function is_root() { fi } +# Check if we can compile the modules before loading them +function has_kdir() { + if [ -z "$KDIR" ]; then + KDIR="/lib/modules/$(uname -r)/build" + fi + + if [ ! -d "$KDIR" ]; then + echo "skip all tests: KDIR ($KDIR) not available to compile modules." + exit $ksft_skip + fi +} + # die(msg) - game over, man # msg - dying words function die() { @@ -108,6 +120,7 @@ function cleanup() { # the ftrace_enabled sysctl. function setup_config() { is_root + has_kdir push_config set_dynamic_debug set_ftrace_enabled 1 diff --git a/tools/testing/selftests/livepatch/test_modules/Makefile b/tools/testing/selftests/livepatch/test_modules/Makefile index f5e880269bff..e6e638c4bcba 100644 --- a/tools/testing/selftests/livepatch/test_modules/Makefile +++ b/tools/testing/selftests/livepatch/test_modules/Makefile @@ -13,8 +13,14 @@ obj-m += test_klp_atomic_replace.o \ test_klp_shadow_vars.o \ test_klp_syscall.o +# Ensure that KDIR exists, otherwise skip the compilation modules: +ifneq ("$(wildcard $(KDIR))", "") $(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR) +endif +# Ensure that KDIR exists, otherwise skip the clean target clean: +ifneq ("$(wildcard $(KDIR))", "") $(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR) +endif