| 1 |
set test "ret-uprobe-var" |
| 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: @var in return probes should not be stale (4.1+)" |
| 10 |
|
| 11 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 12 |
"additional_flags=-O additional_flags=-g"] |
| 13 |
if {$res ne ""} { |
| 14 |
verbose "target_compile failed: $res" 2 |
| 15 |
fail "$test: $subtest1: unable to compile ${test}_1.c" |
| 16 |
} else { |
| 17 |
foreach runtime [get_runtime_list] { |
| 18 |
if {$runtime eq ""} { |
| 19 |
set runtime "kernel" |
| 20 |
} |
| 21 |
set test_name "$test: $subtest1 ($runtime)" |
| 22 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_1.stp'" |
| 23 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 24 |
set exp_out "a = 4\n" |
| 25 |
is "${test_name}: stdout" $out $exp_out |
| 26 |
set exp_stderr "" |
| 27 |
is "${test_name}: stderr" $stderr $exp_stderr |
| 28 |
is "${test_name}: exit code" $exit_code 0 |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
# --- TEST 2 --- |
| 33 |
|
| 34 |
set subtest2 "TEST 2: @var in return probes assumed @entry in release 4.0 or older" |
| 35 |
|
| 36 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 37 |
"additional_flags=-O additional_flags=-g"] |
| 38 |
if {$res ne ""} { |
| 39 |
verbose "target_compile failed: $res" 2 |
| 40 |
fail "$test: $subtest2: unable to compile ${test}_1.c" |
| 41 |
} else { |
| 42 |
foreach runtime [get_runtime_list] { |
| 43 |
if {$runtime eq ""} { |
| 44 |
set runtime "kernel" |
| 45 |
} |
| 46 |
set test_name "$test: $subtest2 ($runtime)" |
| 47 |
set cmd "stap --compatible 4.0 --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_1.stp'" |
| 48 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 49 |
set exp_out "a = 3\n" |
| 50 |
is "${test_name}: stdout" $out $exp_out |
| 51 |
set stderr_pat "\\AWARNING: confusing usage,.*\\@entry\\(\\@var\\(\"a\", \"\[^\"\]+\"\\)\\) in \\.return probe.*: operator '\\@var' at .+?\\.stp:2:24 |
| 52 |
source: printf\\(\"a = %d\\\\n\", \\@var\\(\"a\"\\)\\); |
| 53 |
\\^ |
| 54 |
\\Z" |
| 55 |
like "${test_name}: stderr" $stderr $stderr_pat "-linestop" |
| 56 |
is "${test_name}: exit code" $exit_code 0 |
| 57 |
} |
| 58 |
} |