...
  
  
     1  
     2  
     3  
     4  
     5  
     6  
     7  
     8  
     9  
    10  package cgotest
    11  
    12  
    18  import "C"
    19  
    20  import (
    21  	"testing"
    22  	"time"
    23  )
    24  
    25  func test6997(t *testing.T) {
    26  	r := C.StartThread()
    27  	if r != 0 {
    28  		t.Error("pthread_create failed")
    29  	}
    30  	c := make(chan C.int)
    31  	go func() {
    32  		time.Sleep(500 * time.Millisecond)
    33  		c <- C.CancelThread()
    34  	}()
    35  
    36  	select {
    37  	case r = <-c:
    38  		if r == 0 {
    39  			t.Error("pthread finished but wasn't canceled??")
    40  		}
    41  	case <-time.After(30 * time.Second):
    42  		t.Error("hung in pthread_cancel/pthread_join")
    43  	}
    44  }
    45  
View as plain text