Skip to content

Commit 1073116

Browse files
ATmobicapull[bot]
authored andcommitted
[OIS] Integration test suite improvements (#27516)
Fix handling none arguments commands. Add common functions to parsing help response and log messages from response. Increasing the default timeout value of the wait_for_output function to 30s. Update shell test. Signed-off-by: ATmobica <artur.tynecki@arm.com>
1 parent 0fb3536 commit 1073116

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

src/test_driver/openiotsdk/integration-tests/common/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, name: Optional[str] = None):
3838
else:
3939
self.name = name
4040

41-
def send(self, command, expected_output=None, wait_before_read=None, wait_for_response=10, assert_output=True):
41+
def send(self, command, expected_output=None, wait_before_read=None, wait_for_response=30, assert_output=True):
4242
"""
4343
Send command for client
4444
:param command: Command
@@ -73,7 +73,7 @@ def flush(self, timeout: float = 0) -> [str]:
7373
except queue.Empty:
7474
return lines
7575

76-
def wait_for_output(self, search: str, timeout: float = 10, assert_timeout: bool = True, verbose: bool = False) -> [str]:
76+
def wait_for_output(self, search: str, timeout: float = 30, assert_timeout: bool = True, verbose: bool = False) -> [str]:
7777
"""
7878
Wait for expected output response
7979
:param search: Expected response string

src/test_driver/openiotsdk/integration-tests/common/utils.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_setup_payload(device):
3737
:param device: serial device instance
3838
:return: setup payload or None
3939
"""
40-
ret = device.wait_for_output("SetupQRCode", timeout=30)
40+
ret = device.wait_for_output("SetupQRCode")
4141
if ret is None or len(ret) < 2:
4242
return None
4343

@@ -139,7 +139,10 @@ def send_zcl_command(devCtrl, cluster: str, command: str, nodeId: int, endpoint:
139139

140140
clusterObj = getattr(GeneratedObjects, cluster)
141141
commandObj = getattr(clusterObj.Commands, command)
142-
req = commandObj(**args)
142+
if args is not None:
143+
req = commandObj(**args)
144+
else:
145+
req = commandObj()
143146

144147
res = asyncio.run(devCtrl.SendCommand(int(nodeId), int(endpoint), req, timedRequestTimeoutMs=requestTimeoutMs))
145148

@@ -232,3 +235,21 @@ def read_zcl_attribute(devCtrl, cluster: str, attribute: str, nodeId: int, endpo
232235
err = -1
233236

234237
return (err, res)
238+
239+
240+
def get_shell_commands_from_help_response(response):
241+
"""
242+
Parse shell help command response to get the list of supported commands
243+
:param response: help command response
244+
:return: list of supported commands
245+
"""
246+
return [line.split()[0].strip() for line in response]
247+
248+
249+
def get_log_messages_from_response(response):
250+
"""
251+
Parse shell help command response to get the list of supported commands
252+
:param response: device response
253+
:return: raw log messages
254+
"""
255+
return [' '.join(line.split()[2:]) for line in response]

src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def controllerConfig(request):
4848
def test_smoke_test(device):
4949
ret = device.wait_for_output("Open IoT SDK lock-app example application start")
5050
assert ret is not None and len(ret) > 0
51-
ret = device.wait_for_output("Open IoT SDK lock-app example application run", timeout=30)
51+
ret = device.wait_for_output("Open IoT SDK lock-app example application run")
5252
assert ret is not None and len(ret) > 0
5353

5454

@@ -74,7 +74,7 @@ def test_commissioning(device, controller):
7474
assert nodeId is not None
7575
log.info("Device {} connected".format(commissionable_device.addresses[0]))
7676

77-
ret = device.wait_for_output("Commissioning completed successfully", timeout=30)
77+
ret = device.wait_for_output("Commissioning completed successfully")
7878
assert ret is not None and len(ret) > 0
7979

8080
assert disconnect_device(devCtrl, nodeId)
@@ -104,7 +104,7 @@ def test_lock_ctrl(device, controller):
104104
nodeId = connect_device(devCtrl, setupPayload, commissionable_device)
105105
assert nodeId is not None
106106

107-
ret = device.wait_for_output("Commissioning completed successfully", timeout=30)
107+
ret = device.wait_for_output("Commissioning completed successfully")
108108
assert ret is not None and len(ret) > 0
109109

110110
err, res = send_zcl_command(devCtrl, "DoorLock", "SetUser", nodeId, LOCK_CTRL_TEST_ENDPOINT_ID,

src/test_driver/openiotsdk/integration-tests/shell/test_app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import pytest
2323
from chip import exceptions
2424
from chip.setup_payload import SetupPayload
25+
from common.utils import get_shell_commands_from_help_response
2526
from packaging import version
2627

2728
log = logging.getLogger(__name__)
@@ -40,10 +41,6 @@ def binaryPath(request, rootDir):
4041
"echo", "log", "rand"]
4142

4243

43-
def get_shell_command(response):
44-
return [line.split()[0].strip() for line in response]
45-
46-
4744
def parse_config_response(response):
4845
config = {}
4946
for param in response:
@@ -100,7 +97,7 @@ def test_command_check(device):
10097
# Help
10198
ret = device.send(command="help", expected_output="Done")
10299
assert ret is not None and len(ret) > 1
103-
shell_commands = get_shell_command(ret[1:-1])
100+
shell_commands = get_shell_commands_from_help_response(ret[1:-1])
104101
assert set(SHELL_COMMAND_NAME) == set(shell_commands)
105102

106103
# Echo

src/test_driver/openiotsdk/integration-tests/unit-tests/test_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def binaryPath(request, rootDir):
3232

3333

3434
def test_unit_tests(device):
35-
ret = device.wait_for_output("Open IoT SDK unit-tests start", timeout=30)
35+
ret = device.wait_for_output("Open IoT SDK unit-tests start")
3636
assert ret is not None and len(ret) > 0
37-
ret = device.wait_for_output("Open IoT SDK unit-tests run", timeout=30)
37+
ret = device.wait_for_output("Open IoT SDK unit-tests run")
3838
assert ret is not None and len(ret) > 0
3939

4040
ret = device.wait_for_output("Test status:", 1200)

0 commit comments

Comments
 (0)