try fixing race in tests of ctl socket

there were a few test failures on the github runners. i can't reproduce it
locally. but i can see how they are happening: a gorouting running servectlcmd
could still be doing cleanup (removing files) while a next ctl command was
being run. with this change, we wait for servectlcmd to be done before starting
on a next test.
This commit is contained in:
Mechiel Lukkien 2024-06-10 23:07:01 +02:00
parent 8254e9ce66
commit ac3596a7d7
No known key found for this signature in database

View file

@ -56,9 +56,14 @@ func TestCtl(t *testing.T) {
cconn, sconn := net.Pipe()
clientctl := ctl{conn: cconn, log: pkglog}
serverctl := ctl{conn: sconn, log: pkglog}
go servectlcmd(ctxbg, &serverctl, func() {})
done := make(chan struct{})
go func() {
servectlcmd(ctxbg, &serverctl, func() {})
close(done)
}()
fn(&clientctl)
cconn.Close()
<-done
sconn.Close()
}