| 1 |
set test "process-begin-user" |
| 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: register() in probe process.begin" |
| 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 |
if {! [process_template_file "$srcdir/$subdir/${test}_1.stp" \ |
| 18 |
"./${test}_1.stp" "./a.out" nm_err]} { |
| 19 |
fail "$test: $subtest1: $nm_err" |
| 20 |
} else { |
| 21 |
foreach runtime [get_runtime_list] { |
| 22 |
if {$runtime eq ""} { |
| 23 |
set runtime "kernel" |
| 24 |
} |
| 25 |
set test_name "$test: $subtest1 ($runtime)" |
| 26 |
set cmd "stap --runtime=$runtime -c ./a.out './${test}_1.stp'" |
| 27 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 28 |
set out_pat "\\Arip: 0x\[1-9a-f\]\[0-9a-f\]*\\nsame uaddr\\n\\Z" |
| 29 |
like "${test_name}: stdout" $out $out_pat "-lineanchor" |
| 30 |
is "${test_name}: exit code" $exit_code 0 |
| 31 |
if {$stderr ne ""} { |
| 32 |
send_log "stderr:\n$stderr" |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
# --- TEST 2 --- |
| 39 |
|
| 40 |
set subtest2 "TEST 2: register() in probe process.end" |
| 41 |
|
| 42 |
# NB This test case is expected to fail on CentOS 6 on which registers are |
| 43 |
# actually usable in the prcoess.end probe. |
| 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 |
if {! [process_template_file "$srcdir/$subdir/${test}_2.stp" \ |
| 52 |
"./${test}_2.stp" "./a.out" nm_err]} { |
| 53 |
fail "$test: $subtest2: $nm_err" |
| 54 |
} else { |
| 55 |
foreach runtime [get_runtime_list] { |
| 56 |
if {$runtime eq ""} { |
| 57 |
set runtime "kernel" |
| 58 |
} |
| 59 |
set test_name "$test: $subtest2 ($runtime)" |
| 60 |
set cmd "stap --runtime=$runtime -c ./a.out './${test}_2.stp'" |
| 61 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 62 |
set exp_out "" |
| 63 |
is "${test_name}: stdout" $out $exp_out |
| 64 |
isnt "${test_name}: exit code" $exit_code 0 |
| 65 |
set stderr_pat "ERROR: cannot access CPU registers in this context" |
| 66 |
like "${test_name}: stderr" $stderr $stderr_pat "-linestop" |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
# --- TEST 3 --- |
| 72 |
|
| 73 |
set subtest3 "TEST 3: @var() in probe process(PATH).begin (with vma tracker)" |
| 74 |
|
| 75 |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ |
| 76 |
"additional_flags=-O additional_flags=-g additional_flags=-pie additional_flags=-fpic"] |
| 77 |
if {$res ne ""} { |
| 78 |
verbose "target_compile failed: $res" 2 |
| 79 |
fail "$test: $subtest3: unable to compile ${test}_3.c" |
| 80 |
} else { |
| 81 |
if {! [process_template_file "$srcdir/$subdir/${test}_3.stp" \ |
| 82 |
"./${test}_3.stp" "./a.out" nm_err]} { |
| 83 |
fail "$test: $subtest3: $nm_err" |
| 84 |
} else { |
| 85 |
foreach runtime [get_runtime_list] { |
| 86 |
if {$runtime eq ""} { |
| 87 |
set runtime "kernel" |
| 88 |
} |
| 89 |
set test_name "$test: $subtest3 ($runtime)" |
| 90 |
set cmd "stap --runtime=$runtime -c ./a.out './${test}_3.stp'" |
| 91 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 92 |
set exp_out "a: 32\n" |
| 93 |
is "${test_name}: stdout" $out $exp_out |
| 94 |
is "${test_name}: exit code" $exit_code 0 |
| 95 |
if {$stderr ne ""} { |
| 96 |
send_log "stderr:\n$stderr" |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
# --- TEST 4 --- |
| 103 |
|
| 104 |
set subtest4 "TEST 4: @var() in probe process.begin (with vma tracker)" |
| 105 |
|
| 106 |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ |
| 107 |
"additional_flags=-O additional_flags=-g additional_flags=-pie additional_flags=-fpic"] |
| 108 |
if {$res ne ""} { |
| 109 |
verbose "target_compile failed: $res" 2 |
| 110 |
fail "$test: $subtest4: unable to compile ${test}_3.c" |
| 111 |
} else { |
| 112 |
if {! [process_template_file "$srcdir/$subdir/${test}_4.stp" \ |
| 113 |
"./${test}_4.stp" "./a.out" nm_err]} { |
| 114 |
fail "$test: $subtest4: $nm_err" |
| 115 |
} else { |
| 116 |
foreach runtime [get_runtime_list] { |
| 117 |
if {$runtime eq ""} { |
| 118 |
set runtime "kernel" |
| 119 |
} |
| 120 |
set test_name "$test: $subtest4 ($runtime)" |
| 121 |
set cmd "stap --runtime=$runtime -c ./a.out './${test}_4.stp'" |
| 122 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 123 |
set exp_out "a: 32\n" |
| 124 |
is "${test_name}: stdout" $out $exp_out |
| 125 |
is "${test_name}: exit code" $exit_code 0 |
| 126 |
if {$stderr ne ""} { |
| 127 |
send_log "stderr:\n$stderr" |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
} |