(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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 | |
| 50 | func keys(m map[int]struct{}) []int { |
| 51 | out := make([]int, 0, len(m)) |
nothing calls this directly
no test coverage detected