From nobody Mon Dec 1 23:06:45 2025 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 D093033FE12 for ; Wed, 26 Nov 2025 19:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764185791; cv=none; b=HunPt/447eeVMKkUHHiMTHpN9ydlHpC2SZOXoSVWUCdUYs7QNmfyH/bVoZGnmA2iRQetRa+QhLhKFOduBVoZAYu/TNa+nCnaDnZD667ajD6PPnxePBwdLE2ssAN9nxgvho+2VwzNImkCGv4Wzgru5djZr6zSVE9nHURY7FdpqPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764185791; c=relaxed/simple; bh=xQdAIox14rL920kyxPeD7CGr8MVH1OzKyBlfF0iKpfE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WDsXqDpjXmk81EOJkLXwSKvVWvA0mJeNq9w33qrJBLU6zxsnMfKZ3JqnU5ktYSuhFwDpH0n++tCYAy1fY0eDAkHzOvv+8Q2tQLr5Jdr78ZbncDLSkWJdyl/ozVi7A+mFnEVuBOOadppl02p6HqxQ01l1KYUrUdAjYSIJI95ijJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PVd+SVD9; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PVd+SVD9" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7b89ee2c1a4so76728b3a.2 for ; Wed, 26 Nov 2025 11:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764185788; x=1764790588; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=il8MDXrCBxc/QPsV+lp75cRRTs/ibymz6EtH1r9GxH0=; b=PVd+SVD9/FIoYKdXiKq+36U1PqFFPos0JvjwDGRwbIgOKzCNnaWjPJ507HBKqbVjuu OBvdES4816PnOAe4b06Tu7oQtDG/WrN2jqpbMx+Jc8x3H9T/MSb3t0IACxj9NMydtiT8 qvjbwcDabu8DHvdkNGz72yUZVuEbrjIzHPjgTaZ7SnR6pyBb7jUONSiOEc0JvEmAkS6+ BSz8d8Hz5Gky7joHDFJ6TCEP80chvEl/dgz1Tg9TLCOaxMqTRmKKxqDfj2EnxOSqcz7a fjKIVsh/ZyLSGLtAvuDmu1D6/zvBAr3tL6jQ7PqwlXFivfDU8GuLsZOIC4jgfIl8ZrgB IiIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764185788; x=1764790588; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=il8MDXrCBxc/QPsV+lp75cRRTs/ibymz6EtH1r9GxH0=; b=xRINr6OfSzN0TJXeUuSC2oHq1jABxY12rWLeGZoYVPG9WlADkd+qCDh2bKNYIpabzz WBe4L5o0FIwUxBhT+SprAZ0XCbFrj72Mo0SHS0rf97EZV4gG0Gt3hRg8ux9g0wUviNZv 0F0Clv861kfG8eNTGT+Ljj8QXqpfSY01swrZneIRm2CW+Q59CJRJUTyFAj71Ddf6Rk2b nkW6pXyK9B6cLR1KOvkWnLDstziIpvvxc7G22ZJmbB8hSor+hqgUveaC4Im1eoP1+/Dc NoaS0BWSiDE59kEsA0plOI4O11f4xE/PZndD9Es7N9vOSqX8QjMLFFuW+cboUT+uV4Bu 2uwQ== X-Forwarded-Encrypted: i=1; AJvYcCUc0CH5+FDmqIn4Swt/8ZGIUS1yKGSLIguj3+39j8nehfM19vsqubhw+9t1XNzm5zzrOocdlNG/Jg3jXNM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzm5M4oWb9A2PhruThmWSAj5trz6wRUaQvMO8KFXDYB0iZ1KVE OslAUfHfWw8FesgZELZmMVlB3UHDMnrNT3BTGUJZf8wLLV5EmuaLkZBPQclPEdxxMsy0VrzQ2r7 R9mTm9CiX0piZ0g== X-Google-Smtp-Source: AGHT+IFjRkYzrHjH75Y+Axw4RUqwa3zdxTT3QVQfwdPfSsZ2PKB+LzQLV1cCLFLD84k+auOPTtZD5gnENKFtpA== X-Received: from pfblo2.prod.google.com ([2002:a05:6a00:3d02:b0:7c5:ca53:260e]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1812:b0:7b8:8d43:fcd2 with SMTP id d2e1a72fcca58-7c58c7a883emr24782001b3a.14.1764185787996; Wed, 26 Nov 2025 11:36:27 -0800 (PST) Date: Wed, 26 Nov 2025 19:35:58 +0000 In-Reply-To: <20251126193608.2678510-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251126193608.2678510-1-dmatlack@google.com> X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251126193608.2678510-12-dmatlack@google.com> Subject: [PATCH 11/21] selftests/liveupdate: Move luo_test_utils.* into a reusable library From: David Matlack To: Alex Williamson Cc: Adithya Jayachandran , Alex Mastro , Alistair Popple , Andrew Morton , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Josh Hilke , Kevin Tian , kvm@vger.kernel.org, Leon Romanovsky , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org, Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Philipp Stanner , Pratyush Yadav , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Tomita Moeko , Vipin Sharma , William Tu , Yi Liu , Yunxiang Li , Zhu Yanjun Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vipin Sharma Move luo_test_utils.[ch] into a lib/ directory and pull the rules to build them out into a separate make script. This will enable these utilities to be also built by and used within other selftests (such as VFIO) in subsequent commits. No functional change intended. Signed-off-by: Vipin Sharma Co-Developed-by: David Matlack Signed-off-by: David Matlack --- tools/testing/selftests/liveupdate/.gitignore | 1 + tools/testing/selftests/liveupdate/Makefile | 14 ++++--------- .../include/libliveupdate.h} | 8 ++++---- .../selftests/liveupdate/lib/libliveupdate.mk | 20 +++++++++++++++++++ .../{luo_test_utils.c =3D> lib/liveupdate.c} | 2 +- .../selftests/liveupdate/luo_kexec_simple.c | 2 +- .../selftests/liveupdate/luo_multi_session.c | 2 +- 7 files changed, 32 insertions(+), 17 deletions(-) rename tools/testing/selftests/liveupdate/{luo_test_utils.h =3D> lib/inclu= de/libliveupdate.h} (87%) create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk rename tools/testing/selftests/liveupdate/{luo_test_utils.c =3D> lib/liveu= pdate.c} (99%) diff --git a/tools/testing/selftests/liveupdate/.gitignore b/tools/testing/= selftests/liveupdate/.gitignore index 661827083ab6..18a0c7036cf3 100644 --- a/tools/testing/selftests/liveupdate/.gitignore +++ b/tools/testing/selftests/liveupdate/.gitignore @@ -3,6 +3,7 @@ !/**/ !*.c !*.h +!*.mk !*.sh !.gitignore !config diff --git a/tools/testing/selftests/liveupdate/Makefile b/tools/testing/se= lftests/liveupdate/Makefile index 080754787ede..a060cc21f27f 100644 --- a/tools/testing/selftests/liveupdate/Makefile +++ b/tools/testing/selftests/liveupdate/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only =20 -LIB_C +=3D luo_test_utils.c - TEST_GEN_PROGS +=3D liveupdate =20 TEST_GEN_PROGS_EXTENDED +=3D luo_kexec_simple @@ -10,25 +8,21 @@ TEST_GEN_PROGS_EXTENDED +=3D luo_multi_session TEST_FILES +=3D do_kexec.sh =20 include ../lib.mk +include lib/libliveupdate.mk =20 CFLAGS +=3D $(KHDR_INCLUDES) CFLAGS +=3D -Wall -O2 -Wno-unused-function CFLAGS +=3D -MD =20 -LIB_O :=3D $(patsubst %.c, $(OUTPUT)/%.o, $(LIB_C)) TEST_O :=3D $(patsubst %, %.o, $(TEST_GEN_PROGS)) TEST_O +=3D $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) =20 -TEST_DEP_FILES :=3D $(patsubst %.o, %.d, $(LIB_O)) +TEST_DEP_FILES :=3D $(patsubst %.o, %.d, $(LIBLIVEUPDATE_O)) TEST_DEP_FILES +=3D $(patsubst %.o, %.d, $(TEST_O)) -include $(TEST_DEP_FILES) =20 -$(LIB_O): $(OUTPUT)/%.o: %.c - $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ - -$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIB_O) - $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIB_O) $(LDLIB= S) -o $@ +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIBLIVEUP= DATE_O) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBLIVEUPDATE_= O) $(LDLIBS) -o $@ =20 -EXTRA_CLEAN +=3D $(LIB_O) EXTRA_CLEAN +=3D $(TEST_O) EXTRA_CLEAN +=3D $(TEST_DEP_FILES) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.h b/tools/te= sting/selftests/liveupdate/lib/include/libliveupdate.h similarity index 87% rename from tools/testing/selftests/liveupdate/luo_test_utils.h rename to tools/testing/selftests/liveupdate/lib/include/libliveupdate.h index 90099bf49577..4390a2737930 100644 --- a/tools/testing/selftests/liveupdate/luo_test_utils.h +++ b/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h @@ -7,13 +7,13 @@ * Utility functions for LUO kselftests. */ =20 -#ifndef LUO_TEST_UTILS_H -#define LUO_TEST_UTILS_H +#ifndef SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H +#define SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H =20 #include #include #include -#include "../kselftest.h" +#include "../../../kselftest.h" =20 #define LUO_DEVICE "/dev/liveupdate" =20 @@ -41,4 +41,4 @@ typedef void (*luo_test_stage2_fn)(int luo_fd, int state_= session_fd); int luo_test(int argc, char *argv[], const char *state_session_name, luo_test_stage1_fn stage1, luo_test_stage2_fn stage2); =20 -#endif /* LUO_TEST_UTILS_H */ +#endif /* SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H */ diff --git a/tools/testing/selftests/liveupdate/lib/libliveupdate.mk b/tool= s/testing/selftests/liveupdate/lib/libliveupdate.mk new file mode 100644 index 000000000000..fffd95b085b6 --- /dev/null +++ b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk @@ -0,0 +1,20 @@ +include $(top_srcdir)/scripts/subarch.include +ARCH ?=3D $(SUBARCH) + +LIBLIVEUPDATE_SRCDIR :=3D $(selfdir)/liveupdate/lib + +LIBLIVEUPDATE_C :=3D liveupdate.c + +LIBLIVEUPDATE_OUTPUT :=3D $(OUTPUT)/libliveupdate + +LIBLIVEUPDATE_O :=3D $(patsubst %.c, $(LIBLIVEUPDATE_OUTPUT)/%.o, $(LIBLIV= EUPDATE_C)) + +LIBLIVEUPDATE_O_DIRS :=3D $(shell dirname $(LIBLIVEUPDATE_O) | uniq) +$(shell mkdir -p $(LIBLIVEUPDATE_O_DIRS)) + +CFLAGS +=3D -I$(LIBLIVEUPDATE_SRCDIR)/include + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/= %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN +=3D $(LIBLIVEUPDATE_OUTPUT) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.c b/tools/te= sting/selftests/liveupdate/lib/liveupdate.c similarity index 99% rename from tools/testing/selftests/liveupdate/luo_test_utils.c rename to tools/testing/selftests/liveupdate/lib/liveupdate.c index 3c8721c505df..60121873f685 100644 --- a/tools/testing/selftests/liveupdate/luo_test_utils.c +++ b/tools/testing/selftests/liveupdate/lib/liveupdate.c @@ -21,7 +21,7 @@ #include #include =20 -#include "luo_test_utils.h" +#include =20 int luo_open_device(void) { diff --git a/tools/testing/selftests/liveupdate/luo_kexec_simple.c b/tools/= testing/selftests/liveupdate/luo_kexec_simple.c index d7ac1f3dc4cb..786ac93b9ae3 100644 --- a/tools/testing/selftests/liveupdate/luo_kexec_simple.c +++ b/tools/testing/selftests/liveupdate/luo_kexec_simple.c @@ -8,7 +8,7 @@ * across a single kexec reboot. */ =20 -#include "luo_test_utils.h" +#include =20 #define TEST_SESSION_NAME "test-session" #define TEST_MEMFD_TOKEN 0x1A diff --git a/tools/testing/selftests/liveupdate/luo_multi_session.c b/tools= /testing/selftests/liveupdate/luo_multi_session.c index 0ee2d795beef..aac24a5f5ce3 100644 --- a/tools/testing/selftests/liveupdate/luo_multi_session.c +++ b/tools/testing/selftests/liveupdate/luo_multi_session.c @@ -9,7 +9,7 @@ * files. */ =20 -#include "luo_test_utils.h" +#include =20 #define SESSION_EMPTY_1 "multi-test-empty-1" #define SESSION_EMPTY_2 "multi-test-empty-2" --=20 2.52.0.487.g5c8c507ade-goog