Skip to content

Add FreeBSD CI to replace Cirrus - #1663

Open
neilpang wants to merge 2 commits into
trifectatechfoundation:mainfrom
neilpang:ci/freebsd-vmactions
Open

Add FreeBSD CI to replace Cirrus#1663
neilpang wants to merge 2 commits into
trifectatechfoundation:mainfrom
neilpang:ci/freebsd-vmactions

Conversation

@neilpang

@neilpang neilpang commented Aug 2, 2026

Copy link
Copy Markdown

Closes #1543

Cirrus CI shut down on 2026-06-01, which removed the FreeBSD unit test
coverage. This runs the same test command in a FreeBSD VM booted under
QEMU/KVM on a regular ubuntu-latest runner, keeping the skips
.cirrus.yml carried. The suite runs as an unprivileged user, since
src/su/context.rs notes invalid_shell is allowed to fail under root
while the VM logs in as root.

Second commit: a test-only fix the job is blocked on

Enabling the job surfaced one failing test,
system::time::tests::get_process_start_time. It is a test-only regression,
not a defect in Process::starting_time:

  • On FreeBSD kinfo_proc.ki_start is absolute wall clock -- the kernel adds
    boottime in fill_kinfo_proc_only() before exporting it.
  • SystemTime::now() reads CLOCK_BOOTTIME, which on FreeBSD is an alias
    for the uptime clock (clock_gettime(2): "unrelated to the kern.boottime
    sysctl").

So the test compared an epoch-scale value against the VM's uptime and failed
deterministically on every FreeBSD run; the first assertion passed only
because its right-hand side was negative.

064de34 had handled exactly this with a #[cfg(test)]
ProcessCreateTime::now() that selects CLOCK_REALTIME on FreeBSD. The DRY
cleanup in 62d1d30 removed it and rebuilt the comparand by destructuring
SystemTime's fields into ProcessCreateTime, bypassing the newtype
separation 064de34 introduced -- a no-op on Linux, a guaranteed failure on
FreeBSD.

This restores that helper and documents why it cannot be folded into
SystemTime::now(), which must keep reading the monotonic clock per #1022.
Production code is untouched.

Verification

Before the test fix:
https://github.com/neilpang/sudo-rs/actions/runs/30707863594

test result: FAILED. 175 passed; 1 failed
failures: system::time::tests::get_process_start_time

After:
https://github.com/neilpang/sudo-rs/actions/runs/30730157525

test result: ok. 176 passed; 0 failed
rustc 1.97.1 (pkg), FreeBSD 15.1, job time 2m37s

Cirrus CI shut down on 2026-06-01, which removed the FreeBSD unit test
coverage. Run the same test command in a FreeBSD VM booted under QEMU/KVM
on a regular ubuntu-latest runner, keeping the skips .cirrus.yml carried.

The suite runs as an unprivileged user: src/su/context.rs notes that
invalid_shell is allowed to fail under root, and the VM logs in as root.
get_process_start_time compared a ProcessCreateTime against a value built
by destructuring SystemTime, which bypasses the newtype that keeps the two
clock bases apart. That is a no-op on Linux and fails deterministically on
FreeBSD, where kinfo_proc.ki_start is absolute wall clock while
CLOCK_BOOTTIME is an alias for the uptime clock.

Restore the cfg-aware ProcessCreateTime::now() helper removed in 62d1d30
and document why it cannot be folded into SystemTime::now(), which must
keep reading the monotonic clock (see trifectatechfoundation#1022).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cirrus CI is shutting down

1 participant