tests: provide tests for gnrc_sixlowpan_frag_sfr

This commit is contained in:
Martine S. Lenders 2019-11-15 18:12:58 +01:00 committed by Martine Lenders
parent 1cd1716280
commit ed4ac70887
No known key found for this signature in database
GPG Key ID: CCD317364F63286F
7 changed files with 3116 additions and 0 deletions

View File

@ -0,0 +1,36 @@
include ../Makefile.tests_common
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_sixlowpan_frag_sfr
USEMODULE += gnrc_sixlowpan_iphc
USEMODULE += gnrc_ipv6_nib
USEMODULE += gnrc_netif
USEMODULE += embunit
USEMODULE += netdev_ieee802154
USEMODULE += netdev_test
CFLAGS += -DTEST_SUITES
include $(RIOTBASE)/Makefile.include
ifndef CONFIG_GNRC_IPV6_NIB_NO_RTR_SOL
# disable router solicitations so they don't interfere with the tests
CFLAGS += -DCONFIG_GNRC_IPV6_NIB_NO_RTR_SOL=1
endif
# SFR parameters
ifndef CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE
# fix window size
CFLAGS += -DCONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE=3U
endif
ifndef CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US
# decrease inter frame gap
CFLAGS += -DCONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US=5U
endif
ifndef CONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS
# decrease minimal ARQ timeout
CFLAGS += -DCONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS=100U
endif
ifndef CONFIG_GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS
# decrease initial ARQ timeout
CFLAGS += -DCONFIG_GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS=100U
endif

View File

@ -0,0 +1,42 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-leonardo \
arduino-mega2560 \
arduino-nano \
arduino-uno \
atmega1284p \
atmega328p \
blackpill \
bluepill \
derfmega128 \
hifive1 \
hifive1b \
i-nucleo-lrwan1 \
im880b \
mega-xplained \
microduino-corerf \
msb-430 \
msb-430h \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f070rb \
nucleo-f072rb \
nucleo-f302r8 \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l011k4 \
nucleo-l031k6 \
nucleo-l053r8 \
samd10-xmini \
saml10-xpro \
saml11-xpro \
stk3200 \
stm32f030f4-demo \
stm32f0discovery \
stm32l0538-disco \
stm32mp157c-dk2 \
telosb \
waspmote-pro \
z1 \
#

View File

@ -0,0 +1,10 @@
CONFIG_KCONFIG_USEMODULE_GNRC_IPV6_NIB=y
CONFIG_KCONFIG_USEMODULE_GNRC_SIXLOWPAN=y
CONFIG_KCONFIG_USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR=y
# disable router solicitations so they don't interfere with the tests
CONFIG_GNRC_IPV6_NIB_NO_RTR_SOL=y
# preconfigure SFR for tests
CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE=3
CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US=5
CONFIG_GNRC_SIXLOWPAN_SFR_MIN_ARQ_TIMEOUT_MS=100
CONFIG_GNRC_SIXLOWPAN_SFR_OPT_ARQ_TIMEOUT_MS=100

View File

@ -0,0 +1,50 @@
/*
* 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"
#include "net/gnrc/netif.h"
#ifdef __cplusplus
extern "C" {
#endif
#define _LL0 (0xb8)
#define _LL1 (0x8c)
#define _LL2 (0xcc)
#define _LL3 (0xba)
#define _LL4 (0xef)
#define _LL5 (0x9a)
#define _LL6 (0x67)
#define _LL7 (0x42)
extern gnrc_netif_t *_mock_netif;
void _tests_init(void);
void _common_set_up(void);
#ifdef __cplusplus
}
#endif
#endif /* COMMON_H */
/** @} */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,123 @@
/*
* 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/ethernet.h"
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/netif/ieee802154.h"
#include "net/gnrc/netif/internal.h"
#include "net/netdev_test.h"
#include "sched.h"
#include "thread.h"
#define _MSG_QUEUE_SIZE (2)
gnrc_netif_t *_mock_netif = NULL;
static netdev_test_t _mock_netdev;
static char _mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
static msg_t _main_msg_queue[_MSG_QUEUE_SIZE];
static gnrc_netif_t _netif;
void _common_set_up(void)
{
assert(_mock_netif != NULL);
gnrc_ipv6_nib_init();
gnrc_netif_acquire(_mock_netif);
gnrc_ipv6_nib_init_iface(_mock_netif);
gnrc_netif_release(_mock_netif);
}
int _get_device_type(netdev_t *dev, void *value, size_t max_len)
{
(void)dev;
assert(max_len == sizeof(uint16_t));
*((uint16_t *)value) = NETDEV_TYPE_IEEE802154;
return sizeof(uint16_t);
}
static int _get_netdev_proto(netdev_t *netdev, void *value, size_t max_len)
{
assert(max_len == sizeof(gnrc_nettype_t));
(void)netdev;
*((gnrc_nettype_t *)value) = GNRC_NETTYPE_SIXLOWPAN;
return sizeof(gnrc_nettype_t);
}
int _get_max_packet_size(netdev_t *dev, void *value, size_t max_len)
{
(void)dev;
assert(max_len == sizeof(uint16_t));
*((uint16_t *)value) = 102U;
return sizeof(uint16_t);
}
int _get_src_len(netdev_t *dev, void *value, size_t max_len)
{
(void)dev;
assert(max_len == sizeof(uint16_t));
*((uint16_t *)value) = IEEE802154_LONG_ADDRESS_LEN;
return sizeof(uint16_t);
}
int _get_address_long(netdev_t *dev, void *value, size_t max_len)
{
static const uint8_t addr[] = { _LL0, _LL1, _LL2, _LL3,
_LL4, _LL5, _LL6, _LL7 };
(void)dev;
assert(max_len >= sizeof(addr));
memcpy(value, addr, sizeof(addr));
return sizeof(addr);
}
int _get_proto(netdev_t *dev, void *value, size_t max_len)
{
(void)dev;
assert(max_len == sizeof(gnrc_nettype_t));
*((gnrc_nettype_t *)value) = GNRC_NETTYPE_SIXLOWPAN;
return sizeof(gnrc_nettype_t);
}
void _tests_init(void)
{
int res;
msg_init_queue(_main_msg_queue, _MSG_QUEUE_SIZE);
netdev_test_setup(&_mock_netdev, 0);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_DEVICE_TYPE,
_get_device_type);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_PROTO,
_get_netdev_proto);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_MAX_PACKET_SIZE,
_get_max_packet_size);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_SRC_LEN,
_get_src_len);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_ADDRESS_LONG,
_get_address_long);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_PROTO,
_get_proto);
res = gnrc_netif_ieee802154_create(
&_netif, _mock_netif_stack, THREAD_STACKSIZE_DEFAULT,
GNRC_NETIF_PRIO, "mockup_wpan", &_mock_netdev.netdev.netdev
);
assert(res == 0);
_mock_netif = &_netif;
}
/** @} */

View File

@ -0,0 +1,19 @@
#!/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 sys
from testrunner import run
def testfunc(child):
child.expect(r"OK \(\d+ tests\)")
if __name__ == "__main__":
sys.exit(run(testfunc))