[PATCH 13/17] test: support running labgrid-pytest from out-of-tree build directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The labgrid YAML configs use relative paths to reference the images to
use. This won't work for out-of-tree builds. Do like Linux does for the
scripts/gdb/vmlinux-gdb.py and symlink the labgrid test stuff into the
build directory. With this done, we can now call labgrid-pytest for both
in-tree and out-of-tree builds.

Symlinks are not created for the test directory as a whole:

  - ../../ from within a symlinked directory refers to the original
    destination, not where it's symlinked to
  - Build and test (__pycache__) artifacts are generated into test/.
    we don't want those ending up in the source directory

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 Makefile | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Makefile b/Makefile
index 0a93915cf347..7db7cb7b4a3a 100644
--- a/Makefile
+++ b/Makefile
@@ -1136,6 +1136,10 @@ MRPROPER_FILES += .config .config.old .version .old_version \
                   include/config.h           \
 		  Module.symvers tags TAGS cscope*
 
+ifdef building_out_of_srctree
+MRPROPER_DIRS += test
+endif
+
 # clean - Delete most, but leave enough to build external modules
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
@@ -1264,6 +1268,25 @@ docs: FORCE
 	@$(SPHINXBUILD) -b html -d $(objtree)/doctrees $(srctree)/Documentation \
 		$(objtree)/Documentation/html
 
+# Misc
+# ---------------------------------------------------------------------------
+
+# support running tests from the build directory
+
+PHONY += symlink_tests
+symlink_tests: prepare0
+ifdef building_out_of_srctree
+	@mkdir -p test/$(SRCARCH)
+	@for y in $(abspath $(srctree)/test/$(SRCARCH)/*.yaml); do \
+	  ln -fsn $$y $(objtree)/test/$(SRCARCH)/ ; \
+	done
+	@ln -fsn $(abspath $(srctree)/test/py) $(objtree)/test/
+	@ln -fsn $(abspath $(srctree)/test/conftest.py) $(objtree)/test/
+	@ln -fsn $(abspath $(srctree)/test/__init__.py) $(objtree)/test/
+endif
+
+all: symlink_tests
+
 # Single targets
 # ---------------------------------------------------------------------------
 # Single targets are compatible with:
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux