Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Jul 8, 2024
1 parent 83f1c0f commit 21a7d12
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def waitForActiveAndTriggerCheckIn(test, nodeid):
return await coro


def main():
async def main():
optParser = OptionParser()
optParser.add_option(
"-t",
Expand Down Expand Up @@ -120,28 +120,28 @@ def main():
nodeid=112233, paaTrustStorePath=options.paaTrustStorePath, testCommissioner=True)

logger.info("Testing discovery")
FailIfNot(test.TestDiscovery(discriminator=options.discriminator),
FailIfNot(await test.TestDiscovery(discriminator=options.discriminator),
"Failed to discover any devices.")

devCtrl = test.devCtrl
devCtrl.EnableICDRegistration(devCtrl.GenerateICDRegistrationParameters())
if options.deviceAddress:
logger.info("Testing commissioning (IP)")
FailIfNot(test.TestCommissioning(ip=options.deviceAddress,
FailIfNot(await test.TestCommissioning(ip=options.deviceAddress,
setuppin=20202021,
nodeid=options.nodeid),
"Failed to finish commissioning")
elif options.setupPayload:
logger.info("Testing commissioning (w/ Setup Payload)")
FailIfNot(test.TestCommissioningWithSetupPayload(setupPayload=options.setupPayload,
FailIfNot(await test.TestCommissioningWithSetupPayload(setupPayload=options.setupPayload,
nodeid=options.nodeid,
discoveryType=options.discoveryType),
"Failed to finish commissioning")
else:
TestFail("Must provide device address or setup payload to commissioning the device")
logger.info("Commissioning completed")
logger.info("Testing wait for active")
FailIfNot(asyncio.run(waitForActiveAndTriggerCheckIn(test, nodeid=options.nodeid)), "Failed to test wait for active")
FailIfNot(await waitForActiveAndTriggerCheckIn(test, nodeid=options.nodeid), "Failed to test wait for active")
logger.info('Successfully handled wait-for-active')

timeoutTicker.stop()
Expand All @@ -155,7 +155,9 @@ def main():

if __name__ == "__main__":
try:
main()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
TestFail("Exception occurred when running tests.")

0 comments on commit 21a7d12

Please sign in to comment.