Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Dec 13, 2022
1 parent f0bcec3 commit f0a0e27
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
11 changes: 4 additions & 7 deletions scripts/tests/java/commissioning_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ def TestCmdOnnetworkLong(self, nodeid, setuppin, discriminator, timeout):
def RunTest(self):
logging.info("Testing onnetwork-long pairing")
if self.command_name == 'onnetwork-long':
java_exit_code = self.TestCmdOnnetworkLong(self.nodeid, self.setup_payload, self.discriminator, self.timeout)
if java_exit_code != 0:
logging.error("Testing onnetwork-long pairing failed with error %r" % java_exit_code)
return java_exit_code

# Testing complete without errors
return 0
code = self.TestCmdOnnetworkLong(self.nodeid, self.setup_payload, self.discriminator, self.timeout)
if code != 0:
logging.error(f"Testing onnetwork-long pairing failed with error {code}")
raise Exception("Failed to pair onnetwork device")
11 changes: 4 additions & 7 deletions scripts/tests/java/discover_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ def RunTest(self):
logging.info("Testing discovering commissionables devices")

if self.command_name == 'commissionables':
java_exit_code = self.TestCmdCommissionables()
if java_exit_code != 0:
logging.error("Testing command commissionables failed with error %r" % java_exit_code)
return java_exit_code

# Testing complete without errors
return 0
code = self.TestCmdCommissionables()
if code != 0:
logging.error(f"Testing command commissionables failed with error {code}")
raise Exception("Failed to discover commissionables devices")
23 changes: 10 additions & 13 deletions scripts/tests/run_java_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ def main(app: str, app_args: str, tool_path: str, tool_cluster: str, tool_args:
logging.info("Testing pairing cluster")

test = CommissioningTest(log_cooking_threads, log_queue, command, tool_args)
controller_exit_code = test.RunTest()

if controller_exit_code != 0:
logging.error("Test script exited with error %r" % test_script_exit_code)
try:
test.RunTest()
except Exception:
sys.exit(1)
elif tool_cluster == 'discover':
logging.info("Testing discover cluster")

test = DiscoverTest(log_cooking_threads, log_queue, command, tool_args)
controller_exit_code = test.RunTest()

if controller_exit_code != 0:
logging.error("Test script exited with error %r" % test_script_exit_code)
try:
test.RunTest()
except Exception:
sys.exit(1)

app_exit_code = 0
if app_process:
Expand All @@ -112,11 +112,8 @@ def main(app: str, app_args: str, tool_path: str, tool_cluster: str, tool_args:
for thread in log_cooking_threads:
thread.join()

if controller_exit_code != 0:
sys.exit(controller_exit_code)
else:
# We expect both app and controller should exit with 0
sys.exit(app_exit_code)
# We expect app should exit with 0
sys.exit(app_exit_code)


if __name__ == '__main__':
Expand Down

0 comments on commit f0a0e27

Please sign in to comment.