tests/external_board_native: show an example of external board
Add an example that implements an external board based on native. It relies on 'BOARDSDIR' and uses common files from 'RIOT/boards' through 'RIOTBOARDS'. This application also works with the docker integration.
This commit is contained in:
parent
1427ef998f
commit
633f050d1f
15
tests/external_board_native/Makefile
Normal file
15
tests/external_board_native/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
APPLICATION = external_board
|
||||
RIOTBASE ?= $(CURDIR)/../../
|
||||
|
||||
# Only support this board
|
||||
# No need for a `WHITELIST` as there is only one board in `external_boards`.
|
||||
#
|
||||
# HACK I named the external board as 'native' to be in murdock test path for
|
||||
# 'native'
|
||||
# In practice it should be something else
|
||||
BOARD ?= native
|
||||
|
||||
# Set without '?=' to also verify the docker integration when set with =
|
||||
BOARDSDIR = $(CURDIR)/external_boards
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
14
tests/external_board_native/README.md
Normal file
14
tests/external_board_native/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
Example with an external board
|
||||
==============================
|
||||
|
||||
This tests an external board implementation.
|
||||
The goal is to show using an external board that still needs to use the
|
||||
'RIOT/boards' directory.
|
||||
|
||||
To allow automated testing by `murdock` this board is named 'native'.
|
||||
|
||||
As it wants to extend native, which is not a common board, some hacks must be
|
||||
done as the 'board' module is implemented directly by the 'RIOT/boards/native'.
|
||||
|
||||
If you are running an 'ubuntu-bionic' you could even compile the example in
|
||||
docker and run the test.
|
||||
@ -0,0 +1,6 @@
|
||||
# This must be a different name than 'board' as it is implemented by 'native'
|
||||
MODULE = board_external_native
|
||||
|
||||
DIRS += $(RIOTBOARD)/native
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -0,0 +1,4 @@
|
||||
# This must be a different name than 'board' as it is implemented by 'native'
|
||||
USEMODULE += board_external_native
|
||||
|
||||
include $(RIOTBOARD)/native/Makefile.dep
|
||||
@ -0,0 +1 @@
|
||||
include $(RIOTBOARD)/native/Makefile.features
|
||||
@ -0,0 +1,7 @@
|
||||
CFLAGS += -DTHIS_BOARD_IS='"external_native"'
|
||||
|
||||
# We must duplicate the include done by $(RIOTBASE)/Makefile.include
|
||||
# to also include the main board header
|
||||
INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/native/include))
|
||||
|
||||
include $(RIOTBOARD)/native/Makefile.include
|
||||
@ -0,0 +1,3 @@
|
||||
#include "external_native.h"
|
||||
|
||||
char* external_native_board_description = "An external extended native";
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 boards_external_native
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief A header for an external native
|
||||
*
|
||||
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef EXTERNAL_NATIVE_H
|
||||
#define EXTERNAL_NATIVE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A variable defined in the external header
|
||||
*/
|
||||
extern char* external_native_board_description;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EXTERNAL_NATIVE_H */
|
||||
/** @} */
|
||||
34
tests/external_board_native/main.c
Normal file
34
tests/external_board_native/main.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 External Native application
|
||||
*
|
||||
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "external_native.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("Hello World!");
|
||||
|
||||
printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
|
||||
printf("THIS_BOARD_IS %s\n", THIS_BOARD_IS);
|
||||
printf("This board is '%s'\n", external_native_board_description);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
tests/external_board_native/tests/01-run.py
Executable file
22
tests/external_board_native/tests/01-run.py
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2019 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.
|
||||
|
||||
import sys
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact("Hello World!")
|
||||
child.expect_exact("You are running RIOT on a(n) native board.")
|
||||
child.expect_exact("THIS_BOARD_IS external_native")
|
||||
child.expect_exact("This board is 'An external extended native")
|
||||
print("Test successful!!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
||||
Loading…
x
Reference in New Issue
Block a user