Capture range variable in parallel subtests

Only the last test was running before since the goroutines won't be executed
until after this loop. I added t.Log(test.name) and this is was the result:

TestListenNoAcceptNonUnicastV4/SourceUnspecified:    DestOtherMulticast
TestListenNoAcceptNonUnicastV4/DestUnspecified:      DestOtherMulticast
TestListenNoAcceptNonUnicastV4/DestOtherMulticast:   DestOtherMulticast
TestListenNoAcceptNonUnicastV4/SourceBroadcast:      DestOtherMulticast
TestListenNoAcceptNonUnicastV4/DestOurMulticast:     DestOtherMulticast
TestListenNoAcceptNonUnicastV4/DestBroadcast:        DestOtherMulticast
TestListenNoAcceptNonUnicastV4/SourceOtherMulticast: DestOtherMulticast
TestListenNoAcceptNonUnicastV4/SourceOurMulticast:   DestOtherMulticast

https://github.com/golang/go/wiki/TableDrivenTests#parallel-testing

PiperOrigin-RevId: 310440629
This commit is contained in:
Sam Balana 2020-05-07 14:45:05 -07:00 committed by gVisor bot
parent 9115f26851
commit 9242d3493d
1 changed files with 4 additions and 0 deletions

View File

@ -4905,6 +4905,8 @@ func TestListenNoAcceptNonUnicastV4(t *testing.T) {
}
for _, test := range tests {
test := test // capture range variable
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@ -5007,6 +5009,8 @@ func TestListenNoAcceptNonUnicastV6(t *testing.T) {
}
for _, test := range tests {
test := test // capture range variable
t.Run(test.name, func(t *testing.T) {
t.Parallel()