Skip to content

Commit 5a53494

Browse files
committed
Fix agent bicopy
1 parent cfb679a commit 5a53494

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

agent/agent_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"runtime"
1515
"strconv"
1616
"strings"
17+
"sync"
1718
"testing"
1819
"time"
1920

@@ -463,6 +464,7 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
463464
agentConn := setupAgent(t, agent.Metadata{}, 0)
464465
listener, err := net.Listen("tcp", "127.0.0.1:0")
465466
require.NoError(t, err)
467+
waitGroup := sync.WaitGroup{}
466468
go func() {
467469
defer listener.Close()
468470
for {
@@ -475,11 +477,16 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
475477
_ = conn.Close()
476478
return
477479
}
478-
go agent.Bicopy(context.Background(), conn, ssh)
480+
waitGroup.Add(1)
481+
go func() {
482+
agent.Bicopy(context.Background(), conn, ssh)
483+
waitGroup.Done()
484+
}()
479485
}
480486
}()
481487
t.Cleanup(func() {
482488
_ = listener.Close()
489+
waitGroup.Wait()
483490
})
484491
tcpAddr, valid := listener.Addr().(*net.TCPAddr)
485492
require.True(t, valid)

0 commit comments

Comments
 (0)