Merge pull request #14479 from miri64/riotctrl_shell.netif/fix/non-str-set

riotctrl_shell.netif: allow for non str values with ifconfig_set()
This commit is contained in:
Alexandre Abadie 2020-07-09 21:31:05 +02:00 committed by GitHub
commit dcfe736b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -287,7 +287,7 @@ class Ifconfig(ShellInteraction):
if args is not None: if args is not None:
if netif is None: if netif is None:
raise ValueError("netif required when args are provided") raise ValueError("netif required when args are provided")
cmd += " {args}".format(args=" ".join(args)) cmd += " {args}".format(args=" ".join(str(a) for a in args))
return self.cmd(cmd, timeout=timeout, async_=False) return self.cmd(cmd, timeout=timeout, async_=False)
def ifconfig_help(self, netif, timeout=-1, async_=False): def ifconfig_help(self, netif, timeout=-1, async_=False):

View File

@ -76,12 +76,18 @@ def test_ifconfig_help():
assert res == "ifconfig foobar help" assert res == "ifconfig foobar help"
def test_ifconfig_set(): @pytest.mark.parametrize(
rc = init_ctrl(output="success: address set") "option,value,expected",
[("addr", "42:de:ad:c0:ff:ee",
"ifconfig foobar set addr 42:de:ad:c0:ff:ee"),
("chan", 17, "ifconfig foobar set chan 17")]
)
def test_ifconfig_set(option, value, expected):
rc = init_ctrl(output="success: option set")
si = riotctrl_shell.netif.Ifconfig(rc) si = riotctrl_shell.netif.Ifconfig(rc)
res = si.ifconfig_set("foobar", "addr", "42:de:ad:c0:ff:ee") res = si.ifconfig_set("foobar", option, value)
assert res == "success: address set" assert res == "success: option set"
assert rc.term.last_command == "ifconfig foobar set addr 42:de:ad:c0:ff:ee" assert rc.term.last_command == expected
def test_ifconfig_set_error(): def test_ifconfig_set_error():