From 0453815b9d350da8bb762e7d09db085e036f8b9b Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 13 Nov 2025 11:36:45 +0000 Subject: [PATCH 1/3] Run persistency tests also in EBcLfSA This adds building and running of cpp_tests_persistency with the same scenario used in QNX. --- .github/workflows/build_and_test_ebclfsa.yml | 8 +- ebclfsa/.bazelrc | 18 +++-- ebclfsa/MODULE.bazel | 10 ++- ebclfsa/README.md | 12 +-- ebclfsa/patches/fix_hard_coded_amd64.patch | 27 ++++++- ebclfsa/persistency_integration/BUILD | 76 +++++++++++++++++++ ebclfsa/persistency_integration/run_qemu.sh | 33 ++++++++ .../scripts/cpp_tests_persistency.sh | 4 + ebclfsa/scrample_integration/BUILD | 4 +- ebclfsa/scrample_integration/run_qemu.sh | 2 +- 10 files changed, 171 insertions(+), 23 deletions(-) create mode 100644 ebclfsa/persistency_integration/BUILD create mode 100755 ebclfsa/persistency_integration/run_qemu.sh create mode 100755 ebclfsa/persistency_integration/scripts/cpp_tests_persistency.sh diff --git a/.github/workflows/build_and_test_ebclfsa.yml b/.github/workflows/build_and_test_ebclfsa.yml index 5178ff38f0..b56b1121a8 100644 --- a/.github/workflows/build_and_test_ebclfsa.yml +++ b/.github/workflows/build_and_test_ebclfsa.yml @@ -31,11 +31,15 @@ jobs: uses: actions/checkout@v4 - name: Build for EB corbos Linux for Safety Applications and run tests - run: bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:run + run: | + bazel build --config=aarch64-ebclfsa //scrample_integration:run + bazel build --config=aarch64-ebclfsa //persistency_integration:run working-directory: ./ebclfsa - name: Upload test logs uses: actions/upload-artifact@v5 with: name: test-logs - path: ebclfsa/bazel-bin/scrample_integration/*.log + path: + ebclfsa/bazel-bin/scrample_integration/*.log + ebclfsa/bazel-bin/persistency_integration/*.log diff --git a/ebclfsa/.bazelrc b/ebclfsa/.bazelrc index 4cde06a656..c9589ef9ce 100644 --- a/ebclfsa/.bazelrc +++ b/ebclfsa/.bazelrc @@ -1,10 +1,14 @@ -common --@score_baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False -common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False -common --@score_baselibs//score/json:base_library=nlohmann -common --@score_communication//score/mw/com/flags:tracing_library=stub - common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ common --registry=https://bcr.bazel.build -common --extra_toolchains=@gcc_toolchain//:aarch64_gcc_13 -build:aarch64 --platforms=@score_toolchains_gcc//platforms:aarch64-linux +build:_common --@score_baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False +build:_common --@score_baselibs//score/mw/log/flags:KRemote_Logging=False +build:_common --@score_baselibs//score/json:base_library=nlohmann +build:_common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False +build:_common --@score_communication//score/mw/com/flags:tracing_library=stub +build:_common --cxxopt=-Wno-error=mismatched-new-delete + +build:aarch64-ebclfsa --config=_common +build:aarch64-ebclfsa --extra_toolchains=@gcc_toolchain//:aarch64_gcc_13 +build:aarch64-ebclfsa --platforms=@score_toolchains_gcc//platforms:aarch64-linux +build:aarch64-ebclfsa --spawn_strategy=local diff --git a/ebclfsa/MODULE.bazel b/ebclfsa/MODULE.bazel index 2e63a232cf..4afcd5cc6d 100644 --- a/ebclfsa/MODULE.bazel +++ b/ebclfsa/MODULE.bazel @@ -25,7 +25,8 @@ bazel_dep(name = "score_toolchains_gcc", dev_dependency=True) git_override( # Elektrobit corbos Linux for Safety Applications needs a specific toolchain module_name = "score_toolchains_gcc", remote = "https://github.com/elektrobit-contrib/eclipse-score_toolchains_gcc.git", - tag = "0.5.0-alpha", # commit sha: fb009e490b9b8f28805d587f50d0bf6d885f3414 + #tag = "0.5.0-alpha", # commit sha: fb009e490b9b8f28805d587f50d0bf6d885f3414 + commit = "605020d7a95b7fb128944495e45449eb07fedc01", ) gcc = use_extension("@score_toolchains_gcc//extentions:gcc.bzl", "gcc", dev_dependency=True) gcc.toolchain( @@ -49,6 +50,12 @@ gcc.warning_flags( use_repo(gcc, "gcc_toolchain", "gcc_toolchain_gcc") +bazel_dep(name = "score_docs_as_code", version = "2.0.1") # part of 0.5.0-alpha release +single_version_override( + module_name = "score_docs_as_code", + version = "2.0.1", +) + bazel_dep(name = "score_baselibs") single_version_override( module_name = "score_baselibs", @@ -60,6 +67,7 @@ single_version_override( ) bazel_dep(name = "score_communication", version = "0.1.1") # part of 0.5.0-alpha release bazel_dep(name = "score_scrample", version = "0.1.0") # part of 0.5.0-alpha release +bazel_dep(name = "score_persistency", version = "0.2.1") # part of 0.5.0-alpha release # git_override is not forwarded by bazel_dep, so we need to redefine it here git_override( diff --git a/ebclfsa/README.md b/ebclfsa/README.md index 4d2bdd3590..09f54463c7 100644 --- a/ebclfsa/README.md +++ b/ebclfsa/README.md @@ -24,7 +24,7 @@ However, please understand that we cannot advise you about possible costs in you > - Copy and paste the following command into the terminal and hit "Enter": > > ```bash -> cd ./ebclfsa && bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:run +> cd ./ebclfsa && bazel build --config=aarch64-ebclfsa //scrample_integration:run > ``` > > This will build and run the example. @@ -229,7 +229,7 @@ The demo SDK integrates the [S-CORE toolchain with two extensions](https://githu ### Bazel Rules for the Example Applications The example extends the [`scrample` example](https://github.com/eclipse-score/scrample) of S-CORE with the application setup and the toolchain extensions described above. -With those changes, the toolchain can be used via `bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:`. +With those changes, the toolchain can be used via `bazel build --config=aarch64-ebclfsa //scrample_integration:`. > [!IMPORTANT] > Building inside a sandbox is currently not possible. @@ -253,7 +253,7 @@ The following sections introduce some of the rules mentioned above. The `run` target provides an easy entry point, to build, post-process, deploy, run and stop the example: ```bash -bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:run +bazel build --config=aarch64-ebclfsa //scrample_integration:run ``` This command will take a while to finish, since it performs some downloads and starts the fast-dev image. @@ -322,7 +322,7 @@ SDK:handler_do_el0_svc_pre: syscall __NR_clone3 (435) is not allowed Building all components of the example application can be performed with the `hi_app` rule. ```bash -bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:hi_app +bazel build --config=aarch64-ebclfsa //scrample_integration:hi_app ``` Due the dependencies towards `:scrample_sil` and `:scrample_sil_wrapper` this will build all required binaries. @@ -333,7 +333,7 @@ Including the LI `scrample` binary, a temporary `scrample_sil_wrapper` binary as The easiest way to setup the fast-dev image, is to use the `fastdev-image` rule. ```bash -bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:fastdev-image +bazel build --config=aarch64-ebclfsa //scrample_integration:fastdev-image ``` This will first download the image via the `fetch-fastdev-archive` rule and cache the archive. @@ -362,7 +362,7 @@ ssh -p 2222 root@localhost For deploying the example application to the image, the `upload` rule is available, which will start the image based on the content of `bazel-bin/scrample_integration/deb-qemuarm64/` and deploy all needed files via `scp`. ```bash -bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:upload +bazel build --config=aarch64-ebclfsa //scrample_integration:upload ``` Since the deployment step will change the stored disk image, the `upload` rule stores its output in `bazel-bin/scrample_integration/deb-qemuarm64-modified/`. diff --git a/ebclfsa/patches/fix_hard_coded_amd64.patch b/ebclfsa/patches/fix_hard_coded_amd64.patch index 014b4f80ab..91892e1b20 100644 --- a/ebclfsa/patches/fix_hard_coded_amd64.patch +++ b/ebclfsa/patches/fix_hard_coded_amd64.patch @@ -1,13 +1,32 @@ diff --git a/MODULE.bazel b/MODULE.bazel -index a302a84..7917e2b 100644 +index 16776ba..683c131 100644 --- a/MODULE.bazel +++ b/MODULE.bazel -@@ -60,7 +60,7 @@ deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb") +@@ -70,7 +70,7 @@ deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb") deb( name = "acl-deb", build = "//third_party/acl:acl.BUILD", - urls = ["https://archive.ubuntu.com/ubuntu/pool/main/a/acl/libacl1-dev_2.2.52-3build1_amd64.deb"], -+ urls = ["https://ports.ubuntu.com/pool/main/a/acl/libacl1-dev_2.2.52-3build1_arm64.deb"], ++ urls = ["https://launchpadlibrarian.net/581258948/libacl1-dev_2.3.1-1_arm64.deb"], visibility = ["//visibility:public"], ) - + +diff --git a/third_party/acl/acl.BUILD b/third_party/acl/acl.BUILD +index 718726c..710befd 100644 +--- a/third_party/acl/acl.BUILD ++++ b/third_party/acl/acl.BUILD +@@ -1,7 +1,7 @@ + cc_library( + name = "acl", + srcs = [ +- "usr/lib/libacl.a", ++ "usr/lib/aarch64-linux-gnu/libacl.a", + ], + hdrs = [ + "usr/include/acl/libacl.h", +@@ -9,4 +9,4 @@ cc_library( + ], + includes = ["usr/include/"], + visibility = ["//visibility:public"], +-) ++) diff --git a/ebclfsa/persistency_integration/BUILD b/ebclfsa/persistency_integration/BUILD new file mode 100644 index 0000000000..d2961b0ff3 --- /dev/null +++ b/ebclfsa/persistency_integration/BUILD @@ -0,0 +1,76 @@ +# ******************************************************************************* +# 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("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") + +genrule( + name = "fetch-fastdev-archive", + srcs = [], + outs = ["fastdev-archive.tgz"], + cmd = "wget -O $@ https://github.com/Elektrobit/eclipse-score_toolchains_gcc/releases/download/0.5.0-alpha/fastdev-ubuntu-ebcl-deb-qemu-arm64.tgz" +) + +genrule( + name = "fastdev-image", + srcs = [":fetch-fastdev-archive"], + outs = [ + "deb-qemuarm64/fastdev-ubuntu-ebcl-deb-qemuarm64.wic", + "deb-qemuarm64/fastdev-ubuntu-ebcl-deb-qemuarm64-vmlinux" + ], + cmd = "tar xzf $(location :fetch-fastdev-archive) -C $(RULEDIR)", +) + +genrule( + name = "upload", + srcs = [ + "@score_persistency//tests/cpp_test_scenarios:cpp_test_scenarios", + ":fastdev-image", + "scripts/cpp_tests_persistency.sh", + "run_qemu.sh", + ], + cmd = " \ + mkdir -p $(RULEDIR)/deb-qemuarm64-modified &&\ + cp $(RULEDIR)/deb-qemuarm64/* $(RULEDIR)/deb-qemuarm64-modified/ &&\ + $(location run_qemu.sh) $(RULEDIR)/deb-qemuarm64-modified -pidfile $(RULEDIR)/qemu.pid > $(RULEDIR)/qemu_upload.log &\ + sleep 30 ; \ + sshpass -p linux scp -o StrictHostKeyChecking=no -P 2222 $(location @score_persistency//tests/cpp_test_scenarios:cpp_test_scenarios) root@localhost:/usr/bin/cpp_tests_persistency &&\ + sshpass -p linux scp -o StrictHostKeyChecking=no -P 2222 $(location scripts/cpp_tests_persistency.sh) root@localhost:/usr/bin/cpp_tests_persistency.sh &&\ + sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost sync &&\ + sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost crinit-ctl poweroff || true \ + sleep 5 \ + ", + outs = [ + "qemu_upload.log", + "deb-qemuarm64-modified/fastdev-ubuntu-ebcl-deb-qemuarm64.wic", + "deb-qemuarm64-modified/fastdev-ubuntu-ebcl-deb-qemuarm64-vmlinux" + ], +) + +genrule( + name = "run", + srcs = [ + "deb-qemuarm64-modified/fastdev-ubuntu-ebcl-deb-qemuarm64.wic", + "deb-qemuarm64-modified/fastdev-ubuntu-ebcl-deb-qemuarm64-vmlinux", + "run_qemu.sh" + ], + cmd = " \ + $(location run_qemu.sh) $(RULEDIR)/deb-qemuarm64-modified -pidfile $(RULEDIR)/qemu.pid > $(RULEDIR)/qemu_run.log &\ + sleep 10 ; \ + sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost cpp_tests_persistency.sh > $(RULEDIR)/ssh_persistency_test_scenarios_run.log && \ + sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost crinit-ctl poweroff || true \ + sleep 5 \ + ", + outs = [ + "qemu_run.log", + "ssh_persistency_test_scenarios_run.log", + ], +) diff --git a/ebclfsa/persistency_integration/run_qemu.sh b/ebclfsa/persistency_integration/run_qemu.sh new file mode 100755 index 0000000000..55ef89845e --- /dev/null +++ b/ebclfsa/persistency_integration/run_qemu.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -xu + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi +BASEFOLDER=$1 +IMAGE="${BASEFOLDER}/fastdev-ubuntu-ebcl-deb-qemuarm64.wic" +KERNEL="${BASEFOLDER}/fastdev-ubuntu-ebcl-deb-qemuarm64-vmlinux" +if [ ! -d "${BASEFOLDER}" ] || [ ! -f "${IMAGE}" ] || [ ! -f "${KERNEL}" ] ; then + echo "Run \"bazel build --config=aarch64-ebclfsa //persistency_integration:fastdev-image\" first to fetch the image" +fi + +MACHINE="virt,virtualization=true,gic-version=3" +CPU="cortex-a53" +SMP="8" +MEM="4G" +KERNEL_ARGS=("-append" "root=/dev/vda1 sdk_enable lisa_syscall_whitelist=2026 rw sharedmem.enable_sharedmem=0 init=/usr/bin/ebclfsa-cflinit") +DISK_ARGS="-device virtio-blk-device,drive=vd0 -drive if=none,format=raw,file=${IMAGE},id=vd0" +NETWORK_ARGS="-netdev user,id=net0,net=192.168.7.0/24,dhcpstart=192.168.7.2,dns=192.168.7.3,host=192.168.7.5,hostfwd=tcp::2222-:22,hostfwd=tcp::3333-:3333 -device virtio-net-device,netdev=net0 " + +if ! command -v qemu-system-aarch64 > /dev/null; then + echo "Please install qemu-system-aarch64" + exit 1 +fi + +chmod +w ${IMAGE} + +exec qemu-system-aarch64 -m "${MEM}" -machine "${MACHINE}" -cpu "${CPU}" \ + -smp "${SMP}" -kernel "${KERNEL}" "${KERNEL_ARGS[@]}" ${DISK_ARGS} \ + ${NETWORK_ARGS} -nographic ${@:2} diff --git a/ebclfsa/persistency_integration/scripts/cpp_tests_persistency.sh b/ebclfsa/persistency_integration/scripts/cpp_tests_persistency.sh new file mode 100755 index 0000000000..0dd092d139 --- /dev/null +++ b/ebclfsa/persistency_integration/scripts/cpp_tests_persistency.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Script to run C++ persistency tests inside the QEMU environment +# Wrapper due to quoting issues when calling directly from Bazel +cpp_tests_persistency --name basic.basic --input '{"kvs_parameters":{"instance_id":0}}' diff --git a/ebclfsa/scrample_integration/BUILD b/ebclfsa/scrample_integration/BUILD index a0be59b95d..ab59f1f80f 100644 --- a/ebclfsa/scrample_integration/BUILD +++ b/ebclfsa/scrample_integration/BUILD @@ -107,12 +107,12 @@ genrule( cmd = " \ $(location run_qemu.sh) $(RULEDIR)/deb-qemuarm64-modified -pidfile $(RULEDIR)/qemu.pid > $(RULEDIR)/qemu_run.log &\ sleep 10 ; \ - sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost scrample -n 10 -m send -t 200 -s /etc/mw_com_config.json > $(RULEDIR)/ssh_run.log && \ + sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost scrample -n 10 -m send -t 200 -s /etc/mw_com_config.json > $(RULEDIR)/ssh_scrample_run.log && \ sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost crinit-ctl poweroff || true \ sleep 5 \ ", outs = [ "qemu_run.log", - "ssh_run.log", + "ssh_scrample_run.log", ], ) diff --git a/ebclfsa/scrample_integration/run_qemu.sh b/ebclfsa/scrample_integration/run_qemu.sh index 178adf6d97..0d04cb0745 100755 --- a/ebclfsa/scrample_integration/run_qemu.sh +++ b/ebclfsa/scrample_integration/run_qemu.sh @@ -10,7 +10,7 @@ BASEFOLDER=$1 IMAGE="${BASEFOLDER}/fastdev-ubuntu-ebcl-deb-qemuarm64.wic" KERNEL="${BASEFOLDER}/fastdev-ubuntu-ebcl-deb-qemuarm64-vmlinux" if [ ! -d "${BASEFOLDER}" ] || [ ! -f "${IMAGE}" ] || [ ! -f "${KERNEL}" ] ; then - echo "Run \"bazel build --config=aarch64 --spawn_strategy=local //scrample_integration:fastdev-image\" first to fetch the image" + echo "Run \"bazel build --config=aarch64-ebclfsa //scrample_integration:fastdev-image\" first to fetch the image" fi MACHINE="virt,virtualization=true,gic-version=3" From b5bc7ac6a6dc731406fe146295629d7ae6245ab3 Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 13 Nov 2025 14:05:46 +0000 Subject: [PATCH 2/3] Mention the additional application in README --- ebclfsa/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ebclfsa/README.md b/ebclfsa/README.md index 09f54463c7..598b727754 100644 --- a/ebclfsa/README.md +++ b/ebclfsa/README.md @@ -392,4 +392,7 @@ crinit-ctl poweroff ## Further notes -The toolchain and librares are provided for demonstration and prototyping purposes without further qualification. +* The toolchain and librares are provided for demonstration and prototyping purposes without further qualification. +* A second test case for S-CORE persistency is also integrated. You can run it via + `bazel build --config=aarch64-ebclfsa //persistency_integration:run` + However, this is not integrated as HI application to avoid the additional complexity of the required wrapper. From 48e1083e904ac25ae919ee2487fe1725142a1479 Mon Sep 17 00:00:00 2001 From: Oliver Pajonk Date: Thu, 13 Nov 2025 14:26:13 +0000 Subject: [PATCH 3/3] fix test log upload pattern --- .github/workflows/build_and_test_ebclfsa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test_ebclfsa.yml b/.github/workflows/build_and_test_ebclfsa.yml index b56b1121a8..89521dc5aa 100644 --- a/.github/workflows/build_and_test_ebclfsa.yml +++ b/.github/workflows/build_and_test_ebclfsa.yml @@ -40,6 +40,6 @@ jobs: uses: actions/upload-artifact@v5 with: name: test-logs - path: + path: | ebclfsa/bazel-bin/scrample_integration/*.log ebclfsa/bazel-bin/persistency_integration/*.log