Skip to content

Commit

Permalink
tests: add manual test application for netdev_eth
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed May 26, 2015
1 parent 1c91bae commit 8dda277
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/driver_netdev_eth/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
APPLICATION = driver_netdev_eth
include ../Makefile.tests_common

BOARD_WHITELIST := native

USEMODULE += ng_nativenet
USEMODULE += ng_netbase
USEMODULE += ng_nomac
USEMODULE += ng_pktdump
USEMODULE += ng_netdev_eth
USEMODULE += shell
USEMODULE += shell_commands

include $(RIOTBASE)/Makefile.include
104 changes: 104 additions & 0 deletions tests/driver_netdev_eth/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
* Kaspar Schleiser <kaspar@schleiser.de>
*
* 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 Test application for netdev ethernet device driver
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/

#include <stdio.h>

#include "board.h"
#include "kernel.h"
#include "shell.h"
#include "shell_commands.h"
#include "net/ng_netbase.h"
#include "net/ng_nomac.h"
#include "net/ng_pktdump.h"
#include "net/ng_netdev_eth.h"
#include "net/dev_eth.h"
#include "dev_eth_tap.h"

/**
* @brief Buffer size used by the shell
*/
#define SHELL_BUFSIZE (64U)

/**
* @brief Stack for the nomac thread
*/
static char nomac_stack[KERNEL_CONF_STACKSIZE_DEFAULT];

/**
* @brief Read chars from STDIO
*/
int shell_read(void)
{
return (int)getchar();
}

/**
* @brief Write chars to STDIO
*/
void shell_put(int c)
{
putchar((char)c);
}

/**
* @brief Maybe you are a golfer?!
*/
int main(void)
{
int res;
shell_t shell;
ng_netreg_entry_t dump;

puts("netdev ethernet device driver test");

/* initialize network module(s) */
ng_netif_init();

/* initialize and register pktdump */
dump.pid = ng_pktdump_init();
dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;

if (dump.pid <= KERNEL_PID_UNDEF) {
puts("Error starting pktdump thread");
return -1;
}

ng_netreg_register(NG_NETTYPE_UNDEF, &dump);

/* initialize netdev_eth layer */
ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);

/* start MAC layer */
res = ng_nomac_init(nomac_stack, sizeof(nomac_stack), PRIORITY_MAIN - 3,
"tapnet_l2", (ng_netdev_t *)&ng_netdev_eth);

if (res < 0) {
printf("Error starting nomac thread. res=%i\n", res);
return -1;
}

/* start the shell */
shell_init(&shell, NULL, SHELL_BUFSIZE, shell_read, shell_put);
shell_run(&shell);

return 0;
}

0 comments on commit 8dda277

Please # to comment.