diff --git a/.github/workflows/itf.yml b/.github/workflows/itf.yml index c34888ee..7e3d834f 100644 --- a/.github/workflows/itf.yml +++ b/.github/workflows/itf.yml @@ -42,7 +42,7 @@ jobs: - name: Install qemu run: | sudo apt-get update - sudo apt-get install -y qemu-system-arm + sudo apt-get install -y qemu-system-arm qemu-system-x86 cloud-image-utils - name: Enable KVM group perms run: | sudo chmod 666 /dev/kvm diff --git a/MODULE.bazel b/MODULE.bazel index 011b211a..67ff2d20 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -223,14 +223,12 @@ use_repo(imagefs, "score_qnx_x86_64_ifs_toolchain") ############################################################################### # -# EBclfsa fastdev archive repository for Linux QEMU integration tests +# Linux QEMU images from the dedicated os_images repository # ############################################################################### -http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") - -http_file( - name = "eb_corbos_toolkit_fastdev_archive", - downloaded_file_path = "fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.tar.gz", - sha256 = "9ca3891b27e4b7bbf6c519d8924283e89c03b62513a988f751a3ee3d10c293e4", - urls = ["https://github.com/elektrobit/eb_corbos_toolkit/releases/download/v2.0.0-beta1/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.tar.gz"], +bazel_dep(name = "os_images", version = "0.0.0", dev_dependency = True) +git_override( + module_name = "os_images", + commit = "a024787e2ddb4ceed6ac6fe63b3847ab937c0b5d", + remote = "https://github.com/eclipse-score/os_images.git", ) diff --git a/README.md b/README.md index 408a3fe2..7bfdd1a1 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,47 @@ QEMU targets are configured using a JSON configuration file that specifies netwo } ``` +#### Linux QEMU images + +Running tests with Linux is supported: + +Ubuntu: + +```starlark +py_itf_test( + name = "test_qemu_ubuntu", + srcs = ["test_qemu_ubuntu.py"], + args = [ + "--qemu-rootfs=$(location @os_images//ubuntu_x86_64:image)", + "--qemu-config=$(location @os_images//ubuntu_x86_64:qemu_config)", + ], + data = [ + "@os_images//ubuntu_x86_64:image", + "@os_images//ubuntu_x86_64:qemu_config", + ], + plugins = ["@score_itf//score/itf/plugins:qemu_plugin"], +) +``` + +Ebclfsa: + +```starlark +py_itf_test( + name = "test_qemu_ebclfsa", + srcs = ["test_qemu_ebclfsa.py"], + args = [ + "--qemu-rootfs=$(location @os_images//ebclfsa_aarch64:image)", + "--qemu-kernel=$(location @os_images//ebclfsa_aarch64:kernel)", + "--qemu-config=$(location @os_images//ebclfsa_aarch64:qemu_config)", + ], + data = [ + "@os_images//ebclfsa_aarch64:image", + "@os_images//ebclfsa_aarch64:kernel", + "@os_images//ebclfsa_aarch64:qemu_config", + ], + plugins = ["@score_itf//score/itf/plugins:qemu_plugin"], +) +``` ### Capability-Based Tests @@ -442,9 +483,9 @@ bazel test //test:test_docker \ ### QEMU Tests ```bash -# With pre-built QEMU image +# With a pre-built QEMU root filesystem image bazel test //test:test_qemu \ - --test_arg="--qemu-image=/path/to/kernel.img" + --test_arg="--qemu-rootfs=/path/to/rootfs.img" ``` ## QEMU Setup (Linux) diff --git a/test/integration/BUILD b/test/integration/BUILD index 7a43c8cd..66a190ec 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -213,17 +213,38 @@ py_itf_test( py_itf_test( name = "test_ebclfsa_ping", srcs = [ - "test_ebclfsa_ping.py", + "test_ping.py", ], args = [ - "--qemu-config=$(location //test/resources/ebclfsa_aarch64:qemu_config)", - "--qemu-kernel=$(location //test/resources/ebclfsa_aarch64:kernel)", - "--qemu-rootfs=$(location //test/resources/ebclfsa_aarch64:image)", + "--qemu-config=$(location @os_images//ebclfsa_aarch64:qemu_config)", + "--qemu-kernel=$(location @os_images//ebclfsa_aarch64:kernel)", + "--qemu-rootfs=$(location @os_images//ebclfsa_aarch64:image)", ], data = [ - "//test/resources/ebclfsa_aarch64:image", - "//test/resources/ebclfsa_aarch64:kernel", - "//test/resources/ebclfsa_aarch64:qemu_config", + "@os_images//ebclfsa_aarch64:image", + "@os_images//ebclfsa_aarch64:kernel", + "@os_images//ebclfsa_aarch64:qemu_config", + ], + plugins = [ + "//score/itf/plugins:qemu_plugin", + ], + tags = [ + "manual", + ], +) + +py_itf_test( + name = "test_ubuntu_ping", + srcs = [ + "test_ping.py", + ], + args = [ + "--qemu-config=$(location @os_images//ubuntu_x86_64:qemu_config)", + "--qemu-rootfs=$(location @os_images//ubuntu_x86_64:image)", + ], + data = [ + "@os_images//ubuntu_x86_64:image", + "@os_images//ubuntu_x86_64:qemu_config", ], plugins = [ "//score/itf/plugins:qemu_plugin", @@ -240,6 +261,7 @@ test_suite( ], tests = [ ":test_ebclfsa_ping", + ":test_ubuntu_ping", ], ) diff --git a/test/integration/test_ebclfsa_ping.py b/test/integration/test_ping.py similarity index 100% rename from test/integration/test_ebclfsa_ping.py rename to test/integration/test_ping.py diff --git a/test/resources/ebclfsa_aarch64/BUILD b/test/resources/ebclfsa_aarch64/BUILD deleted file mode 100644 index bd8335bb..00000000 --- a/test/resources/ebclfsa_aarch64/BUILD +++ /dev/null @@ -1,85 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 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:tar.bzl", "pkg_tar") - -genrule( - name = "extract-fastdev-image", - srcs = ["@eb_corbos_toolkit_fastdev_archive//file"], - outs = [ - "ebcl-qemuarm64/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.wic", - "ebcl-qemuarm64/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64-vmlinux", - ], - cmd = "mkdir -p $(RULEDIR)/ebcl-qemuarm64 && tar xzf $(location @eb_corbos_toolkit_fastdev_archive//file) -C $(RULEDIR)/ebcl-qemuarm64 && chmod +w $(RULEDIR)/ebcl-qemuarm64/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.wic", - tags = [ - "manual", - ], - visibility = ["//visibility:private"], -) - -pkg_tar( - name = "network_config_tar", - srcs = [ - "config-overlay/etc/config/network/network", - ], - mode = "0644", - package_dir = "/etc/config/network", -) - -genrule( - name = "itf-image", - srcs = [ - ":extract-fastdev-image", - ":network_config_tar", - "build_image.sh", - ], - outs = [ - "ebcl-qemuarm64-itf/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.wic", - "ebcl-qemuarm64-itf/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64-vmlinux", - ], - cmd = """ - bash $(location build_image.sh) \ - $(RULEDIR) \ - $(RULEDIR)/ebcl-qemuarm64 \ - $(RULEDIR)/ebcl-qemuarm64-itf \ - $(location :network_config_tar) - """, - tags = [ - "manual", - ], - visibility = ["//visibility:private"], -) - -filegroup( - name = "image", - srcs = [":ebcl-qemuarm64-itf/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64.wic"], - tags = [ - "manual", - ], - visibility = ["//visibility:public"], -) - -filegroup( - name = "kernel", - srcs = [":ebcl-qemuarm64-itf/fastdev-ubuntu-ebclfsa-ebcl-qemuarm64-vmlinux"], - tags = [ - "manual", - ], - visibility = ["//visibility:public"], -) - -filegroup( - name = "qemu_config", - srcs = ["qemu_config.json"], - visibility = ["//:__subpackages__"], -) diff --git a/test/resources/ebclfsa_aarch64/build_image.sh b/test/resources/ebclfsa_aarch64/build_image.sh deleted file mode 100644 index 3bc99418..00000000 --- a/test/resources/ebclfsa_aarch64/build_image.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# ******************************************************************************* -# Copyright (c) 2026 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 -# ******************************************************************************* - -set -euxo pipefail - -if [[ $# -lt 4 ]]; then - echo "Error: Expected at least 4 arguments (working directory, image source location, image target location, and one or more tar files to deploy relative to the root of the image)" >&2 - exit 1 -fi - -if ! command -v sshpass &> /dev/null; then - echo "Error: sshpass is not installed. Please install it to proceed." >&2 - exit 1 -fi - -WORKING_DIR="$1" -IMAGE_SOURCE="$2" -IMAGE_TARGET="$3" -shift 3 -DEPLOY_SRCS=("$@") - -if [[ ! -d "${IMAGE_SOURCE}" ]]; then - echo "Error: Image source location is not a directory: ${IMAGE_SOURCE}" >&2 - exit 1 -fi - -if ! find "${IMAGE_SOURCE}" -maxdepth 1 \( -name "*.wic" -type f -o -name "*.wic" -type l \) | grep -q .; then - echo "Error: No .wic file found in ${IMAGE_SOURCE}" >&2 - exit 1 -fi - -if ! find "${IMAGE_SOURCE}" -maxdepth 1 \( -name "*vmlinux" -type f -o -name "*vmlinux" -type l \) | grep -q .; then - echo "Error: No vmlinux file found in ${IMAGE_SOURCE}" >&2 - exit 1 -fi - -if [[ -e "${IMAGE_TARGET}" && ! -d "${IMAGE_TARGET}" ]]; then - echo "Error: Image target location exists but is not a directory: ${IMAGE_TARGET}" >&2 - exit 1 -fi - -for src in "${DEPLOY_SRCS[@]}"; do - if [[ ! -f "${src}" ]]; then - echo "Error: Deploy source file does not exist: ${src}" >&2 - exit 1 - fi - if [[ ! "${src}" =~ \.tar(\.(gz|bz2|xz))?$ ]]; then - echo "Error: Deploy source is not a tar file: ${src}" >&2 - exit 1 - fi -done - -mkdir -p "${IMAGE_TARGET}" -rm -f "${IMAGE_TARGET:?}/"* -cp -L "${IMAGE_SOURCE}"/* "${IMAGE_TARGET}"/ - -IMAGE=$(find "${IMAGE_TARGET}" -maxdepth 1 \( -name "*.wic" -type f -o -name "*.wic" -type l \) -print -quit) -KERNEL=$(find "${IMAGE_TARGET}" -maxdepth 1 \( -name "*vmlinux" -type f -o -name "*vmlinux" -type l \) -print -quit) - -# The image file must be writable for qemu overlay handling. -chmod +w "${IMAGE}" - -qemu-system-aarch64 -m 2048 -cpu cortex-a53 \ - -kernel "${KERNEL}" \ - -machine "virt,virtualization=true,gic-version=3" \ - -smp 8 \ - -device virtio-blk-device,drive=vd0 -drive if=none,format=raw,file="${IMAGE}",id=vd0 \ - -append "root=/dev/vda1 sdk_enable lisa_syscall_whitelist=2026 rw sharedmem.enable_sharedmem=0 init=/usr/bin/ebclfsa-cflinit" \ - -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 \ - -device virtio-net-device,netdev=net0 \ - -pidfile "${WORKING_DIR}/qemu.pid" \ - -nographic > "${WORKING_DIR}/qemu_deployment.log" & - -for _ in {1..60}; do - if sshpass -p linux ssh -o StrictHostKeyChecking=no -o ConnectTimeout=1 -p 2222 root@localhost true 2>/dev/null; then - break - fi - sleep 1 -done - -for src in "${DEPLOY_SRCS[@]}"; do - sshpass -p linux scp -rp -o StrictHostKeyChecking=no -P 2222 "${src}" root@localhost:/ - sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "tar -xf /$(basename "${src}") -C /" - sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "rm -f /$(basename "${src}")" -done - -# Enable root login and empty passwords for integration testing, not for production use. -sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "printf 'PermitRootLogin yes\nPermitEmptyPasswords yes\nPasswordAuthentication yes\n' > /etc/ssh/sshd_config.d/99-integration-test.conf" -sshpass -p linux ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "sed -i 's/^root:[^:]*:/root::/' /etc/shadow && sync && crinit-ctl poweroff" || true - -if [[ -f "${WORKING_DIR}/qemu.pid" ]]; then - wait "$(cat "${WORKING_DIR}/qemu.pid")" 2>/dev/null || true - rm -f "${WORKING_DIR}/qemu.pid" -fi diff --git a/test/resources/ebclfsa_aarch64/config-overlay/etc/config/network/network b/test/resources/ebclfsa_aarch64/config-overlay/etc/config/network/network deleted file mode 100644 index f2a81178..00000000 --- a/test/resources/ebclfsa_aarch64/config-overlay/etc/config/network/network +++ /dev/null @@ -1,12 +0,0 @@ -config interface 'loopback' - option device 'lo' - option proto 'static' - option ipaddr '127.0.0.1' - option netmask '255.0.0.0' - -config interface 'lan' - option device 'eth0' - option proto 'static' - option ipaddr '169.254.158.190' - option netmask '255.255.0.0' - option gateway '169.254.21.88' diff --git a/test/resources/ebclfsa_aarch64/qemu_config.json b/test/resources/ebclfsa_aarch64/qemu_config.json deleted file mode 100644 index 9c7237b9..00000000 --- a/test/resources/ebclfsa_aarch64/qemu_config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "networks": [ - { - "name": "tap0", - "ip_address": "169.254.158.190", - "gateway": "169.254.21.88" - } - ], - "ssh_port": 22, - "qemu_num_cores": 2, - "qemu_ram_size": "1G", - "qemu_machine": "virt-aarch64", - "qemu_kernel_cmdline": "root=/dev/vda1 sdk_enable lisa_syscall_whitelist=2026 rw sharedmem.enable_sharedmem=0 init=/usr/bin/ebclfsa-cflinit" -}