@@ -70,11 +70,8 @@ func TestWaitGroupMisuse(t *testing.T) {
70
70
71
71
func TestWaitGroupMisuse2 (t * testing.T ) {
72
72
knownRacy (t )
73
- if testing .Short () {
74
- t .Skip ("skipping flaky test in short mode; see issue 11443" )
75
- }
76
- if runtime .NumCPU () <= 2 {
77
- t .Skip ("NumCPU<=2, skipping: this test requires parallelism" )
73
+ if runtime .NumCPU () <= 4 {
74
+ t .Skip ("NumCPU<=4, skipping: this test requires parallelism" )
78
75
}
79
76
defer func () {
80
77
err := recover ()
@@ -86,24 +83,37 @@ func TestWaitGroupMisuse2(t *testing.T) {
86
83
}()
87
84
defer runtime .GOMAXPROCS (runtime .GOMAXPROCS (4 ))
88
85
done := make (chan interface {}, 2 )
89
- // The detection is opportunistically , so we want it to panic
86
+ // The detection is opportunistic , so we want it to panic
90
87
// at least in one run out of a million.
91
88
for i := 0 ; i < 1e6 ; i ++ {
92
89
var wg WaitGroup
90
+ var here uint32
93
91
wg .Add (1 )
94
92
go func () {
95
93
defer func () {
96
94
done <- recover ()
97
95
}()
96
+ atomic .AddUint32 (& here , 1 )
97
+ for atomic .LoadUint32 (& here ) != 3 {
98
+ // spin
99
+ }
98
100
wg .Wait ()
99
101
}()
100
102
go func () {
101
103
defer func () {
102
104
done <- recover ()
103
105
}()
106
+ atomic .AddUint32 (& here , 1 )
107
+ for atomic .LoadUint32 (& here ) != 3 {
108
+ // spin
109
+ }
104
110
wg .Add (1 ) // This is the bad guy.
105
111
wg .Done ()
106
112
}()
113
+ atomic .AddUint32 (& here , 1 )
114
+ for atomic .LoadUint32 (& here ) != 3 {
115
+ // spin
116
+ }
107
117
wg .Done ()
108
118
for j := 0 ; j < 2 ; j ++ {
109
119
if err := <- done ; err != nil {
0 commit comments