Skip to content
Closed
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
34 changes: 31 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
workflow_dispatch:
pull_request:
branches: [ master ]
branches: [master]

jobs:
build-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

# Use the toolchain from rust-toolchain.toml
- name: Install Rust
Expand All @@ -33,3 +33,31 @@ jobs:

- name: Run unit tests for libkernel
run: cargo test -p libkernel --target x86_64-unknown-linux-gnu --all-features

- name: Install dependencies
run: sudo apt update && sudo apt install qemu-system-aarch64 dosfstools mtools binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu

- name: Install arm GNU toolchain
run: |
wget https://developer.arm.com/-/media/Files/downloads/gnu/15.2.rel1/binrel/arm-gnu-toolchain-15.2.rel1-x86_64-aarch64-none-elf.tar.xz
tar -xf arm-gnu-toolchain-15.2.rel1-x86_64-aarch64-none-elf.tar.xz
mv arm-gnu-toolchain-15.2.rel1-x86_64-aarch64-none-elf arm-gnu-toolchain
echo "${{ github.workspace }}/arm-gnu-toolchain/bin" >> $GITHUB_PATH

- name: Build Image
run: |
wget https://github.com/arihant2math/prebuilt-musl/raw/refs/heads/main/aarch64-linux-musl-cross.tgz
mkdir build
mv aarch64-linux-musl-cross.tgz ./build/
ls
./scripts/build-deps.sh
./scripts/create-image.sh

- name: Upload Image
uses: actions/upload-artifact@v6
with:
name: image
path: moss.img

- name: Run userspace testing
run: CARGO_TARGET_AARCH64_UNKNOWN_NONE_SOFTFLOAT_RUNNER=./scripts/qemu-test-runner.sh cargo run -r
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.img
.idea/
.vscode/
test_output.log
22 changes: 22 additions & 0 deletions scripts/qemu-test-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

base="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"

elf="$1"
bin="${elf%.elf}.bin"

# Locate a suitable objcopy implementation (prefer bare-metal, fall back to linux/llvm/rust versions)
OBJCOPY=${OBJCOPY:-$(command -v aarch64-none-elf-objcopy \
|| command -v aarch64-linux-gnu-objcopy \
|| command -v llvm-objcopy \
|| command -v rust-objcopy)}

if [[ -z "$OBJCOPY" ]]; then
echo "Error: no compatible aarch64 objcopy found (looked for aarch64-none-elf-objcopy, aarch64-linux-gnu-objcopy, llvm-objcopy, rust-objcopy)." >&2
exit 1
fi

# Convert to binary format
"$OBJCOPY" -O binary "$elf" "$bin"
qemu-system-aarch64 -M virt,gic-version=3 -initrd moss.img -cpu cortex-a72 -m 2G -smp 4 -nographic -s -kernel "$bin" -append "--init=/usertest --rootfs=fat32fs --automount=/dev,devfs --automount=/tmp,tmpfs"
Loading