Skip to content

cmd/system_test.go systemd-branch tests fail on real OpenRC (Alpine) #296

Description

@sgnilreutr

Summary

Running go test ./cmd/... -run 'TestSystemStartupCmd_SystemdBranchDeclined|TestSystemStartupCommand|TestSystemUnstartupCommand' on a real Alpine/OpenRC machine (non-root, normal user) fails all three tests. Found via the new cross-distro e2e test matrix harness (see the test/matrix.yml PR) actually running go test ./cmd ./internal/... against a real OpenRC target for the first time -- previously this only ran on systemd distros or macOS.

Root cause

These tests branch only on runtime.GOOS != "linux" vs linux, treating all Linux as systemd. OpenRC is a second real Linux init system this repo supports (see runtime-detection code, test-openrc-orb Make target) but these three tests never account for it as a third branch:

  • TestSystemStartupCmd_SystemdBranchDeclined (cmd/system_test.go:940) -- only skips on runtime.GOOS != "linux"
  • TestSystemUnstartupCmd_SystemdBranchDeclined -- same pattern
  • TestSystemStartupCommand (cmd/system_test.go:1580) -- doc comment explicitly reasons about darwin vs "non-darwin" assuming systemd, never OpenRC

On Alpine/OpenRC, eos system startup's real runtime-detection path apparently probes /etc/init.d/ (a system-wide path) before ever reaching the $HOME/.config/systemd permission check these tests are built around, so the assertions never match:

```
--- FAIL: TestSystemStartupCmd_SystemdBranchDeclined (0.07s)
system_test.go:954: expected startup to return nil when the unit-file prompt is declined, got: command failed
--- FAIL: TestSystemStartupCommand (0.07s)
system_test.go:1613: expected 'creating user systemd directory' error, got: error checking destination file: directory "/etc/init.d/" does not appear to be writable: open /etc/init.d/.write-check-2270715003: permission denied
--- FAIL: TestSystemUnstartupCommand (0.07s)
system_test.go:1629: expected ErrCommandFailed, got:
```

Why this went unnoticed

Nobody had run the general (non-openrc-scoped) go test ./cmd/... suite against a real OpenRC machine before -- test-openrc-orb only runs a narrow -run 'Openrc|OpenRC|DetectActiveSystemRuntime' subset, and these three tests' names don't match that filter, so they were never exercised there either.

Fix direction (not yet investigated in depth)

Either:

  1. Add an explicit OpenRC skip/branch to all three tests (mirroring the systemd-vs-darwin split already present), or
  2. If OpenRC startup wiring genuinely should behave differently here, assert the OpenRC-appropriate outcome instead of skipping.

Needs someone to trace the actual ensureRuntime/startup-detection code path on OpenRC to pick the right fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions