mirror of
https://github.com/Plexi09/Nadir-Kernel.git
synced 2026-10-20 15:07:27 +02:00
Added .github
This commit is contained in:
parent
7f91a9586a
commit
53f1295927
5 changed files with 144 additions and 0 deletions
67
.github/scripts/check_boot.py
vendored
Normal file
67
.github/scripts/check_boot.py
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
"""QEMU boot check for Nadir CI.
|
||||
|
||||
Runs the boot sector headless on a pseudo-terminal with the curses display,
|
||||
waits for the boot, then asserts the welcome message reached the screen.
|
||||
A garbage image (SeaBIOS "No bootable device") fails this check.
|
||||
|
||||
Usage: python3 .github/scripts/check_boot.py (from the repository root)
|
||||
Requires: qemu-system-x86_64 on PATH. Stdlib only.
|
||||
"""
|
||||
|
||||
import fcntl
|
||||
import os
|
||||
import pty
|
||||
import select
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import termios
|
||||
import time
|
||||
|
||||
IMAGE = "boot.bin"
|
||||
NEEDLE = b"Nadir"
|
||||
BOOT_WAIT_S = 8
|
||||
|
||||
|
||||
def main() -> int:
|
||||
master, slave = pty.openpty()
|
||||
fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack("HHHH", 24, 80, 0, 0))
|
||||
env = dict(os.environ, TERM="xterm")
|
||||
proc = subprocess.Popen(
|
||||
["qemu-system-x86_64", "-display", "curses", "-fda", IMAGE],
|
||||
stdin=slave,
|
||||
stdout=slave,
|
||||
stderr=subprocess.DEVNULL,
|
||||
env=env,
|
||||
)
|
||||
os.close(slave)
|
||||
time.sleep(BOOT_WAIT_S)
|
||||
proc.terminate()
|
||||
try:
|
||||
proc.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
proc.wait()
|
||||
fcntl.fcntl(master, fcntl.F_SETFL, os.O_NONBLOCK)
|
||||
data = b""
|
||||
while True:
|
||||
ready, _, _ = select.select([master], [], [], 1)
|
||||
if not ready:
|
||||
break
|
||||
try:
|
||||
chunk = os.read(master, 65536)
|
||||
except OSError:
|
||||
break
|
||||
if not chunk:
|
||||
break
|
||||
data += chunk
|
||||
os.close(master)
|
||||
if NEEDLE not in data:
|
||||
print(f"FAIL: {NEEDLE!r} not found on the QEMU screen")
|
||||
return 1
|
||||
print("OK: QEMU booted and printed the welcome message")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue