Skip to content

Commit

Permalink
fixup! tests/gnrc_rpl: add automated test for gnrc_rpl
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Dec 8, 2021
1 parent 78a9058 commit 743dd3a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions tests/gnrc_rpl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ TEST_ON_CI_WHITELIST += native

ifeq (native, $(BOARD))
USEMODULE += socket_zep
USEMODULE += socket_zep_hello
USEMODULE += netdev
TERMFLAGS += -z [::1]:17754
else
Expand Down
3 changes: 0 additions & 3 deletions tests/gnrc_rpl/test.topo

This file was deleted.

33 changes: 19 additions & 14 deletions tests/gnrc_rpl/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

import os
import signal
import subprocess
import atexit
import time

from subprocess import Popen
from riotctrl_shell.gnrc import GNRCICMPv6Echo, GNRCICMPv6EchoParser
from riotctrl_shell.netif import Ifconfig
from contextlib import ContextDecorator
Expand Down Expand Up @@ -39,15 +39,15 @@ def __exit__(self, *exc):
for ctrl in self.ctrl_list:
ctrl.stop_term()

def get_shell(self, application_directory='.', env=None):
def get_shell(self, application_directory='.', env={'BOARD': 'native'}):
# retrieve a RIOTCtrl Object
ctrl = super().get_ctrl(
env=env,
application_directory=application_directory
)
# append ctrl to list
self.ctrl_list.append(ctrl)
# flash and start terminal
# start terminal
ctrl.start_term()
# return ctrl with started terminal
return Shell(ctrl)
Expand All @@ -74,24 +74,29 @@ def global_addr(ifconfig_out):
with RIOTCtrlAppFactory() as factory:

# spawn dispatcher
pid = os.spawnl(os.P_NOWAIT, '../../dist/tools/zep_dispatch/bin/zep_dispatch',
'zep_dispatch', '-t', 'test.topo', '::1', '17754')
atexit.register(os.kill, pid, signal.SIGTERM)
zep_dispatch = Popen(['../../dist/tools/zep_dispatch/bin/zep_dispatch',
'-t', '-', '::1', '17754'], stdin = subprocess.PIPE)
atexit.register(Popen.terminate, zep_dispatch)

# create native instances
env = {'BOARD': 'native'}
# linear topology with 4 nodes
topology = ("A B\n"
"B C\n"
"C D\n")
zep_dispatch.stdin.write(topology.encode())
zep_dispatch.stdin.close()

A = factory.get_shell(env=env)
B = factory.get_shell(env=env)
C = factory.get_shell(env=env)
D = factory.get_shell(env=env)
# create native instances
A = factory.get_shell()
B = factory.get_shell()
C = factory.get_shell()
D = factory.get_shell()

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

# wait for the creation of the DODAG
time.sleep(5)
time.sleep(6)

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

0 comments on commit 743dd3a

Please sign in to comment.