Merge pull request #14460 from miri64/riotctrl_shell.netif/fix/check_term-decorator
riotctrl_shell.netif: add missing check_term decorator
This commit is contained in:
commit
79f26bd09e
2
dist/pythonlibs/riotctrl_shell/netif.py
vendored
2
dist/pythonlibs/riotctrl_shell/netif.py
vendored
@ -279,6 +279,7 @@ class Ifconfig(ShellInteraction):
|
|||||||
def ifconfig_list(self, netif=None, timeout=-1, async_=False):
|
def ifconfig_list(self, netif=None, timeout=-1, async_=False):
|
||||||
return self.ifconfig_cmd(netif=netif, timeout=timeout, async_=async_)
|
return self.ifconfig_cmd(netif=netif, timeout=timeout, async_=async_)
|
||||||
|
|
||||||
|
@ShellInteraction.check_term
|
||||||
def ifconfig_cmd(self, netif=None, args=None, timeout=-1, async_=False):
|
def ifconfig_cmd(self, netif=None, args=None, timeout=-1, async_=False):
|
||||||
cmd = "ifconfig"
|
cmd = "ifconfig"
|
||||||
if netif is not None:
|
if netif is not None:
|
||||||
@ -370,6 +371,7 @@ class Ifconfig(ShellInteraction):
|
|||||||
|
|
||||||
|
|
||||||
class TXTSnd(ShellInteraction):
|
class TXTSnd(ShellInteraction):
|
||||||
|
@ShellInteraction.check_term
|
||||||
def netif_txtsnd(self, netif, target, data, timeout=-1, async_=False):
|
def netif_txtsnd(self, netif, target, data, timeout=-1, async_=False):
|
||||||
cmd = "txtsnd {netif} {target} {data}".format(
|
cmd = "txtsnd {netif} {target} {data}".format(
|
||||||
netif=netif,
|
netif=netif,
|
||||||
|
|||||||
31
dist/pythonlibs/riotctrl_shell/tests/common.py
vendored
31
dist/pythonlibs/riotctrl_shell/tests/common.py
vendored
@ -4,25 +4,27 @@
|
|||||||
# General Public License v2.1. See the file LICENSE in the top level
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
# directory for more details.
|
# directory for more details.
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
|
||||||
|
|
||||||
class MockSpawn():
|
class MockSpawn():
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, ctrl, *args, **kwargs):
|
||||||
|
self.ctrl = ctrl
|
||||||
|
self.last_command = None
|
||||||
# set some expected attributes
|
# set some expected attributes
|
||||||
self.before = None
|
self.before = None
|
||||||
self.echo = False
|
self.echo = False
|
||||||
self.output = None
|
|
||||||
self.last_command = None
|
|
||||||
|
|
||||||
def sendline(self, line, *args, **kwargs):
|
def sendline(self, line, *args, **kwargs):
|
||||||
self.last_command = line
|
self.last_command = line
|
||||||
if self.output is None:
|
if self.ctrl.output is None:
|
||||||
# just echo last input for before (what replwrap is assembling
|
# just echo last input for before (what replwrap is assembling
|
||||||
# output from)
|
# output from)
|
||||||
self.before = line
|
self.before = line
|
||||||
else:
|
else:
|
||||||
# use pre-configured output in case command expects a specific
|
# use pre-configured output in case command expects a specific
|
||||||
# output
|
# output
|
||||||
self.before = self.output
|
self.before = self.ctrl.output
|
||||||
|
|
||||||
def expect_exact(self, *args, **kwargs):
|
def expect_exact(self, *args, **kwargs):
|
||||||
# always match on prompt with replwrap
|
# always match on prompt with replwrap
|
||||||
@ -34,11 +36,26 @@ class MockRIOTCtrl():
|
|||||||
Mock RIOT ctrl
|
Mock RIOT ctrl
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.term = MockSpawn()
|
self.term = None
|
||||||
|
self.output = None
|
||||||
self.last_command = None
|
self.last_command = None
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def run_term(self, reset=True, **startkwargs):
|
||||||
|
try:
|
||||||
|
self.start_term(**startkwargs)
|
||||||
|
yield self.term
|
||||||
|
finally:
|
||||||
|
self.stop_term()
|
||||||
|
|
||||||
|
def start_term(self, **spawnkwargs):
|
||||||
|
self.term = MockSpawn(self)
|
||||||
|
|
||||||
|
def stop_term(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def init_ctrl(output=None):
|
def init_ctrl(output=None):
|
||||||
rc = MockRIOTCtrl("foobar", env={"BOARD": "native"})
|
rc = MockRIOTCtrl("foobar", env={"BOARD": "native"})
|
||||||
rc.term.output = output
|
rc.output = output
|
||||||
return rc
|
return rc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user