Files
AetherForge/agent/stats/cpu_linux_test.go
AetherForge 1551bd5dad feat: Emberwake, Crucible phases, Linux agent, musical dashboard, e2e
Emberwake spread/waterhole UI, campaign DB, spread handler, spread-kit web publisher, and SPREAD_TECHNIQUES doc. Crucible Phase A-C: expanded ops, port-forward matrix, remote dir browser, crucible help/tests.

Linux agent hardening: credential vault, persistence audit, firewall/defender deploy, SMB spread status, CPU stats, screenshots/crypt/file-ops split. Docker compose and agent/server images with e2e validation script and docs.

Musical dashboard: ambient music player, hover SFX, SoundContext/AmbientMusicContext, steampunk polish. Public builds API, dropper handler updates, SessionGate and fleet UX. README and PROBLEMS.md refresh.
2026-06-04 21:53:31 -07:00

35 lines
806 B
Go

//go:build linux
package stats
import "testing"
func TestParseProcStatCPU(t *testing.T) {
idle, total, ok := parseProcStatCPU("cpu 4705 0 1234 8123 45 0 12 0 0 0")
if !ok {
t.Fatal("expected ok")
}
if idle != 8123+45 {
t.Fatalf("idle=%d", idle)
}
wantTotal := uint64(4705 + 0 + 1234 + 8123 + 45 + 0 + 12 + 0 + 0 + 0)
if total != wantTotal {
t.Fatalf("total=%d want %d", total, wantTotal)
}
}
func TestParseProcStatCPUBadLine(t *testing.T) {
if _, _, ok := parseProcStatCPU("meminfo"); ok {
t.Fatal("expected false for non-cpu line")
}
}
func TestSystemCPUPercentLinuxSecondSample(t *testing.T) {
r := NewReporter()
_ = r.SystemCPUPercent() // first sample seeds baseline
pct := r.SystemCPUPercent()
if pct < 0 || pct > 100 {
t.Fatalf("cpu percent out of range: %v", pct)
}
}