Skip to content
Snippets Groups Projects
Unverified Commit 545f54c9 authored by Martine Lenders's avatar Martine Lenders
Browse files

tests: add tests for host NDP behavior

parent 1b36cdf7
Branches
No related tags found
No related merge requests found
# name of your application
APPLICATION = gnrc_ipv6_nib
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := chronos nucleo32-f031 nucleo32-f042
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_ipv6_nib
USEMODULE += embunit
CFLAGS += -DDEVELHELP
CFLAGS += -DGNRC_NETTYPE_NDP2=GNRC_NETTYPE_TEST
CFLAGS += -DGNRC_PKTBUF_SIZE=512
CFLAGS += -DTEST_SUITES
include $(RIOTBASE)/Makefile.include
test:
# `testrunner` calls `make term` recursively, results in duplicated `TERMFLAGS`.
# So clears `TERMFLAGS` before run.
TERMFLAGS= tests/01-run.py
/*
* Copyright (C) 2017 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.
*/
/**
* @defgroup tests_gnrc_ipv6_nib Common header for GNRC's NIB tests
* @ingroup tests
* @brief Common definitions for GNRC's NIB tests
* @{
*
* @file
*
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#ifndef COMMON_H
#define COMMON_H
#include <stdio.h>
#include "net/gnrc.h"
#ifdef __cplusplus
extern "C" {
#endif
#define _CALL(fn) _common_set_up(); _set_up(); puts("Calling " # fn); fn()
extern kernel_pid_t _mock_netif_pid;
void _tests_init(void);
int _mock_netif_get(gnrc_netapi_opt_t *opt);
void _common_set_up(void);
#ifdef __cplusplus
}
#endif
#endif /* COMMON_H */
/** @} */
This diff is collapsed.
/*
* Copyright (C) 2017 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.
*/
/**
* @{
*
* @file
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#include "common.h"
#include "msg.h"
#include "net/gnrc.h"
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/netdev.h"
#include "sched.h"
#include "thread.h"
#define _MSG_QUEUE_SIZE (2)
kernel_pid_t _mock_netif_pid = KERNEL_PID_UNDEF;
static char _mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
static gnrc_netreg_entry_t dumper;
static msg_t _main_msg_queue[_MSG_QUEUE_SIZE];
static msg_t _mock_netif_msg_queue[_MSG_QUEUE_SIZE];
static void *_mock_netif_thread(void *args)
{
msg_t msg, reply = { .type = GNRC_NETAPI_MSG_TYPE_ACK };
(void)args;
msg_init_queue(_mock_netif_msg_queue, _MSG_QUEUE_SIZE);
while (1) {
msg_receive(&msg);
switch (msg.type) {
case GNRC_NETAPI_MSG_TYPE_GET:
reply.content.value = (uint32_t)_mock_netif_get(msg.content.ptr);
break;
case GNRC_NETAPI_MSG_TYPE_SET:
reply.content.value = (uint32_t)(-ENOTSUP);
break;
case GNRC_NETAPI_MSG_TYPE_SND:
case GNRC_NETAPI_MSG_TYPE_RCV:
gnrc_pktbuf_release(msg.content.ptr);
}
msg_reply(&msg, &reply);
}
return NULL;
}
void _common_set_up(void)
{
gnrc_ipv6_nib_init();
gnrc_ipv6_nib_init_iface(_mock_netif_pid);
}
void _tests_init(void)
{
msg_init_queue(_main_msg_queue, _MSG_QUEUE_SIZE);
_mock_netif_pid = thread_create(_mock_netif_stack,
sizeof(_mock_netif_stack),
GNRC_NETDEV_MAC_PRIO,
THREAD_CREATE_STACKTEST,
_mock_netif_thread, NULL, "mock_netif");
assert(_mock_netif_pid > KERNEL_PID_UNDEF);
gnrc_netif_add(_mock_netif_pid);
gnrc_ipv6_netif_init_by_dev();
thread_yield();
gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid);
gnrc_netreg_register(GNRC_NETTYPE_NDP2, &dumper);
}
/** @} */
#!/usr/bin/env python3
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
# Copyright (C) 2016 Takuo Yonezawa <Yonezawa-T2@mail.dnp.co.jp>
#
# 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 os
import sys
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
import testrunner
def testfunc(child):
child.expect(r"OK \(\d+ tests\)")
if __name__ == "__main__":
sys.exit(testrunner.run(testfunc, timeout=1))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment