From nobody Tue Feb 10 01:35:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1768104755; cv=none; d=zohomail.com; s=zohoarc; b=hQ1XIyoThIJrKPrpDFXpX8+CNPqi0ZeHNW7D2PQ+WJD/wfcDLJptHmmDvdPQdQI3Zp+Sm6dqMeJsp4m14OISpet63Iy0pfjZV2Guc9aaqVj7pjJKe7SFNikiX07J7dheXwGutp8b/lvPUXFJeGHuYryK1j3bRQA5YUldo1BIAdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768104755; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/m1LF2NtAIDgbIpy2Al8n60LY4uT2dvKj7zYoQhSDbo=; b=V8X3r8sgEKdRqVQwpk7rQczFroquvf1ql4TePHQe/vKAQ3UOR5rEdiLnz1lCmoyWES7yl9YOMNWFKxH68EzQ3TEdTK3DjdT847t6Gx2s0W85Aw6dQu20Vjdx2SN4AZe1wl2HRvYq974Itkadp1pOJl7qR9KqHg4gXQ4QBPC/ptI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1768104755964872.3946839545982; Sat, 10 Jan 2026 20:12:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1199668.1515895 (Exim 4.92) (envelope-from ) id 1vemo5-0004kw-NO; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (output) from mailman id 1199668.1515895; Sun, 11 Jan 2026 04:12:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo5-0004jX-JR; Sun, 11 Jan 2026 04:12:01 +0000 Received: by outflank-mailman (input) for mailman id 1199668; Sun, 11 Jan 2026 04:12:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vemo4-0004c9-U8 for xen-devel@lists.xenproject.org; Sun, 11 Jan 2026 04:12:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1vemo2-001xog-19; Sun, 11 Jan 2026 04:11:58 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vemo2-000Y62-1F; Sun, 11 Jan 2026 04:11:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=/m1LF2NtAIDgbIpy2Al8n60LY4uT2dvKj7zYoQhSDbo=; b=CUAl6W3UatzdFdEXzrnO6uITi1 5AaHssv4pclOCF7xrV739auHVlzo7QXZP3AkfWJe3PQGhlAo3Zwf6WwumunB3OH8Xwi9QyUR3t/ik nxBAHU9gzsS34J+fbJigMuALA9Mf9MgLuYxPyCXCXoIG7xq60dr7IlVhCSf+WJYXmZXQ=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2 1/4] tests: fixup domid make fragment Date: Sat, 10 Jan 2026 20:11:42 -0800 Message-ID: <20260111041145.553673-2-dmukhin@ford.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260111041145.553673-1-dmukhin@ford.com> References: <20260111041145.553673-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1768104756455158500 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 There can be multiple test harnesses per one test target (e.g. harness.h and harness2.h). Account for that by further parametrizing existing emit-harness-nested-rule(). Add guard against HOSTCC !=3D CC (similarly to how its done in PDX unit tes= t). Account for multiple test targets in install and uninstall make targets. Introduce CFLAGS dedicated for find-next-bit.c only to avoid contaminating global CFLAGS. Honor mocked hypervisor header over tools/include/xen symlinks. Finally, add some clarifications for the functions. Amends: 2d5065060710 ("xen/domain: unify domain ID allocation") Signed-off-by: Denis Mukhin --- Changes since v1: - updated commentaries - added ability to select the harness header filename - fixup for picking up mocked header files --- tools/tests/domid/Makefile | 63 ++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile index 753129029ed9..dd22a25b038a 100644 --- a/tools/tests/domid/Makefile +++ b/tools/tests/domid/Makefile @@ -4,36 +4,55 @@ # # Copyright 2025 Ford Motor Company =20 -XEN_ROOT=3D$(CURDIR)/../../.. -include $(XEN_ROOT)/tools/Rules.mk - TESTS :=3D test-domid =20 +XEN_ROOT =3D $(CURDIR)/../../.. +include $(XEN_ROOT)/tools/Rules.mk + define list-c-headers $(shell sed -n \ 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) endef =20 -# NB: $1 cannot be a list +# Generate mock environment by replicating header file hierarchy; +# each header file will point to a harness header. +# +# $1 target +# $2 list of test harnesses define emit-harness-nested-rule -$(1): $(CURDIR)/harness.h - mkdir -p $$(@D); - ln -sf $$< $$@; +$(1): $(2) + set -e; \ + mkdir -p $$(@D); \ + for i in $(2); do [ -e $$@ ] || ln -s $$$$i $$@; done =20 endef =20 +# Helper function to emit mocked hypervisor code dependencies. +# +# $1 Harness file name. +# $2 Mocked hypervisor file name. +# $3 List of dependencies to mock. define emit-harness-rules -$(foreach x,$(2),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(x))) -$(1:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(2)) +$(foreach x,$(3),$(call emit-harness-nested-rule,\ + $(CURDIR)/generated/$(x),\ + $(addprefix $(CURDIR)/,$(1)))) +$(2:.c=3D.o): $(addprefix $(CURDIR)/generated/,$(3)) endef =20 define emit-harness-deps -$(if $(strip $(2)),$(call emit-harness-rules,$1,$2),) +$(if $(strip $(3)),$(call emit-harness-rules,$1,$2,$3),) endef =20 +# Emit dependencies for mocked hypervisor code. +# +# $1 Hypervisor file name. +# $2 Hypervisor source path. +# $3 Harness header file name (optional). define vpath-with-harness-deps vpath $(1) $(2) -$(call emit-harness-deps,$(1),$(call list-c-headers,$(2)$(1))) +$(call emit-harness-deps,$(or $(strip $(3)),harness.h),\ + $(1),\ + $(call list-c-headers,$(2)$(1))) endef =20 .PHONY: all @@ -41,7 +60,11 @@ all: $(TESTS) =20 .PHONY: run run: $(TESTS) +ifeq ($(CC),$(HOSTCC)) set -e; $(foreach t,$(TESTS),./$(t);) +else + $(warning HOSTCC !=3D CC, will not run test) +endif =20 .PHONY: clean clean: @@ -55,25 +78,27 @@ distclean: clean .PHONY: install install: all $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests - $(INSTALL_PROG) test-domid $(DESTDIR)$(LIBEXEC)/tests + set -e; $(foreach t,$(TESTS),$(INSTALL_PROG) $t $(DESTDIR)$(LIBEXEC)/test= s;) =20 .PHONY: uninstall uninstall: - $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid + set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;) =20 CFLAGS +=3D -D__XEN_TOOLS__ + # find-next-bit.c -CFLAGS +=3D '-DEXPORT_SYMBOL(x)=3D' \ +CFLAGS-find-next-bit.c +=3D '-DEXPORT_SYMBOL(x)=3D' \ -Dfind_first_bit \ -Dfind_first_zero_bit \ -Dfind_next_bit \ -Dfind_next_bit_le \ -Dfind_next_zero_bit_le -CFLAGS +=3D $(APPEND_CFLAGS) -CFLAGS +=3D $(CFLAGS_xeninclude) -CFLAGS +=3D -I./generated/ =20 -LDFLAGS +=3D $(APPEND_LDFLAGS) +find-next-bit.o: CFLAGS +=3D $(CFLAGS-find-next-bit.c) + +# Honor mocked hypervisor header over tools/include/xen symlinks +CFLAGS +=3D -I$(CURDIR)/generated/ +CFLAGS +=3D $(CFLAGS_xeninclude) =20 vpath find-next-bit.c $(XEN_ROOT)/xen/lib/ =20 @@ -83,6 +108,6 @@ vpath find-next-bit.c $(XEN_ROOT)/xen/lib/ $(eval $(call vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/)) =20 test-domid: domid.o find-next-bit.o test-domid.o - $(CC) $^ -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ =20 -include $(DEPS_INCLUDE) --=20 2.52.0