1 // Copyright 2011 The Go Authors. 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.
8 // force US/Pacific for time zone tests
9 ForceUSPacificForTesting()
12 var Interrupt
= interrupt
15 func empty(arg
interface{}, seq
uintptr) {}
17 // Test that a runtimeTimer with a duration so large it overflows
18 // does not cause other timers to hang.
20 // This test has to be in internal_test.go since it fiddles with
21 // unexported data structures.
22 func CheckRuntimeTimerOverflow() {
23 // We manually create a runtimeTimer to bypass the overflow
24 // detection logic in NewTimer: we're testing the underlying
25 // runtime.addtimer function.
27 when
: runtimeNano() + (1<<63 - 1),
33 // Start a goroutine that should send on t.C right away.
37 // Subsequent tests won't work correctly if we don't stop the
38 // overflow timer and kick the timer proc back into service.
40 // The timer proc is now sleeping and can only be awoken by
41 // adding a timer to the *beginning* of the heap. We can't
42 // wake it up by calling NewTimer since other tests may have
43 // left timers running that should have expired before ours.
44 // Instead we zero the overflow timer duration and start it
52 // If the test fails, we will hang here until the timeout in the testing package
53 // fires, which is 10 minutes. It would be nice to catch the problem sooner,
54 // but there is no reliable way to guarantee that timerproc schedules without
55 // doing something involving timerproc itself. Previous failed attempts have
56 // tried calling runtime.Gosched and runtime.GC, but neither is reliable.
57 // So we fall back to hope: We hope we don't hang here.