mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-devtest
synced 2026-01-15 18:33:31 +01:00
test.cmd_expect(): Add support for echo_cmd command line arg
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
2a7267a004
commit
6da9e6af00
1 changed files with 3 additions and 3 deletions
|
|
@ -45,14 +45,14 @@ async def expect(conn, cmd=None, regex=None, subject=None, act_timeout=0.1, tota
|
|||
return buf
|
||||
raise Exception("never reached")
|
||||
|
||||
async def cmd_expect(conn, cmd, subject=None, regex=None, log_act=None, act_timeout=0.1): # export
|
||||
async def cmd_expect(conn, cmd, subject=None, regex=None, log_act=None, act_timeout=0.1, echo_cmd=None): # export
|
||||
slog(NOTICE, 'sending command "{}"'.format(str(cmd).rstrip("\n")))
|
||||
res = await cmd_exec(conn, cmd)
|
||||
res = await cmd_exec(conn, cmd, echo_cmd=echo_cmd)
|
||||
if not isinstance(res, list):
|
||||
msg = 'failed to send command over connection {}'.format(conn)
|
||||
slog(ERR, 'FAIL: ' + msg)
|
||||
return msg
|
||||
if expect(conn, regex=regex, subject=subject, act_timeout=act_timeout, log_act=log_act):
|
||||
if await expect(conn, regex=regex, subject=subject, act_timeout=act_timeout, log_act=log_act):
|
||||
slog(NOTICE, 'PASS: found pattern "{}" in command output'.format(regex))
|
||||
return None
|
||||
r = "FAIL: failed to find {} in command output".format(regex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue