Home | History | Annotate | Download | only in test
      1 // Copyright 2015 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 package cgotest
      6 
      7 /*
      8 #cgo CFLAGS: -pthread
      9 #cgo LDFLAGS: -pthread
     10 extern int RunSigThread();
     11 extern int CheckBlocked();
     12 */
     13 import "C"
     14 import (
     15 	"os"
     16 	"os/signal"
     17 	"syscall"
     18 	"testing"
     19 )
     20 
     21 var blocked bool
     22 
     23 //export IntoGoAndBack
     24 func IntoGoAndBack() {
     25 	// Verify that SIGIO stays blocked on the C thread
     26 	// even when unblocked for signal.Notify().
     27 	signal.Notify(make(chan os.Signal), syscall.SIGIO)
     28 	blocked = C.CheckBlocked() != 0
     29 }
     30 
     31 func testSigProcMask(t *testing.T) {
     32 	if r := C.RunSigThread(); r != 0 {
     33 		t.Error("pthread_create/pthread_join failed")
     34 	}
     35 	if !blocked {
     36 		t.Error("Go runtime unblocked SIGIO")
     37 	}
     38 }
     39