| 1 |
set test "at_var_print" |
| 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: atvar_op::print() output the module arg properly." |
| 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 |
set stp_fh [open "$srcdir/$subdir/${test}_1.stp" r] |
| 18 |
set stp_src [read $stp_fh] |
| 19 |
close $stp_fh |
| 20 |
|
| 21 |
set cwd [pwd] |
| 22 |
regsub -all -- {\$\^PWD\y} $stp_src $cwd stp_src |
| 23 |
|
| 24 |
set stp_fh [open "./${test}_1.stp" w+] |
| 25 |
puts -nonewline $stp_fh $stp_src |
| 26 |
close $stp_fh |
| 27 |
|
| 28 |
set test_name "$test: $subtest1" |
| 29 |
|
| 30 |
set exit_code [run_cmd_2way "stap -p1 -c ./a.out './${test}_1.stp'" out stderr] |
| 31 |
|
| 32 |
set out_pat "\\yreturn \\@var\\(\"v\", \"\[^\\n\"\]+/a\\.out\"\\);" |
| 33 |
like "${test_name}: stdout" $out $out_pat "-lineanchor" |
| 34 |
|
| 35 |
is "${test_name}: exit code" $exit_code 0 |
| 36 |
if {$stderr ne ""} { |
| 37 |
send_log "stderr:\n$stderr" |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
# --- TEST 2 --- |
| 42 |
|
| 43 |
set subtest2 "TEST 2: atvar_op::print() does not output the module arg if there is none" |
| 44 |
|
| 45 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 46 |
"additional_flags=-O additional_flags=-g"] |
| 47 |
if {$res ne ""} { |
| 48 |
verbose "target_compile failed: $res" 2 |
| 49 |
fail "$test: $subtest2: unable to compile ${test}_1.c" |
| 50 |
} else { |
| 51 |
set test_name "$test: $subtest2" |
| 52 |
|
| 53 |
set exit_code [run_cmd_2way "stap -p1 -c ./a.out '$srcdir/$subdir/${test}_2.stp'" out stderr] |
| 54 |
|
| 55 |
set out_pat "\\yprintln\\(\\@var\\(\"v\"\\)\\);" |
| 56 |
like "${test_name}: stdout" $out $out_pat "-lineanchor" |
| 57 |
|
| 58 |
is "${test_name}: exit code" $exit_code 0 |
| 59 |
if {$stderr ne ""} { |
| 60 |
send_log "stderr:\n$stderr" |
| 61 |
} |
| 62 |
} |