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 kernel/reliefnt
Submodule reliefnt updated 39 files
+14 −3 Documentation/admin-guide/boot.rst
+11 −8 Documentation/locale/en/LC_MESSAGES/admin-guide/boot.po
+11 −7 Documentation/locale/ja/LC_MESSAGES/admin-guide/boot.po
+1 −7 arch/x86_64/interrupt/idt.c
+9 −0 arch/x86_64/interrupt/irq.c
+3 −0 arch/x86_64/platform/power.c
+24 −65 drivers/console/core.c
+2 −6 drivers/console/internal.h
+241 −179 drivers/console/log.c
+2 −0 drivers/console/panic.c
+0 −1 drivers/console/vga_console.c
+3 −3 drivers/tty/serial/Kconfig
+8 −57 drivers/tty/serial/serial_main.c
+17 −24 include/reliefnt/console.h
+54 −0 include/reliefnt/serial.h
+1 −1 kernel/device/Kbuild
+0 −40 kernel/device/early_serial.c
+2 −46 kernel/device/manager_internal.h
+7 −5 kernel/device/registry.c
+319 −0 kernel/device/serial_tx.c
+4 −33 kernel/device/services.c
+0 −4 kernel/exec/userland.c
+11 −9 kernel/init/kernel.c
+14 −11 kernel/syscall/device/device_io.c
+3 −2 kernel/syscall/entry.c
+13 −2 kernel/syscall/event/poll.c
+1 −1 kernel/syscall/io/io.c
+11 −0 tools/test_console.py
+1 −2 tools/tests/console_replay_test.c
+4 −1 tools/tests/descriptor_table_test.c
+3 −0 tools/tests/keyboard_irq_ready_test.c
+18 −0 tools/tests/modules/console.h
+1 −1 tools/tests/modules/driver_manager.h
+2 −0 tools/tests/panic_console_runtime_test.c
+3 −0 tools/tests/ps2_interleaved_irq_test.c
+143 −0 tools/tests/serial_tx_test.c
+1 −1 tools/tests/syscall_io_test.c
+2 −2 tools/tests/vga_console_test.c
+43 −4 tools/tests/vt_console_test.c
16 changes: 14 additions & 2 deletions tools/test_fltk_apps_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ def clone_private_raw(image: Path, output: Path) -> Path:


def prepare_disk(image: Path, kernel: Path, output: Path,
payload: list[tuple[Path, str, int]]) -> dict[str, object]:
payload: list[tuple[Path, str, int]], *,
trace_exec: bool = False) -> dict[str, object]:
image_hash_before = sha256(image)
raw = clone_private_raw(image, output)
partitions = vdso.gpt_partitions(raw)
Expand All @@ -485,6 +486,17 @@ def prepare_disk(image: Path, kernel: Path, output: Path,
injected = inject_payload(root_image, output, payload)
vdso.put_root_back(raw, root_image, layout)
kernel_hashes = vdso.install_private_kernel(raw, int(layout["esp_first"]), kernel, output)
if trace_exec:
# Process events are DEBUG. Enable them only in this private VM image.
esp_image = f"{raw}@@{int(layout['esp_first']) * vdso.PAGE_SIZE}"
grub = output / "probe-grub.cfg"
run(["mcopy", "-i", esp_image, "::/grub/grub.cfg", grub])
traced, count = re.subn(r"^([ \t]*multiboot2 [^\r\n]*\S)[ \t]*$",
r"\1 loglevel=8", grub.read_text(), flags=re.MULTILINE)
if not count:
raise ValueError("private boot configuration has no multiboot2 entries")
grub.write_text(traced)
run(["mcopy", "-o", "-i", esp_image, grub, "::/grub/grub.cfg"])
image_hash_after = sha256(image)
if image_hash_before != image_hash_after:
raise RuntimeError("source image changed while preparing private disk")
Expand Down Expand Up @@ -1969,7 +1981,7 @@ def main() -> int:
required_needed=("libfltk.so.1.3", "libstdc++.so.6",
"libgcc_s.so.1"))
payload = payload_files(output, probe)
disk = prepare_disk(image, kernel, output, payload)
disk = prepare_disk(image, kernel, output, payload, trace_exec="fileman" in args.apps)
metadata: dict[str, object] = {
"started_utc": datetime.now(timezone.utc).isoformat(),
"input_image_sha256": source_image_hash, "disk": disk,
Expand Down
4 changes: 2 additions & 2 deletions tools/test_installer_accounts_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ def shutdown_after_login(probe, process, *, root):


def login_desktop(probe, serial, process):
wait_log(serial, "path=/usr/lib/reliefos/apps/login/login.elf", process)
time.sleep(5)
from test_xorg_vm_qemu import wait_greeter_stage
wait_greeter_stage(probe, process, "login", "login-ready", timeout=90)
probe.frame("login")
probe.key("down")
probe.text(USER_PASSWORD)
Expand Down
2 changes: 1 addition & 1 deletion tools/test_linux_ioctl_cloexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def artifact(*names: str) -> str:

kernel = artifact("build/system/kernel.sys", "out/x86_64/release/generated/system/kernel.sys")
font = artifact("build/generated/grub/leonos-unicode.pf2", "out/x86_64/release/generated/grub/leonos-unicode.pf2")
config.write_text(GRUB_TEMPLATE, encoding="ascii")
config.write_text(GRUB_TEMPLATE.replace(" root=/", " root=/ loglevel=8", 1), encoding="ascii")
assert "bootlog=1" not in config.read_text(encoding="ascii")
run([
sys.executable, "tools/make_installer_iso.py", "--out", str(output.relative_to(ROOT)),
Expand Down
9 changes: 7 additions & 2 deletions tools/test_openrc_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
from test_sudo_e2e_qemu import Probe, type_line
from test_installer_window_qemu import wait_log
from test_xorg_vm_qemu import wait_greeter_stage
from run_gcc_probe_qemu import qmp_quit

ROOT = Path(__file__).resolve().parents[1]
Expand All @@ -36,9 +37,13 @@ def main():
process = subprocess.Popen(command,stdout=log,stderr=subprocess.STDOUT)
probe = None
try:
wait_log(serial, 'path=/usr/lib/reliefos/apps/login/login.elf', process, timeout=90)
time.sleep(5)
deadline = time.monotonic() + 10
while not qmp.exists():
if process.poll() is not None or time.monotonic() >= deadline:
raise RuntimeError("QEMU QMP socket did not become ready")
time.sleep(.05)
probe = Probe(qmp,work)
wait_greeter_stage(probe, process, 'login', 'login-ready', timeout=90)
probe.frame('login')
probe.key('down')
probe.text('test')
Expand Down
31 changes: 8 additions & 23 deletions tools/test_pam_desktop_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""Exercise PAM login and Terminal startup on a disposable copy of a raw disk."""
import argparse
import json
import re
from pathlib import Path
import subprocess
import time
Expand Down Expand Up @@ -90,38 +89,24 @@ def main():
probe.key("ret")
time.sleep(5)
probe.frame("terminal-identity")
probe.text("cat /tmp/pam-uid /tmp/flock-result; sync")
probe.text("cat /tmp/pam-uid /tmp/flock-result; sync && echo PAM_DESKTOP_SYNCED >/dev/ttyS0")
probe.key("ret")
wait_log(serial, "name=sync code=0", process, timeout=30)
wait_log(serial, "PAM_DESKTOP_SYNCED", process, timeout=30)
time.sleep(1)
probe.frame("terminal-results")
if args.core:
sudo_offset = len(serial.read_text(errors="replace"))
probe.text("sudo -k; sudo -p CORE_PASSWORD /bin/su -c '/bin/core-probe --sudo-child' > /tmp/core-sudo 2>&1; echo CORE_EXIT=$? >> /tmp/core-sudo")
probe.text("sudo -k; sudo -p CORE_PASSWORD /bin/su -c '/bin/core-probe --sudo-child' "
"> /tmp/core-sudo 2>&1; echo CORE_EXIT=$? >> /tmp/core-sudo; "
"echo PAM_DESKTOP_SUDO_DONE >/dev/ttyS0")
probe.key("ret")
# The prompt is redirected to the guest file; allow sudo to open /dev/tty.
time.sleep(4)
probe.text(password)
probe.key("ret")
deadline = time.monotonic() + 45
while True:
log = serial.read_text(errors="replace")[sudo_offset:]
parents = re.findall(r"exec pid=(\d+) path=/usr/bin/sudo ", log)
if len(parents) >= 2 and re.search(
rf"scheduler wait reaped pid={parents[1]} by pid=\d+", log):
break
if process.poll() is not None or time.monotonic() >= deadline:
raise AssertionError("sudo did not return to its calling shell")
time.sleep(.2)
time.sleep(1)
sync_count = serial.read_text(errors="replace").count("name=sync code=0")
probe.text("cat /tmp/core-sudo; sync")
wait_log(serial, "PAM_DESKTOP_SUDO_DONE", process, timeout=45)
probe.text("cat /tmp/core-sudo; sync && echo PAM_DESKTOP_CORE_SYNCED >/dev/ttyS0")
probe.key("ret")
deadline = time.monotonic() + 30
while serial.read_text(errors="replace").count("name=sync code=0") <= sync_count:
if process.poll() is not None or time.monotonic() >= deadline:
raise AssertionError("sudo result sync did not complete")
time.sleep(.2)
wait_log(serial, "PAM_DESKTOP_CORE_SYNCED", process, timeout=30)
time.sleep(1)
probe.frame("sudo-core-results")
except Exception:
Expand Down
5 changes: 3 additions & 2 deletions tools/test_pam_login_switch_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def login_case(output, disk, wrong_password=False):
command = ("grep -E '^(Uid|Gid):' /proc/self/status > /tmp/login-switch-identity; "
"printf 'Groups: ' >> /tmp/login-switch-identity; "
"id -G >> /tmp/login-switch-identity; "
"pwd >> /tmp/login-switch-identity; cat /tmp/login-switch-identity; sync")
"pwd >> /tmp/login-switch-identity; cat /tmp/login-switch-identity; "
"sync && echo PAM_SWITCH_SYNCED >/dev/ttyS0")
probe.text(command)
probe.key("ret")
wait_log(serial, "name=sync code=0", process, timeout=30)
wait_log(serial, "PAM_SWITCH_SYNCED", process, timeout=30)
time.sleep(1)
probe.frame("terminal-identity")
filesystem = output / "root-check.ext2"
Expand Down
3 changes: 2 additions & 1 deletion tools/test_reliefmail_ca_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def prepare(image, output, bundle, public, server_port):
(runner, '/usr/bin/mailcatest', 0o100755),
(probe, fltk.PROBE_GUEST, 0o100755),
(output / 'tls-probe.elf', '/usr/lib/reliefos/tests/mail-tls-probe', 0o100755)]
metadata = fltk.prepare_disk(image, OUT / 'generated/system/kernel.sys', output, payload)
metadata = fltk.prepare_disk(image, OUT / 'generated/system/kernel.sys', output,
payload, trace_exec=True)
(output / 'prepare.json').write_text(json.dumps(metadata, indent=2) + '\n')
return metadata

Expand Down
6 changes: 0 additions & 6 deletions tools/test_vga_text_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ def state():

def normal_login(probe,process,vt=2):
"""Capture the stock login shell before any terminal probe can clear it."""
offset=len(probe.serial.read_text(errors="replace"))
login_vt(probe,process,vt,fresh=True)
def automatic_fastfetch():
log=probe.serial.read_text(errors="replace")[offset:]
pids=re.findall(r"exec pid=(\d+) path=/usr/bin/fastfetch ",log)
return any(re.search(rf"task exited pid={pid} name=fastfetch code=0\b",log) for pid in pids)
wait(probe,process,automatic_fastfetch,"automatic-login-fastfetch",timeout=120)
wait(probe,process,lambda:all(s in text_cells(probe) for s in
(b"OS: ReliefOS",b"Shell: bash",b"test@reliefos:~$")),"normal-bash-prompt")
assert visible_text(probe,"02-tty-login") is not None
Expand Down
18 changes: 3 additions & 15 deletions tools/test_vt_installer_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""Exercise installer VT switching and optional installation on a new scratch disk."""
import argparse
from pathlib import Path
import re
import subprocess
import time

Expand Down Expand Up @@ -65,16 +64,9 @@ def main():
probe.text('echo TUI-EXIT-OK >/dev/ttyS0')
probe.key('ret')
wait_log(serial, 'TUI-EXIT-OK', process, 20)
before = serial.read_text().count(
'path=/usr/lib/reliefos/apps/login/login.elf')
probe.text('exit')
probe.text(r"printf '\033[2J\033[H'; exit")
probe.key('ret')
deadline = time.monotonic() + 30
while serial.read_text().count(
'path=/usr/lib/reliefos/apps/login/login.elf') <= before:
assert process.poll() is None and time.monotonic() < deadline, \
'the installer shell did not respawn after exit'
time.sleep(.2)
wait_text(probe, process, 'installer-tui-respawn', 'built-in shell')
probe.text('echo TUI-RESPAWN-OK >/dev/ttyS0')
probe.key('ret')
wait_log(serial, 'TUI-RESPAWN-OK', process, 20)
Expand All @@ -88,11 +80,7 @@ def main():
# installer-media fallthrough in console-session).
probe.key('ctrl-alt-f2')
wait_text(probe, process, 'exit-recovery-shell', 'built-in shell')
match = re.search(
r'exec pid=(\d+) path=/usr/bin/Xorg',
serial.read_text())
assert match, 'graphical session pid not recorded'
probe.text(f'kill {match[1]}')
probe.text('kill $(pidof Xorg)')
probe.key('ret')
time.sleep(2)
probe.frame('installer-session-killed')
Expand Down
Loading