testrunner/utils: add helper for test_utils_interactive_sync
Add helper to do the synchronisation.
This commit is contained in:
parent
027426793c
commit
e5e9d81cce
1
dist/pythonlibs/testrunner/__init__.py
vendored
1
dist/pythonlibs/testrunner/__init__.py
vendored
@ -14,6 +14,7 @@ import pexpect
|
||||
|
||||
from .spawn import find_exc_origin, setup_child, teardown_child
|
||||
from .unittest import PexpectTestCase # noqa, F401 expose to users
|
||||
from .utils import test_utils_interactive_sync # noqa, F401 expose to users
|
||||
|
||||
# Timeout for tests can be changed by setting RIOT_TEST_TIMEOUT to the desired
|
||||
# value in the environment variables
|
||||
|
||||
27
dist/pythonlibs/testrunner/utils.py
vendored
Normal file
27
dist/pythonlibs/testrunner/utils.py
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2019 Freie Universität Berlin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
"""Utility functions for writing tests."""
|
||||
|
||||
import pexpect
|
||||
|
||||
|
||||
def test_utils_interactive_sync(child, retries=5, delay=1):
|
||||
"""Synchronisation for 'test_utils_interactive_sync' function.
|
||||
|
||||
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)
|
||||
if ret == 0:
|
||||
break
|
||||
else:
|
||||
# Last call to make it fail her,
|
||||
child.expect_exact('READY', timeout=0)
|
||||
|
||||
child.sendline('s')
|
||||
child.expect_exact('START')
|
||||
Loading…
x
Reference in New Issue
Block a user