Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
target = "aarch64-unknown-none-softfloat"

[target.aarch64-unknown-none-softfloat]
runner = "scripts/qemu-runner.sh"
runner = "scripts/qemu_runner.py"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
- name: Run tests
if: ${{ matrix.smp-feature == '' }}
run: |
cargo run -r --no-default-features -- /bin/usertest >> usertest.log
cargo run -r --no-default-features -- --init /bin/usertest >> usertest.log
cargo test -r --no-default-features >> unittest.log
# If any feature is enabled
- name: Run tests
if: ${{ matrix.smp-feature == 'smp' }}
run: |
cargo run -r --no-default-features --features "${{ matrix.smp-feature }}" -- /bin/usertest >> usertest.log
cargo run -r --no-default-features --features "${{ matrix.smp-feature }}" -- --init /bin/usertest >> usertest.log
cargo test -r --no-default-features --features "${{ matrix.smp-feature }}" >> unittest.log
- name: Display usertest output
run: cat usertest.log
Expand Down
26 changes: 0 additions & 26 deletions scripts/qemu-runner.sh

This file was deleted.

56 changes: 56 additions & 0 deletions scripts/qemu_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3

import argparse
import subprocess

parser = argparse.ArgumentParser(description="QEMU runner")

parser.add_argument("elf_executable", help="Location of compiled ELF executable to run")
# QEMU options
parser.add_argument("--init", default="/bin/sh", help="Location of the init process (in the rootfs)")
parser.add_argument("--rootfs", default="moss.img", help="Location of the root filesystem image to use")
parser.add_argument("--cpu", default="cortex-a72")
parser.add_argument("--smp", default=4, help="Number of CPU cores to use")
parser.add_argument("--memory", default="2G")
parser.add_argument("--debug", action="store_true", help="Enable QEMU debugging")



args = parser.parse_args()


elf_executable = args.elf_executable
bin_executable_location = elf_executable.replace(".elf", "") + ".bin"
# Convert the ELF executable to a binary format
subprocess.run(["aarch64-none-elf-objcopy", "-O", "binary", elf_executable, bin_executable_location], check=True)

append_args = ""

if args.init.split("/")[-1] in ["bash", "sh"]:
append_args = f"--init={args.init} --init-arg=-i"
else:
append_args = f"--init={args.init}"

default_args = {
"-M": "virt,gic-version=3",
"-initrd": args.rootfs,
"-cpu": args.cpu,
"-m": args.memory,
"-smp": str(args.smp),
"-nographic": None,
"-s": None,
"-kernel": bin_executable_location,
"-append": f"{append_args} --rootfs=ext4fs --automount=/dev,devfs --automount=/tmp,tmpfs --automount=/proc,procfs --automount=/sys,sysfs"
}

if args.debug:
default_args["-S"] = None

qemu_command = ["qemu-system-aarch64"]

for key, value in default_args.items():
qemu_command.append(key)
if value is not None:
qemu_command.append(value)

subprocess.run(qemu_command, check=True)
Loading