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
|
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 ""]
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
expect {
-timeout 180
-re {^towers_n=0x[0-9a-f]{2,}\r\n} { incr ok; exp_continue }
-re {^XXX_n=0x0\r\n} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}
catch {close}; catch {wait}
if {$ok == 2} {
pass "$test $subtest"
} else {
fail "$test $subtest ($ok)"
}
set subtest "process"
spawn $stap_path $srcdir/$subdir/perf02.stp -c $exepath
set ok 0
expect {
-timeout 180
-re {^towers_n=0x[0-9a-f]{2,}\r\n} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}
catch {close}; catch {wait}
if {$ok == 1} {
pass "$test $subtest"
} else {
fail "$test $subtest ($ok)"
}
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
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]{6,}\r\n} { incr ok; exp_continue }
-re {^min towers=[0-9]{6,}\r\n} { incr ok; exp_continue }
-re {^max main=[0-9]{6,}\r\n} { incr ok; exp_continue }
-re {^max towers=[0-9]{9,}\r\n} { incr ok; exp_continue }
-re {^WARNING:[^\r]*not supported by this kernel[^\r]*\r\n} {
# If this type of perf probe isn't supported by this kernel,
# kfail the test.
setup_kfail 15727 *-*-*; 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} {
pass "$test $subtest"
} else {
fail "$test $subtest ($ok)"
}
}
set subtest "global"
spawn $stap_path $srcdir/$subdir/perf05.stp
set ok 0
expect {
-timeout 180
-re {^hit=0x1\r\n} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}
catch {close}; catch {wait}
if {$ok == 1} {
pass "$test $subtest"
} else {
fail "$test $subtest ($ok)"
}
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
|