github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/runtime/futex_test.go (about)

     1  // Copyright 2013 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.
     4  
     5  // Futex is only available on Dragonfly, FreeBSD and Linux.
     6  // The race detector emits calls to split stack functions so it breaks the test.
     7  // +build dragonfly freebsd linux
     8  // +build !race
     9  
    10  package runtime_test
    11  
    12  import (
    13  	. "runtime"
    14  	"testing"
    15  	"time"
    16  )
    17  
    18  func TestFutexsleep(t *testing.T) {
    19  	ch := make(chan bool, 1)
    20  	var dummy uint32
    21  	start := time.Now()
    22  	go func() {
    23  		Entersyscall()
    24  		Futexsleep(&dummy, 0, (1<<31+100)*1e9)
    25  		Exitsyscall()
    26  		ch <- true
    27  	}()
    28  	select {
    29  	case <-ch:
    30  		t.Errorf("futexsleep finished early after %s!", time.Since(start))
    31  	case <-time.After(time.Second):
    32  		Futexwakeup(&dummy, 1)
    33  	}
    34  }