|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 1/5] tests: fixup domid make fragment
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |