MCPcopy Create free account
hub / github.com/PasarGuard/node / waitForProcesses

Function waitForProcesses

backend/xray/process_unix_test.go:181–210  ·  view source on GitHub ↗
(exe string, children []struct {
	pid    int
	waitCh <-chan error
}, t *testing.T)

Source from the content-addressed store, hash-verified

179}
180
181func waitForProcesses(exe string, children []struct {
182 pid int
183 waitCh <-chan error
184}, t *testing.T) {
185 t.Helper()
186
187 want := make(map[int]struct{}, len(children))
188 for _, c := range children {
189 want[c.pid] = struct{}{}
190 }
191
192 for i := 0; i < 20 && len(want) > 0; i++ {
193 procs, err := findXrayProcesses(exe)
194 if err != nil {
195 t.Fatalf("findXrayProcesses returned error: %v", err)
196 }
197 for _, p := range procs {
198 delete(want, p.PID)
199 }
200
201 if len(want) == 0 {
202 return
203 }
204 time.Sleep(100 * time.Millisecond)
205 }
206
207 if len(want) > 0 {
208 t.Fatalf("missing xray PIDs in process list after wait: %v", keys(want))
209 }
210}
211
212func TestFindXrayProcessesReturnsEmptyWhenNoMatch(t *testing.T) {
213 // Use a clearly non-existent executable path; expect empty results, no error.

Callers 1

Calls 2

keysFunction · 0.85
findXrayProcessesFunction · 0.70

Tested by

no test coverage detected