~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to misc/cgo/test/issue6997_linux.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 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
// Test that pthread_cancel works as expected
 
6
// (NPTL uses SIGRTMIN to implement thread cancellation)
 
7
// See http://golang.org/issue/6997
 
8
package cgotest
 
9
 
 
10
/*
 
11
#cgo CFLAGS: -pthread
 
12
#cgo LDFLAGS: -pthread
 
13
extern int StartThread();
 
14
extern int CancelThread();
 
15
*/
 
16
import "C"
 
17
 
 
18
import "testing"
 
19
import "time"
 
20
 
 
21
func test6997(t *testing.T) {
 
22
        r := C.StartThread()
 
23
        if r != 0 {
 
24
                t.Error("pthread_create failed")
 
25
        }
 
26
        c := make(chan C.int)
 
27
        go func() {
 
28
                time.Sleep(500 * time.Millisecond)
 
29
                c <- C.CancelThread()
 
30
        }()
 
31
 
 
32
        select {
 
33
        case r = <-c:
 
34
                if r == 0 {
 
35
                        t.Error("pthread finished but wasn't cancelled??")
 
36
                }
 
37
        case <-time.After(5 * time.Second):
 
38
                t.Error("hung in pthread_cancel/pthread_join")
 
39
        }
 
40
}