From 7e6834ba5eff5c0e61891ec1935e5e0ca8291c2f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 12:32:23 -0300 Subject: tests on FreeBSD: Linux's /proc/1 fixtures, the builtins lists, daemon.py and fs.py without /proc - The refusing directory some tests name is Linux's /proc/1/root: that part skips elsewhere. The committed builtins-*.json are Linux builds' (Tty9p): their check skips, and a key the docs give a word this build leaves out is found in the other's list. - kitty: a shared memory object is sized before it is written (FreeBSD's write does not grow it); a FIFO in /dev/shm is Linux's case. - daemon.py asks ps and procstat where there is no /proc, and finds bash on PATH. fs.py runs printenv once a name, and skips two permission checks as root, who searches and writes anywhere. Co-Authored-By: Claude Opus 5.5 --- test/daemon.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/daemon.py') diff --git a/test/daemon.py b/test/daemon.py index bf3d237c..f4f46286 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -94,10 +94,21 @@ def run(client, serial, line): client.close(fid) +# FreeBSD has no /proc: ps and procstat answer instead. +procfs = os.path.isdir('/proc/self') + + +def ps(*args): + return subprocess.run(['ps', *args], capture_output=True).stdout + + def processes(root): """The pids whose environment is this run's (its runtime directory).""" found = [] mark = f'XDG_RUNTIME_DIR={root}'.encode() + if not procfs: # ps -e prints each environment before its command + return [int(row.split()[0]) for row in ps('-axeww', '-o', 'pid=', '-o', 'command=').splitlines() + if mark in row.split()] for entry in os.listdir('/proc'): if not entry.isdigit(): continue @@ -111,6 +122,8 @@ def processes(root): def cmdline(pid): + if not procfs: + return ps('-ww', '-o', 'args=', '-p', str(pid)).split() try: return open(f'/proc/{pid}/cmdline', 'rb').read().split(b'\0') except OSError: @@ -122,6 +135,8 @@ def alive(pid): os.kill(pid, 0) except ProcessLookupError: return False + if not procfs: + return not ps('-o', 'state=', '-p', str(pid)).startswith(b'Z') try: state = open(f'/proc/{pid}/stat').read().rsplit(')', 1)[1].split()[0] except OSError: @@ -130,6 +145,8 @@ def alive(pid): def fds(pid): + if not procfs: + return len(subprocess.run(['procstat', '-f', str(pid)], capture_output=True).stdout.splitlines()) - 1 try: return len(os.listdir(f'/proc/{pid}/fd')) except OSError: @@ -146,7 +163,7 @@ def main(binary, cycles): root = Path(tempfile.mkdtemp(prefix='rt-', dir=scratch)) env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), - TERM='xterm-256color', SHELL='/bin/bash', PARDES_NOTIME='1') + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') daemon_sock = root / 'pardes-daemon.sock' -- cgit v1.3