From 2e73e7f043321d32b8dc1f83ff56e6881a30dacf Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Mon, 1 Jul 2019 17:01:26 +0200 Subject: [PATCH] tests: add Nordic SoftDevice test app --- tests/nordic_softdevice/Makefile | 19 +++++++++++ tests/nordic_softdevice/README.md | 13 ++++++++ tests/nordic_softdevice/main.c | 44 +++++++++++++++++++++++++ tests/nordic_softdevice/tests/01-run.py | 14 ++++++++ 4 files changed, 90 insertions(+) create mode 100644 tests/nordic_softdevice/Makefile create mode 100644 tests/nordic_softdevice/README.md create mode 100644 tests/nordic_softdevice/main.c create mode 100755 tests/nordic_softdevice/tests/01-run.py diff --git a/tests/nordic_softdevice/Makefile b/tests/nordic_softdevice/Makefile new file mode 100644 index 0000000000..16ec68138d --- /dev/null +++ b/tests/nordic_softdevice/Makefile @@ -0,0 +1,19 @@ +BOARD ?= nrf52dk +include ../Makefile.tests_common + +# Use the Nordic SoftDevice +USEPKG += nordic_softdevice_ble + +# use a minimal GNRC configuration +USEMODULE += gnrc_netdev_default +USEMODULE += auto_init_gnrc_netif +USEMODULE += gnrc_ipv6 +USEMODULE += gnrc_icmpv6_echo +# also add the shell with some basic shell commands +USEMODULE += shell +USEMODULE += shell_commands +USEMODULE += ps + +TEST_ON_CI_WHITELIST += nrf52dk + +include $(RIOTBASE)/Makefile.include diff --git a/tests/nordic_softdevice/README.md b/tests/nordic_softdevice/README.md new file mode 100644 index 0000000000..686ac15cf0 --- /dev/null +++ b/tests/nordic_softdevice/README.md @@ -0,0 +1,13 @@ +# Nordic SoftDevice Test Application +The main purpose of this test application is to ensure the inclusion of the +Nordic SoftDevice package in RIOTs build test. + +In addition, this example includes a minimal GNRC configuration and the +corresponding shell commands, so it can be used for some simple tests of +network functionality. Please refer to `pkg/nordic_softdevice_ble/README.md` +and `pkg/nordic_softdevice_ble/README-BLE-6LoWPAN.md` for more information on +how to setup an IPv6 connection to your device. + +For more features, you can use the SoftDevice with RIOTs `gnrc_networking` +example application. Simply build `gnrc_networking` for a SoftDevice-capable +device, e.g. `USEPKG=nordic_softdevice_ble BOARD=nrf52dk make ...`. diff --git a/tests/nordic_softdevice/main.c b/tests/nordic_softdevice/main.c new file mode 100644 index 0000000000..f6dbe9085c --- /dev/null +++ b/tests/nordic_softdevice/main.c @@ -0,0 +1,44 @@ +/* + * 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 This test application ensures that the Nordic SoftDevice + * integration is included in the build test + * + * @author Hauke Petersen + * + * @} + */ + +#include + +#include "shell.h" +#include "msg.h" + +#define MAIN_QUEUE_SIZE (8) +static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; + +int main(void) +{ + /* we need a message queue for the thread running the shell in order to + * receive potentially fast incoming networking packets */ + msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); + puts("Test for the RIOT integration of the Nordic SoftDevice"); + + /* start shell */ + puts("All up, running the shell now"); + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + + /* should be never reached */ + return 0; +} diff --git a/tests/nordic_softdevice/tests/01-run.py b/tests/nordic_softdevice/tests/01-run.py new file mode 100755 index 0000000000..7329c74091 --- /dev/null +++ b/tests/nordic_softdevice/tests/01-run.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import sys +from testrunner import run + + +def testfunc(child): + child.expect("All up, running the shell now") + child.sendline("ifconfig") + child.expect(r"Iface\s+(\d+)\s+HWaddr:") + + +if __name__ == "__main__": + sys.exit(run(testfunc, timeout=1, echo=False))