From d434e8eb909a0a45cd2a23636a66383dec931cf9 Mon Sep 17 00:00:00 2001 From: VasilyZa <450270247@qq.com> Date: Mon, 23 Nov 2026 19:32:00 +0800 Subject: [PATCH 1/3] kernel: pin asynchronous serial logging and adapt integration tests Use visible readiness and explicit test results in place of routine kernel DEBUG messages. Enable the required diagnostics on private test disks only. --- kernel/reliefnt | 2 +- tools/test_fltk_apps_qemu.py | 16 ++++++++++++-- tools/test_installer_accounts_qemu.py | 4 ++-- tools/test_linux_ioctl_cloexec.py | 2 +- tools/test_openrc_gui.py | 9 ++++++-- tools/test_pam_desktop_qemu.py | 31 +++++++-------------------- tools/test_pam_login_switch_qemu.py | 5 +++-- tools/test_reliefmail_ca_qemu.py | 3 ++- tools/test_vga_text_qemu.py | 6 ------ tools/test_vt_installer_qemu.py | 18 +++------------- 10 files changed, 41 insertions(+), 55 deletions(-) diff --git a/kernel/reliefnt b/kernel/reliefnt index 0591a921..8dd4d8b6 160000 --- a/kernel/reliefnt +++ b/kernel/reliefnt @@ -1 +1 @@ -Subproject commit 0591a921e10f738de558551b23775d92c1d76fe3 +Subproject commit 8dd4d8b69ebe9edab0da345405a9c5311a42398a diff --git a/tools/test_fltk_apps_qemu.py b/tools/test_fltk_apps_qemu.py index b93d77dd..9814a4e2 100644 --- a/tools/test_fltk_apps_qemu.py +++ b/tools/test_fltk_apps_qemu.py @@ -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) @@ -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") @@ -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, diff --git a/tools/test_installer_accounts_qemu.py b/tools/test_installer_accounts_qemu.py index 38b4528c..2e47a418 100644 --- a/tools/test_installer_accounts_qemu.py +++ b/tools/test_installer_accounts_qemu.py @@ -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) diff --git a/tools/test_linux_ioctl_cloexec.py b/tools/test_linux_ioctl_cloexec.py index ff5658fe..9ce01e1b 100644 --- a/tools/test_linux_ioctl_cloexec.py +++ b/tools/test_linux_ioctl_cloexec.py @@ -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)), diff --git a/tools/test_openrc_gui.py b/tools/test_openrc_gui.py index 823e857c..5e048767 100644 --- a/tools/test_openrc_gui.py +++ b/tools/test_openrc_gui.py @@ -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] @@ -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') diff --git a/tools/test_pam_desktop_qemu.py b/tools/test_pam_desktop_qemu.py index f8b3060a..a5473308 100644 --- a/tools/test_pam_desktop_qemu.py +++ b/tools/test_pam_desktop_qemu.py @@ -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 @@ -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: diff --git a/tools/test_pam_login_switch_qemu.py b/tools/test_pam_login_switch_qemu.py index 58350449..744051e9 100644 --- a/tools/test_pam_login_switch_qemu.py +++ b/tools/test_pam_login_switch_qemu.py @@ -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" diff --git a/tools/test_reliefmail_ca_qemu.py b/tools/test_reliefmail_ca_qemu.py index 0e0ac3b8..1981024a 100755 --- a/tools/test_reliefmail_ca_qemu.py +++ b/tools/test_reliefmail_ca_qemu.py @@ -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 diff --git a/tools/test_vga_text_qemu.py b/tools/test_vga_text_qemu.py index b6967e25..f1e55943 100644 --- a/tools/test_vga_text_qemu.py +++ b/tools/test_vga_text_qemu.py @@ -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 diff --git a/tools/test_vt_installer_qemu.py b/tools/test_vt_installer_qemu.py index ca9f0108..80252b83 100644 --- a/tools/test_vt_installer_qemu.py +++ b/tools/test_vt_installer_qemu.py @@ -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 @@ -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) @@ -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') From 4c51bc1bf8d09f3cedb5d7614fb471350292d7b3 Mon Sep 17 00:00:00 2001 From: VasilyZa <450270247@qq.com> Date: Mon, 23 Nov 2026 19:37:46 +0800 Subject: [PATCH 2/3] kernel: pin COM1 host regression fixtures --- kernel/reliefnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/reliefnt b/kernel/reliefnt index 8dd4d8b6..ea95c786 160000 --- a/kernel/reliefnt +++ b/kernel/reliefnt @@ -1 +1 @@ -Subproject commit 8dd4d8b69ebe9edab0da345405a9c5311a42398a +Subproject commit ea95c786a84306b5ff31609bd722d5127cabdcfe From 3f3577573dd1120c4008999ba3c82f5dbfff6f81 Mon Sep 17 00:00:00 2001 From: VasilyZa <450270247@qq.com> Date: Mon, 23 Nov 2026 20:12:25 +0800 Subject: [PATCH 3/3] kernel: pin ReliefNT PR #39 merge commit --- kernel/reliefnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/reliefnt b/kernel/reliefnt index ea95c786..bdadb0bb 160000 --- a/kernel/reliefnt +++ b/kernel/reliefnt @@ -1 +1 @@ -Subproject commit ea95c786a84306b5ff31609bd722d5127cabdcfe +Subproject commit bdadb0bb53c294413e01fa0fe344571beecdf987