Yeqi Fu <fufuyqqq...@gmail.com> writes:
> Introduce a new test for native calls to ensure their functionality. > The process involves cross-compiling the test cases, building them > as dynamically linked binaries, and running these binaries which > necessitates the addition of the appropriate interpreter prefix. > > Signed-off-by: Yeqi Fu <fufuyqqq...@gmail.com> > --- > tests/tcg/multiarch/Makefile.target | 17 +++++ > tests/tcg/multiarch/native/nativecall.c | 98 +++++++++++++++++++++++++ > 2 files changed, 115 insertions(+) > create mode 100644 tests/tcg/multiarch/native/nativecall.c > > diff --git a/tests/tcg/multiarch/Makefile.target > b/tests/tcg/multiarch/Makefile.target > index 43bddeaf21..5231df34ba 100644 > --- a/tests/tcg/multiarch/Makefile.target > +++ b/tests/tcg/multiarch/Makefile.target > @@ -138,5 +138,22 @@ run-plugin-semiconsole-with-%: > TESTS += semihosting semiconsole > endif > > +nativecall: native/nativecall.c > + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(filter-out > -static,$(LDFLAGS)) > + > +ifneq ($(LD_PREFIX),) > +ifneq ($(wildcard $(LIBNATIVE)),) > +run-nativecall: nativecall > + $(call run-test,$<, $(QEMU) -L $(LD_PREFIX) --native-bypass > $(LIBNATIVE) $<, "nativecall") > +else > +run-nativecall: nativecall > + $(call skip-test, $<, "no native library found") > +endif > +else > +run-nativecall: nativecall > + $(call skip-test, $<, "no elf interpreter prefix found") > +endif > +EXTRA_RUNS += run-nativecall > + Or indeed just expand VPATH and use TESTS instead of EXTRA_RUNS (which is for additional configurations of tests): modified tests/tcg/multiarch/Makefile.target @@ -138,13 +138,18 @@ run-plugin-semiconsole-with-%: TESTS += semihosting semiconsole endif -nativecall: native/nativecall.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(filter-out -static,$(LDFLAGS)) - ifneq ($(LD_PREFIX),) ifneq ($(wildcard $(LIBNATIVE)),) +VPATH += $(MULTIARCH_SRC)/native + +nativecall: nativecall.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(filter-out -static,$(LDFLAGS)) + run-nativecall: nativecall - $(call run-test,$<, $(QEMU) -L $(LD_PREFIX) --native-bypass $(LIBNATIVE) $<, "nativecall") + $(call run-test,$<, $(QEMU) -L $(LD_PREFIX) --native-bypass + $(LIBNATIVE) $<, "nativecall") + +TESTS += nativecall else run-nativecall: nativecall $(call skip-test, $<, "no native library found") @@ -153,7 +158,6 @@ else run-nativecall: nativecall $(call skip-test, $<, "no elf interpreter prefix found") endif -EXTRA_RUNS += run-nativecall -- Alex Bennée Virtualisation Tech Lead @ Linaro