dispatchWithTimeout runs registry.Dispatch in a goroutine and waits for completion.
(t *testing.T, b *Bridge, sessionID string, taskID uint32, spite *implantpb.Spite, timeout time.Duration)
| 146 | |
| 147 | // dispatchWithTimeout runs registry.Dispatch in a goroutine and waits for completion. |
| 148 | func dispatchWithTimeout(t *testing.T, b *Bridge, sessionID string, taskID uint32, spite *implantpb.Spite, timeout time.Duration) { |
| 149 | t.Helper() |
| 150 | ctx := b.moduleContext() |
| 151 | done := make(chan bool, 1) |
| 152 | go func() { |
| 153 | ok := b.registry.Dispatch(ctx, sessionID, taskID, spite) |
| 154 | done <- ok |
| 155 | }() |
| 156 | select { |
| 157 | case ok := <-done: |
| 158 | if !ok { |
| 159 | t.Errorf("dispatch returned false for spite=%s", spite.Name) |
| 160 | } |
| 161 | case <-time.After(timeout): |
| 162 | t.Fatalf("dispatch timed out after %v for spite=%s", timeout, spite.Name) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // =================================================================== |
| 167 | // E2E: Direct Upload (small text file via Write tool) |
no test coverage detected