qemu-system-test-runner
БесплатноБез исполняемых скриптовНе проверенUse when embedded tests must run on a virtual MCU or SoC instead of the host or real hardware, for correct endianness, alignment and interrupts…
от testland★ 18 звёзд на GitHubОб этом скилле
qemu-system-test-runner
Overview
QEMU system emulation (per
qemu.org system docs)
runs cross-compiled ELF test binaries on virtual MCUs and SoCs.
The embedded-relevant binaries are qemu-system-arm,
qemu-system-aarch64, qemu-system-riscv32, and
qemu-system-riscv64.
In an embedded test pipeline QEMU sits between the host build
(fast, but misses arch-specific behaviour) and the physical
hardware-in-loop rig (slow, expensive). A cross-compiled
GoogleTest or Unity binary runs under QEMU with semihosting; the
test's main() returns the failure count; QEMU exits with that
code; CI gates on it.
Composes with:
googletest-embedded-arm- cross-compiled C++ test binary.unity-test-framework-c- cross-compiled C test binary.ceedling-build-runner- Ceedling project configured for ARM cross-compile.hardware-in-loop-reference- the next rung up the V-cycle (PIL / HIL).
When to use
- Host tests pass but you suspect arch-specific bugs (endianness, alignment, interrupt-vector ordering, weak-symbol resolution).
- Physical HIL is expensive / scheduled - QEMU is the V-cycle PIL stage between SIL and HIL.
- The team wants reproducible "on-target" tests in CI without flashing a real board.
- Cross-compile target is one of QEMU's supported boards (Cortex-M3/M4/M7/M33 via mps2-* boards; Cortex-A* via virt / raspi / zynq; RISC-V via virt).
QEMU does not emulate analog I/O, sensor wiring, or
real-time timing precisely - for that, escalate to a real HIL
rig per
hardware-in-loop-reference.
Authoring
Machine + CPU selection
Match the machine to the CPU profile: mps2-* boards for
M-profile cores, virt for A-profile and RISC-V. The common
Cortex-M mapping:
| Test target | QEMU command | Typical -cpu |
|---|---|---|
| Cortex-M0 / M0+ | qemu-system-arm -M mps2-an385 |
cortex-m0 |
| Cortex-M3 | qemu-system-arm -M mps2-an385 |
cortex-m3 (board default) |
| Cortex-M4 | qemu-system-arm -M mps2-an386 |
cortex-m4 |
The full machine list, the A-profile / Raspberry Pi / Xilinx
targets, and the max CPU note are in
references/boards.md.
Booting the test ELF
For an embedded test, load the ELF with -kernel and send serial
to the console with -nographic. The full invocation flag table
(-M, -cpu, -smp, -m, -bios, -serial, -monitor,
-qmp), per
invocation.html,
is in references/flags.md.
ARM semihosting
The critical flag for cross-compiled test binaries:
-semihosting-config [enable=on|off][,target=native|gdb|auto][,chardev=name][,arg=string]
Per the same invocation page, semihosting "allows direct host
system calls and I/O operations". When the test ELF was linked
with --specs=rdimon.specs, printf and exit() from the
binary go through ARM semihosting calls; with
-semihosting-config enable=on,target=native QEMU services those
calls against the host.
Practically: the test binary's main() returns the failure
count; the C runtime calls _exit(rc); QEMU exits with rc. CI
gates on $?.
Building (the test binary side)
The test side is covered in
googletest-embedded-arm
and
unity-test-framework-c;
the canonical Cortex-M4 build:
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -O0 -g \
--specs=rdimon.specs \
test/test_ringbuffer.c test/test_ringbuffer_Runner.c \
src/ringbuffer.c ext/Unity/src/unity.c \
-o build/test.elf -lrdimon
-lrdimon links the ARM semihosting library
(developer.arm.com GNU Toolchain).
--specs=rdimon.specs pulls in startup code that wires printf
/ _write / _exit to the semihosting interface.
Running
Smoke run
qemu-system-arm -M mps2-an386 -cpu cortex-m4 \
-nographic \
-semihosting-config enable=on,target=native \
-kernel build/test.elf
Output (Unity-style):
test/test_ringbuffer.c:34:test_ringbuffer_initially_empty:PASS
test/test_ringbuffer.c:42:test_ringbuffer_push_increments_size:PASS
-----------------------
2 Tests 0 Failures 0 Ignored
OK
Exit code: 0 (or the failure count for Unity / GoogleTest).
Inspecting boot / interrupt behaviour
Per the invocation page, -d "activates debug logging for
specified subsystems":
qemu-system-arm -M mps2-an386 -cpu cortex-m4 \
-nographic -semihosting-config enable=on,target=native \
-d int,cpu_reset,unimp \
-kernel build/test.elf 2> qemu-debug.log
-d help lists the available items. int traces interrupts;
cpu_reset traces resets; unimp traces unimplemented
features (board-quirk hunts).
GDB-attached debug
# Terminal 1
qemu-system-arm -M mps2-an386 -cpu cortex-m4 -nographic \
-semihosting-config enable=on,target=native \
-S -gdb tcp::1234 \
-kernel build/test.elf
# Terminal 2
arm-none-eabi-gdb build/test
Установить qemu-system-test-runner в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл qemu-system-test-runner?
Use when embedded tests must run on a virtual MCU or SoC instead of the host or real hardware, for correct endianness, alignment and interrupts: qemu-system-arm, aarch64 and riscv32 machine and CPU flags, loading ELF binaries, semihosting exit codes, GDB and QMP, and CI.
Как установить скилл qemu-system-test-runner?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл qemu-system-test-runner запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic