| 1 |
# This test answers the following questions: |
| 2 |
# |
| 3 |
# - Can we attach to stopped processes correctly? Before PR?????? fix, |
| 4 |
# stap would cause a kernel warn. |
| 5 |
# |
| 6 |
# - Does resuming work on those processes? Before PR?????? fix, |
| 7 |
# processes would get stuck. |
| 8 |
|
| 9 |
set test "process_resume" |
| 10 |
|
| 11 |
# Only run on make installcheck and if we have utrace |
| 12 |
if {![installtest_p]} { untested "$test"; return } |
| 13 |
if {![utrace_p]} { untested "$test : no kernel utrace support found"; return } |
| 14 |
|
| 15 |
# "load" generation function for stap_run. It waits a bit, tells the |
| 16 |
# test program to continue and then waits a bit. |
| 17 |
proc resume_load {} { |
| 18 |
global pid |
| 19 |
|
| 20 |
wait_n_secs 2 |
| 21 |
kill -cont $pid 0 |
| 22 |
wait_n_secs 2 |
| 23 |
return 0 |
| 24 |
} |
| 25 |
|
| 26 |
set getpid_script { |
| 27 |
global getpid_calls = 0 |
| 28 |
probe begin { printf("systemtap starting probe\n") } |
| 29 |
probe syscall.getpid { getpid_calls++ } |
| 30 |
probe end { printf("systemtap ending probe\n") |
| 31 |
printf("getpid calls = %d\n", getpid_calls) } |
| 32 |
} |
| 33 |
# Notice we don't care how many getpid() calls we see. |
| 34 |
set getpid_script_output "getpid calls = \[0-9\]+\r\n" |
| 35 |
|
| 36 |
set end_script { |
| 37 |
global end_probes_fired = 0 |
| 38 |
probe begin { printf("systemtap starting probe\n") } |
| 39 |
probe process("%s").end { end_probes_fired++ } |
| 40 |
probe end { printf("systemtap ending probe\n") |
| 41 |
printf("end probes = %%d\n", end_probes_fired) } |
| 42 |
} |
| 43 |
set end_script_output "end probes = 1\r\n" |
| 44 |
|
| 45 |
# Compile test program. |
| 46 |
set res [target_compile $srcdir/$subdir/${test}.c ${test} executable \ |
| 47 |
"additional_flags=-O2 additional_flags=-g"] |
| 48 |
if { $res != "" } { |
| 49 |
verbose "target_compile failed: $res" 2 |
| 50 |
fail "${test}: unable to compile ${test}.c" |
| 51 |
return |
| 52 |
} |
| 53 |
|
| 54 |
# Start the application and put it in the background before each |
| 55 |
# test. It will stop itself and be resumed by the 'resume_load' proc. |
| 56 |
|
| 57 |
set TEST_NAME "${test}-getpid" |
| 58 |
set pid [exec ./$test &] |
| 59 |
#spawn "./$test" |
| 60 |
#set id $spawn_id |
| 61 |
#set pid [exp_pid -i $spawn_id] |
| 62 |
stap_run $TEST_NAME resume_load $getpid_script_output -e $getpid_script |
| 63 |
if {[file isdirectory /proc/$pid]} { |
| 64 |
kill -KILL $pid 0 |
| 65 |
fail "$TEST_NAME: process didn't resume properly" |
| 66 |
} else { |
| 67 |
pass "$TEST_NAME: process resumed properly" |
| 68 |
} |
| 69 |
|
| 70 |
set TEST_NAME "${test}-end" |
| 71 |
set pid [exec ./$test &] |
| 72 |
set script [format $end_script $test] |
| 73 |
stap_run $TEST_NAME resume_load $end_script_output -e $script |
| 74 |
if {[file isdirectory /proc/$pid]} { |
| 75 |
kill -KILL $pid 0 |
| 76 |
fail "$TEST_NAME: process didn't resume properly" |
| 77 |
} else { |
| 78 |
pass "$TEST_NAME: process resumed properly" |
| 79 |
} |
| 80 |
|
| 81 |
# Cleanup |
| 82 |
if { $verbose == 0 } { catch { exec rm -f $test } } |