1 // Copyright 2009 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.
14 func TestSleep(t *testing.T) {
15 const delay = int64(100e6)
18 syscall.Kill(os.Getpid(), syscall.SIGCHLD)
20 start := Nanoseconds()
22 duration := Nanoseconds() - start
24 t.Fatalf("Sleep(%d) slept for only %d ns", delay, duration)
28 func TestAfter(t *testing.T) {
29 const delay = int64(100e6)
30 start := Nanoseconds()
32 if duration := Nanoseconds() - start; duration < delay {
33 t.Fatalf("After(%d) slept for only %d ns", delay, duration)
35 if min := start + delay; end < min {
36 t.Fatalf("After(%d) expect >= %d, got %d", delay, min, end)