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