From 05d4f951a5b88c1ea056166266dde081c22e861c Mon Sep 17 00:00:00 2001 From: Dragan Bjedov Date: Wed, 6 Aug 2025 15:57:11 +0200 Subject: [PATCH 1/5] Bazel setup for ITF plugins --- BUILD | 3 ++ itf/plugins/base/BUILD | 28 +++++++++++++++ itf/plugins/base/os/BUILD | 25 ++++++++++++++ itf/plugins/base/os/__init__.py | 12 +++++++ itf/plugins/base/target/BUILD | 30 +++++++++++++++++ itf/plugins/base/target/config/BUILD | 25 ++++++++++++++ itf/plugins/base/target/processors/BUILD | 30 +++++++++++++++++ itf/plugins/base/test/BUILD | 21 ++++++++++++ itf/plugins/com/BUILD | 43 ++++++++++++++++++++++++ 9 files changed, 217 insertions(+) create mode 100644 itf/plugins/base/BUILD create mode 100644 itf/plugins/base/os/BUILD create mode 100644 itf/plugins/base/os/__init__.py create mode 100644 itf/plugins/base/target/BUILD create mode 100644 itf/plugins/base/target/config/BUILD create mode 100644 itf/plugins/base/target/processors/BUILD create mode 100644 itf/plugins/base/test/BUILD create mode 100644 itf/plugins/com/BUILD diff --git a/BUILD b/BUILD index 7a34947..5bb2a43 100644 --- a/BUILD +++ b/BUILD @@ -32,7 +32,10 @@ py_library( imports = ["."], visibility = ["//visibility:public"], deps = [ + "//itf/plugins/base", + "//itf/plugins/com", "//itf/plugins/dlt", + "//itf/plugins/utils", ], ) diff --git a/itf/plugins/base/BUILD b/itf/plugins/base/BUILD new file mode 100644 index 0000000..49ae2aa --- /dev/null +++ b/itf/plugins/base/BUILD @@ -0,0 +1,28 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "base", + srcs = [ + "__init__.py", + "base_plugin.py", + "constants.py", + ], + imports = ["."], + visibility = ["//visibility:public"], + deps = [ + "//itf/plugins/base/os", + "//itf/plugins/base/target", + "//itf/plugins/base/test", + "//itf/plugins/utils", + ], +) diff --git a/itf/plugins/base/os/BUILD b/itf/plugins/base/os/BUILD new file mode 100644 index 0000000..2e92899 --- /dev/null +++ b/itf/plugins/base/os/BUILD @@ -0,0 +1,25 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "os", + srcs = [ + "__init__.py", + "config.py", + "operating_system.py", + ], + imports = ["."], + visibility = ["//visibility:public"], + deps = [ + "//itf/plugins/utils", + ], +) diff --git a/itf/plugins/base/os/__init__.py b/itf/plugins/base/os/__init__.py new file mode 100644 index 0000000..6bdeed2 --- /dev/null +++ b/itf/plugins/base/os/__init__.py @@ -0,0 +1,12 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* diff --git a/itf/plugins/base/target/BUILD b/itf/plugins/base/target/BUILD new file mode 100644 index 0000000..aedac15 --- /dev/null +++ b/itf/plugins/base/target/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "target", + srcs = [ + "__init__.py", + "base_target.py", + "hw_target.py", + "qemu_target.py", + "qvp_target.py", + ], + imports = ["."], + visibility = ["//visibility:public"], + deps = [ + "//itf/plugins/base/os", + "//itf/plugins/base/target/config", + "//itf/plugins/base/target/processors", + "//itf/plugins/dlt", + ], +) diff --git a/itf/plugins/base/target/config/BUILD b/itf/plugins/base/target/config/BUILD new file mode 100644 index 0000000..c3b704e --- /dev/null +++ b/itf/plugins/base/target/config/BUILD @@ -0,0 +1,25 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "config", + srcs = [ + "__init__.py", + "base_processor.py", + "config.py", + "ecu.py", + "performance_processor.py", + "safety_processor.py", + ], + imports = ["."], + visibility = ["//visibility:public"], +) diff --git a/itf/plugins/base/target/processors/BUILD b/itf/plugins/base/target/processors/BUILD new file mode 100644 index 0000000..5a0d02e --- /dev/null +++ b/itf/plugins/base/target/processors/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "processors", + srcs = [ + "__init__.py", + "qemu_processor.py", + "qvp_processor.py", + "safety_processor.py", + "target_processor.py", + ], + imports = ["."], + visibility = ["//visibility:public"], + deps = [ + "//itf/plugins/base/os", + "//itf/plugins/base/target/config", + "//itf/plugins/com:ping", + "//itf/plugins/com:ssh", + ], +) diff --git a/itf/plugins/base/test/BUILD b/itf/plugins/base/test/BUILD new file mode 100644 index 0000000..63087be --- /dev/null +++ b/itf/plugins/base/test/BUILD @@ -0,0 +1,21 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "test", + srcs = [ + "__init__.py", + "utils.py", + ], + imports = ["."], + visibility = ["//visibility:public"], +) diff --git a/itf/plugins/com/BUILD b/itf/plugins/com/BUILD new file mode 100644 index 0000000..5ebd8b1 --- /dev/null +++ b/itf/plugins/com/BUILD @@ -0,0 +1,43 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +py_library( + name = "ssh", + srcs = [ + "__init__.py", + "sftp.py", + "ssh.py", + "ssh_command.py", + ], + imports = ["."], + visibility = ["//visibility:public"], +) + +py_library( + name = "ping", + srcs = [ + "__init__.py", + "ping.py", + ], + imports = ["."], + visibility = ["//visibility:public"], +) + +py_library( + name = "com", + imports = ["."], + visibility = ["//visibility:public"], + deps = [ + ":ping", + ":ssh", + ], +) From 64dbc9ef8e601381a02a62d1cd0293a7360ecdb2 Mon Sep 17 00:00:00 2001 From: Dragan Bjedov Date: Wed, 6 Aug 2025 15:59:57 +0200 Subject: [PATCH 2/5] Added target configuration for S-CORE QNX Qemu --- BUILD | 3 +++ config/BUILD | 19 +++++++++++++++++ config/target_config.json | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 config/BUILD create mode 100644 config/target_config.json diff --git a/BUILD b/BUILD index 5bb2a43..27a939c 100644 --- a/BUILD +++ b/BUILD @@ -29,6 +29,9 @@ py_library( srcs = [ "//itf/plugins:docker", ], + data = [ + "//config", + ], imports = ["."], visibility = ["//visibility:public"], deps = [ diff --git a/config/BUILD b/config/BUILD new file mode 100644 index 0000000..2020dae --- /dev/null +++ b/config/BUILD @@ -0,0 +1,19 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +filegroup( + name = "config", + srcs = [ + "target_config.json", + ], + visibility = ["//visibility:public"], +) diff --git a/config/target_config.json b/config/target_config.json new file mode 100644 index 0000000..1bdcdad --- /dev/null +++ b/config/target_config.json @@ -0,0 +1,44 @@ +{ + "S_CORE_ECU_QEMU_BRIDGE_NETWORK": { + "performance_processor": { + "name": "S_CORE_ECU_QEMU_BRIDGE_NETWORK_PP", + "ip_address": "192.168.122.77", + "ext_ip_address": "192.168.122.77", + "diagnostic_ip_address": "192.168.122.77", + "diagnostic_address": "0x91", + "serial_device": "", + "network_interfaces": [], + "ecu_name": "s_core_ecu_qemu_bridge_network_pp" + }, + "safety_processor": { + "name": "S_CORE_ECU_QEMU_BRIDGE_NETWORK_SC", + "ip_address": "192.168.122.77", + "diagnostic_ip_address": "192.168.122.77", + "diagnostic_address": "0x90", + "serial_device": "", + "use_doip": true + }, + "other_processors": {} + }, + "S_CORE_ECU_QEMU_PORT_FORWARDING": { + "performance_processor": { + "name": "S_CORE_ECU_QEMU_PORT_FORWARDING_PP", + "ip_address": "localhost", + "ext_ip_address": "localhost", + "diagnostic_ip_address": "localhost", + "diagnostic_address": "0x91", + "serial_device": "", + "network_interfaces": [], + "ecu_name": "s_core_ecu_qemu_port_forwarding_pp" + }, + "safety_processor": { + "name": "CORE_ECU_QEMU_PORT_FORWARDING_SC", + "ip_address": "localhost", + "diagnostic_ip_address": "localhost", + "diagnostic_address": "0x90", + "serial_device": "", + "use_doip": true + }, + "other_processors": {} + } +} From 51b3db795c950b6c2d2651e77f6a6552c334a1a6 Mon Sep 17 00:00:00 2001 From: Dragan Bjedov Date: Wed, 6 Aug 2025 16:01:09 +0200 Subject: [PATCH 3/5] Added hard-coded data router configuration --- itf/plugins/base/target/qemu_target.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/itf/plugins/base/target/qemu_target.py b/itf/plugins/base/target/qemu_target.py index 5c50fd5..df96108 100644 --- a/itf/plugins/base/target/qemu_target.py +++ b/itf/plugins/base/target/qemu_target.py @@ -42,6 +42,10 @@ def qemu_target(target_config, test_config): target_ip=target_config.ip_address, protocol=Protocol.UDP, binary_path="./itf/plugins/dlt/dlt-receive", + drconfig={ # TODO make this configurable + "vlan_addr": "127.0.0.1", + "mcast_addrs": [], + }, ): target = TargetQemu(test_config.ecu, test_config.os) target.register_processors(qemu_process) From e88aa3e1bf1a53c0bc7db67b31cb5fad49228120 Mon Sep 17 00:00:00 2001 From: Dragan Bjedov Date: Wed, 6 Aug 2025 16:01:56 +0200 Subject: [PATCH 4/5] Extended SSH to allow overwrite default port --- .../base/target/processors/target_processor.py | 3 ++- itf/plugins/com/ssh.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/itf/plugins/base/target/processors/target_processor.py b/itf/plugins/base/target/processors/target_processor.py index a63c4a2..2bc8060 100644 --- a/itf/plugins/base/target/processors/target_processor.py +++ b/itf/plugins/base/target/processors/target_processor.py @@ -83,10 +83,11 @@ def ext_ip_address(self): def uses_doip(self): return self.__config.use_doip - def ssh(self, timeout=15, n_retries=5, retry_interval=1, pkey_path="", password="", ext_ip=False): + def ssh(self, timeout=15, port=22, n_retries=5, retry_interval=1, pkey_path="", password="", ext_ip=False): ssh_ip = self.ext_ip_address if ext_ip else self.ip_address return Ssh( target_ip=ssh_ip, + port=port, timeout=timeout, n_retries=n_retries, retry_interval=retry_interval, diff --git a/itf/plugins/com/ssh.py b/itf/plugins/com/ssh.py index 5a4d2bb..62f2ab1 100644 --- a/itf/plugins/com/ssh.py +++ b/itf/plugins/com/ssh.py @@ -24,18 +24,20 @@ class Ssh: def __init__( self, target_ip, + port=22, timeout=15, n_retries=5, retry_interval=1, - pkey_path="platform/aas/tools/itf/itf/ssh_keys/id_mPAD", - password="", + pkey_path=None, + password=None, ): self._target_ip = target_ip + self._port = port self._timeout = timeout self._retries = n_retries self._retry_interval = retry_interval self._ssh = None - self._pkey = paramiko.ECDSAKey.from_private_key_file(pkey_path) + self._pkey = paramiko.ECDSAKey.from_private_key_file(pkey_path) if pkey_path else None self._password = password def __enter__(self): @@ -45,7 +47,8 @@ def __enter__(self): for _ in range(self._retries): try: self._ssh.connect( - self._target_ip, + hostname=self._target_ip, + port=self._port, timeout=self._timeout, username="root", password=self._password, @@ -240,8 +243,7 @@ def execute_command_output(ssh_connection, cmd, timeout=30, max_exec_time=180, l def execute_command(ssh_connection, cmd, timeout=30, max_exec_time=180, logger_in=None, verbose=True): - logger.debug(f"Executing command.") - logger.debug(f"cmd: {cmd}") + logger.debug(f"Executing command: {cmd}") logger.debug(f"timeout: {timeout}; max_exec_time: {max_exec_time}; logger_in: {logger_in}; verbose: {verbose};") exit_code, stdout_lines, stderr_lines = execute_command_output( ssh_connection, cmd, timeout, max_exec_time, logger_in, verbose From bb95ffa3100d11e9ebf6c40490a7e57739a8fc76 Mon Sep 17 00:00:00 2001 From: Dragan Bjedov Date: Wed, 6 Aug 2025 16:03:07 +0200 Subject: [PATCH 5/5] Added SSH tests for S-CORE QNX Qemu --- README.md | 24 ++++++++++++++++++++++ test/BUILD | 34 ++++++++++++++++++++++++++++++++ test/test_ssh_bridge_network.py | 18 +++++++++++++++++ test/test_ssh_port_forwarding.py | 18 +++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 test/test_ssh_bridge_network.py create mode 100644 test/test_ssh_port_forwarding.py diff --git a/README.md b/README.md index 236211c..42d32a4 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,27 @@ Specify additionally: - ```--test_arg="-s"``` to get stdout/err from pytest - ```--test_output=all``` to get stdout/err from bazel - ```--nocache_test_results``` not to cache test runs + +### Running test against QNX Qemu +ITF can be run against running Qemu defined here https://github.com/eclipse-score/reference_integration/tree/main/qnx_qemu. +Steps: +* Checkout repository https://github.com/eclipse-score/reference_integration +* Run ssh test with qemu started with bridge network + * Start Qemu with bridge network from `reference_integration/qnx_qemu` folder: + ``` + $ bazel run --config=x86_64-qnx //:run_qemu + ``` + * Run ITF test from `itf` folder: + ``` + $ bazel test //:test_ssh_bridge_network + ``` + * Note: If it fails check IP Address of started Qemu with `ifconfig` and update IP addresses in `itf/config/target_config.json` for `S_CORE_ECU_QEMU_BRIDGE_NETWORK` +* Run ssh test with qemu started with port forwarding + * Start Qemu with bridge network from `reference_integration/qnx_qemu` folder: + ``` + $ bazel run --config=x86_64-qnx //:run_qemu_portforward + ``` + * Run ITF test from `itf` folder: + ``` + $ bazel test //:test_ssh_port_forwarding + ``` diff --git a/test/BUILD b/test/BUILD index 6bb205c..ed1d216 100644 --- a/test/BUILD +++ b/test/BUILD @@ -39,3 +39,37 @@ py_itf_test( "test_dlt.py", ], ) + +py_itf_test( + name = "test_ssh_bridge_network", + srcs = [ + "test_ssh_bridge_network.py", + ], + args = [ + "--target_config=config/target_config.json", + "--ecu=s_core_ecu_qemu_bridge_network", + "--os=qnx", + "--qemu", + ], + plugins = [ + "itf.plugins.base.base_plugin", + ], + tags = ["manual"], +) + +py_itf_test( + name = "test_ssh_port_forwarding", + srcs = [ + "test_ssh_port_forwarding.py", + ], + args = [ + "--target_config=config/target_config.json", + "--ecu=s_core_ecu_qemu_port_forwarding", + "--os=qnx", + "--qemu", + ], + plugins = [ + "itf.plugins.base.base_plugin", + ], + tags = ["manual"], +) diff --git a/test/test_ssh_bridge_network.py b/test/test_ssh_bridge_network.py new file mode 100644 index 0000000..8720229 --- /dev/null +++ b/test/test_ssh_bridge_network.py @@ -0,0 +1,18 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +from itf.plugins.com.ssh import execute_command + + +def test_ssh(target_fixture): + with target_fixture.sut.ssh() as ssh: + execute_command(ssh, "uname -a && ifconfig") diff --git a/test/test_ssh_port_forwarding.py b/test/test_ssh_port_forwarding.py new file mode 100644 index 0000000..a9f6dab --- /dev/null +++ b/test/test_ssh_port_forwarding.py @@ -0,0 +1,18 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +from itf.plugins.com.ssh import execute_command + + +def test_ssh(target_fixture): + with target_fixture.sut.ssh(port=2222) as ssh: + execute_command(ssh, "uname -a && ifconfig")