1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

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%`.
This commit is contained in:
Marian Buschsieweke 2025-09-30 14:50:21 +02:00
parent 5987b19788
commit 651e1907dc
No known key found for this signature in database
GPG Key ID: 758BD52517F79C41
2 changed files with 16 additions and 2 deletions

View File

@ -19,13 +19,20 @@ DEPS_FOR_RUNNING_DOCKER :=
DOCKER ?= docker
# List of Docker-enabled make goals
export DOCKER_MAKECMDGOALS_POSSIBLE = \
DOCKER_MAKECMDGOALS_POSSIBLE := \
all \
scan-build \
scan-build-analyze \
tests-% \
#
export DOCKER_MAKECMDGOALS = $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS))
# On native, we also can run the test in docker
ifneq (, $(filter native%,$(BOARD)))
DOCKER_MAKECMDGOALS_POSSIBLE += test
endif
export DOCKER_MAKECMDGOALS_POSSIBLE
export DOCKER_MAKECMDGOALS := $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS))
# Docker creates the files .dockerinit and .dockerenv in the root directory of
# the container, we check for the files to determine if we are inside a container.

View File

@ -22,10 +22,17 @@ TEST_DEPS += $(TERMDEPS)
TEST_EXECUTOR ?=
TEST_EXECUTOR_FLAGS ?=
# Are tests going to be run in docker and we are not yet in docker?
ifeq (0-test,$(INSIDE_DOCKER)-$(filter test,$(DOCKER_MAKECMDGOALS)))
# Yes --> defer test execution to docker
test: ..in-docker-container
else
# No --> run test in this context
test: $(TEST_DEPS)
$(Q) for t in $(TESTS); do \
$(TEST_EXECUTOR) $(TEST_EXECUTOR_FLAGS) $$t || exit 1; \
done
endif
test/available:
ifneq (,$(TEST_ON_CI_WHITELIST))