tools/tests: test harness fragment
v3 cover tools/tests: test harness fragment
This series introduces the use of a new common unit test fragment across several existing unit tests.
Patch 1 contains assorted fixups for the domid Makefile.
Patch 2 adds a new fragment for auto-generating test harness dependencies. Patch 3 adds some prerequisite changes for vPCI test (patch 4). Patch 4 switches the vPCI unit test to the new common fragment. Patch 5 switches the PDX unit test to the new common fragment.
[1] Link to v2: https://lore.kernel.org/xen-devel/[email protected]/
[2] CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2323352235
Denis Mukhin (5):
tests: fixup domid make fragment
tests: use unit test fragment in domid test
xen/include: customize headers for host builds
tests: use unit test fragment in vPCI test
tests: use unit test fragment in PDX test
tools/tests/Rules.mk | 106 ++++++++++++++++++++++++++++++++++++ tools/tests/domid/Makefile | 68 ++--------------------- tools/tests/pdx/.gitignore | 2 +- tools/tests/pdx/Makefile | 59 ++++++-------------- tools/tests/pdx/harness.h | 2 +- tools/tests/pdx/test-pdx.c | 2 - tools/tests/vpci/.gitignore | 2 + tools/tests/vpci/Makefile | 52 ++++++------------ tools/tests/vpci/emul.h | 50 ++++++----------- tools/tests/vpci/main.c | 2 - xen/common/pdx.c | 3 +- xen/include/xen/irq.h | 2 + xen/include/xen/list.h | 2 + xen/include/xen/numa.h | 2 + xen/include/xen/pci.h | 2 + xen/include/xen/pdx.h | 2 + xen/include/xen/pfn.h | 2 + xen/include/xen/spinlock.h | 2 + xen/include/xen/types.h | 4 ++ 19 files changed, 185 insertions(+), 181 deletions(-) create mode 100644 tools/tests/Rules.mk create mode 100644 tools/tests/vpci/.gitignore
Signature · 1 line
2.52.0
PATCH v3 1/5 tests: fixup domid make fragment
From: Denis Mukhin <[email protected]>
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")
---
Changes since v2:
- fixed emit-harness-nested-rule
- honor LDFLAGS_APPEND
--- tools/tests/domid/Makefile | 59 +++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 16 deletions(-)
tools/tests/domid/Makefile +43 -16
@@ -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
Signature · 1 line
2.52.0
PATCH v3 2/5 tests: use unit test fragment in domid test
In reply to [email protected]From: Denis Mukhin <[email protected]>
Introduce common fragment for unit tests to minimize some code duplication.
Use the new make fragment to generate test harness code for the domain ID allocator unit test.
Introduce CFLAGS dedicated for find-next-bit.c only to avoid contaminating global CFLAGS.
---
Changes since v2:
- honor LDFLAGS
--- tools/tests/Rules.mk | 93 +++++++++++++++++++++++++++++++++++++ tools/tests/domid/Makefile | 95 ++------------------------------------ 2 files changed, 98 insertions(+), 90 deletions(-) create mode 100644 tools/tests/Rules.mk
tools/tests/Rules.mk new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Common unit test fragment. +# + +include $(XEN_ROOT)/tools/Rules.mk + +define list-c-headers +$(shell sed -n \ + 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) +endef + +# 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): $(2) + set -e; \ + mkdir -p $$(@D); \ + [ -e $$@ ] || ln -s $(2) $$@ + +endef + +# Helper function to emit mock hypervisor code dependencies. +# +# $1 Hypervisor filename. +# $2 Harness filename. +define emit-harness-deps +$(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,$(addprefix $(2),$(1)),\ + $(CURDIR)/harness.h) +endef + +.PHONY: all +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: + $(RM) -r generated + $(RM) -- *.o $(TESTS) $(DEPS_RM) + +.PHONY: distclean +distclean: clean + $(RM) -- *~ + +.PHONY: install +install: all + $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests + set -e; $(foreach t,$(TESTS),$(INSTALL_PROG) $t $(DESTDIR)$(LIBEXEC)/tests;) + +.PHONY: uninstall +uninstall: + set -e; $(foreach t,$(TESTS),$(RM) -- $(DESTDIR)$(LIBEXEC)/tests/$t;) + +CFLAGS += -D__XEN_TOOLS__ + +# Honor mock hypervisor headers over tools/include/xen +CFLAGS += -I$(CURDIR)/generated/ +CFLAGS += $(CFLAGS_xeninclude) +CFLAGS += $(APPEND_CFLAGS) + +LDFLAGS += $(APPEND_LDFLAGS) + +ifeq ($(filter clean distclean,$(MAKECMDGOALS)),) +-include $(DEPS_INCLUDE) +endif
tools/tests/domid/Makefile +5 -90
114 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v3 3/5 xen/include: customize headers for host builds
In reply to [email protected]From: Denis Mukhin <[email protected]>
Update hypervisor headers to allow vpci.c to compile in a host build environment, as required for the vPCI unit test.
---
Changes since v2:
- new patch
--- xen/include/xen/irq.h | 2 ++ xen/include/xen/list.h | 2 ++ xen/include/xen/numa.h | 2 ++ xen/include/xen/pci.h | 2 ++ xen/include/xen/pfn.h | 2 ++ xen/include/xen/spinlock.h | 2 ++ xen/include/xen/types.h | 4 ++++ 7 files changed, 16 insertions(+)
xen/include/xen/irq.h +2 -0
@@ -1,5 +1,6 @@#ifndef __XEN_IRQ_H__#define __XEN_IRQ_H__ +#ifdef __XEN__#include <xen/cpumask.h> #include <xen/rcupdate.h>
@@ -208,4 +209,5 @@ unsigned int arch_hwdom_irqs(const struct domain *d);void arch_evtchn_bind_pirq (struct domain *d,int pirq);#endif +#endif /* __XEN__ */ #endif /* __XEN_IRQ_H__ */
xen/include/xen/list.h +2 -0
@@ -7,8 +7,10 @@#ifndef __XEN_LIST_H__#define __XEN_LIST_H__ +#ifdef __XEN__#include <xen/bug.h> #include <asm/system.h> +#endif /* * These are non-NULL pointers that will result in faults under normal
xen/include/xen/numa.h +2 -0
@@ -1,5 +1,6 @@#ifndef _XEN_NUMA_H#define _XEN_NUMA_H +#ifdef __XEN__#include <xen/mm-frame.h>
@@ -152,4 +153,5 @@ static inline nodeid_t mfn_to_nid(mfn_t mfn)#define page_to_nid (pg) mfn_to_nid(page_to_mfn(pg)) +#endif /* __XEN__ */ #endif /* _XEN_NUMA_H */
xen/include/xen/pci.h +2 -0
@@ -14,7 +14,9 @@#include <xen/numa.h> #include <xen/pci_regs.h> #include <xen/pfn.h> +#ifdef __XEN__#include <asm/device.h> +#endif /* * The PCI interface treats multi-function devices as independent
xen/include/xen/pfn.h +2 -0
@@ -1,7 +1,9 @@#ifndef __XEN_PFN_H__#define __XEN_PFN_H__ +#ifdef __XEN__#include <xen/page-size.h> +#endif #define PFN_DOWN (x) ((x) >> PAGE_SHIFT)#define PFN_UP (x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
xen/include/xen/spinlock.h +2 -0
@@ -1,5 +1,6 @@#ifndef __SPINLOCK_H__#define __SPINLOCK_H__ +#ifdef __XEN__#include <xen/nospec.h> #include <xen/time.h>
@@ -360,4 +361,5 @@ static always_inline void nrspin_lock_irq(rspinlock_t *l)#define nrspin_unlock_irqrestore (l, f) _nrspin_unlock_irqrestore(l, f)#define nrspin_unlock_irq (l) _nrspin_unlock_irq(l) +#endif /* __XEN__ */ #endif /* __SPINLOCK_H__ */
xen/include/xen/types.h +4 -0
@@ -4,6 +4,7 @@#include <xen/stdbool.h> #include <xen/stdint.h> +#ifdef __XEN__/* Linux inherited types which are being phased out */ typedef uint8_t u8 ;typedef uint16_t u16 ;
@@ -15,6 +16,7 @@ typedef uint64_t u64;typedef __SIZE_TYPE__ size_t ;typedef signed long ssize_t ; +#endif /* __XEN__ */ typedef __PTRDIFF_TYPE__ ptrdiff_t ;typedef __UINTPTR_TYPE__ uintptr_t ;
@@ -33,6 +35,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define NULL ((void*)0)#endif +#ifdef __XEN__#define INT8_MIN (-127-1)#define INT16_MIN (-32767-1)#define INT32_MIN (-2147483647-1)
@@ -52,6 +55,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define LONG_MAX ((long)(~0UL>>1))#define LONG_MIN (-LONG_MAX - 1)#define ULONG_MAX (~0UL) +#endif /* __XEN__ */ typedef uint16_t __le16 ;typedef uint16_t __be16 ;
Signature · 1 line
2.52.0
Re: [PATCH v3 3/5] xen/include: customize headers for host builds
Quoted 9 lines · On 13.02.2026 03:49, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Update hypervisor headers to allow
vpci.cto compile in a host build environment, as required for the vPCI unit test.Signed-off-by Denis Mukhin <[email protected]>---
Changes since v2:
- new patch
I'm firmly against such scattering around of "#ifdef __XEN__". It should be the harnesses to carry the burden of re-using hypervisor headers.
Jan
Quoted 128 lines
xen/include/xen/irq.h +2
-0@@ -1,5 +1,6 @@#ifndef __XEN_IRQ_H__#define __XEN_IRQ_H__ +#ifdef __XEN__#include <xen/cpumask.h> #include <xen/rcupdate.h> @@ -208,4 +209,5 @@ unsigned int arch_hwdom_irqs(const struct domain *d);void arch_evtchn_bind_pirq (struct domain *d,int pirq);#endif +#endif /* __XEN__ */ #endif /* __XEN_IRQ_H__ */ xen/include/xen/list.h +2
-0@@ -7,8 +7,10 @@#ifndef __XEN_LIST_H__#define __XEN_LIST_H__ +#ifdef __XEN__#include <xen/bug.h> #include <asm/system.h> +#endif /* * These are non-NULL pointers that will result in faults under normal xen/include/xen/numa.h +2
-0@@ -1,5 +1,6 @@#ifndef _XEN_NUMA_H#define _XEN_NUMA_H +#ifdef __XEN__#include <xen/mm-frame.h> @@ -152,4 +153,5 @@ static inline nodeid_t mfn_to_nid(mfn_t mfn)#define page_to_nid (pg) mfn_to_nid(page_to_mfn(pg)) +#endif /* __XEN__ */ #endif /* _XEN_NUMA_H */ xen/include/xen/pci.h +2
-0@@ -14,7 +14,9 @@#include <xen/numa.h> #include <xen/pci_regs.h> #include <xen/pfn.h> +#ifdef __XEN__#include <asm/device.h> +#endif /* * The PCI interface treats multi-function devices as independent xen/include/xen/pfn.h +2
-0@@ -1,7 +1,9 @@#ifndef __XEN_PFN_H__#define __XEN_PFN_H__ +#ifdef __XEN__#include <xen/page-size.h> +#endif #define PFN_DOWN (x) ((x) >> PAGE_SHIFT)#define PFN_UP (x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)xen/include/xen/spinlock.h +2
-0@@ -1,5 +1,6 @@#ifndef __SPINLOCK_H__#define __SPINLOCK_H__ +#ifdef __XEN__#include <xen/nospec.h> #include <xen/time.h> @@ -360,4 +361,5 @@ static always_inline void nrspin_lock_irq(rspinlock_t *l)#define nrspin_unlock_irqrestore (l, f) _nrspin_unlock_irqrestore(l, f)#define nrspin_unlock_irq (l) _nrspin_unlock_irq(l) +#endif /* __XEN__ */ #endif /* __SPINLOCK_H__ */ xen/include/xen/types.h +4
-0@@ -4,6 +4,7 @@#include <xen/stdbool.h> #include <xen/stdint.h> +#ifdef __XEN__/* Linux inherited types which are being phased out */ typedef uint8_t u8 ;typedef uint16_t u16 ;@@ -15,6 +16,7 @@ typedef uint64_t u64;typedef __SIZE_TYPE__ size_t ;typedef signed long ssize_t ; +#endif /* __XEN__ */ typedef __PTRDIFF_TYPE__ ptrdiff_t ;typedef __UINTPTR_TYPE__ uintptr_t ;@@ -33,6 +35,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define NULL ((void*)0)#endif +#ifdef __XEN__#define INT8_MIN (-127-1)#define INT16_MIN (-32767-1)#define INT32_MIN (-2147483647-1)@@ -52,6 +55,7 @@ typedef __UINTPTR_TYPE__ uintptr_t;#define LONG_MAX ((long)(~0UL>>1))#define LONG_MIN (-LONG_MAX - 1)#define ULONG_MAX (~0UL) +#endif /* __XEN__ */ typedef uint16_t __le16 ;typedef uint16_t __be16 ;
PATCH v3 4/5 tests: use unit test fragment in vPCI test
In reply to [email protected]From: Denis Mukhin <[email protected]>
Use the new make fragment to generate test harness code for the vPCI unit test.
Add new prepare-harness target to tests/Rules.mk as an optional step for setting up mocked environment for building a test.
Add ability to override the test harness header file.
Fix hypervisor headers used to compile vpci.c against host environment where necessary.
Fixup emul.h by adding missing mocks to account for new unit test infra.
Update .gitignore to exclude generated test build-time dependencies.
---
Changes since v2:
- moved hypervisor headers changes to a separate patch
--- tools/tests/Rules.mk | 8 ++++-- tools/tests/vpci/.gitignore | 2 ++ tools/tests/vpci/Makefile | 52 ++++++++++++------------------------- tools/tests/vpci/emul.h | 50 +++++++++++++---------------------- tools/tests/vpci/main.c | 2 -- 5 files changed, 42 insertions(+), 72 deletions(-) create mode 100644 tools/tests/vpci/.gitignore
tools/tests/Rules.mk +6 -2
@@ -10,13 +10,16 @@ $(shell sed -n \ 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) endef +.PHONY: prepare-harness +prepare-harness: + # 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): $(2) +$(1): prepare-harness $(2) set -e; \ mkdir -p $$(@D); \ [ -e $$@ ] || ln -s $(2) $$@
@@ -44,10 +47,11 @@ endef # # $1 Hypervisor filename. # $2 Hypervisor source path. +# $3 Harness header filename (optional). define vpath-with-harness-deps vpath $(1) $(2) $(call emit-harness-deps,$(addprefix $(2),$(1)),\ - $(CURDIR)/harness.h) + $(strip $(or $(3),$(CURDIR)/harness.h))) endef .PHONY: all
tools/tests/vpci/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/generated +test-vpci
tools/tests/vpci/Makefile +16 -36
59 lines not on this page · raw message
tools/tests/vpci/emul.h +18 -32
71 lines not on this page · raw message
tools/tests/vpci/main.c +0 -2
@@ -189,8 +189,6 @@ main(int argc, char **argv)uint32_t r24 =0 ;uint8_t r28, r30;struct mask_data r32; -unsigned int i; -int rc;INIT_LIST_HEAD (&vpci.handlers);spin_lock_init (&vpci.lock);
Signature · 1 line
2.52.0
PATCH v3 5/5 tests: use unit test fragment in PDX test
In reply to [email protected]From: Denis Mukhin <[email protected]>
Use the new make fragment to generate test harness code for the PDX unit test.
Add ability to pass custom CFLAGS for mock code and object file suffix.
Move <xen/bitops.h> earlier in xen/common/pdx.c to ensure harness.h is included before triggering the #ifndef MAX_PFN_RANGES check when building a unit test.
Additionally, use real <xen/pdx.h> in harness.h instead of a locally copied version.
Update .gitignore to exclude generated test build-time dependencies.
---
Changes since v2:
- added lost -DCONFIG_PDX_OFFSET_COMPRESSION test
--- tools/tests/Rules.mk | 19 ++++++++---- tools/tests/pdx/.gitignore | 2 +- tools/tests/pdx/Makefile | 59 +++++++++++--------------------------- tools/tests/pdx/harness.h | 2 +- tools/tests/pdx/test-pdx.c | 2 -- xen/common/pdx.c | 3 +- xen/include/xen/pdx.h | 2 ++ 7 files changed, 36 insertions(+), 53 deletions(-)
tools/tests/Rules.mk +14 -5
@@ -16,11 +16,13 @@ prepare-harness: # Generate mock environment by replicating header file hierarchy; # each mock header file will point to a harness header. # +# NB: double-colon rule for mocking environment for multiple tests. +# # $1 Hypervisor header. # $2 Test harness header. define emit-harness-nested-rule -$(1): prepare-harness $(2) - set -e; \ +$(1):: prepare-harness $(2) + @set -e; \ mkdir -p $$(@D); \ [ -e $$@ ] || ln -s $(2) $$@
@@ -30,16 +32,19 @@ endef # # $1 Hypervisor filename. # $2 Harness filename. +# $3 Extra CFLAGS. +# $4 Object file suffix. define emit-harness-deps $(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))) +$(eval c-obj := $(if $(strip $(4)),-$(strip $(4)),)) $(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 $$^) +$(c-name:%.c=%$(c-obj).o): $(c-file) $(c-deps) + $(CC) $(3) $(CFLAGS) -o $$@ -c $$(firstword $$^) endef
@@ -48,10 +53,14 @@ endef # $1 Hypervisor filename. # $2 Hypervisor source path. # $3 Harness header filename (optional). +# $4 Extra CFLAGS (optional). +# $5 Object file suffix (optional). define vpath-with-harness-deps vpath $(1) $(2) $(call emit-harness-deps,$(addprefix $(2),$(1)),\ - $(strip $(or $(3),$(CURDIR)/harness.h))) + $(strip $(or $(3),$(CURDIR)/harness.h)),\ + $(4),\ + $(5)) endef .PHONY: all
tools/tests/pdx/.gitignore +1 -1
@@ -1,3 +1,3 @@ -/pdx.h +/generated /test-pdx-mask /test-pdx-offset
tools/tests/pdx/Makefile +16 -43
66 lines not on this page · raw message
tools/tests/pdx/harness.h +1 -1
@@ -84,7 +84,7 @@ typedef uint64_t paddr_t;qsort (elem, nr, size, cmp); \ }) -#include "pdx.h" +#include <xen/pdx.h> #endif
tools/tests/pdx/test-pdx.c +0 -2
@@ -7,8 +7,6 @@#include "harness.h" -#include "../../xen/common/pdx.c" -struct range {/* Ranges are defined as [start, end). */ unsigned long start, end;
xen/common/pdx.c +2 -1
@@ -15,11 +15,12 @@* along with this program; If not, see <http://www.gnu.org/licenses/>. */ +#include <xen/bitops.h> +/* Trim content when built for the test harness. */ #ifdef __XEN__#include <xen/init.h> #include <xen/mm.h> -#include <xen/bitops.h> #include <xen/nospec.h> #include <xen/param.h> #include <xen/pfn.h>
xen/include/xen/pdx.h +2 -0
@@ -199,7 +199,9 @@ static inline paddr_t directmapoff_to_maddr_xlate(unsigned long offset)#elif defined(CONFIG_PDX_OFFSET_COMPRESSION )/* CONFIG_PDX_MASK_COMPRESSION */ +#ifdef __XEN__#include <xen/page-size.h> +#endif #define CONFIG_PDX_NR_LOOKUP (1UL << CONFIG_PDX_OFFSET_TBL_ORDER)#define PDX_TBL_MASK (CONFIG_PDX_NR_LOOKUP - 1)
Signature · 1 line
2.52.0
Quoted 12 lines · On 13.02.2026 03:49, [email protected] wrote:
This series introduces the use of a new common unit test fragment across several existing unit tests.
Patch 1 contains assorted fixups for the domid
Makefile.
Patch 2 adds a new fragment for auto-generating test harness dependencies. Patch 3 adds some prerequisite changes for vPCI test (patch 4). Patch 4 switches the vPCI unit test to the new common fragment. Patch 5 switches the PDX unit test to the new common fragment.[1] Link to v2: https://lore.kernel.org/xen-devel/[email protected]/
[2] CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2323352235
Quoted 6 lines
Denis Mukhin (5):
tests: fixup domid make fragment
tests: use unit test fragment in domid test
xen/include: customize headers for host builds
tests: use unit test fragment in vPCI test
tests: use unit test fragment in PDX test
I remain unconvinced of this attempt to generalize things. Yes, it eliminates some redundancy, but at the same time some of the new constructs are harder to read / follow. Perhaps it would help if smaller pieces were abstracted out first / incrementally.
Jan
Quoted 20 lines · Jan Beulich
Quoted 12 lines · On 13.02.2026 03:49, [email protected] wrote:
This series introduces the use of a new common unit test fragment across several existing unit tests.
Patch 1 contains assorted fixups for the domid
Makefile.
Patch 2 adds a new fragment for auto-generating test harness dependencies. Patch 3 adds some prerequisite changes for vPCI test (patch 4). Patch 4 switches the vPCI unit test to the new common fragment. Patch 5 switches the PDX unit test to the new common fragment.[1] Link to v2: https://lore.kernel.org/xen-devel/[email protected]/
[2] CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2323352235Quoted 6 lines
Denis Mukhin (5):
tests: fixup domid make fragment
tests: use unit test fragment in domid test
xen/include: customize headers for host builds
tests: use unit test fragment in vPCI test
tests: use unit test fragment in PDX test
Quoted 4 lines
I remain unconvinced of this attempt to generalize things. Yes, it eliminates some redundancy, but at the same time some of the new constructs are harder to read / follow. Perhaps it would help if smaller pieces were abstracted out first / incrementally.
I don't think breaking it down further would help, it is already in pretty small pieces. At least, I cannot think of a way that breaking it down would make a difference. Do you have something specific in mind?
Also, I appreciate you being unconvinced about this series, but now it leaves me in a bit of limbo. I am fine with this series going in -- should I continue reviewing it regardless?
Quoted 21 lines · Stefano Stabellini
Quoted 20 lines · Jan Beulich
Quoted 18 lines · On 13.02.2026 03:49, [email protected] wrote:
This series introduces the use of a new common unit test fragment across several existing unit tests.
Patch 1 contains assorted fixups for the domid
Makefile.
Patch 2 adds a new fragment for auto-generating test harness dependencies. Patch 3 adds some prerequisite changes for vPCI test (patch 4). Patch 4 switches the vPCI unit test to the new common fragment. Patch 5 switches the PDX unit test to the new common fragment.[1] Link to v2: https://lore.kernel.org/xen-devel/[email protected]/
[2] CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/2323352235Denis Mukhin (5):
tests: fixup domid make fragment
tests: use unit test fragment in domid test
xen/include: customize headers for host builds
tests: use unit test fragment in vPCI test
tests: use unit test fragment in PDX test
Quoted 8 lines
Quoted 4 lines
I remain unconvinced of this attempt to generalize things. Yes, it eliminates some redundancy, but at the same time some of the new constructs are harder to read / follow. Perhaps it would help if smaller pieces were abstracted out first / incrementally.
I don't think breaking it down further would help, it is already in pretty small pieces. At least, I cannot think of a way that breaking it down would make a difference. Do you have something specific in mind?
See Edwin's series moving in effectively the same direction.
Quoted 3 lines
Also, I appreciate you being unconvinced about this series, but now it leaves me in a bit of limbo. I am fine with this series going in -- should I continue reviewing it regardless?
Hard to say. Maybe take a look at Edwin's first?
Jan