Skip to content

Commit

Permalink
tests/gnrc_rpl: speed up test
Browse files Browse the repository at this point in the history
Add a printout when the global prefix has been received that we can await.
Strangely we still have to wait 5s after that for ping to work.
  • Loading branch information
benpicco committed Jan 12, 2023
1 parent 75c909b commit cfac5e5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tests/gnrc_rpl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ USEMODULE += auto_init_gnrc_netif
USEMODULE += auto_init_gnrc_rpl
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_icmpv6_echo
USEMODULE += gnrc_netif_bus
USEMODULE += gnrc_rpl

USEMODULE += shell
USEMODULE += shell_cmds_default

DISABLE_MODULE += test_utils_print_stack_usage

ifeq (native, $(BOARD))
USEMODULE += socket_zep
USEMODULE += socket_zep_hello
Expand Down
20 changes: 20 additions & 0 deletions tests/gnrc_rpl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,36 @@
* @}
*/

#include <stdio.h>
#include "shell.h"
#include "msg.h"
#include "thread.h"
#include "net/gnrc/netif.h"

#define MAIN_QUEUE_SIZE (8)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
static char _uplink_mon_stack[THREAD_STACKSIZE_DEFAULT];

static void * _uplink_mon(void *arg)
{
(void)arg;

if (gnrc_netif_ipv6_wait_for_global_address(NULL, 10 * MS_PER_SEC)) {
puts("uplink ready");
} else {
puts("uplink timeout");
}

return NULL;
}

int main(void)
{
char line_buf[SHELL_DEFAULT_BUFSIZE];

thread_create(_uplink_mon_stack, sizeof(_uplink_mon_stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_STACKTEST, _uplink_mon, NULL, "uplink monitor");

msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);

Expand Down
14 changes: 8 additions & 6 deletions tests/gnrc_rpl/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ def test_linear_topology(factory, zep_dispatch):
D = nodes[3]

# add prefix to root node
A.cmd("nib prefix add 5 2001:db8::/32")
A.cmd("ifconfig 5 add 2001:db8::1/32")
A.cmd("nib prefix add 5 2001:db8::/64")
A.cmd("ifconfig 5 add 2001:db8::1/64")
A.cmd("rpl root 0 2001:db8::1")
root_addr = global_addr(A.ifconfig_list())[1]

# wait for the creation of the DODAG
time.sleep(10)
D.riotctrl.term.expect("uplink ready")
time.sleep(5)

# ping root node from last node
parser = GNRCICMPv6EchoParser()
Expand Down Expand Up @@ -137,13 +138,14 @@ def test_alternative_route(factory, zep_dispatch):
D = nodes[3]

# add prefix to root node
A.cmd("nib prefix add 5 2001:db8::/32")
A.cmd("ifconfig 5 add 2001:db8::1/32")
A.cmd("nib prefix add 5 2001:db8::/64")
A.cmd("ifconfig 5 add 2001:db8::1/64")
A.cmd("rpl root 0 2001:db8::1")
root_addr = global_addr(A.ifconfig_list())[1]

# wait for the creation of the DODAG
time.sleep(10)
D.riotctrl.term.expect("uplink ready")
time.sleep(5)

# ping root node from last node
parser = GNRCICMPv6EchoParser()
Expand Down

0 comments on commit cfac5e5

Please sign in to comment.