Skip to content

Commit 0c9de5d

Browse files
authored
Merge pull request #7 from draganbjedov/main
Added ITF Integration
2 parents fd42478 + d591de1 commit 0c9de5d

File tree

7 files changed

+166
-14
lines changed

7 files changed

+166
-14
lines changed

qnx_qemu/.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
22
common --registry=https://bcr.bazel.build
33

4+
build:x86_64-qnx --noexperimental_merged_skyframe_analysis_execution
5+
build:x86_64-qnx --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
6+
build:x86_64-qnx --incompatible_enable_cc_toolchain_resolution
47
build:x86_64-qnx --incompatible_strict_action_env
58
build:x86_64-qnx --platforms=@score_toolchains_qnx//platforms:x86_64-qnx
69
build:x86_64-qnx --sandbox_writable_path=/var/tmp
10+
11+
build:qemu-integration --config=x86_64-qnx
12+
build:qemu-integration --run_under=@score_itf//scripts:run_under_qemu
13+
build:qemu-integration --test_arg="--qemu"
14+
build:qemu-integration --test_arg="--os=qnx"

qnx_qemu/BUILD

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
13-
13+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
14+
load("@score_itf//:defs.bzl", "py_itf_test")
1415

1516

1617
sh_binary(
@@ -49,7 +50,7 @@ sh_binary(
4950
"$(location @toolchains_qnx_sdp//:host_dir)",
5051
"$(location //build:init)",
5152
"--timeout=90",
52-
"--ssh-port=2222",
53+
"--ssh-port=2222",
5354
"--boot-wait=15",
5455
],
5556
data = [
@@ -66,7 +67,7 @@ sh_binary(
6667
"$(location @toolchains_qnx_sdp//:host_dir)",
6768
"$(location //build:init)",
6869
"--timeout=90",
69-
"--ssh-port=2222",
70+
"--ssh-port=2222",
7071
"--boot-wait=15",
7172
],
7273
data = [
@@ -75,3 +76,22 @@ sh_binary(
7576
"@toolchains_qnx_sdp//:host_dir",
7677
],
7778
)
79+
80+
py_itf_test(
81+
name = "test_ssh_qemu",
82+
srcs = [
83+
"test/itf/test_ssh.py",
84+
],
85+
args = [
86+
"--target_config=$(location target_config.json)",
87+
"--ecu=s_core_ecu_qemu",
88+
"--qemu_image=$(location //build:init)",
89+
],
90+
plugins = [
91+
"itf.plugins.base.base_plugin",
92+
],
93+
data = [
94+
"//build:init",
95+
"target_config.json",
96+
],
97+
)

qnx_qemu/MODULE.bazel

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,59 @@ use_repo(toolchains_qnx, "toolchains_qnx_qcc")
3030
use_repo(toolchains_qnx, "toolchains_qnx_ifs")
3131

3232
register_toolchains("@toolchains_qnx_qcc//:qcc_x86_64")
33-
3433
register_toolchains("@toolchains_qnx_ifs//:ifs_x86_64")
34+
35+
###############################################################################
36+
#
37+
# Shell dependency
38+
#
39+
###############################################################################
40+
bazel_dep(name = "rules_shell", version = "0.6.0")
41+
42+
###############################################################################
43+
#
44+
# Python version
45+
#
46+
###############################################################################
47+
bazel_dep(name = "rules_python", version = "1.0.0")
48+
49+
PYTHON_VERSION = "3.12"
50+
51+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
52+
python.toolchain(
53+
configure_coverage_tool = True,
54+
is_default = True,
55+
python_version = PYTHON_VERSION,
56+
)
57+
use_repo(python)
58+
59+
###############################################################################
60+
#
61+
# LLVM Toolchains
62+
#
63+
###############################################################################
64+
bazel_dep(name = "toolchains_llvm", version = "1.2.0")
65+
66+
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
67+
llvm.toolchain(
68+
cxx_standard = {"": "c++17"},
69+
llvm_version = "19.1.0",
70+
)
71+
use_repo(llvm, "llvm_toolchain")
72+
use_repo(llvm, "llvm_toolchain_llvm")
73+
74+
register_toolchains("@llvm_toolchain//:all")
75+
76+
###############################################################################
77+
#
78+
# C++ rules
79+
#
80+
###############################################################################
81+
bazel_dep(name = "rules_cc", version = "0.1.1")
82+
83+
###############################################################################
84+
#
85+
# ITF dependency
86+
#
87+
###############################################################################
88+
bazel_dep(name = "score_itf", version = "0.1.0")

qnx_qemu/README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ qnx_qemu/
8383
│ ├── run_qemu.sh # QEMU launcher with bridge networking
8484
│ ├── run_qemu_portforward.sh # QEMU launcher with port forwarding
8585
│ └── qnx_wireshark.sh # Wireshark integration for network analysis
86-
86+
8787
└── test/ # Testing framework
8888
├── test_qnx_qemu_bridge.sh # Bridge networking integration tests
8989
└── test_qnx_qemu_portforward.sh # Port forwarding integration tests
@@ -128,7 +128,17 @@ bazel run --config=x86_64-qnx //:test_qemu_bridge
128128

129129
# Run integration tests for port forwarding
130130
bazel run --config=x86_64-qnx //:test_qemu_portforward
131+
132+
# Run ITF tests for ssh
133+
bazel test --config=qemu-integration //:test_ssh_qemu --test_output=streamed
134+
```
135+
136+
In order to provide credentials for qnx.com pass to bazel command:
137+
```bash
138+
--credential_helper=*.qnx.com=<path_to_toolchains-qnx>/tools/qnx_credential_helper.py
131139
```
140+
See more in [toolchains_qnx README](https://github.com/eclipse-score/toolchains_qnx?tab=readme-ov-file#using-pre-packaged-qnx-80-sdp).
141+
132142

133143
## Running the System
134144

@@ -201,7 +211,7 @@ qemu-system-x86_64 \
201211

202212
- **`-smp 2`** - Enable 2 CPU cores for SMP support
203213
- **`--enable-kvm`** - Use hardware virtualization for better performance
204-
- **`-cpu Cascadelake-Server-v5`** - Emulate modern Intel CPU features for older Ubuntu Versions change that to -cpu host in case of errors
214+
- **`-cpu Cascadelake-Server-v5`** - Emulate modern Intel CPU features for older Ubuntu versions change that to `-cpu host` in case of errors
205215
- **`-m 1G`** - Allocate 1GB of RAM
206216
- **`-nographic`** - Disable graphical display (console-only)
207217
- **`-netdev bridge`** - Connect to host bridge network for direct IP access
@@ -236,7 +246,7 @@ To modify the default IP address, edit the network configuration:
236246
vim configs/network_setup.sh
237247
```
238248

239-
2. **Eample on modify the IP configuration line**:
249+
2. **Example on modify the IP configuration line**:
240250

241251
```bash
242252
# Change this line to your desired IP
@@ -279,11 +289,16 @@ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
279289
```
280290

281291
In case of failed to parse default acl file /etc/qemu/bridge.conf'
282-
1. Check acl of /etc/qemu/bridge.conf
292+
1. Check acl of `/etc/qemu/bridge.conf`
283293
2. If file does not exist; create that file and add the following line in it
284-
allow virbr0
294+
`allow virbr0`
285295
3. Run qemu with Sudo as debug option in case of failure with acl
286296

297+
In case of error "Operation not permitted" for `qemu-bridge-helper` run
298+
```bash
299+
sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper
300+
```
301+
287302
## User Accounts and Access
288303

289304
### Available Users

qnx_qemu/configs/network_setup_dhcp.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,22 @@ MAX_RETRIES=10 # 10 retries * 3 seconds = 30 seconds tot
4242
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
4343
# Get current IP address for vtnet0
4444
IP_ADDR=$(ifconfig vtnet0 | grep 'inet ' | awk '{print $2}')
45-
45+
4646
if [ -n "$IP_ADDR" ] && [ "$IP_ADDR" != "0.0.0.0" ]; then
4747
echo "---> DHCP successful! Acquired IP"
4848
# Get additional network info
4949
NETMASK=$(ifconfig vtnet0 | grep 'inet ' | awk '{print $4}')
5050
echo "---> Network configuration:"
51-
51+
5252
# Save basic DHCP status
5353
echo "DHCP_SUCCESS" > /tmp_ram/dhcp_status
5454
IP_ADDR=$(ifconfig vtnet0 | grep 'inet ' | awk '{print $2}')
55+
echo "IP address set to: $IP_ADDR"
5556
echo "IP: $IP_ADDR" >> /tmp_ram/dhcp_status
5657
echo "Date: $(date)" >> /tmp_ram/dhcp_status
5758
break
5859
fi
59-
60+
6061
echo "---> Still waiting for DHCP lease... (attempt $((RETRY_COUNT + 1))/$MAX_RETRIES)"
6162
sleep 3
6263
RETRY_COUNT=$((RETRY_COUNT + 1))
@@ -70,14 +71,15 @@ if [ -z "$IP_ADDR" ] || [ "$IP_ADDR" = "0.0.0.0" ]; then
7071
if kill -0 $DHCP_PID 2>/dev/null; then
7172
kill $DHCP_PID 2>/dev/null
7273
fi
73-
74+
7475
# Configure static IP as fallback
7576
echo "---> Configuring static IP fallback: 192.168.122.100"
7677
ifconfig vtnet0 192.168.122.100 netmask 255.255.255.0
7778
route add default 192.168.122.1 # Add default gateway
78-
79+
7980
# Save fallback status
8081
echo "DHCP_FAILED_STATIC_FALLBACK" > /tmp_ram/dhcp_status
82+
echo "IP address set to: 192.168.122.100"
8183
echo "IP: 192.168.122.100" >> /tmp_ram/dhcp_status
8284
echo "Date: $(date)" >> /tmp_ram/dhcp_status
8385
else

qnx_qemu/target_config.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"S_CORE_ECU_QEMU": {
3+
"performance_processor": {
4+
"name": "S_CORE_ECU_QEMU_PP",
5+
"ip_address": "169.254.158.190",
6+
"ext_ip_address": "169.254.158.190",
7+
"ssh_port": 22,
8+
"diagnostic_ip_address": "169.254.158.190",
9+
"diagnostic_address": "0x91",
10+
"serial_device": "",
11+
"network_interfaces": [],
12+
"ecu_name": "s_core_ecu_qemu_pp",
13+
"data_router_config": {
14+
"vlan_address": "127.0.0.1",
15+
"multicast_addresses": []
16+
},
17+
"qemu_num_cores": 2,
18+
"qemu_ram_size": "1G"
19+
},
20+
"safety_processor": {
21+
"name": "S_CORE_ECU_QEMU_SC",
22+
"ip_address": "169.254.158.190",
23+
"diagnostic_ip_address": "169.254.158.190",
24+
"diagnostic_address": "0x90",
25+
"serial_device": "",
26+
"use_doip": true
27+
},
28+
"other_processors": {}
29+
}
30+
}

qnx_qemu/test/itf/test_ssh.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
from itf.plugins.com.ssh import execute_command
14+
15+
16+
def test_ssh_with_default_user(target_fixture):
17+
with target_fixture.sut.ssh() as ssh:
18+
execute_command(ssh, "echo 'Username:' $USER && uname -a")
19+
20+
21+
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")

0 commit comments

Comments
 (0)