Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/atcast-index.exp

raw
1 set test "atcast-index"
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: const folding in array index of a translated array address"
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 -vvv --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_1.stp'"
23 set exit_code [run_cmd_2way $cmd out stderr]
24 set out_pat "^78\\n\\Z"
25 like "${test_name}: stdout" $out $out_pat "-linestop -lineanchor"
26 set stderr_pat "Collapsing constant-identity binary operator operator '\\*' at "
27 like "${test_name}: stderr" $stderr $stderr_pat "-lineanchor"
28 is "${test_name}: exit code" $exit_code 0
29 }
30 }
31
32 # --- TEST 2 ---
33
34 set subtest2 "TEST 2: ternary expressions inside dwarf array indexes"
35
36 set res [target_compile ${testpath}/${test}_2.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}_2.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 --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_2.stp'"
48 set exit_code [run_cmd_2way $cmd out stderr]
49 set exp_out "91
50 78
51 "
52 is "${test_name}: stdout" $out $exp_out
53 is "${test_name}: exit code" $exit_code 0
54 if {$stderr ne ""} {
55 send_log "stderr:\n$stderr"
56 }
57 }
58 }