Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix
build:x86_64-qnx --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0
build:x86_64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_pc_nto_qnx800
build:x86_64-qnx --extra_toolchains=@score_qnx_x86_64_ifs_toolchain//:ifs-x86_64-qnx-sdp_8.0.0
test:x86_64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
test:x86_64-qnx --test_tag_filters=-skip_local # see https://github.com/eclipse-score/lifecycle/issues/272
test:x86_64-qnx --test_lang_filters=cc,rust
build:x86_64-qnx --define config=x86_64-qnx

build:unit-tests-x86_64-qnx --config=x86_64-qnx
Comment thread
danth marked this conversation as resolved.
test:unit-tests-x86_64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
test:unit-tests-x86_64-qnx --test_tag_filters=-skip_local # see https://github.com/eclipse-score/lifecycle/issues/272

# Target configuration for CPU:AArch64|OS:QNX build (do not use it in case of system toolchains!)
build:arm64-qnx --config=stub
Expand All @@ -98,10 +100,10 @@ build:arm64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix
build:arm64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0
build:arm64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_aarch64_unknown_nto_qnx800
build:arm64-qnx --extra_toolchains=@score_qnx_aarch64_ifs_toolchain//:ifs-aarch64-qnx-sdp_8.0.0
test:arm64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
test:arm64-qnx --test_tag_filters=-skip_local # see https://github.com/eclipse-score/lifecycle/issues/272
test:arm64-qnx --test_timeout=300
test:arm64-qnx --test_lang_filters=cc,rust

build:unit-tests-arm64-qnx --config=arm64-qnx
test:unit-tests-arm64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
test:unit-tests-arm64-qnx --test_tag_filters=-skip_local # see https://github.com/eclipse-score/lifecycle/issues/272


# Ferrocene Rust coverage config
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/qnx8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ jobs:
matrix:
include:
- bazel-config: x86_64-qnx
bazel-test-target: >-
//score/...
bazel-test-target: //examples/... //tests/...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to merge the unit tests and other tests into a single entry so that we utilize the cache more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now they need to be run with separate configs so that would have to be resolved first.

- bazel-config: unit-tests-x86_64-qnx
bazel-test-target: //score/...
- bazel-config: arm64-qnx
bazel-test-target: >-
//score/...
bazel-test-target: //examples/... //tests/...
- bazel-config: unit-tests-arm64-qnx
bazel-test-target: //score/...
extra-bazel-test-flags: "--test_timeout=120,600,1800,7200" # Increase test timeout due to QEMU emulation
uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@af347722c7ae3ed85518895c11268d96ac728f62
permissions:
Expand Down
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ compile_pip_requirements(
src = "requirements.in",
data = [
"//scripts/config_mapping:pip_requirements",
"//tests/integration:pip_requirements",
],
extra_args = [
"--no-annotate",
Expand Down
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ pip.parse(
use_repo(pip, "score_lifecycle_pip")

bazel_dep(name = "score_itf", version = "0.5.0", dev_dependency = True)
git_override(
module_name = "score_itf",
branch = "fix/qemu-pid",
remote = "https://github.com/etas-contrib/score_itf.git",
)

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci", dev_dependency = True)
oci.pull(
Expand Down
2 changes: 0 additions & 2 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ bazel build --config=x86_64-qnx //...
bazel build --config=arm64-qnx //...
```

Integration tests via [QEMU](https://www.qemu.org/):

```sh
bazel test --config=x86_64-qnx //tests/integration/...
```

Unit tests via [QEMU](https://www.qemu.org/):

```sh
bazel test --config=unit-tests-x86_64-qnx //score/...
```

A different flag is needed for unit tests because the emulation is configured
using `--run_under`, which applies to all targets, even those that should run
natively on the host.

**Linux**

```sh
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_verification/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_examples(target, setup_test, remote_test_dir):
_assert_not_running(target, "cpp_supervised_app")

_step("Stopping launch manager (SIGTERM)")
res, _ = target.execute(f"kill -15 -{lm_proc.pid()}")
res, _ = target.execute(f"kill -TERM {lm_proc.pid()}")
assert res == 0, "Failed to send SIGTERM to launch manager process group"
time.sleep(0.5)
assert not lm_proc.is_running(), "Launch manager did not stop after SIGTERM"
3 changes: 0 additions & 3 deletions requirements.in
Comment thread
danth marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Python dependencies for generating lifecycle configuration files
-r ./scripts/config_mapping/requirements.txt

-r ./tests/integration/requirements.txt

3 changes: 0 additions & 3 deletions requirements_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jsonschema==4.23.0 \
jsonschema-specifications==2023.12.1 \
--hash=sha256:48a76787b3e70f5ed53f1160d2b81f586e4ca6d1548c5de7085d1682674764cc \
--hash=sha256:87e4fdf3a94858b8a2ba2778d9ba57d8a9cafca7c7489c46ba0d30a8bc6a9c3c
junitparser==5.0.0 \
--hash=sha256:9e279f2214dc74b6a86b22db757abda2e8e66e819fe882dad5b392d57024cd26 \
--hash=sha256:f15e292877258d7c5755d672ce86f82c3622c7ea4c2f44f55de44ed7518484d3
packaging==26.0 \
--hash=sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4 \
--hash=sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529
Expand Down
20 changes: 0 additions & 20 deletions tests/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,3 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@score_lifecycle_pip//:requirements.bzl", "requirement")
load("@score_tooling//python_basics:defs.bzl", "score_virtualenv")

filegroup(
name = "pip_requirements",
srcs = ["requirements.txt"],
visibility = ["//:__pkg__"],
)

# Only pass packages that don't overlap with pip_tooling (which already
# provides: iniconfig, packaging, pluggy, pygments, pytest).
score_virtualenv(
name = "python_tc_venv",
reqs = [
requirement("junitparser"),
],
venv_name = ".python_tc_venv",
)
3 changes: 3 additions & 0 deletions tests/integration/process_fd_leak/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cc_binary(
"get_fds.hpp",
"native.cpp",
],
target_compatible_with = ["@platforms//os:linux"],
deps = [
"//tests/utils/test_helper",
"@googletest//:gtest_main",
Expand All @@ -34,6 +35,7 @@ cc_binary(
"get_fds.hpp",
"reporting.cpp",
],
target_compatible_with = ["@platforms//os:linux"],
deps = [
"//score/launch_manager:lifecycle_cc",
"//tests/utils/test_helper",
Expand All @@ -48,6 +50,7 @@ cc_binary(
"control_client.cpp",
"get_fds.hpp",
],
target_compatible_with = ["@platforms//os:linux"],
Comment thread
danth marked this conversation as resolved.
deps = [
"//score/launch_manager:control_cc",
"//score/launch_manager:lifecycle_cc",
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/requirements.txt

This file was deleted.

92 changes: 65 additions & 27 deletions tests/utils/bazel/integration.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,39 +69,77 @@ def integration_test(

pkg_tar(name = "environment", srcs = [":binaries", ":files"])

final_deps = kwargs.pop("deps", []) + all_requirements + [
"@score_tooling//python_basics/score_pytest:attribute_plugin",
"//tests/utils/testing_utils",
]
final_data = kwargs.pop("data", []) + [":environment"] + select({
"//config:x86_64-linux": [
"//tests/utils/environments/x86_64-linux",
],
"//config:x86_64-qnx": [
"//tests/utils/environments/x86_64-qnx:qemu_config.json",
"//tests/utils/environments/x86_64-qnx:qemu_image",
],
"//conditions:default": [],
})
final_args = kwargs.pop("args", []) + [
"--score-test-binary-path=$(locations :environment)",
"--score-test-remote-directory={}/tests/{}".format(install_prefix, name),
] + select({
"//config:x86_64-linux": [
"--docker-image-bootstrap=$(location //tests/utils/environments/x86_64-linux)",
"--docker-image=score_itf_examples:latest",
],
"//config:x86_64-qnx": [
"--qemu-config=$(location //tests/utils/environments/x86_64-qnx:qemu_config.json)",
"--qemu-image=$(location //tests/utils/environments/x86_64-qnx:qemu_image)",
],
"//config:host": [
"--local-dir=/tmp/score_itf_host/{}".format(name),
],
"//conditions:default": [],
})
final_plugins = ["//tests/utils/plugins:integration_plugin"] + select({
"//config:x86_64-linux": ["@score_itf//score/itf/plugins:docker_plugin"],
"//config:x86_64-qnx": ["@score_itf//score/itf/plugins:qemu_plugin"],
"//config:host": ["//tests/utils/plugins:localhost_plugin"],
"//conditions:default": [],
})

# The QEMU plugin uses a hardcoded port so we can only run one test at a time.
# See https://github.com/eclipse-score/itf/issues/125.
# However we should not unnecessarily slow down Docker tests by adding the
# exclusive tag all the time. Bazel does not allow select() to be used in tags.
# So we have to create two separate targets and skip whichever is not needed.

py_itf_test(
name = name,
srcs = srcs,
tags = kwargs.pop("tags", []) + [
tags = [
"integration",
"no-asan", # The test container does not ship the sanitizer runtime; daemon fails to start.
],
deps = kwargs.pop("deps", []) + all_requirements + [
"@score_tooling//python_basics/score_pytest:attribute_plugin",
"//tests/utils/testing_utils",
deps = final_deps,
data = final_data,
args = final_args,
plugins = final_plugins,
target_compatible_with = ["@platforms//os:linux"],
**kwargs
)

py_itf_test(
name = "{}_QNX".format(name),
srcs = srcs,
tags = [
"exclusive", # The QEMU plugin uses a hardcoded port so we can only run one test at a time.
"integration",
"no-asan", # The test container does not ship the sanitizer runtime; daemon fails to start.
],
data = kwargs.pop("data", []) + [":environment"] + select({
"//config:host": [],
"//conditions:default": ["//tests/utils/environments:test_environment"],
}),
args = kwargs.pop("args", []) + [
"--score-test-binary-path=$(locations :environment)",
"--score-test-remote-directory={}/tests/{}".format(install_prefix, name),
] + select({
"//config:x86_64-linux": [
"--docker-image-bootstrap=$(location //tests/utils/environments:test_environment)",
"--docker-image=score_itf_examples:latest",
],
"//config:host": [
"--local-dir=/tmp/score_itf_host/{}".format(name),
],
"//conditions:default": [],
}),
plugins = ["//tests/utils/plugins:integration_plugin"] + select({
"//config:x86_64-linux": ["@score_itf//score/itf/plugins:docker_plugin"],
"//config:x86_64-qnx": ["@score_itf//score/itf/plugins/qemu"],
"//config:host": ["//tests/utils/plugins:localhost_plugin"],
"//conditions:default": [],
}),
deps = final_deps,
data = final_data,
args = final_args,
plugins = final_plugins,
target_compatible_with = ["@platforms//os:qnx"],
**kwargs
)
22 changes: 0 additions & 22 deletions tests/utils/environments/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,3 @@ exports_files(
["ecu_logging_config.json"],
visibility = ["//tests/utils/environments:__subpackages__"],
)

# Empty target for native builds
filegroup(
name = "empty_target",
srcs = [],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)

alias(
name = "test_environment",
actual = select({
"//config:x86_64-linux": "//tests/utils/environments/x86_64-linux",
"//conditions:default": ":empty_target",
}),
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)
2 changes: 2 additions & 0 deletions tests/utils/environments/x86_64-linux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ pkg_tar(
oci_image(
name = "image",
base = "@debian-test-runtime",
target_compatible_with = ["@platforms//os:linux"],
tars = [":ecu_logging_config_layer"],
)

oci_load(
name = "x86_64-linux",
image = ":image",
repo_tags = ["score_itf_examples:latest"],
target_compatible_with = ["@platforms//os:linux"],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
Expand Down
40 changes: 40 additions & 0 deletions tests/utils/environments/x86_64-qnx/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# *******************************************************************************
# 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
# *******************************************************************************

load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("@score_rules_imagefs//rules/qnx:ifs.bzl", "qnx_ifs")

exports_files(
["qemu_config.json"],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)

pkg_files(
name = "logging_config.json",
srcs = ["//tests/utils/environments:ecu_logging_config.json"],
prefix = "/etc",
)

qnx_ifs(
name = "qemu_image",
srcs = [":logging_config.json"],
build_file = ":init.build",
target_compatible_with = ["@platforms//os:qnx"],
visibility = [
"//examples:__subpackages__",
"//tests:__subpackages__",
],
)
Loading
Loading