Skip to content

Add karch:test

Add karch:test #183

Workflow file for this run

name: Unit Test
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
unittest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
name: Unit Test (${{ matrix.arch }})
env:
ARCH: ${{ matrix.arch }}
SMP: 4
steps:
- name: Checkout X-Kernel
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: xkernel-unittest-${{ matrix.arch }}
- name: Install musl toolchain for ${{ matrix.arch }}
uses: arceos-org/setup-musl@v1
with:
arch: ${{ matrix.arch }}
- name: Install QEMU
uses: arceos-org/setup-qemu@v1
with:
version: 10.1.0
arch_list: ${{ matrix.arch }}
- name: Prepare Rust toolchain
run: |
if [ "${{ matrix.arch }}" = "x86_64" ]; then
rustup target add x86_64-unknown-none
else
rustup target add aarch64-unknown-none
fi
rustup target list --installed | grep ${{ matrix.arch }}
- name: Download rootfs template
run: |
ROOTFS_VERSION=20250917
IMG_URL="https://github.com/Starry-OS/rootfs/releases/download/${ROOTFS_VERSION}"
echo "Downloading rootfs-${{ matrix.arch }}.img..."
curl -f -L "${IMG_URL}/rootfs-${{ matrix.arch }}.img.xz" -o rootfs-${{ matrix.arch }}.img.xz
xz -d rootfs-${{ matrix.arch }}.img.xz
cp rootfs-${{ matrix.arch }}.img disk.img
echo "Rootfs prepared: disk.img"
- name: Prepare .config
run: |
if [ "${{ matrix.arch }}" = "aarch64" ]; then
cp ./platforms/aarch64-qemu-virt/defconfig .config
elif [ "${{ matrix.arch }}" = "x86_64" ]; then
cp ./platforms/x86_64-qemu-virt/defconfig .config
fi
- name: Run kernel unit tests
run: |
timeout 120 make UNITTEST=y VSOCK=n run | tee unittest-output.log || true
if grep -q "UNITTEST_STATUS: TESTS_FAILED" unittest-output.log; then
echo "❌ Unit tests failed!"
echo "::error::Unit tests failed - see logs for details"
exit 1
fi
# Check for test success status message
if grep -q "UNITTEST_STATUS: ALL_TESTS_PASSED" unittest-output.log; then
echo "✅ Unit tests passed!"
exit 0
fi
# Check for kernel panic
if grep -q "panicked at" unittest-output.log; then
echo "❌ Kernel panicked during unit tests!"
echo "::error::Kernel panic detected"
exit 1
fi
# Fallback: check old-style test result output
if grep -q "test result:.*FAILED" unittest-output.log; then
echo "❌ Unit tests failed (legacy detection)!"
echo "::error::Unit tests failed"
exit 1
fi
if grep -q "test result: ok" unittest-output.log; then
echo "✅ Unit tests passed (legacy detection)!"
exit 0
fi
echo "⚠️ Unable to determine test result from output"
echo "::warning::Test status unclear - check logs"
exit 1
# - name: Upload test logs
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: unittest-logs-${{ matrix.arch }}-${{ github.run_id }}
# path: unittest-output.log
# if-no-files-found: warn