1 // Copyright 2014 Google Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 // This test is only run when --regressions is passed on the go test line.
15 var regressions = flag.Bool("regressions", false, "run uuid regression tests")
17 // TestClockSeqRace tests for a particular race condition of returning two
18 // identical Version1 UUIDs. The duration of 1 minute was chosen as the race
19 // condition, before being fixed, nearly always occured in under 30 seconds.
20 func TestClockSeqRace(t *testing.T) {
22 t.Skip("skipping regression tests")
24 duration := time.Minute
26 done := make(chan struct{})
29 ch := make(chan UUID, 10000)
30 ncpu := runtime.NumCPU()
33 // We can't run the test effectively.
34 t.Skip("skipping race test, only one CPU detected")
37 runtime.GOMAXPROCS(ncpu)
39 for i := 0; i < ncpu; i++ {
51 uuids := make(map[string]bool)
57 t.Errorf("duplicate uuid after %d in %v: %s", cnt, time.Since(start), s)
61 if time.Since(start) > duration {