Skip to content

Commit 651e190

Browse files
committed
build system: Allow running tests in docker
When building for native with `BUILD_IN_DOCKER=1`, the created elf file may not be compatible with the host system if: - The container used is using glibc and the host system is using another C lib - Both container and host are using glibc, but the container is using a more recent one than the host To avoid these issues, this commit changes behavior to just run the `test` goal inside the docker image as well when the board is `native%`.
1 parent 5987b19 commit 651e190

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

makefiles/docker.inc.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ DEPS_FOR_RUNNING_DOCKER :=
1919
DOCKER ?= docker
2020

2121
# List of Docker-enabled make goals
22-
export DOCKER_MAKECMDGOALS_POSSIBLE = \
22+
DOCKER_MAKECMDGOALS_POSSIBLE := \
2323
all \
2424
scan-build \
2525
scan-build-analyze \
2626
tests-% \
2727
#
28-
export DOCKER_MAKECMDGOALS = $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS))
28+
29+
# On native, we also can run the test in docker
30+
ifneq (, $(filter native%,$(BOARD)))
31+
DOCKER_MAKECMDGOALS_POSSIBLE += test
32+
endif
33+
34+
export DOCKER_MAKECMDGOALS_POSSIBLE
35+
export DOCKER_MAKECMDGOALS := $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS))
2936

3037
# Docker creates the files .dockerinit and .dockerenv in the root directory of
3138
# the container, we check for the files to determine if we are inside a container.

makefiles/tests/tests.inc.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ TEST_DEPS += $(TERMDEPS)
2222
TEST_EXECUTOR ?=
2323
TEST_EXECUTOR_FLAGS ?=
2424

25+
# Are tests going to be run in docker and we are not yet in docker?
26+
ifeq (0-test,$(INSIDE_DOCKER)-$(filter test,$(DOCKER_MAKECMDGOALS)))
27+
# Yes --> defer test execution to docker
28+
test: ..in-docker-container
29+
else
30+
# No --> run test in this context
2531
test: $(TEST_DEPS)
2632
$(Q) for t in $(TESTS); do \
2733
$(TEST_EXECUTOR) $(TEST_EXECUTOR_FLAGS) $$t || exit 1; \
2834
done
35+
endif
2936

3037
test/available:
3138
ifneq (,$(TEST_ON_CI_WHITELIST))

0 commit comments

Comments
 (0)