[LTP] [PATCH v2 4/8] metadata: test.sh: Add support for building out-of-tree
Petr Vorel
pvorel@suse.cz
Fri Jul 10 07:55:52 CEST 2026
NOTE out-of-tree build is supported only from the top level directory,
otherwise it requires to set METAPARSEDIR variable by user (similarly to
other tests run via testcases/lib/run_tests.sh).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Fix out of tree build
* Try to detect out-of-tree build without specifying variable
LTP running internal testing is implemented for every directory
differently. It would be nice to unify it.
Also much of the complexity is done by out-of-tree part. I really wish
one day we migrate to meson (which is faster, support out-of-tree
modules and de facto standard for userspace nowadays).
Makefile | 2 +-
metadata/Makefile | 2 +-
metadata/tests/test.sh | 11 ++++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f1b59609a5..2efbe8c6c0 100644
--- a/Makefile
+++ b/Makefile
@@ -213,7 +213,7 @@ test-metadata: metadata-all
ifneq ($(build),$(host))
$(error running tests on cross-compile build not supported)
endif
- $(MAKE) -C $(abs_srcdir)/metadata test
+ METAPARSEDIR=$(abs_builddir)/metadata $(MAKE) -C $(abs_srcdir)/metadata test
MODULE_DIRS := $(shell \
dirname $$(grep -l 'include.*module\.mk' $$(find $(abs_srcdir)/testcases/ -type f -name 'Makefile')))
diff --git a/metadata/Makefile b/metadata/Makefile
index 7e4ee38d2e..af194bcc94 100644
--- a/metadata/Makefile
+++ b/metadata/Makefile
@@ -16,6 +16,6 @@ ltp.json: metaparse metaparse-sh
$(abs_srcdir)/parse.sh > ltp.json
test: metaparse metaparse-sh
- $(MAKE) -C $(abs_srcdir)/tests/ test
+ METAPARSEDIR=$$METAPARSEDIR $(MAKE) -C tests/ test
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/metadata/tests/test.sh b/metadata/tests/test.sh
index a9ebc768f9..89a7857ad2 100755
--- a/metadata/tests/test.sh
+++ b/metadata/tests/test.sh
@@ -2,9 +2,18 @@
fail=0
+METAPARSE="${METAPARSEDIR:-..}/metaparse"
+
+cd "${SRCDIR:-.}"
+
+if [ ! -x "$METAPARSE" ]; then
+ echo "Error: $METAPARSE not found (wrong PATH? out-of-tree build without specifying \$METAPARSEDIR?)" >&2
+ exit 1
+fi
+
for i in *.c; do
printf "* $i "
- ../metaparse $i > tmp.json
+ $METAPARSE $i > tmp.json
if ! diff tmp.json $i.json >/dev/null 2>&1; then
echo '[FAIL]'
echo "$i output differs!"
--
2.54.0
More information about the ltp
mailing list