Skip to content

Commit

Permalink
Go back to using a QR code for test pairing. (#12506)
Browse files Browse the repository at this point in the history
Vivien pointed out that there are benefits to exercising the QR code
codepath, since that will likely be the most common commissioning path
in practice.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed May 17, 2022
1 parent b63f66b commit 1130052
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions scripts/tests/chiptest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import threading
import time
import pty
import re

from dataclasses import dataclass

Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion scripts/tests/chiptest/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 1130052

Please sign in to comment.