diff --git a/scripts/tests/chiptest/runner.py b/scripts/tests/chiptest/runner.py index 4c6a37c00c2be9..aa17a09f4ea5c6 100644 --- a/scripts/tests/chiptest/runner.py +++ b/scripts/tests/chiptest/runner.py @@ -19,6 +19,7 @@ import threading import time import pty +import re from dataclasses import dataclass @@ -49,6 +50,13 @@ def __init__(self, level, capture_delegate=None, name=None): def CapturedLogContains(self, txt: str): return any(txt in l for l in self.captured_logs) + def FindLastMatchingLine(self, matcher): + for l in reversed(self.captured_logs): + match = re.match(matcher, l) + if match: + return match + return None + def fileno(self): """Return the write file descriptor of the pipe""" return self.fd_write diff --git a/scripts/tests/chiptest/test_definition.py b/scripts/tests/chiptest/test_definition.py index c5c80d171e09e7..50bf96c84cc2c8 100644 --- a/scripts/tests/chiptest/test_definition.py +++ b/scripts/tests/chiptest/test_definition.py @@ -119,8 +119,11 @@ def Run(self, runner, paths: ApplicationPaths): server_is_listening = outpipe.CapturedLogContains( "Server Listening") logging.debug('Server is listening. Can proceed.') + qrLine = outpipe.FindLastMatchingLine('.*SetupQRCode: *\\[(.*)]') + if not qrLine: + raise Exception("Unable to find QR code") - runner.RunSubprocess(tool_cmd + ['pairing', 'onnetwork-long', TEST_NODE_ID, '20202021', discriminator], + runner.RunSubprocess(tool_cmd + ['pairing', 'qrcode', TEST_NODE_ID, qrLine.group(1)], name='PAIR', dependencies=[app_process]) runner.RunSubprocess(tool_cmd + ['tests', self.run_name, TEST_NODE_ID],