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.
10 // force US/Pacific for time zone tests
11 ForceUSPacificForTesting()
14 func initTestingZone() {
15 z
, err
:= loadLocation("America/Los_Angeles", zoneSources
[len(zoneSources
)-1:])
16 if runtime
.Compiler
== "gccgo" && err
!= nil {
17 z
, err
= loadLocation("America/Los_Angeles", zoneSources
)
20 panic("cannot load America/Los_Angeles for testing: " + err
.Error())
26 var OrigZoneSources
= zoneSources
28 func forceZipFileForTesting(zipOnly
bool) {
29 zoneSources
= make([]string, len(OrigZoneSources
))
30 copy(zoneSources
, OrigZoneSources
)
32 zoneSources
= zoneSources
[len(zoneSources
)-1:]
36 var Interrupt
= interrupt
39 func empty(arg
interface{}, seq
uintptr) {}
41 // Test that a runtimeTimer with a duration so large it overflows
42 // does not cause other timers to hang.
44 // This test has to be in internal_test.go since it fiddles with
45 // unexported data structures.
46 func CheckRuntimeTimerOverflow() {
47 // We manually create a runtimeTimer to bypass the overflow
48 // detection logic in NewTimer: we're testing the underlying
49 // runtime.addtimer function.
51 when
: runtimeNano() + (1<<63 - 1),
57 // Start a goroutine that should send on t.C right away.
61 // Subsequent tests won't work correctly if we don't stop the
62 // overflow timer and kick the timer proc back into service.
64 // The timer proc is now sleeping and can only be awoken by
65 // adding a timer to the *beginning* of the heap. We can't
66 // wake it up by calling NewTimer since other tests may have
67 // left timers running that should have expired before ours.
68 // Instead we zero the overflow timer duration and start it
76 // If the test fails, we will hang here until the timeout in the testing package
77 // fires, which is 10 minutes. It would be nice to catch the problem sooner,
78 // but there is no reliable way to guarantee that timerproc schedules without
79 // doing something involving timerproc itself. Previous failed attempts have
80 // tried calling runtime.Gosched and runtime.GC, but neither is reliable.
81 // So we fall back to hope: We hope we don't hang here.