Skip to content

Commit

Permalink
Merge pull request #13665 from leandrolanzieri/pr/dist/testrunner_che…
Browse files Browse the repository at this point in the history
…ck_unittests_fix_regex

dist/testrunner: Capture number of unittests that passed
  • Loading branch information
miri64 committed Apr 3, 2020
2 parents f1bf969 + 8ce1bcd commit 942c63e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
13 changes: 11 additions & 2 deletions dist/pythonlibs/testrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ def run(testfunc, timeout=TIMEOUT, echo=True, traceback=False):


def check_unittests(child, timeout=TIMEOUT, nb_tests=None):
_tests = r'\d+' if nb_tests is None else int(nb_tests)
child.expect(r'OK \({} tests\)'.format(_tests), timeout=timeout)
""" Check the number of unit tests that passed, and return the amount.
If the amount of expected tests to pass is known, nd_tests can be set
to perform an exact match against that number.
"""
if nb_tests is None:
child.expect(r'OK \((\d+) tests\)', timeout=timeout)
return int(child.match.group(1))
_tests = int(nb_tests)
child.expect_exact('OK ({} tests)'.format(_tests), timeout=timeout)
return _tests


def run_check_unittests(timeout=TIMEOUT, echo=True, traceback=False,
Expand Down
4 changes: 2 additions & 2 deletions tests/gnrc_ipv6_ext_frag/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ def testfunc(child):
tap = get_bridge(os.environ["TAP"])

child.sendline("unittests")
check_unittests(child) # wait for and check result of unittests
print("." * int(child.match.group(1)), end="", flush=True)
# wait for and check result of unittests
print("." * check_unittests(child), end="", flush=True)

lladdr_src = get_host_lladdr(tap)

Expand Down
4 changes: 2 additions & 2 deletions tests/gnrc_rpl_srh/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def testfunc(child):
global sniffer
tap = get_bridge(os.environ["TAP"])
child.sendline("unittests")
check_unittests(child) # wait for and check result of unittests
print("." * int(child.match.group(1)), end="", flush=True)
# wait for and check result of unittests
print("." * check_unittests(child), end="", flush=True)
lladdr_src = get_host_lladdr(tap)
child.sendline("ifconfig")
child.expect(r"HWaddr: (?P<hwaddr>[A-Fa-f:0-9]+)\s")
Expand Down
3 changes: 1 addition & 2 deletions tests/gnrc_sixlowpan_iphc_w_vrb/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def testfunc(child):
)
child.expect_exact("Original fragmentation header:")
child.expect_exact("IPHC headers + payload:")
check_unittests(child)
assert int(child.match.group(1)) >= 4
assert check_unittests(child) >= 4


if __name__ == "__main__":
Expand Down

0 comments on commit 942c63e

Please sign in to comment.