Skip to content
Open
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
63 changes: 63 additions & 0 deletions .github/scripts/run_qemu_and_verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Unified QEMU runner for Zephyr CI.
# Uses `west build -t run` to launch the emulator with a timeout,
# and verifies expected strings appear in the output.
#
# Usage: run_qemu_and_verify.sh <build_dir> <timeout_seconds> <expected_string> [expected_string ...]

set -euo pipefail

if [ "$#" -lt 3 ]; then
echo "Usage: $0 <build_dir> <timeout_seconds> <expected_string> [expected_string ...]"
exit 1
fi

BUILD_DIR="$1"
TIMEOUT_SECONDS="$2"
shift 2
EXPECTED_STRINGS=("$@")

if [ ! -d "$BUILD_DIR" ]; then
echo "Error: build directory not found at $BUILD_DIR"
exit 1
fi

echo "=== Running 'west build -t run' with ${TIMEOUT_SECONDS}s timeout ==="

LOG_FILE=$(mktemp /tmp/qemu_output.XXXXXX)
trap "rm -f $LOG_FILE" EXIT

# Run the emulator via west. Exit code 124 means timeout — that's expected since
# Zephyr doesn't shut down the emulator. Any other non-zero exit is also fine
# for some boards (e.g., x86 with isa-debug-exit returns 1).
set +e
timeout "${TIMEOUT_SECONDS}s" west build -t run --build-dir "$BUILD_DIR" 2>&1 | tee "$LOG_FILE"
WEST_EXIT=${PIPESTATUS[0]}
set -e

echo "=== west exited with code $WEST_EXIT ==="

# Verify expected strings
FAILED=0
for expected in "${EXPECTED_STRINGS[@]}"; do
if grep -qF "$expected" "$LOG_FILE"; then
echo "PASS: found '$expected'"
else
echo "FAIL: missing '$expected'"
FAILED=1
fi
done

if [ "$FAILED" -ne 0 ]; then
echo ""
echo "=== Full output ==="
cat "$LOG_FILE"
echo "=== End of output ==="
exit 1
fi

echo "=== All expected strings found ==="
46 changes: 0 additions & 46 deletions .github/scripts/run_qemu_arc.sh

This file was deleted.

76 changes: 35 additions & 41 deletions .github/workflows/compilation_on_zephyr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ permissions:
jobs:
smoke_test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# -- Architecture --
arch:
- name: ARC
board: qemu_arc/qemu_arc_hs
target: ARC
toolchains: arc-zephyr-elf:arc64-zephyr-elf
- name: x86-32
board: qemu_x86
target: X86_32
toolchains: x86_64-zephyr-elf
# -- Sample variant --
sample:
- name: simple
path: simple
extra_cmake: ""
verify: '"Hello world!" "elapsed"'
- name: user-mode
path: user-mode
extra_cmake: ""
verify: '"Hello world!" "elapsed"'
- name: user-mode prebuilt
path: user-mode
extra_cmake: "-DWAMR_USE_PREBUILT_LIB=1"
verify: '"Hello world!" "elapsed"'
name: ${{ matrix.sample.name }} (${{ matrix.arch.name }})
container:
# For Zephyr 3.7 LTS, use the v0.26-branch or the latest v0.26.x release Docker image.
# ci require a larger runner to avoid "no space left on device"
Expand Down Expand Up @@ -94,50 +122,16 @@ jobs:
app-path: application
manifest-file-name: west_lite.yml
sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
toolchains: arc-zephyr-elf:arc64-zephyr-elf
toolchains: ${{ matrix.arch.toolchains }}

- name: Build a sample application(simple)
- name: Build and run
shell: bash
run: |
pushd product-mini/platforms/zephyr/simple
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
pushd product-mini/platforms/zephyr/${{ matrix.sample.path }}
west build . -b ${{ matrix.arch.board }} -p always -- \
-DWAMR_BUILD_TARGET=${{ matrix.arch.target }} ${{ matrix.sample.extra_cmake }}
popd

# west build -t run will fork several processes, which will cause the job to hang.
# run in the background and kill it after 5 seconds
.github/scripts/run_qemu_arc.sh \
../../zephyr-sdk \
product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
sleep 5
pkill qemu-system-arc
working-directory: modules/wasm-micro-runtime

- name: Build a sample application(user-mode)
shell: bash
run: |
pushd product-mini/platforms/zephyr/user-mode
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
popd

# west build -t run will fork several processes, which will cause the job to hang.
# run in the background and kill it after 5 seconds
.github/scripts/run_qemu_arc.sh \
../../zephyr-sdk \
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
sleep 5
pkill qemu-system-arc
working-directory: modules/wasm-micro-runtime

- name: Build a sample application(user-mode, prebuilt library approach)
shell: bash
run: |
pushd product-mini/platforms/zephyr/user-mode
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC -DWAMR_USE_PREBUILT_LIB=1
popd

.github/scripts/run_qemu_arc.sh \
../../zephyr-sdk \
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
sleep 5
pkill qemu-system-arc
.github/scripts/run_qemu_and_verify.sh \
product-mini/platforms/zephyr/${{ matrix.sample.path }}/build 10 ${{ matrix.sample.verify }}
working-directory: modules/wasm-micro-runtime
5 changes: 5 additions & 0 deletions product-mini/platforms/zephyr/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ target_sources(app PRIVATE
${WAMR_RUNTIME_LIB_SOURCE}
src/main.c)

# Suppress -Wtype-limits warnings originating from Zephyr's own headers
# (e.g. net_if.h "comparison is always true due to limited range of data type").
# Pulled in transitively via platform_internal.h → net_pkt.h → net_if.h.
target_compile_options(app PRIVATE -Wno-type-limits)

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ zephyr_library_sources (
wamr_lib.c
)

# Suppress -Wtype-limits warnings originating from Zephyr's own headers
# (e.g. net_if.h:861 "comparison is always true due to limited range of data type").
# These are pulled in transitively via platform_internal.h → net_pkt.h → net_if.h
# and cannot be fixed in WAMR source code.
zephyr_library_compile_options(-Wno-type-limits)

# Ensure generated headers (e.g. heap_constants.h) are ready before compiling
# the library. Zephyr adds this dependency for its own libraries automatically,
# but parallel builds can race when the library is added via add_subdirectory.
Expand Down
Loading