|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 3/4] tests: use unit test fragment in PDX test
From: Denis Mukhin <dmukhin@xxxxxxxx>
Use the new make fragment to generate test harness code for the PDX unit test.
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.
Not a functional change.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v1:
- new patch
---
tools/tests/pdx/.gitignore | 2 +-
tools/tests/pdx/Makefile | 55 +++++++++-----------------------------
tools/tests/pdx/harness.h | 2 +-
tools/tests/pdx/test-pdx.c | 2 --
xen/common/pdx.c | 3 ++-
5 files changed, 16 insertions(+), 48 deletions(-)
diff --git a/tools/tests/pdx/.gitignore b/tools/tests/pdx/.gitignore
index 1202a531a7fd..1bf9c05985c4 100644
--- a/tools/tests/pdx/.gitignore
+++ b/tools/tests/pdx/.gitignore
@@ -1,3 +1,3 @@
-/pdx.h
+/generated
/test-pdx-mask
/test-pdx-offset
diff --git a/tools/tests/pdx/Makefile b/tools/tests/pdx/Makefile
index 3c431d7c7822..178b451cb611 100644
--- a/tools/tests/pdx/Makefile
+++ b/tools/tests/pdx/Makefile
@@ -1,50 +1,19 @@
-XEN_ROOT=$(CURDIR)/../../..
-include $(XEN_ROOT)/tools/Rules.mk
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Unit tests for PDX (Page inDeX).
+#
-TARGETS := test-pdx-mask test-pdx-offset
+TESTS := test-pdx-mask test-pdx-offset
-.PHONY: all
-all: $(TARGETS)
+XEN_ROOT = $(CURDIR)/../../..
-.PHONY: run
-run: $(TARGETS)
-ifeq ($(CC),$(HOSTCC))
- set -e; \
- for test in $? ; do \
- ./$$test ; \
- done
-else
- $(warning HOSTCC != CC, will not run test)
-endif
+CFLAGS += -DCONFIG_PDX_MASK_COMPRESSION
-.PHONY: clean
-clean:
- $(RM) -- *.o $(TARGETS) $(DEPS_RM) pdx.h
+include $(XEN_ROOT)/tools/tests/Rules.mk
-.PHONY: distclean
-distclean: clean
- $(RM) -- *~
+CFLAGS += -I $(XEN_ROOT)/xen/include/
-.PHONY: install
-install: all
- $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
- $(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC)/tests
+$(eval $(call vpath-with-harness-deps,pdx.c,$(XEN_ROOT)/xen/common/))
-.PHONY: uninstall
-uninstall:
- $(RM) -- $(patsubst %,$(DESTDIR)$(LIBEXEC)/tests/%,$(TARGETS))
-
-pdx.h: $(XEN_ROOT)/xen/include/xen/pdx.h
- sed -e '/^#[[:space:]]*include/d' <$< >$@
-
-CFLAGS += -D__XEN_TOOLS__
-CFLAGS += $(APPEND_CFLAGS)
-CFLAGS += $(CFLAGS_xeninclude)
-
-test-pdx-mask: CFLAGS += -DCONFIG_PDX_MASK_COMPRESSION
-test-pdx-offset: CFLAGS += -DCONFIG_PDX_OFFSET_COMPRESSION
-
-test-pdx-%: test-pdx.c pdx.h
- $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -o $@ $< $(APPEND_CFLAGS)
-
--include $(DEPS_INCLUDE)
+test-pdx-%: test-pdx.o pdx.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
diff --git a/tools/tests/pdx/harness.h b/tools/tests/pdx/harness.h
index e49d6bcf92c2..4cdda931feb2 100644
--- a/tools/tests/pdx/harness.h
+++ b/tools/tests/pdx/harness.h
@@ -84,7 +84,7 @@ typedef uint64_t paddr_t;
qsort(elem, nr, size, cmp); \
})
-#include "pdx.h"
+#include <xen/pdx.h>
#endif
diff --git a/tools/tests/pdx/test-pdx.c b/tools/tests/pdx/test-pdx.c
index eefd54c76815..3633c231abaa 100644
--- a/tools/tests/pdx/test-pdx.c
+++ b/tools/tests/pdx/test-pdx.c
@@ -7,8 +7,6 @@
#include "harness.h"
-#include "../../xen/common/pdx.c"
-
struct range {
/* Ranges are defined as [start, end). */
unsigned long start, end;
diff --git a/xen/common/pdx.c b/xen/common/pdx.c
index 7e070ff962e8..068a2098b41b 100644
--- a/xen/common/pdx.c
+++ b/xen/common/pdx.c
@@ -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>
--
2.52.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |