Merge pull request #8075 from miri64/tests/fix/resolve-gnrc_netif2-conflict

tests: revert gnrc_netif2 Makefile to resolve merge conflict
This commit is contained in:
Hauke Petersen 2017-11-17 15:50:16 +01:00 committed by GitHub
commit 582abd4e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1991 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# name of your application
APPLICATION = gnrc_ipv6_nib
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := airfy-beacon b-l072z-lrwan1 calliope-mini \
cc2650-launchpad cc2650stk chronos maple-mini \
microbit msb-430 msb-430h nrf51dongle nrf6310 \
nucleo-f030 nucleo-f070 nucleo-f072 nucleo-f103 \
nucleo-f302 nucleo-f334 nucleo-l053 nucleo-l073 \
nucleo32-f031 nucleo32-f042 nucleo32-f303 \
nucleo32-l031 opencm904 pca10000 pca10005 \
spark-core stm32f0discovery telosb wsn430-v1_3b \
wsn430-v1_4 yunjia-nrf51822 z1 \
USEMODULE += embunit
USEMODULE += gnrc_netif
USEMODULE += gnrc_pktdump
USEMODULE += gnrc_sixlowpan
USEMODULE += gnrc_sixlowpan_iphc
USEMODULE += gnrc_ipv6
USEMODULE += netdev_eth
USEMODULE += netdev_ieee802154
USEMODULE += netdev_test
USEMODULE += od
CFLAGS += -DDEVELHELP
CFLAGS += -DGNRC_NETIF_NUMOF=4
CFLAGS += -DGNRC_NETIF_ADDRS_NUMOF=16
CFLAGS += -DGNRC_NETIF_GROUPS_NUMOF=8
CFLAGS += -DLOG_LEVEL=LOG_NONE
CFLAGS += -DTEST_SUITES
include $(RIOTBASE)/Makefile.include
test:
tests/01-run.py

182
tests/gnrc_netif2/common.c Normal file
View File

@ -0,0 +1,182 @@
/*
* 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 <errno.h>
#include <stdio.h>
#include "common.h"
#include "net/ethernet.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/pktdump.h"
#include "net/ipv6.h"
#include "net/netdev_test.h"
#include "od.h"
static netdev_test_t _devs[GNRC_NETIF_NUMOF];
netdev_t *ethernet_dev = (netdev_t *)&_devs[0];
netdev_t *ieee802154_dev = (netdev_t *)&_devs[1];
netdev_t *devs[DEFAULT_DEVS_NUMOF];
#define MSG_QUEUE_SIZE (8)
static gnrc_netreg_entry_t dumper_undef, dumper_ipv6;
static msg_t _main_msg_queue[MSG_QUEUE_SIZE];
static uint8_t tmp_buffer[ETHERNET_DATA_LEN];
static size_t tmp_buffer_bytes = 0;
static int _dump_send_packet(netdev_t *netdev, const struct iovec *vector,
int count)
{
int res;
tmp_buffer_bytes = 0;
printf("Sending data from ");
if (netdev == ethernet_dev) {
printf("Ethernet ");
}
else if (netdev == ieee802154_dev) {
printf("IEEE 802.15.4 ");
}
else {
printf("unknown ");
}
puts("device:");
for (int i = 0; i < count; i++) {
if ((tmp_buffer_bytes + vector[i].iov_len) > ETHERNET_DATA_LEN) {
return -ENOBUFS;
}
memcpy(&tmp_buffer[tmp_buffer_bytes], vector[i].iov_base,
vector[i].iov_len);
tmp_buffer_bytes += vector[i].iov_len;
}
od_hex_dump(tmp_buffer, tmp_buffer_bytes, OD_WIDTH_DEFAULT);
res = (int)tmp_buffer_bytes;
return res;
}
void _test_trigger_recv(gnrc_netif_t *netif, const uint8_t *data,
size_t data_len)
{
netdev_t *dev = netif->dev;
assert(data_len <= ETHERNET_DATA_LEN);
if ((data != NULL) || (data_len > 0)) {
tmp_buffer_bytes = data_len;
memcpy(tmp_buffer, data, data_len);
}
else {
tmp_buffer_bytes = 0;
}
assert(dev->event_callback);
dev->event_callback(dev, NETDEV_EVENT_ISR);
}
static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
{
int res;
(void)dev;
(void)info;
res = (int)tmp_buffer_bytes;
if (buf == NULL) {
if (len > 0) {
tmp_buffer_bytes = 0;
}
return res;
}
if (((unsigned)len) < tmp_buffer_bytes) {
return -ENOBUFS;
}
memcpy(buf, tmp_buffer, tmp_buffer_bytes);
return res;
}
static void _netdev_isr(netdev_t *dev)
{
assert(dev->event_callback);
dev->event_callback(dev, NETDEV_EVENT_RX_COMPLETE);
}
static int _get_netdev_device_type(netdev_t *netdev, void *value, size_t max_len)
{
netdev_test_t *dev = (netdev_test_t *)netdev;
assert(max_len == sizeof(uint16_t));
if (dev->state == 0x0) {
*((uint16_t *)value) = NETDEV_TYPE_ETHERNET;
}
else if (dev->state == (void *)0x1) {
*((uint16_t *)value) = NETDEV_TYPE_IEEE802154;
}
else {
*((uint16_t *)value) = NETDEV_TYPE_UNKNOWN;
}
return sizeof(uint16_t);
}
static int _get_netdev_max_packet_size(netdev_t *netdev, void *value, size_t max_len)
{
netdev_test_t *dev = (netdev_test_t *)netdev;
assert(max_len == sizeof(uint16_t));
if (dev->state == 0x0) {
*((uint16_t *)value) = ETHERNET_DATA_LEN;
}
else if (dev->state == ((void *)0x1)) {
*((uint16_t *)value) = TEST_IEEE802154_MAX_FRAG_SIZE;
}
else {
*((uint16_t *)value) = IPV6_MIN_MTU;
}
return sizeof(uint16_t);
}
void _tests_init(void)
{
msg_init_queue(_main_msg_queue, MSG_QUEUE_SIZE);
netdev_test_setup((netdev_test_t *)ethernet_dev, 0);
netdev_test_set_send_cb((netdev_test_t *)ethernet_dev, _dump_send_packet);
netdev_test_set_recv_cb((netdev_test_t *)ethernet_dev, _netdev_recv);
netdev_test_set_isr_cb((netdev_test_t *)ethernet_dev, _netdev_isr);
netdev_test_set_get_cb((netdev_test_t *)ethernet_dev, NETOPT_DEVICE_TYPE,
_get_netdev_device_type);
netdev_test_set_get_cb((netdev_test_t *)ethernet_dev, NETOPT_MAX_PACKET_SIZE,
_get_netdev_max_packet_size);
netdev_test_setup((netdev_test_t *)ieee802154_dev, (void *)1);
netdev_test_set_send_cb((netdev_test_t *)ieee802154_dev, _dump_send_packet);
netdev_test_set_recv_cb((netdev_test_t *)ieee802154_dev, _netdev_recv);
netdev_test_set_isr_cb((netdev_test_t *)ieee802154_dev, _netdev_isr);
netdev_test_set_get_cb((netdev_test_t *)ieee802154_dev, NETOPT_DEVICE_TYPE,
_get_netdev_device_type);
netdev_test_set_get_cb((netdev_test_t *)ieee802154_dev,
NETOPT_MAX_PACKET_SIZE, _get_netdev_max_packet_size);
for (intptr_t i = SPECIAL_DEVS; i < GNRC_NETIF_NUMOF; i++) {
devs[i - SPECIAL_DEVS] = (netdev_t *)&_devs[i];
netdev_test_setup(&_devs[i], (void *)i);
netdev_test_set_get_cb(&_devs[i], NETOPT_DEVICE_TYPE,
_get_netdev_device_type);
netdev_test_set_get_cb(&_devs[i], NETOPT_MAX_PACKET_SIZE,
_get_netdev_max_packet_size);
}
gnrc_netreg_entry_init_pid(&dumper_undef, GNRC_NETREG_DEMUX_CTX_ALL,
gnrc_pktdump_pid);
gnrc_netreg_entry_init_pid(&dumper_ipv6, GNRC_NETREG_DEMUX_CTX_ALL,
gnrc_pktdump_pid);
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dumper_undef);
gnrc_netreg_register(GNRC_NETTYPE_IPV6, &dumper_ipv6);
}
/** @} */

View File

@ -0,0 +1,97 @@
/*
* 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 "net/gnrc/netif.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SPECIAL_DEVS (2)
#define DEFAULT_DEVS_NUMOF (GNRC_NETIF_NUMOF - SPECIAL_DEVS)
#define GP1 (0x20U)
#define GP2 (0x01U)
#define GP3 (0x0dU)
#define GP4 (0xb8U)
#define GP5 (0x00U)
#define GP6 (0x00U)
#define GP7 (0x5aU)
#define GP8 (0x1aU)
#define LP1 (0xfeU)
#define LP2 (0x80U)
#define LP3 (0x00U)
#define LP4 (0x00U)
#define LP5 (0x00U)
#define LP6 (0x00U)
#define LP7 (0x00U)
#define LP8 (0x00U)
#define LA1 (0x3eU)
#define LA2 (0xe6U)
#define LA3 (0xb5U)
#define LA4 (0x0fU)
#define LA5 (0x19U)
#define LA6 (0x22U)
#define LA7 (0xfdU)
#define LA8 (0x0aU)
#define TEST_IEEE802154_MAX_FRAG_SIZE (102)
#define ETHERNET_SRC { LA1, LA2, LA3, LA6, LA7, LA8 }
#define ETHERNET_IPV6_LL { LP1, LP2, LP3, LP4, LP5, LP6, LP7, LP8, \
LA1 ^ 0x2, LA2, LA3, 0xff, 0xfe, LA6, LA7, LA8 }
#define ETHERNET_IPV6_G { GP1, GP2, GP3, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x2, LA2, LA3, 0xff, 0xfe, LA6, LA7, LA8 }
#define IEEE802154_LONG_SRC { LA1, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
#define IEEE802154_SHORT_SRC { LA7, LA8 }
#define IEEE802154_IPV6_LL { LP1, LP2, LP3, LP4, LP5, LP6, LP7, LP8, \
LA1 ^ 0x2, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
#define IEEE802154_IPV6_G { GP1, GP2, GP3, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x2, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
#define NETIF0_SRC { LA1, LA2 + 1, LA3, LA4, LA5, LA6, LA7, LA8 }
#define NETIF0_IPV6_LL { LP1, LP2, LP3, LP4, LP5, LP6, LP7, LP8, \
LA1 ^ 0x2, LA2 + 1, LA3, LA4, LA5, LA6, LA7, LA8 }
#define NETIF0_IPV6_G { GP1, GP2, GP3, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x2, LA2 + 1, LA3, LA4, LA5, LA6, LA7, LA8 }
#define GLOBAL_PFX18 { GP1, GP2, GP3 ^ 0x3f, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x2, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
#define GLOBAL_PFX23 { GP1, GP2, GP3 ^ 0x1, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x2, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
#define GLOBAL_PFX64 { GP1, GP2, GP3, GP4, GP5, GP6, GP7, GP8, \
LA1 ^ 0x82, LA2, LA3, LA4, LA5, LA6, LA7, LA8 }
extern netdev_t *ethernet_dev;
extern netdev_t *ieee802154_dev;
extern netdev_t *devs[DEFAULT_DEVS_NUMOF];
void _tests_init(void);
void _test_trigger_recv(gnrc_netif_t *netif, const uint8_t *data,
size_t data_len);
#ifdef __cplusplus
}
#endif
#endif /* COMMON_H */
/** @} */

1524
tests/gnrc_netif2/main.c Normal file

File diff suppressed because it is too large Load Diff

152
tests/gnrc_netif2/tests/01-run.py Executable file
View File

@ -0,0 +1,152 @@
#!/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):
# embUnit tests
child.expect(r"OK \(\d+ tests\)")
# output cross-checked hex data with WireShark -> "Import from Hex Dump..."
# test_netapi_send__raw_unicast_ethernet_packet
child.expect("Sending data from Ethernet device:")
child.expect("00000000 3E E6 B5 0F 19 23 3E E6 B5 22 FD 0A " +
"FF FF 41 42")
child.expect("00000010 43 44 45 46 47 00")
# test_netapi_send__raw_broadcast_ethernet_packet
child.expect("Sending data from Ethernet device:")
child.expect("00000000 FF FF FF FF FF FF 3E E6 B5 22 FD 0A " +
"FF FF 41 42")
child.expect("00000010 43 44 45 46 47 00")
# test_netapi_send__raw_unicast_ieee802154_long_long_packet
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 DC 00 00 00 0B FD 22 19 0F B5 E6 " +
"3E 0A FD 22")
child.expect("00000010 19 0F B5 E6 3E 31 32 33 41 42 43 44 " +
"45 46 47 00")
# test_netapi_send__raw_unicast_ieee802154_long_short_packet
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 D8 01 00 00 0B FD 0A FD 22 19 0F " +
"B5 E6 3E 31")
child.expect("00000010 32 33 41 42 43 44 45 46 47 00")
# test_netapi_send__raw_unicast_ieee802154_short_long_packet1
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 9C 02 00 00 0B FD 22 19 0F B5 E6 " +
"3E 0A FD 31")
child.expect("00000010 32 33 41 42 43 44 45 46 47 00")
# test_netapi_send__raw_unicast_ieee802154_short_long_packet2
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 9C 03 00 00 0B FD 22 19 0F B5 E6 " +
"3E 0A FD 31")
child.expect("00000010 32 33 41 42 43 44 45 46 47 00")
# test_netapi_send__raw_unicast_ieee802154_short_short_packet
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 98 04 00 00 0B FD 0A FD 31 32 33 " +
"41 42 43 44")
child.expect("00000010 45 46 47 00")
# test_netapi_send__raw_broadcast_ieee802154_long_packet
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 D8 05 00 00 FF FF 0A FD 22 19 0F " +
"B5 E6 3E 31")
child.expect("00000010 32 33 41 42 43 44 45 46 47 00")
# test_netapi_send__raw_broadcast_ieee802154_short_packet
child.expect(r"Sending data from IEEE 802\.15\.4 device:")
child.expect("00000000 41 98 06 00 00 FF FF 0A FD 31 32 33 " +
"41 42 43 44")
child.expect("00000010 45 46 47 00")
# test_netapi_send__ipv6_unicast_ethernet_packet
child.expect("Sending data from Ethernet device:")
child.expect("00000000 3E E6 B5 0F 19 23 3E E6 B5 22 FD 0A 86 DD 60 00")
child.expect("00000010 00 00 00 08 3B 40 FE 80 00 00 00 00 00 00 3C E6")
child.expect("00000020 B5 FF FE 22 FD 0A FE 80 00 00 00 00 00 00 3C E6")
child.expect("00000030 B5 FF FE 0F 19 23 41 42 43 44 45 46 47 00")
# test_netapi_send__ipv6_multicast_ethernet_packet
child.expect("Sending data from Ethernet device:")
child.expect("00000000 33 33 00 00 00 01 3E E6 B5 22 FD 0A 86 DD 60 00")
child.expect("00000010 00 00 00 08 3B 40 FE 80 00 00 00 00 00 00 3C E6")
child.expect("00000020 B5 FF FE 22 FD 0A FF 02 00 00 00 00 00 00 00 00")
child.expect("00000030 00 00 00 00 00 01 41 42 43 44 45 46 47 00")
# test_netapi_send__ipv6_unicast_ieee802154_packet
child.expect("Sending data from IEEE 802.15.4 device:")
child.expect("00000000 41 DC 07 00 00 0B FD 22 19 0F B5 E6 3E 0A FD 22")
child.expect("00000010 19 0F B5 E6 3E 60 00 00 00 00 08 3B 40 FE 80 00")
child.expect("00000020 00 00 00 00 00 3C E6 B5 0F 19 22 FD 0A FE 80 00")
child.expect("00000030 00 00 00 00 00 3C E6 B5 FF FE 0F 19 23 41 42 43")
child.expect("00000040 44 45 46 47 00")
# test_netapi_send__ipv6_multicast_ieee802154_packet
child.expect("Sending data from IEEE 802.15.4 device:")
child.expect("00000000 41 D8 08 00 00 FF FF 0A FD 22 19 0F B5 E6 3E 60")
child.expect("00000010 00 00 00 00 08 3B 40 FE 80 00 00 00 00 00 00 3C")
child.expect("00000020 E6 B5 0F 19 22 FD 0A FF 02 00 00 00 00 00 00 00")
child.expect("00000030 00 00 00 00 00 00 01 41 42 43 44 45 46 47 00")
# test_netapi_recv__empty_ethernet_payload
child.expect("pktdump dumping Ethernet packet with empty payload")
child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)")
child.expect(r"00000000~~ SNIP 1 - size: 20 byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: \d+ rssi: \d+ lqi: \d+")
child.expect("flags: 0x0")
child.expect("src_l2addr: 3e:e6:b5:22:fd:0b")
child.expect("dst_l2addr: 3e:e6:b5:22:fd:0a")
child.expect("~~ PKT - 2 snips, total size: 20 byte")
# test_netapi_recv__empty_ieee802154_payload
child.expect(r"pktdump dumping IEEE 802\.15\.4 packet with empty payload")
child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)")
child.expect(r"00000000~~ SNIP 1 - size: 24 byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: \d+ rssi: \d+ lqi: \d+")
child.expect("flags: 0x0")
child.expect("src_l2addr: 3e:e6:b5:0f:19:22:fd:0b")
child.expect("dst_l2addr: 3e:e6:b5:0f:19:22:fd:0a")
child.expect("~~ PKT - 2 snips, total size: 24 byte")
# test_netapi_recv__raw_ethernet_payload
child.expect("pktdump dumping Ethernet packet with payload 12 34 45 56")
child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 4 byte, type: NETTYPE_UNDEF \(0\)")
child.expect("00000000 12 34 45 56")
child.expect(r"~~ SNIP 1 - size: 20 byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: \d+ rssi: \d+ lqi: \d+")
child.expect("flags: 0x0")
child.expect("src_l2addr: 3e:e6:b5:22:fd:0b")
child.expect("dst_l2addr: 3e:e6:b5:22:fd:0a")
child.expect("~~ PKT - 2 snips, total size: 24 byte")
# test_netapi_recv__raw_ieee802154_payload
child.expect(r"pktdump dumping IEEE 802\.15\.4 packet with payload 12 34 45 56")
child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 4 byte, type: NETTYPE_UNDEF \(0\)")
child.expect("00000000 12 34 45 56")
child.expect(r"~~ SNIP 1 - size: 24 byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: \d+ rssi: \d+ lqi: \d+")
child.expect("flags: 0x0")
child.expect("src_l2addr: 3e:e6:b5:0f:19:22:fd:0b")
child.expect("dst_l2addr: 3e:e6:b5:0f:19:22:fd:0a")
child.expect("~~ PKT - 2 snips, total size: 28 byte")
# test_netapi_recv__ipv6_ethernet_payload
child.expect("pktdump dumping IPv6 over Ethernet packet with payload 01")
child.expect("PKTDUMP: data received:")
# payload not dumped because not parsed yet, but header looks okay, so let's
# assume the payload is as well
child.expect(r"~~ SNIP 0 - size: 41 byte, type: NETTYPE_IPV6 \(2\)")
child.expect(r"traffic class: 0x00 \(ECN: 0x0, DSCP: 0x00\)")
child.expect("flow label: 0x00000")
child.expect("length: 1 next header: 59 hop limit: 64")
child.expect("source address: fe80::3fe6:b5ff:fe22:fd0a")
child.expect("destination address: fe80::3fe6:b5ff:fe22:fd0b")
child.expect(r"~~ SNIP 1 - size: 20 byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: \d+ rssi: \d+ lqi: \d+")
child.expect("flags: 0x0")
child.expect("src_l2addr: 3e:e6:b5:22:fd:0b")
child.expect("dst_l2addr: 3e:e6:b5:22:fd:0a")
child.expect("~~ PKT - 2 snips, total size: 61 byte")
if __name__ == "__main__":
sys.exit(testrunner.run(testfunc, timeout=1, traceback=True))