Skip to content

Commit

Permalink
Make start take an optional arg instead of forcing an empty dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
carol-apple committed Apr 20, 2022
1 parent 7eaffbc commit cd596ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
9 changes: 5 additions & 4 deletions scripts/tests/chiptest/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ def __stopXMLRPCServer(self):

def __createCommandLineOptions(self, args):
# args should contain a list of strings in key-value pair, e.g. [option1, value1, option2, value2, ...]
options = {}
if (len(args) % 2) == 0:
# Create a dictionary from the key-value pair list
options = {args[i]: args[i+1] for i in range(0, len(args), 2)}
if len(args) == 0 or (len(args) % 2) != 0:
return None

# Create a dictionary from the key-value pair list
options = {args[i]: args[i+1] for i in range(0, len(args), 2)}
return options
19 changes: 11 additions & 8 deletions scripts/tests/chiptest/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, runner, command):
self.lastLogIndex = 0
self.kvs = '/tmp/chip_kvs'

def start(self, options):
def start(self, options = None):
if not self.process:
# Make sure to assign self.process before we do any operations that
# might fail, so attempts to kill us on failure actually work.
Expand Down Expand Up @@ -102,12 +102,15 @@ def wait(self, timeout=None):
def __startServer(self, runner, command, options):
app_cmd = command + ['--interface-id', str(-1)]

logging.debug('Executing application under test with the following args:')
for key, value in options.items():
logging.debug(' %s: %s' % (key, value))
app_cmd = app_cmd + [key, value]
if key == '--KVS':
self.kvs = value
if options is None:
logging.debug('Executing application under test with default args')
else:
logging.debug('Executing application under test with the following args:')
for key, value in options.items():
logging.debug(' %s: %s' % (key, value))
app_cmd = app_cmd + [key, value]
if key == '--KVS':
self.kvs = value
return runner.RunSubprocess(app_cmd, name='APP ', wait=False)

def __waitFor(self, waitForString, server_process, outpipe):
Expand Down Expand Up @@ -233,7 +236,7 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str):
# Remove server application storage (factory reset),
# so it will be commissionable again.
app.factoryReset()
app.start({})
app.start()

runner.RunSubprocess(
tool_cmd + ['pairing', 'qrcode', TEST_NODE_ID, app.setupCode] +
Expand Down

0 comments on commit cd596ef

Please sign in to comment.