...
1
2
3
4
5
6
7
8 package cgotest
9
10
14 import "C"
15
16 import (
17 "runtime"
18 "runtime/debug"
19 "sync/atomic"
20 "testing"
21
22 "cmd/cgo/internal/test/issue9400"
23 )
24
25 func test9400(t *testing.T) {
26
27 defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2))
28
29
30 atomic.StoreInt32(&issue9400.Baton, 0)
31 go func() {
32
33 for atomic.LoadInt32(&issue9400.Baton) == 0 {
34 runtime.Gosched()
35 }
36
37 runtime.LockOSThread()
38 C.setgid(0)
39
40 atomic.StoreInt32(&issue9400.Baton, 0)
41 }()
42
43
44 const pattern = 0x123456789abcdef
45 var big [1024]uint64
46 for i := range big {
47 big[i] = pattern
48 }
49
50
51
52 defer debug.SetGCPercent(debug.SetGCPercent(-1))
53
54
55
56 runtime.GC()
57
58
59 issue9400.RewindAndSetgid()
60
61
62 for i := range big {
63 if big[i] != pattern {
64 t.Fatalf("entry %d of test pattern is wrong; %#x != %#x", i, big[i], uint64(pattern))
65 }
66 }
67 }
68
View as plain text