File tree 1 file changed +46
-0
lines changed 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2019 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
+ // invoke signal hander in the VDSO context
6
+ // see issue 32912
7
+
8
+ package runtime_test
9
+
10
+ import (
11
+ "fmt"
12
+ "io/ioutil"
13
+ "os"
14
+ "runtime/pprof"
15
+ "time"
16
+ "testing"
17
+ )
18
+
19
+ func TestVDSO (t * testing.T ) {
20
+ f , err := ioutil .TempFile ("" , "timeprofnow" )
21
+ if err != nil {
22
+ fmt .Fprintln (os .Stderr , err )
23
+ os .Exit (2 )
24
+ }
25
+ if err := pprof .StartCPUProfile (f ); err != nil {
26
+ fmt .Fprintln (os .Stderr , err )
27
+ os .Exit (2 )
28
+ }
29
+ t0 := time .Now ()
30
+ t1 := t0
31
+ // We should get a profiling signal 100 times a second,
32
+ // so running for 10 seconds should be sufficient.
33
+ for t1 .Sub (t0 ) < 10 * time .Second {
34
+ t1 = time .Now ()
35
+ }
36
+ pprof .StopCPUProfile ()
37
+ name := f .Name ()
38
+ if err := f .Close (); err != nil {
39
+ fmt .Fprintln (os .Stderr , err )
40
+ os .Exit (2 )
41
+ }
42
+ if err := os .Remove (name ); err != nil {
43
+ fmt .Fprintln (os .Stderr , err )
44
+ os .Exit (2 )
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments