Files
privatae-bastion/client-go/agents_linux_test.go
T
Privatae e4c9b69b46
ci / personal-data (push) Successful in 5s
ci / test (push) Successful in 3m4s
ci / fuzz (push) Successful in 3m45s
bastion 0.53.2
2026-10-20 04:42:14 +00:00

31 lines
1014 B
Go

//go:build linux
package main
import (
"path/filepath"
"testing"
)
// The REAL enumerator's failure path, not the seam above it: an unreadable
// /proc must come back as an error. The bug this plane had was an empty map
// with a nil error here, which the heartbeat sent as "looked, nothing there"
// and the host read as a kill order carried out. scanProcessesFn is stubbed
// by every other test, so without this one the guard stops at the seam.
func TestTheLinuxWalkFailsLoudlyWhenProcIsUnreadable(t *testing.T) {
prev := procRoot
t.Cleanup(func() { procRoot = prev })
procRoot = filepath.Join(t.TempDir(), "no-proc-here")
m, err := scanProcesses()
if err == nil {
t.Fatalf("an unreadable %s returned %d processes and no error — an empty map with a nil error is the bug", procRoot, len(m))
}
if m != nil {
t.Fatalf("a failed walk must return no map, got %v", m)
}
procRoot = prev
if _, err := scanProcesses(); err != nil {
t.Fatalf("the real /proc walk failed on this box: %v", err)
}
}