//go:build linux package host import "testing" func TestPlan14GenerationServiceSupervisor(t *testing.T) { for _, tc := range []struct { name, unit, group, status string main int want bool }{ {"main", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\n", 42, true}, {"other process", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t43\n", 42, false}, {"child group", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise/child", "Tgid:\t42\n", 42, false}, {"other service", "unknown.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\n", 42, false}, {"missing main", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t0\n", 0, false}, {"missing identity", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Uid:\t999\n", 42, false}, {"duplicate", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\nTgid:\t42\n", 42, false}, } { t.Run(tc.name, func(t *testing.T) { if got := generationServiceSupervisor(tc.unit, tc.group, "/carlos.slice/carlos-edge.service", []byte(tc.status), tc.main); got != tc.want { t.Fatal(got) } }) } }