Skip to content

Commit

Permalink
tests: add a test for buildir integration with docker
Browse files Browse the repository at this point in the history
Add a test to verify that the build system correctly integrates 'build'
with docker even if set outside of RIOTBASE.
  • Loading branch information
cladmi committed Nov 22, 2018
1 parent b259b76 commit cfb0889
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/build_system_builddir_docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Only one board the goal is not the compilation but the build system
# integration
BOARD_WHITELIST = native

include ../Makefile.tests_common
include $(RIOTBASE)/Makefile.include


.PHONY: test_file_in_build clean_file_in_build


TESTFILE = $(BUILD_DIR)/tmp/output_$(APPLICATION)

# Create the file as a dependency of an intermediate target
# This ensures it is executed in docker
$(ELFFILE): | $(TESTFILE)
test: test_file_in_build
clean: clean_file_in_build


$(TESTFILE): Makefile # Rebuild if this Makefile changed
$(Q)mkdir -p $(dir $(@))
$(Q)echo '$(APPLICATION)/$(BOARD)' > $@

test_file_in_build:
test -f $(TESTFILE) && test $$(cat $(TESTFILE)) = '$(APPLICATION)/$(BOARD)'

clean_file_in_build:
$(Q)rm -rf $(dir $(TESTFILE))
24 changes: 24 additions & 0 deletions tests/build_system_builddir_docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Build system test: build directory
==================================

Test handling of the build directory within docker.

This test is mainly done to test 'docker' integration to verify that the
`BUILD_DIR` variable is correctly passed and mounted into docker.


Usage
-----

The test can be run with

make clean all test \
BUILD_DIR=/tmp/riot/build \
BUILD_IN_DOCKER=1 DOCKER='sudo docker'

I used a directory outside of 'RIOT' to show that the directory is mounted in
the container.
A directory with an absolute path in RIOT should also fail but we can use a
different one anyway.

It can also be run without docker but does not really test anything.
28 changes: 28 additions & 0 deletions tests/build_system_builddir_docker/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2018 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup tests
* @{
*
* @file
* @brief Empty application
*
* @author Gaëtan Harter <[email protected]>
*
* @}
*/

int main(void)
{
/*
* The main part of the test is in the Makefile. See README.md for more
* informations
*/
return 0;
}

0 comments on commit cfb0889

Please sign in to comment.