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

Function TestFindXrayProcessesMultiple

backend/xray/process_unix_test.go:16–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestFindXrayProcessesMultiple(t *testing.T) {
17 exe := resolveXrayBinary(t)
18
19 const instanceCount = 5
20 children := make([]struct {
21 pid int
22 waitCh <-chan error
23 }, 0, instanceCount)
24
25 for i := 0; i < instanceCount; i++ {
26 pid, waitCh := startXrayProcess(t, exe)
27 children = append(children, struct {
28 pid int
29 waitCh <-chan error
30 }{pid: pid, waitCh: waitCh})
31 }
32
33 waitForProcesses(exe, children, t)
34
35 for _, c := range children {
36 if err := killProcessTree(c.pid); err != nil {
37 t.Fatalf("killProcessTree(%d) error: %v", c.pid, err)
38 }
39 }
40
41 for _, c := range children {
42 select {
43 case <-c.waitCh:
44 case <-time.After(5 * time.Second):
45 t.Fatalf("xray process %d did not exit after kill", c.pid)
46 }
47 }
48}
49
50func keys(m map[int]struct{}) []int {
51 out := make([]int, 0, len(m))

Callers

nothing calls this directly

Calls 4

resolveXrayBinaryFunction · 0.85
startXrayProcessFunction · 0.85
waitForProcessesFunction · 0.85
killProcessTreeFunction · 0.70

Tested by

no test coverage detected