CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
77 lines
2.6 KiB
Python
Executable File
77 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# ===----------------------------------------------------------------------===##
|
|
#
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
#
|
|
# ===----------------------------------------------------------------------===##
|
|
|
|
"""qemu_baremetal.py is a utility for running a program with QEMU's system mode.
|
|
|
|
It is able to pass command line arguments to the program and forward input and
|
|
output (if the underlying baremetal enviroment supports QEMU semihosting).
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
import shutil
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--qemu", type=str, required=True)
|
|
parser.add_argument("--cpu", type=str, required=False)
|
|
parser.add_argument("--machine", type=str, default="virt")
|
|
parser.add_argument(
|
|
"--qemu-arg", dest="qemu_args", type=str, action="append", default=[]
|
|
)
|
|
parser.add_argument("--semihosting", action="store_true", default=True)
|
|
parser.add_argument("--no-semihosting", dest="semihosting", action="store_false")
|
|
parser.add_argument("--execdir", type=str, required=True)
|
|
parser.add_argument("test_binary")
|
|
parser.add_argument("test_args", nargs=argparse.ZERO_OR_MORE, default=[])
|
|
args = parser.parse_args()
|
|
|
|
if not shutil.which(args.qemu):
|
|
sys.exit(f"Failed to find QEMU binary from --qemu value: '{args.qemu}'")
|
|
|
|
if not os.path.exists(args.test_binary):
|
|
sys.exit(f"Expected argument to be a test executable: '{args.test_binary}'")
|
|
|
|
qemu_commandline = [
|
|
args.qemu,
|
|
"-chardev",
|
|
"stdio,mux=on,id=stdio0",
|
|
"-monitor",
|
|
"none",
|
|
"-serial",
|
|
"none",
|
|
"-machine",
|
|
f"{args.machine},accel=tcg",
|
|
"-device",
|
|
f"loader,file={args.test_binary},cpu-num=0",
|
|
"-nographic",
|
|
*args.qemu_args,
|
|
]
|
|
if args.cpu:
|
|
qemu_commandline += ["-cpu", args.cpu]
|
|
|
|
if args.semihosting:
|
|
# Use QEMU's semihosting support to pass argv (supported by picolibc)
|
|
semihosting_config = f"enable=on,chardev=stdio0,arg={args.test_binary}"
|
|
for arg in args.test_args:
|
|
semihosting_config += f",arg={arg}"
|
|
qemu_commandline += ["-semihosting-config", semihosting_config]
|
|
elif args.test_args:
|
|
sys.exit(
|
|
"Got non-empty test arguments but do no know how to pass them to "
|
|
"QEMU without semihosting support"
|
|
)
|
|
os.execvp(qemu_commandline[0], qemu_commandline)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit(main())
|