From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 72ED737DE99 for ; Wed, 10 Jun 2026 23:09:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781132960; cv=none; b=WXr45up8A4GUM+uFkD2NAMrxTjjGPjF5l3n8TbsnaJXmdtGPCo7yFodOky57fu170sJJy3cuPfu0gj3r06SVWXdM58kQBtu9RXUplxBoI5D14Agdpn3ROmqN36UQwJrCJ9Sb5JnxAsxup57kj+FYN1PoFGigYXxpNYB6tf5il0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781132960; c=relaxed/simple; bh=YSL0TIPoLxBEltwVkzIBvgEr5xZ8reyI/QfTO/n+yFQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IWUs59ifTHr04VwUzhAKVYnjbm+54maVhE82FwapzyjIhRGyOfvoh8Uxl5AE9eK/GvMh7UWbLA145LcT33mTNXjvA2I+NZpYL94TXy4E6RrW5eE/eGam1ovLuGtiMuypurDrwpZ1MmMny8ErNYgzRdoN42PWs4Lolzm3TLr30VA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vipinsh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qLDnYbqg; arc=none smtp.client-ip=209.85.214.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--vipinsh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qLDnYbqg" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2bf11699875so3626635ad.1 for ; Wed, 10 Jun 2026 16:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781132956; x=1781737756; 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=b0+7RpPS1OtZ4KOjVApYD0qDi4zot9K60kAK3POmulg=; b=qLDnYbqgFnq8z0BVSTixBrQ1HZrQHpPG/svKzClgrFqUu7H0x1Q6Y0WMxpk3WCN0RU fsvp9q8xHRiLd1uQaorzscef0xzQrNZQtK0lwcMlwRCikVbnMSUolDBfNIVg7YJgKnUn /g0SA7bCP3RA1NkjEU3CFwx/X98G3UpuK77mpoHoWmrTHvqXIMLnCqzBR/uFFb/wHoxy 5tWe2KK6CAucInsyNvOO2/+V0AkICtOU9szWTL5+DC3HfBIhsGIf6xpw8k5iV6FYTO9K tE66FbE8A0vYpr5LJVgYzBDG9D0IVtEjQXI0rSHbQOiKEwNlFrGQ/wBNGtBmLoaMQcYn J+mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781132956; x=1781737756; 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=b0+7RpPS1OtZ4KOjVApYD0qDi4zot9K60kAK3POmulg=; b=CqFfsBPdk7kvPNEj1+aRLLTWcIzW6P7csgH6ltHUnDNDZE2nm8P5zT9kdlMzJfFN6G wea+Zz1/u3vwXbG37fEsRyCxtHAX/h1k6ncuRsxs5q/PXnslkb0Jl4D/PHbHPK5S4pPF l1slBiFhCiKp39iUBGEdIieMXsfqm07il0N6iVkKPmwQvR/DY26tDn+V/JuZNqrCLDW9 gkaXVT6dn2nDRQ+50h36Fk0Fs0SlVBLXlbgMEWGROfcO6jjjMZxd+p8NguzbDiFU/Jtz TiK2rh1HTo7cZBwaYKcCK2gxQYtryj7yzsbD0onRijLnTxQUCjWoq6fGO3IOE4og8sYw duxg== X-Forwarded-Encrypted: i=1; AFNElJ8/de947YPkMfjLKR3bvqP4ObgUK8+h54OVTOwIn/05M6LgpAPUhIFsahy/SCBZE7JTw/shhza2kwSbYL4=@vger.kernel.org X-Gm-Message-State: AOJu0YzMAjvlfQ+turHJx5vgsJTB4fWk8awSDcyDugfJYZiVv9Tn5vmI oHAj0q1JLOzqnanz3FiWIMHrHQ55D6CVMxNxpKp6wjOveOcTbIX8RHxqQGeZhuyNoKYzinksKKn zJLsMCHFuww== X-Received: from plrf3.prod.google.com ([2002:a17:902:ab83:b0:2ba:39b8:446f]) (user=vipinsh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e742:b0:2c0:dc5c:9069 with SMTP id d9443c01a7336-2c2f57aeff0mr244655ad.2.1781132955512; Wed, 10 Jun 2026 16:09:15 -0700 (PDT) Date: Wed, 10 Jun 2026 16:09:07 -0700 In-Reply-To: <20260610230909.876546-1-vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260610230909.876546-1-vipinsh@google.com> X-Mailer: git-send-email 2.54.0.1099.g489fc7bff1-goog Message-ID: <20260610230909.876546-2-vipinsh@google.com> Subject: [PATCH v2 1/2] selftests/liveupdate: Move luo_test_utils.* into a reusable library From: Vipin Sharma To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org Cc: tarunsahu@google.com, skhawaja@google.com, shuah@kernel.org, dmatlack@google.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-kselftest@vger.kernel.org, Vipin Sharma Content-Type: text/plain; charset="UTF-8" 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). No functional change intended. Co-developed-by: David Matlack Signed-off-by: David Matlack Acked-by: Pratyush Yadav (Google) Signed-off-by: Vipin Sharma --- 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 => lib/liveupdate.c} | 2 +- .../testing/selftests/liveupdate/liveupdate.c | 2 +- .../selftests/liveupdate/luo_kexec_simple.c | 2 +- .../selftests/liveupdate/luo_multi_session.c | 2 +- .../selftests/liveupdate/luo_stress_files.c | 2 +- .../liveupdate/luo_stress_sessions.c | 2 +- 10 files changed, 35 insertions(+), 20 deletions(-) rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (87%) create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.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/selftests/liveupdate/Makefile index 30689d22cb02..634211c66652 100644 --- a/tools/testing/selftests/liveupdate/Makefile +++ b/tools/testing/selftests/liveupdate/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -LIB_C += luo_test_utils.c - TEST_GEN_PROGS += liveupdate TEST_GEN_PROGS_EXTENDED += luo_kexec_simple @@ -12,25 +10,21 @@ TEST_GEN_PROGS_EXTENDED += luo_stress_files TEST_FILES += do_kexec.sh include ../lib.mk +include lib/libliveupdate.mk CFLAGS += $(KHDR_INCLUDES) CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -MD -LIB_O := $(patsubst %.c, $(OUTPUT)/%.o, $(LIB_C)) TEST_O := $(patsubst %, %.o, $(TEST_GEN_PROGS)) TEST_O += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) -TEST_DEP_FILES := $(patsubst %.o, %.d, $(LIB_O)) +TEST_DEP_FILES := $(patsubst %.o, %.d, $(LIBLIVEUPDATE_O)) TEST_DEP_FILES += $(patsubst %.o, %.d, $(TEST_O)) -include $(TEST_DEP_FILES) -$(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) $(LDLIBS) -o $@ +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIBLIVEUPDATE_O) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBLIVEUPDATE_O) $(LDLIBS) -o $@ -EXTRA_CLEAN += $(LIB_O) EXTRA_CLEAN += $(TEST_O) EXTRA_CLEAN += $(TEST_DEP_FILES) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.h b/tools/testing/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 6a0d85386613..6ff71d7c3d9c 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. */ -#ifndef LUO_TEST_UTILS_H -#define LUO_TEST_UTILS_H +#ifndef SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H +#define SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H #include #include #include -#include "../kselftest.h" +#include "../../../kselftest.h" #define LUO_DEVICE "/dev/liveupdate" @@ -43,4 +43,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); -#endif /* LUO_TEST_UTILS_H */ +#endif /* SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H */ diff --git a/tools/testing/selftests/liveupdate/lib/libliveupdate.mk b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file mode 100644 index 000000000000..0fb738c02330 --- /dev/null +++ b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk @@ -0,0 +1,20 @@ +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + +LIBLIVEUPDATE_SRCDIR := $(selfdir)/liveupdate/lib + +LIBLIVEUPDATE_C := liveupdate.c + +LIBLIVEUPDATE_OUTPUT := $(OUTPUT)/libliveupdate + +LIBLIVEUPDATE_O := $(patsubst %.c, $(LIBLIVEUPDATE_OUTPUT)/%.o, $(LIBLIVEUPDATE_C)) + +CFLAGS += -I$(LIBLIVEUPDATE_SRCDIR)/include + +$(LIBLIVEUPDATE_OUTPUT): + $(Q)mkdir -p $@ + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/%.c | $(LIBLIVEUPDATE_OUTPUT) + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN += $(LIBLIVEUPDATE_OUTPUT) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.c b/tools/testing/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 333a3530051b..897c200f3845 100644 --- a/tools/testing/selftests/liveupdate/luo_test_utils.c +++ b/tools/testing/selftests/liveupdate/lib/liveupdate.c @@ -22,7 +22,7 @@ #include #include -#include "luo_test_utils.h" +#include int luo_open_device(void) { diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testing/selftests/liveupdate/liveupdate.c index 502fb3567e38..6bfd4e53528c 100644 --- a/tools/testing/selftests/liveupdate/liveupdate.c +++ b/tools/testing/selftests/liveupdate/liveupdate.c @@ -25,8 +25,8 @@ #include #include +#include -#include "luo_test_utils.h" #include "../kselftest.h" #include "../kselftest_harness.h" 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. */ -#include "luo_test_utils.h" +#include #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. */ -#include "luo_test_utils.h" +#include #define SESSION_EMPTY_1 "multi-test-empty-1" #define SESSION_EMPTY_2 "multi-test-empty-2" diff --git a/tools/testing/selftests/liveupdate/luo_stress_files.c b/tools/testing/selftests/liveupdate/luo_stress_files.c index 0cdf9cd4bac7..c0f15c892950 100644 --- a/tools/testing/selftests/liveupdate/luo_stress_files.c +++ b/tools/testing/selftests/liveupdate/luo_stress_files.c @@ -10,7 +10,7 @@ #include #include -#include "luo_test_utils.h" +#include #define NUM_FILES 500 #define STATE_SESSION_NAME "kexec_many_files_state" diff --git a/tools/testing/selftests/liveupdate/luo_stress_sessions.c b/tools/testing/selftests/liveupdate/luo_stress_sessions.c index f201b1839d1d..8af19259ced3 100644 --- a/tools/testing/selftests/liveupdate/luo_stress_sessions.c +++ b/tools/testing/selftests/liveupdate/luo_stress_sessions.c @@ -10,7 +10,7 @@ #include #include -#include "luo_test_utils.h" +#include #define NUM_SESSIONS 2000 #define STATE_SESSION_NAME "kexec_many_state" -- 2.54.0.1099.g489fc7bff1-goog