Skip to content

Commit 3573428

Browse files
authored
Add assertions to tests (#8)
Refine with checking the output of commands
1 parent 0c9de5d commit 3573428

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

qnx_qemu/test/itf/test_ssh.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,37 @@
1010
#
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
13-
from itf.plugins.com.ssh import execute_command
13+
from itf.plugins.com.ping import ping
14+
from itf.plugins.com.ssh import execute_command_output
1415

1516

1617
def test_ssh_with_default_user(target_fixture):
1718
with target_fixture.sut.ssh() as ssh:
18-
execute_command(ssh, "echo 'Username:' $USER && uname -a")
19+
exit_code, stdout, stderr = execute_command_output(
20+
ssh, "echo 'Username:' $USER && uname -a"
21+
)
22+
assert exit_code == 0, "SSH command failed"
23+
assert "Username: root" in stdout[0], "Expected username not found in output"
24+
assert "QNX Qnx_S-core 8.0.0" in stdout[1], (
25+
"Expected QNX kernel information not found in output"
26+
)
27+
assert stderr == [], "Expected no error output"
1928

2029

2130
def test_ssh_with_qnx_user(target_fixture):
22-
with target_fixture.sut.ssh(username="qnxuser") as ssh:
23-
execute_command(ssh, "echo 'Username:' $USER && uname -a")
31+
user = "qnxuser"
32+
with target_fixture.sut.ssh(username=user) as ssh:
33+
exit_code, stdout, stderr = execute_command_output(
34+
ssh, "echo 'Username:' $USER && uname -a"
35+
)
36+
assert exit_code == 0, "SSH command failed"
37+
assert f"Username: {user}" in stdout[0], "Expected username not found in output"
38+
assert "QNX Qnx_S-core 8.0.0" in stdout[1], (
39+
"Expected QNX kernel information not found in output"
40+
)
41+
assert stderr == [], "Expected no error output"
42+
43+
44+
def test_ping_ok(target_fixture):
45+
is_reachable = ping(target_fixture.sut.ip_address)
46+
assert is_reachable, "QNX Target is not reachable via ping"

0 commit comments

Comments
 (0)