[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 1/5] tests: fixup domid make fragment


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Thu, 12 Feb 2026 18:49:48 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 148.163.138.245) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gwKKWwFQSxOL2nXP9KGBiAgclLhKYOLn3uWhkxYkz78=; b=Y900s3dqp3kMxUWmTDmyblFPaS0rZsXrBLd+jaRGvfM0M2OLivrQo9xOC4x/0AePNPMPsenqaNspdtgywDPLTiKcy6ggM131OMHch0ggPmTy4Tb8AA1wKNLOP663PF9qTCUjBmiYWRLMtozqDtzmsBCI07V57TC8epf0lv4ocRsmKrkrTLTHhxhRSbI3MTb3Z3+pQ0AdytPs77IzBZOm1mofsvvECvfP5ns4B23ZDPg1w7ISGRLc/qQvGDHtidse7EiMJZqryl0ed2/VN4YdC1Oh9kDre/aMJRkBeEs9ht9zTn7xfUxd+w+uaK9QLtI4KJe2/hBedMnRC02YESTD1Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XjdIFgOky16Ql43XpphN5yJNrmjOlzpexS0wJw4oZEdnRkIJ7b3F5FrgiGa9Bq8av8bs/4gLQkjOjQ8cgkmWvE0wr+4tcSd8xyTrKG9utqKT3+Yx/8bZ/aFlDNJqgyRtQouOdFHtJi9QseCaAXHcHzIWYMp4qx7ZYs5+wT4pe+JFMtjW3FFui2P+I3hVVyZov3PDoo8YqyCYSKxpez9UWS46dKuCQ/qDUdqOY2WuXvvZOTxyxndgRV/1Ldh5ZfcD3FEpT5CJV8NAV3RJMDMipmRuE1uaPtwdvw/iBI9YPXd2reN79XCd0QE9y9UOjCBv5qgC8mM+H84dqOBkwIw+5g==
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger.pau@xxxxxxxxxx, sstabellini@xxxxxxxxxx, dmukhin@xxxxxxxx
  • Delivery-date: Fri, 13 Feb 2026 02:50:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx> 

Add guard against HOSTCC != CC (similarly to how its done in PDX unit test).

Account for multiple test targets in install and uninstall make targets.

Honor mocked hypervisor header over tools/include/xen symlinks.

Finally, add some clarifications for the functions and do some cleanup.

Amends: 2d5065060710 ("xen/domain: unify domain ID allocation")
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v2:
- fixed emit-harness-nested-rule
- honor LDFLAGS_APPEND
---
 tools/tests/domid/Makefile | 59 +++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 16 deletions(-)

diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
index 753129029ed9..74cadab25b2e 100644
--- a/tools/tests/domid/Makefile
+++ b/tools/tests/domid/Makefile
@@ -14,26 +14,44 @@ $(shell sed -n \
     's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null)
 endef
 
-# NB: $1 cannot be a list
+# Generate mock environment by replicating header file hierarchy;
+# each mock header file will point to a harness header.
+#
+# $1 Hypervisor header.
+# $2 Test harness header.
 define emit-harness-nested-rule
-$(1): $(CURDIR)/harness.h
-       mkdir -p $$(@D);
-       ln -sf $$< $$@;
+$(1): $(2)
+       set -e; \
+       mkdir -p $$(@D); \
+       [ -e $$@ ] || ln -s $(2) $$@
 
 endef
 
-define emit-harness-rules
-$(foreach x,$(2),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(x)))
-$(1:.c=.o): $(addprefix $(CURDIR)/generated/,$(2))
-endef
-
+# Helper function to emit mock hypervisor code dependencies.
+#
+# $1 Hypervisor filename.
+# $2 Harness filename.
 define emit-harness-deps
-$(if $(strip $(2)),$(call emit-harness-rules,$1,$2),)
+$(eval c-file := $(abspath $(1)))
+$(eval c-name := $(notdir $(c-file)))
+$(eval c-headers := $(call list-c-headers,$(c-file)))
+$(eval c-deps := $(addprefix $(CURDIR)/generated/,$(c-headers)))
+$(foreach x,$(c-headers),$(call emit-harness-nested-rule,\
+                         $(addprefix $(CURDIR)/generated/,$(x)),\
+                         $(2)))
+$(c-name:%.c=%.o): $(c-file) $(c-deps)
+       $(CC) $(CFLAGS) -o $$@ -c $$(firstword $$^)
+
 endef
 
+# Emit dependencies for mock hypervisor code.
+#
+# $1 Hypervisor filename.
+# $2 Hypervisor source path.
 define vpath-with-harness-deps
 vpath $(1) $(2)
-$(call emit-harness-deps,$(1),$(call list-c-headers,$(2)$(1)))
+$(call emit-harness-deps,$(addprefix $(2),$(1)),\
+                         $(CURDIR)/harness.h)
 endef
 
 .PHONY: all
@@ -41,7 +59,11 @@ all: $(TESTS)
 
 .PHONY: run
 run: $(TESTS)
+ifeq ($(CC),$(HOSTCC))
        set -e; $(foreach t,$(TESTS),./$(t);)
+else
+       $(warning HOSTCC != CC, will not run test)
+endif
 
 .PHONY: clean
 clean:
@@ -55,13 +77,12 @@ 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)/tests;)
 
 .PHONY: uninstall
 uninstall:
-       $(RM) -- $(DESTDIR)$(LIBEXEC)/tests/test-domid
+       set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;)
 
-CFLAGS += -D__XEN_TOOLS__
 # find-next-bit.c
 CFLAGS += '-DEXPORT_SYMBOL(x)=' \
           -Dfind_first_bit \
@@ -69,9 +90,13 @@ CFLAGS += '-DEXPORT_SYMBOL(x)=' \
           -Dfind_next_bit \
           -Dfind_next_bit_le \
           -Dfind_next_zero_bit_le
-CFLAGS += $(APPEND_CFLAGS)
+
+CFLAGS += -D__XEN_TOOLS__
+
+# Honor mock hypervisor headers over tools/include/xen
+CFLAGS += -I$(CURDIR)/generated/
 CFLAGS += $(CFLAGS_xeninclude)
-CFLAGS += -I./generated/
+CFLAGS += $(APPEND_CFLAGS)
 
 LDFLAGS += $(APPEND_LDFLAGS)
 
@@ -85,4 +110,6 @@ $(eval $(call 
vpath-with-harness-deps,domid.c,$(XEN_ROOT)/xen/common/))
 test-domid: domid.o find-next-bit.o test-domid.o
        $(CC) $^ -o $@ $(LDFLAGS)
 
+ifeq ($(filter clean distclean,$(MAKECMDGOALS)),)
 -include $(DEPS_INCLUDE)
+endif
-- 
2.52.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.