Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/perf.exp

raw
1 set test "perf"
2
3 if {! [installtest_p]} { untested "$test"; return }
4 if {! [perf_probes_p]} { untested "$test"; return }
5
6 proc cleanup_handler { verbose } {
7 catch {exec rm -f towers.x}
8 }
9
10 set stap_path $env(SYSTEMTAP_PATH)/stap
11 set exepath "[pwd]/towers.x"
12 set subtest "process()"
13
14 set res [target_compile $srcdir/$subdir/towers.c $exepath executable \
15 "additional_flags=-O2 additional_flags=-g"]
16 if { $res != "" } {
17 verbose "target_compile failed: $res" 2
18 fail "$test compiling towers.c"
19 cleanup_handler $verbose
20 return
21 } else {
22 pass "$test compiling towers.c"
23 }
24
25 spawn $stap_path $srcdir/$subdir/perf01.stp $exepath -c $exepath
26
27 # there is no "XXX" process so this probe should have been ignored
28 set ok 0
29 set compile_errors 0
30 expect {
31 -timeout 180
32 -re {^towers_n=[0-9a-f]{2,}\r\n} { incr ok; exp_continue }
33 -re {^XXX_n=0\r\n} { incr ok; exp_continue }
34 -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
35 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
36 incr compile_errors 1; exp_continue }
37 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
38 timeout { fail "$test (timeout)" }
39 eof { }
40 }
41 catch {close}; catch {wait}
42
43 if {$ok == 2 && $compile_errors == 0} {
44 pass "$test $subtest"
45 } else {
46 fail "$test $subtest ($ok - $compile_errors)"
47 }
48
49 set subtest "process"
50
51 spawn $stap_path $srcdir/$subdir/perf02.stp -c $exepath
52
53 set ok 0
54 set compile_errors 0
55 expect {
56 -timeout 180
57 -re {^towers_n=[0-9a-f]{2,}\r\n} { incr ok; exp_continue }
58 -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
59 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
60 incr compile_errors 1; exp_continue }
61 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
62 timeout { fail "$test (timeout)" }
63 eof { }
64 }
65 catch {close}; catch {wait}
66
67 if {$ok == 1 && $compile_errors == 0} {
68 pass "$test $subtest"
69 } else {
70 fail "$test $subtest ($ok - $compile_errors)"
71 }
72
73 set subtest "counter"
74
75 target_compile $srcdir/$subdir/towers.c $exepath executable "additional_flags=-g"
76
77 if {! [uprobes_p]} {
78 untested "$test $subtest"
79 } else {
80 spawn $stap_path $srcdir/$subdir/perf03.stp $exepath -c $exepath
81
82 set ok 0
83 set compile_errors 0
84 set hw_perf_probes 1
85 expect {
86 -timeout 180
87 -re {^count main=1\r\n} { incr ok; exp_continue }
88 -re {^count towers=500\r\n} { incr ok; exp_continue }
89 -re {^min main=[\-0-9]+\r\n} { incr ok; exp_continue }
90 -re {^min towers=[\-0-9]+\r\n} { incr ok; exp_continue }
91 -re {^max main=[0-9]+\r\n} { incr ok; exp_continue }
92 -re {^max towers=[0-9]+\r\n} { incr ok; exp_continue }
93 -re {^WARNING:[^\r]*not supported by this kernel[^\r]*\r\n} {
94 # If this type of hardware perf probe isn't supported by
95 # this kernel, kfail the test. Remember this kfail, and
96 # try again with a software perf probe.
97 set hw_perf_probes 0; setup_kfail 15727 *-*-*; exp_continue }
98 -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
99 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
100 incr compile_errors 1; exp_continue }
101 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1;
102 exp_continue }
103 timeout { fail "$test (timeout)" }
104 eof { }
105 }
106 catch {close}; catch {wait}
107
108 spawn $stap_path -W $srcdir/$subdir/perf04.stp $exepath -c $exepath
109
110 expect {
111 -timeout 180
112 -re {^count main=1\r\n} { incr ok; exp_continue }
113 timeout { fail "$test (timeout)" }
114 eof { }
115 }
116 catch {close}; catch {wait}
117
118 if {$ok == 7 && $compile_errors == 0} {
119 pass "$test $subtest"
120 } else {
121 fail "$test $subtest ($ok - $compile_errors)"
122 }
123
124 if {! $hw_perf_probes} {
125 set subtest "counter (sw)"
126 spawn $stap_path $srcdir/$subdir/perf03sw.stp $exepath -c $exepath
127
128 set ok 0
129 set compile_errors 0
130 expect {
131 -timeout 180
132 -re {^count main=1\r\n} { incr ok; exp_continue }
133 -re {^count towers=500\r\n} { incr ok; exp_continue }
134 -re {^min main=[\-0-9]+\r\n} { incr ok; exp_continue }
135 -re {^min towers=[\-0-9]+\r\n} { incr ok; exp_continue }
136 -re {^max main=[0-9]+\r\n} { incr ok; exp_continue }
137 -re {^max towers=[0-9]+\r\n} { incr ok; exp_continue }
138 -re {^parse error[^\r\n]*\r\n} {
139 incr compile_errors 1; exp_continue }
140 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
141 incr compile_errors 1; exp_continue }
142 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1;
143 exp_continue }
144 timeout { fail "$test (timeout)" }
145 eof { }
146 }
147 catch {close}; catch {wait}
148
149 spawn $stap_path -W $srcdir/$subdir/perf04sw.stp $exepath -c $exepath
150
151 expect {
152 -timeout 180
153 -re {^count main=1\r\n} { incr ok; exp_continue }
154 timeout { fail "$test (timeout)" }
155 eof { }
156 }
157 catch {close}; catch {wait}
158
159 if {$ok == 7 && $compile_errors == 0} {
160 pass "$test $subtest"
161 } else {
162 fail "$test $subtest ($ok - $compile_errors)"
163 }
164 }
165 }
166
167 set subtest "global"
168
169 spawn $stap_path $srcdir/$subdir/perf05.stp
170
171 set ok 0
172 set compile_errors 0
173 expect {
174 -timeout 180
175 -re {^hit=1\r\n} { incr ok; exp_continue }
176 -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
177 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
178 incr compile_errors 1; exp_continue }
179 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
180 timeout { fail "$test (timeout)" }
181 eof { }
182 }
183 catch {close}; catch {wait}
184
185 if {$ok == 1 && $compile_errors == 0} {
186 pass "$test $subtest"
187 } else {
188 fail "$test $subtest ($ok - $compile_errors)"
189 }
190
191 set subtest "counter order"
192
193 spawn $srcdir/$subdir/perf.sh $stap_path
194
195 expect {
196 -timeout 180
197 -re {PASS: [0-9 ]+} { regexp " .*$" $expect_out(0,string) s;
198 pass "$subtest $s"; exp_continue }
199 -re {UNRESOLVED: [0-9 ]+} { regexp " .*$" $expect_out(0,string) s;
200 unresolved "$subtest $s"; exp_continue }
201 -re {FAIL: [0-9 ]+} { regexp " .*$" $expect_out(0,string) s;
202 fail "$subtest $s"; exp_continue }
203 timeout { fail "$test (timeout)" }
204 eof { }
205 }
206 catch {close}; catch {wait}
207
208 cleanup_handler $verbose