From 9242d3493d7be2d5c105c8503a73ffd46bbd59e1 Mon Sep 17 00:00:00 2001 From: Sam Balana Date: Thu, 7 May 2020 14:45:05 -0700 Subject: 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 --- pkg/tcpip/transport/tcp/tcp_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/tcpip/transport/tcp/tcp_test.go b/pkg/tcpip/transport/tcp/tcp_test.go index 49e4ba214..d2c90ebd5 100644 --- a/pkg/tcpip/transport/tcp/tcp_test.go +++ b/pkg/tcpip/transport/tcp/tcp_test.go @@ -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() -- cgit v1.2.3