Skip to content

Commit 818f179

Browse files
committed
intra/netstack: m gofmt
1 parent 4a7e228 commit 818f179

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

intra/netstack/waitgroup_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
// TestWaitGroupRaceCondition tests that the WaitGroup reuse issue is fixed.
11-
// This test reproduces the scenario where an endpoint is swapped while
11+
// This test reproduces the scenario where an endpoint is swapped while
1212
// another goroutine is waiting on the old endpoint.
1313
func TestWaitGroupRaceCondition(t *testing.T) {
1414
// Create a temp file to simulate a TUN device
@@ -20,7 +20,7 @@ func TestWaitGroupRaceCondition(t *testing.T) {
2020
defer tmpFile.Close()
2121

2222
fd := int(tmpFile.Fd())
23-
23+
2424
// Create a magiclink endpoint
2525
endpoint, err := NewEndpoint(fd, 1500, &testSink{})
2626
if err != nil {
@@ -37,7 +37,7 @@ func TestWaitGroupRaceCondition(t *testing.T) {
3737
// while we swap endpoints in the background
3838
var wg sync.WaitGroup
3939
errors := make(chan error, 10)
40-
40+
4141
for i := 0; i < 5; i++ {
4242
wg.Add(1)
4343
go func(id int) {
@@ -47,15 +47,15 @@ func TestWaitGroupRaceCondition(t *testing.T) {
4747
errors <- r.(error)
4848
}
4949
}()
50-
50+
5151
// Call Wait() multiple times to increase chance of race condition
5252
for j := 0; j < 10; j++ {
5353
magicLink.Wait()
5454
time.Sleep(time.Millisecond)
5555
}
5656
}(i)
5757
}
58-
58+
5959
// Swap endpoints multiple times while Wait() is being called
6060
go func() {
6161
for i := 0; i < 5; i++ {
@@ -65,23 +65,23 @@ func TestWaitGroupRaceCondition(t *testing.T) {
6565
continue
6666
}
6767
fd2 := int(tmpFile2.Fd())
68-
68+
6969
// Swap to new fd
7070
magicLink.Swap(fd2, 1500)
7171
time.Sleep(time.Millisecond * 5)
72-
72+
7373
tmpFile2.Close()
7474
os.Remove(tmpFile2.Name())
7575
}
7676
}()
77-
77+
7878
// Wait for all goroutines to complete
7979
done := make(chan struct{})
8080
go func() {
8181
wg.Wait()
8282
close(done)
8383
}()
84-
84+
8585
select {
8686
case <-done:
8787
// Check if any errors occurred
@@ -108,7 +108,7 @@ func TestStackTraceScenario(t *testing.T) {
108108
defer tmpFile.Close()
109109

110110
fd := int(tmpFile.Fd())
111-
111+
112112
// Create a magiclink endpoint
113113
endpoint, err := NewEndpoint(fd, 1500, &testSink{})
114114
if err != nil {
@@ -125,7 +125,7 @@ func TestStackTraceScenario(t *testing.T) {
125125
// seamless.go:312>fdbased.go:413 - magiclink.Wait() calls endpoint.Wait()
126126
panicked := false
127127
done := make(chan struct{})
128-
128+
129129
// Start a goroutine that continuously calls Wait() like the tunnel waiter
130130
go func() {
131131
defer func() {
@@ -134,29 +134,29 @@ func TestStackTraceScenario(t *testing.T) {
134134
}
135135
close(done)
136136
}()
137-
137+
138138
for i := 0; i < 100; i++ {
139139
magicLink.Wait()
140140
time.Sleep(time.Millisecond)
141141
}
142142
}()
143-
143+
144144
// Concurrently perform rapid endpoint swaps
145145
for i := 0; i < 10; i++ {
146146
tmpFile2, err := os.CreateTemp("", "test_tun2")
147147
if err != nil {
148148
continue
149149
}
150150
fd2 := int(tmpFile2.Fd())
151-
151+
152152
// Rapid swap - this should not cause WaitGroup reuse panic
153153
magicLink.Swap(fd2, 1500)
154-
154+
155155
tmpFile2.Close()
156156
os.Remove(tmpFile2.Name())
157157
time.Sleep(time.Millisecond * 2)
158158
}
159-
159+
160160
// Wait for the wait goroutine to complete
161161
select {
162162
case <-done:
@@ -177,4 +177,4 @@ func (ts *testSink) Write(p []byte) (n int, err error) {
177177

178178
func (ts *testSink) Close() error {
179179
return nil
180-
}
180+
}

0 commit comments

Comments
 (0)