mirror of
https://github.com/gosticks/RIOT.git
synced 2026-10-07 00:07:12 +00:00
tests: add interactive_sync adapted to shell
This commit is contained in:
Vendored
+23
-9
@@ -9,19 +9,33 @@
|
||||
import pexpect
|
||||
|
||||
|
||||
def test_utils_interactive_sync(child, retries, delay):
|
||||
"""Synchronisation for 'test_utils_interactive_sync' function.
|
||||
def _test_utils_interactive_sync(child, retries, delay, ready_cmd='r',
|
||||
ready_exp='READY'):
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
for _ in range(0, retries):
|
||||
child.sendline('r')
|
||||
ret = child.expect_exact(['READY', pexpect.TIMEOUT], timeout=delay)
|
||||
for _ in range(retries):
|
||||
child.sendline(ready_cmd)
|
||||
ret = child.expect_exact([ready_exp, pexpect.TIMEOUT], timeout=delay)
|
||||
if ret == 0:
|
||||
break
|
||||
else:
|
||||
# Last call to make it fail her,
|
||||
child.expect_exact('READY', timeout=0)
|
||||
# Last call to make it fail here,
|
||||
child.expect_exact(ready_exp, timeout=0)
|
||||
|
||||
|
||||
def test_utils_interactive_sync(child, retries, delay):
|
||||
"""Synchronization for 'test_utils_interactive_sync' function
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
_test_utils_interactive_sync(child, retries, delay)
|
||||
child.sendline('s')
|
||||
child.expect_exact('START')
|
||||
|
||||
|
||||
def test_utils_interactive_sync_shell(child, retries, delay):
|
||||
"""Synchronization `shell` and `test_utils_interactive_sync` modules are
|
||||
used ('test_utils_interactive_sync' function is not)
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
_test_utils_interactive_sync(child, retries, delay, '\n', '>')
|
||||
|
||||
Reference in New Issue
Block a user