Skip to content

Commit

Permalink
Add test case for detecting data race
Browse files Browse the repository at this point in the history
  • Loading branch information
dims committed Aug 5, 2019
1 parent 959d342 commit 47ffc4e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions klog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,36 @@ func TestVmoduleOff(t *testing.T) {
}
}

func TestSetOutputDataRace(t *testing.T) {
setFlags()
defer logging.swap(logging.newBuffers())
for i := 1; i <= 50; i++ {
go func() {
logging.flushDaemon()
}()
}
for i := 1; i <= 50; i++ {
go func() {
SetOutput(ioutil.Discard)
}()
}
for i := 1; i <= 50; i++ {
go func() {
logging.flushDaemon()
}()
}
for i := 1; i <= 50; i++ {
go func() {
SetOutputBySeverity("INFO", ioutil.Discard)
}()
}
for i := 1; i <= 50; i++ {
go func() {
logging.flushDaemon()
}()
}
}

// vGlobs are patterns that match/don't match this file at V=2.
var vGlobs = map[string]bool{
// Easy to test the numeric match here.
Expand Down

0 comments on commit 47ffc4e

Please sign in to comment.