| 1 |
# Tests backtrace in the classic Fibonacci program |
| 2 |
|
| 3 |
|
| 4 |
set test "fib" |
| 5 |
|
| 6 |
# Only run on make installcheck and utrace present. |
| 7 |
if {! [installtest_p]} { untested "$test"; return } |
| 8 |
if {! [utrace_p]} { untested "$test"; return } |
| 9 |
if {! [uretprobes_p]} { untested "$test"; return } |
| 10 |
|
| 11 |
set testpath "$srcdir/$subdir" |
| 12 |
set testsrc "$testpath/fib.c" |
| 13 |
set testexe "[pwd]/$test" |
| 14 |
|
| 15 |
# We want debug info and no optimization (is that totally necessary?) |
| 16 |
set testflags "additional_flags=-g additional_flags=-O0" |
| 17 |
set teststp "$testpath/$test.stp" |
| 18 |
|
| 19 |
# When possible explicitly set 64 bit mode if kernel is 64 bit. So, we |
| 20 |
# grab the 1st set of compile flags. |
| 21 |
set arch_flag [arch_compile_flag 0] |
| 22 |
if { $arch_flag != "" } { |
| 23 |
set testflags "$testflags $arch_flag" |
| 24 |
} |
| 25 |
|
| 26 |
set res [target_compile $testsrc $testexe executable $testflags] |
| 27 |
if { $res != "" } { |
| 28 |
verbose "target_compile failed: $res" 2 |
| 29 |
fail "unable to compile $testsrc" |
| 30 |
return |
| 31 |
} |
| 32 |
|
| 33 |
spawn stap -c "$testexe 10" $teststp |
| 34 |
set fibcalls 0 |
| 35 |
set maincalls 0 |
| 36 |
expect { |
| 37 |
-timeout 120 |
| 38 |
-re {^fib[^\r\n]*[\r\n]} { incr fibcalls; exp_continue } |
| 39 |
-re {^main[^\r\n]*[\r\n]} { incr maincalls; exp_continue } |
| 40 |
-re {^[^\r\n]*[\r\n]} {exp_continue} |
| 41 |
timeout { fail "$test (timeout)" } |
| 42 |
eof { } |
| 43 |
} |
| 44 |
catch { close }; catch { wait } |
| 45 |
if {$fibcalls == 18 && $maincalls == 2} { pass "$test ($fibcalls $maincalls)" } { fail "$test ($fibcalls $maincalls)" } |
| 46 |
|
| 47 |
spawn stap -c "$testexe 10" -- $teststp --entry |
| 48 |
set fibcalls 0 |
| 49 |
set maincalls 0 |
| 50 |
expect { |
| 51 |
-timeout 120 |
| 52 |
-re {^fib[^\r\n]*[\r\n]} { incr fibcalls; exp_continue } |
| 53 |
-re {^main[^\r\n]*[\r\n]} { incr maincalls; exp_continue } |
| 54 |
-re {^[^\r\n]*[\r\n]} {exp_continue} |
| 55 |
timeout { fail "$test (timeout)" } |
| 56 |
eof { } |
| 57 |
} |
| 58 |
catch { close }; catch { wait } |
| 59 |
if {$fibcalls == 55 && $maincalls == 10} { pass "$test ($fibcalls $maincalls)" } { fail "$test ($fibcalls $maincalls)" } |