Skip to content

Commit 916ddc8

Browse files
crypto: Add qnx test execution for test binaries (cc_test)
- Update used toolchain version and add rules_imagefs for qnx images. - Update bazel dependencies to remove warnings. - Update devcontainer to support local execution. - Rename existing test workflow to test_linux. - Add test workflow for qnx. - Fix incorrect destruction orders identified by testing on qnx.
1 parent adef48b commit 916ddc8

15 files changed

Lines changed: 428 additions & 108 deletions

File tree

.bazelrc

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,49 +59,35 @@ build:shared_qnx --cxxopt=-DIP_PKTINFO=0
5959
# -------------------------------------------------------------------------------
6060
build:x86_64-linux --config=shared
6161
build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
62-
63-
# -------------------------------------------------------------------------------
64-
# Different toolchain configuration for x86_64-linux
65-
# -------------------------------------------------------------------------------
66-
build:host_config_1 --config=x86_64-linux
67-
build:host_config_1 --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0
68-
build:host_config_1 --features=use_pthread
62+
build:x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0
63+
build:x86_64-linux --features=use_pthread
6964

7065
# -------------------------------------------------------------------------------
7166
# Config dedicated to target platform CPU:aarch64 and OS:linux
7267
# -------------------------------------------------------------------------------
7368
build:aarch64-linux --config=shared
7469
build:aarch64-linux --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix
75-
76-
# -------------------------------------------------------------------------------
77-
# Different toolchain configuration for aarch64-linux
78-
# -------------------------------------------------------------------------------
79-
build:target_config_3 --config=aarch64-linux
80-
build:target_config_3 --extra_toolchains=@score_gcc_aarch64_toolchain//:aarch64-linux-gcc_12.2.0
81-
70+
build:aarch64-linux --extra_toolchains=@score_gcc_aarch64_toolchain//:aarch64-linux-gcc_12.2.0
8271

8372
# -------------------------------------------------------------------------------
8473
# Config dedicated to target platform CPU:x86_64 and OS:QNX
8574
# -------------------------------------------------------------------------------
8675
build:x86_64-qnx --config=shared_qnx
8776
# Use custom platform that extends score platform with @platforms//os:qnx constraint
8877
build:x86_64-qnx --platforms=//platforms:x86_64-qnx-extended
89-
90-
# -------------------------------------------------------------------------------
91-
# Different toolchain configuration for x86_64-qnx
92-
# -------------------------------------------------------------------------------
93-
build:target_config_1 --config=x86_64-qnx
94-
build:target_config_1 --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0
78+
build:x86_64-qnx --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0
79+
build:x86_64-qnx --extra_toolchains=@score_qnx_x86_64_ifs_toolchain//:ifs-x86_64-qnx-sdp_8.0.0
80+
test:x86_64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
81+
test:x86_64-qnx --test_lang_filters=cc,rust
9582

9683
# -------------------------------------------------------------------------------
9784
# Config dedicated to target platform CPU:aarch64 and OS:QNX
9885
# -------------------------------------------------------------------------------
9986
build:aarch64-qnx --config=shared_qnx
10087
# Use custom platform that extends score platform with @platforms//os:qnx constraint
10188
build:aarch64-qnx --platforms=//platforms:aarch64-qnx-extended
102-
103-
# -------------------------------------------------------------------------------
104-
# Different toolchain configuration for aarch64-qnx
105-
# -------------------------------------------------------------------------------
106-
build:target_config_2 --config=aarch64-qnx
107-
build:target_config_2 --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0
89+
build:aarch64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0
90+
build:aarch64-qnx --extra_toolchains=@score_qnx_aarch64_ifs_toolchain//:ifs-aarch64-qnx-sdp_8.0.0
91+
test:aarch64-qnx --run_under=@score_qnx_unit_tests//src:run_under_qnx
92+
test:aarch64-qnx --test_lang_filters=cc,rust
93+
test:aarch64-qnx --test_timeout=200

.devcontainer/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ RUN if [ "$USERNAME" != "vscode" ]; then \
2828
&& chmod 0440 /etc/sudoers.d/${USERNAME}; \
2929
fi
3030

31+
# Install dependencies and configure system trust store
32+
RUN apt-get update && apt-get install -y --no-install-recommends \
33+
qemu-system-x86 \
34+
&& rm -rf /var/lib/apt/lists/*
35+
3136
# Set the default user for the container
3237
USER ${USERNAME}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"features": {
3+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
4+
"version": "2.17.0",
5+
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c",
6+
"integrity": "sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c"
7+
}
8+
}
9+
}

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414

1515
// Create empty folder in case mandatory mount points are missing.
16-
"initializeCommand": "mkdir -p ${localEnv:HOME}/.cache/bazel /usr/local/share/ca-certificates/ ${localEnv:HOME}/.qnx/license && sudo mkdir -p /etc/docker",
16+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.cache/bazel ${localEnv:HOME}/.qnx/license",
1717

1818
"mounts": [
1919
{
@@ -39,8 +39,8 @@
3939

4040
],
4141
"onCreateCommand": {
42-
"update certificates & install acl library": "sudo apt update && sudo apt install -y --no-install-recommends ca-certificates-java openjdk-17-jre-headless && sudo update-ca-certificates",
43-
"bazel use system trust store": "echo 'startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit' | sudo tee --append /etc/bazel.bazelrc"
42+
"update certificates": "sudo apt update && sudo apt install -y --no-install-recommends ca-certificates-java openjdk-17-jre-headless && sudo update-ca-certificates",
43+
"add user to kvm group": "KVM_GID=$(stat -c '%g' /dev/kvm) && (getent group kvm > /dev/null 2>&1 || sudo groupadd -g $KVM_GID kvm) && sudo usermod -aG kvm $(whoami)"
4444
},
4545

4646
"runArgs": ["--network", "host"]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
3+
# *******************************************************************************
4+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
5+
#
6+
# See the NOTICE file(s) distributed with this work for additional
7+
# information regarding copyright ownership.
8+
#
9+
# This program and the accompanying materials are made available under the
10+
# terms of the Apache License Version 2.0 which is available at
11+
# https://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# SPDX-License-Identifier: Apache-2.0
14+
# *******************************************************************************
15+
16+
import http.cookiejar
17+
import json
18+
import netrc
19+
import os
20+
import sys
21+
import urllib.parse
22+
import urllib.request
23+
24+
25+
def eprint(*args, **kwargs):
26+
print(*args, file=sys.stderr, **kwargs)
27+
28+
29+
if __name__ == "__main__":
30+
data = json.load(sys.stdin)
31+
32+
if "qnx.com" not in data["uri"]:
33+
eprint("Unsupported domain")
34+
sys.exit(1)
35+
36+
if "SCORE_QNX_USER" in os.environ and "SCORE_QNX_PASSWORD" in os.environ:
37+
login = os.environ["SCORE_QNX_USER"]
38+
password = os.environ["SCORE_QNX_PASSWORD"]
39+
else:
40+
try:
41+
nrc = netrc.netrc()
42+
auth = nrc.authenticators("qnx.com")
43+
if auth:
44+
login, _, password = auth
45+
else:
46+
raise Exception("No credential found for QNX")
47+
except Exception as excp:
48+
eprint(excp)
49+
eprint("Failed getting credentials from .netrc")
50+
sys.exit(1)
51+
52+
data = urllib.parse.urlencode(
53+
{"userlogin": login, "password": password, "UseCookie": "1"}
54+
)
55+
data = data.encode("ascii")
56+
57+
cookie_jar = http.cookiejar.CookieJar()
58+
cookie_processor = urllib.request.HTTPCookieProcessor(cookie_jar)
59+
opener = urllib.request.build_opener(cookie_processor)
60+
urllib.request.install_opener(opener)
61+
62+
r = urllib.request.urlopen("https://www.qnx.com/account/login.html", data)
63+
if r.status != 200:
64+
eprint("Failed to login to QNX")
65+
sys.exit(1)
66+
67+
cookies = {c.name: c.value for c in list(cookie_jar)}
68+
if not "myQNX" in cookies:
69+
eprint("Failed to get myQNX cookie from login page")
70+
sys.exit(1)
71+
72+
myQNX = cookies["myQNX"]
73+
print(
74+
json.dumps(
75+
{
76+
"headers": {
77+
"Cookie": [f"myQNX={myQNX}"],
78+
}
79+
}
80+
)
81+
)

.github/workflows/test_qnx.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 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+
name: Build and Test (QNX)
14+
15+
on:
16+
pull_request_target:
17+
types: [opened, reopened, synchronize]
18+
push:
19+
branches:
20+
- main
21+
merge_group:
22+
types: [checks_requested]
23+
workflow_call:
24+
jobs:
25+
qnx-build:
26+
name: Build and Test ${{ matrix.bazel-config }}
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- bazel-config: x86_64-qnx
32+
bazel-test-target: >-
33+
//score/... //tests/...
34+
- bazel-config: aarch64-qnx
35+
bazel-test-target: >-
36+
//score/... //tests/...
37+
extra-bazel-test-flags: "--test_timeout=120,600,1800,7200" # Increase test timeout due to QEMU emulation
38+
uses: eclipse-score/cicd-workflows/.github/workflows/qnx-build.yml@17318d27366522721504b60040590dc822264a38
39+
permissions:
40+
contents: read
41+
pull-requests: read
42+
with:
43+
bazel-target: "//score/... //tests/..."
44+
bazel-config: ${{ matrix.bazel-config }}
45+
bazel-test-target: ${{ matrix.bazel-test-target }}
46+
credential-helper: ".github/tools/qnx_credential_helper.py"
47+
bazel-disk-cache: ${{ matrix.bazel-config }}
48+
secrets:
49+
score-qnx-license: ${{ secrets.SCORE_QNX_LICENSE }}
50+
score-qnx-user: ${{ secrets.SCORE_QNX_USER }}
51+
score-qnx-password: ${{ secrets.SCORE_QNX_PASSWORD }}

.vscode/settings.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@
5252
]
5353
},
5454

55-
"bazel.lsp.command": "bazel",
56-
"bazel.lsp.args": [
57-
"run",
58-
"//:starpls_server"
59-
],
55+
"bazel.lsp.command": "starpls",
6056

6157
// RST Settings
6258
"[restructuredtext]": {

MODULE.bazel

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bazel_dep(name = "rules_cc", version = "0.2.21")
5555
# *******************************************************************************
5656
bazel_dep(
5757
name = "score_bazel_cpp_toolchains",
58-
version = "0.3.1",
58+
version = "0.5.4",
5959
dev_dependency = True,
6060
)
6161

@@ -97,7 +97,7 @@ gcc.toolchain(
9797
# *******************************************************************************
9898
gcc.toolchain(
9999
name = "score_qcc_x86_64_toolchain",
100-
sdp_version = "8.0.0",
100+
sdp_version = "8.0.4",
101101
target_cpu = "x86_64",
102102
target_os = "qnx",
103103
use_default_package = True,
@@ -109,7 +109,7 @@ gcc.toolchain(
109109
# *******************************************************************************
110110
gcc.toolchain(
111111
name = "score_qcc_aarch64_toolchain",
112-
sdp_version = "8.0.0",
112+
sdp_version = "8.0.4",
113113
target_cpu = "aarch64",
114114
target_os = "qnx",
115115
use_default_package = True,
@@ -120,7 +120,9 @@ use_repo(
120120
"score_gcc_aarch64_toolchain",
121121
"score_gcc_x86_64_toolchain",
122122
"score_qcc_aarch64_toolchain",
123+
"score_qcc_aarch64_toolchain_pkg",
123124
"score_qcc_x86_64_toolchain",
125+
"score_qcc_x86_64_toolchain_pkg",
124126
)
125127

126128
# *******************************************************************************
@@ -131,6 +133,34 @@ bazel_dep(name = "rules_rust", version = "0.71.3")
131133

132134
bazel_dep(name = "score_toolchains_rust", version = "0.9.1", dev_dependency = True)
133135

136+
# *******************************************************************************
137+
# QNX IFS (Image File System) toolchain for building boot images
138+
# *******************************************************************************
139+
bazel_dep(name = "score_rules_imagefs", version = "0.0.3")
140+
141+
imagefs = use_extension("@score_rules_imagefs//extensions:imagefs.bzl", "imagefs", dev_dependency = True)
142+
imagefs.toolchain(
143+
name = "score_qnx_x86_64_ifs_toolchain",
144+
sdp_to_import = "@score_qcc_x86_64_toolchain_pkg",
145+
sdp_version = "8.0.0",
146+
target_cpu = "x86_64",
147+
target_os = "qnx",
148+
type = "ifs",
149+
)
150+
imagefs.toolchain(
151+
name = "score_qnx_aarch64_ifs_toolchain",
152+
sdp_to_import = "@score_qcc_aarch64_toolchain_pkg",
153+
sdp_version = "8.0.0",
154+
target_cpu = "aarch64",
155+
target_os = "qnx",
156+
type = "ifs",
157+
)
158+
use_repo(
159+
imagefs,
160+
"score_qnx_aarch64_ifs_toolchain",
161+
"score_qnx_x86_64_ifs_toolchain",
162+
)
163+
134164
# ===============================================================================
135165
# T H I R D - P A R T Y D E P E N D E N C I E S
136166
# ===============================================================================
@@ -227,7 +257,7 @@ filegroup(
227257

228258
# tooling
229259
bazel_dep(name = "score_tooling", version = "1.1.2")
230-
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
260+
bazel_dep(name = "aspect_rules_lint", version = "2.3.0")
231261
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2")
232262

233263
#docs-as-code
@@ -237,11 +267,19 @@ bazel_dep(name = "score_docs_as_code", version = "4.6.0")
237267
bazel_dep(name = "score_process", version = "1.6.0")
238268
bazel_dep(name = "score_platform", version = "0.6.0")
239269

240-
# GoogleTest
241-
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
242-
243270
# s-core baselibs
244271
bazel_dep(name = "score_baselibs", version = "0.2.7")
245272

246-
# Integration testing
273+
# Testing
274+
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
275+
276+
bazel_dep(name = "score_qnx_unit_tests", version = "0.2.0", dev_dependency = True)
277+
git_override(
278+
module_name = "score_qnx_unit_tests",
279+
commit = "279075a08287f2fc1254a9fc141fdc0a328e8766",
280+
patch_strip = 1,
281+
patches = ["//:qnx_unit_tests.patch"],
282+
remote = "https://github.com/eclipse-score/qnx_unit_tests.git",
283+
)
284+
247285
bazel_dep(name = "score_itf", version = "0.1.0")

0 commit comments

Comments
 (0)