summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/futex_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/futex_test.go')
-rw-r--r--src/pkg/runtime/futex_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pkg/runtime/futex_test.go b/src/pkg/runtime/futex_test.go
new file mode 100644
index 000000000..51f4d0f12
--- /dev/null
+++ b/src/pkg/runtime/futex_test.go
@@ -0,0 +1,31 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux freebsd
+
+package runtime_test
+
+import (
+ . "runtime"
+ "testing"
+ "time"
+)
+
+func TestFutexsleep(t *testing.T) {
+ ch := make(chan bool, 1)
+ var dummy uint32
+ start := time.Now()
+ go func() {
+ Entersyscall()
+ Futexsleep(&dummy, 0, (1<<31+100)*1e9)
+ Exitsyscall()
+ ch <- true
+ }()
+ select {
+ case <-ch:
+ t.Errorf("futexsleep finished early after %s!", time.Since(start))
+ case <-time.After(time.Second):
+ Futexwakeup(&dummy, 1)
+ }
+}