| 1 |
set test "ustack" |
| 2 |
set testpath "$srcdir/$subdir" |
| 3 |
|
| 4 |
if {! [installtest_p]} { untested $test; return } |
| 5 |
if {! [uretprobes_p]} { untested $test; return } |
| 6 |
|
| 7 |
# --- TEST 1 --- |
| 8 |
|
| 9 |
set subtest1 "TEST 1: PR23799: sprint_ustack() returns empty strings" |
| 10 |
|
| 11 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 12 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 13 |
if {$res ne ""} { |
| 14 |
verbose "target_compile failed: $res" 2 |
| 15 |
fail "$test: $subtest1: unable to compile ${test}_1.c" |
| 16 |
} else { |
| 17 |
set test_name "$test: $subtest1" |
| 18 |
|
| 19 |
set cmd "stap --ldd -c ./a.out '$srcdir/$subdir/${test}_1.stp'" |
| 20 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 21 |
set out_pat " : foo\\+.*? : bar\\+.*? : main\\+" |
| 22 |
like "${test_name}: stdout" $out $out_pat "" |
| 23 |
is "${test_name}: exit code" $exit_code 0 |
| 24 |
if {$stderr ne ""} { |
| 25 |
send_log "stderr:\n$stderr" |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
# --- TEST 2 --- |
| 30 |
|
| 31 |
set subtest2 "TEST 2: print_ustack()" |
| 32 |
|
| 33 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 34 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 35 |
if {$res ne ""} { |
| 36 |
verbose "target_compile failed: $res" 2 |
| 37 |
fail "$test: $subtest2: unable to compile ${test}_1.c" |
| 38 |
} else { |
| 39 |
set test_name "$test: $subtest2" |
| 40 |
|
| 41 |
set cmd "stap --ldd -c ./a.out '$srcdir/$subdir/${test}_2.stp'" |
| 42 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 43 |
set out_pat " : foo\\+.*? : bar\\+.*? : main\\+" |
| 44 |
like "${test_name}: stdout" $out $out_pat "" |
| 45 |
is "${test_name}: exit code" $exit_code 0 |
| 46 |
if {$stderr ne ""} { |
| 47 |
send_log "stderr:\n$stderr" |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
# --- TEST 3 --- |
| 52 |
|
| 53 |
set subtest3 "TEST 3: sprint_ubacktrace()" |
| 54 |
|
| 55 |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ |
| 56 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 57 |
if {$res ne ""} { |
| 58 |
verbose "target_compile failed: $res" 2 |
| 59 |
fail "$test: $subtest2: unable to compile ${test}_3.c" |
| 60 |
} else { |
| 61 |
set test_name "$test: $subtest3" |
| 62 |
|
| 63 |
set cmd "stap -DMAXBACKTRACE=256 --ldd -c ./a.out '$srcdir/$subdir/${test}_3.stp'" |
| 64 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 65 |
set out_pat "bt: mark.*" |
| 66 |
like "${test_name}: stdout" $out $out_pat "" |
| 67 |
is "${test_name}: exit code" $exit_code 0 |
| 68 |
if {$stderr ne ""} { |
| 69 |
send_log "stderr:\n$stderr" |
| 70 |
} |
| 71 |
} |