Skip to content

Commit

Permalink
Merge pull request #14522 from miri64/backport/2020.07/riotctrl.netif…
Browse files Browse the repository at this point in the history
…/bug/multi-iface-w-stats

riotctrl_shell.netif: fix for multiple interfaces with netstats [backport 2020.07]
  • Loading branch information
miri64 authored Jul 15, 2020
2 parents 8923701 + a25cf65 commit d4531f7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dist/pythonlibs/riotctrl_shell/netif.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def parse(self, cmd_output):
if stats is not None:
current["stats"] = stats
# assume stats to be always last
break
current = None
parse_blacklist = False
parse_ipv6 = False
offset += len(line)
return netifs

Expand Down
46 changes: 46 additions & 0 deletions dist/pythonlibs/riotctrl_shell/tests/test_netif_list_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,49 @@ def test_ifconfig_list_parser6():
assert "mcs" not in res["7"]
assert len(res["7"]["ipv6_addrs"]) == 1
assert len(res["7"]["ipv6_groups"]) == 3


def test_ifconfig_list_parser7():
cmd_output = """
Iface 8 HWaddr: 45:5B Channel: 26 NID: 0x23
Long HWaddr: 00:5A:45:50:0A:00:45:5B
L2-PDU:102 MTU:1280 HL:64 RTR
6LO IPHC
Source address length: 8
Link type: wireless
inet6 addr: fe80::25a:4550:a00:455b scope: link VAL
inet6 group: ff02::2
inet6 group: ff02::1
inet6 group: ff02::1:ff00:455b
Statistics for Layer 2
RX packets 0 bytes 0
TX packets 2 (Multicast: 2) bytes 43
TX succeeded 3 errors 0
Statistics for IPv6
RX packets 0 bytes 0
TX packets 2 (Multicast: 2) bytes 128
TX succeeded 2 errors 0
Iface 7 HWaddr: B6:4F:A1:0E:8F:CC
L2-PDU:1500 MTU:1500 HL:64 RTR
Source address length: 6
Link type: wired
inet6 addr: fe80::b44f:a1ff:fe0e:8fcc scope: link VAL
inet6 group: ff02::2
inet6 group: ff02::1
inet6 group: ff02::1:ff0e:8fcc
Statistics for Layer 2
RX packets 4 bytes 480
TX packets 3 (Multicast: 3) bytes 210
TX succeeded 3 errors 0
Statistics for IPv6
RX packets 4 bytes 424
TX packets 3 (Multicast: 3) bytes 168
TX succeeded 3 errors 0"""
parser = riotctrl_shell.netif.IfconfigListParser()
res = parser.parse(cmd_output)
assert len(res) == 2
assert "7" in res
assert "8" in res

0 comments on commit d4531f7

Please # to comment.