| 1 |
set test "addr_op" |
| 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: 2 excessive parens after unary '&' - with components" |
| 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 exit_code [run_cmd_2way "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_1.stp'" \ |
| 23 |
out stderr] |
| 24 |
set exp_out "1\n" |
| 25 |
is "${test_name}: stdout" $out $exp_out |
| 26 |
is "${test_name}: exit code" $exit_code 0 |
| 27 |
if {$stderr ne ""} { |
| 28 |
send_log "stderr:\n$stderr" |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
# --- TEST 2 --- |
| 34 |
|
| 35 |
set subtest2 "TEST 2: one excessive paren after unary '&' - with components" |
| 36 |
|
| 37 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 38 |
"additional_flags=-O additional_flags=-g"] |
| 39 |
if {$res ne ""} { |
| 40 |
verbose "target_compile failed: $res" 2 |
| 41 |
fail "$test: $subtest2: unable to compile ${test}_1.c" |
| 42 |
} else { |
| 43 |
foreach runtime [get_runtime_list] { |
| 44 |
if {$runtime eq ""} { |
| 45 |
set runtime "kernel" |
| 46 |
} |
| 47 |
set test_name "$test: $subtest2 ($runtime)" |
| 48 |
set exit_code [run_cmd_2way "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_2.stp'" \ |
| 49 |
out stderr] |
| 50 |
set exp_out "1 |
| 51 |
1 |
| 52 |
0 |
| 53 |
" |
| 54 |
is "${test_name}: stdout" $out $exp_out |
| 55 |
is "${test_name}: exit code" $exit_code 0 |
| 56 |
if {$stderr ne ""} { |
| 57 |
send_log "stderr:\n$stderr" |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
# --- TEST 3 --- |
| 63 |
|
| 64 |
set subtest3 "TEST 3: 2 excessive parens after unary '&' - without components" |
| 65 |
|
| 66 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 67 |
"additional_flags=-O additional_flags=-g"] |
| 68 |
if {$res ne ""} { |
| 69 |
verbose "target_compile failed: $res" 2 |
| 70 |
fail "$test: $subtest3: unable to compile ${test}_1.c" |
| 71 |
} else { |
| 72 |
foreach runtime [get_runtime_list] { |
| 73 |
if {$runtime eq ""} { |
| 74 |
set runtime "kernel" |
| 75 |
} |
| 76 |
set test_name "$test: $subtest3 ($runtime)" |
| 77 |
set exit_code [run_cmd_2way "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_3.stp'" \ |
| 78 |
out stderr] |
| 79 |
set exp_out "1\n" |
| 80 |
is "${test_name}: stdout" $out $exp_out |
| 81 |
is "${test_name}: exit code" $exit_code 0 |
| 82 |
if {$stderr ne ""} { |
| 83 |
send_log "stderr:\n$stderr" |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
# --- TEST 4 --- |
| 89 |
|
| 90 |
set subtest4 "TEST 4: taking address of int globals" |
| 91 |
|
| 92 |
set res [target_compile ${testpath}/${test}_4.c ./a.out executable \ |
| 93 |
"additional_flags=-O additional_flags=-g"] |
| 94 |
if {$res ne ""} { |
| 95 |
verbose "target_compile failed: $res" 2 |
| 96 |
fail "$test: $subtest4: unable to compile ${test}_4.c" |
| 97 |
} else { |
| 98 |
foreach runtime [get_runtime_list] { |
| 99 |
if {$runtime eq ""} { |
| 100 |
set runtime "kernel" |
| 101 |
} |
| 102 |
set test_name "$test: $subtest4 ($runtime)" |
| 103 |
set exit_code [run_cmd_2way "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_4.stp'" \ |
| 104 |
out stderr] |
| 105 |
set exp_out "1 |
| 106 |
-32 |
| 107 |
" |
| 108 |
is "${test_name}: stdout" $out $exp_out |
| 109 |
is "${test_name}: exit code" $exit_code 0 |
| 110 |
if {$stderr ne ""} { |
| 111 |
send_log "stderr:\n$stderr" |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
# --- TEST 5 --- |
| 117 |
|
| 118 |
set subtest5 "TEST 5: duplicate unary '&'" |
| 119 |
|
| 120 |
set res [target_compile ${testpath}/${test}_4.c ./a.out executable \ |
| 121 |
"additional_flags=-O additional_flags=-g"] |
| 122 |
if {$res ne ""} { |
| 123 |
verbose "target_compile failed: $res" 2 |
| 124 |
fail "$test: $subtest5: unable to compile ${test}_4.c" |
| 125 |
} else { |
| 126 |
foreach runtime [get_runtime_list] { |
| 127 |
if {$runtime eq ""} { |
| 128 |
set runtime "kernel" |
| 129 |
} |
| 130 |
set test_name "$test: $subtest5 ($runtime)" |
| 131 |
set exit_code [run_cmd_2way "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_5.stp'" \ |
| 132 |
out stderr] |
| 133 |
set exp_out "" |
| 134 |
is "${test_name}: stdout" $out $exp_out |
| 135 |
isnt "${test_name}: exit code" $exit_code 0 |
| 136 |
set stderr_pat "\\Aparse error: cannot take address more than once |
| 137 |
at: operator '&' at .*?\\.stp:2:9 |
| 138 |
source: q = &\\(\\(&\\@var\\(\"a\"\\)\\)\\); |
| 139 |
\\^ |
| 140 |
|
| 141 |
1 parse error\\. |
| 142 |
" |
| 143 |
like "${test_name}: stderr" $stderr $stderr_pat "-linestop" |
| 144 |
} |
| 145 |
} |