1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
set test "parallel execute"
set process_num 10
set script {
probe syscall.open
{
if (pid() != target()) next
log("open")
}
probe syscall.close
{
if (pid() != target()) next
log("close")
}
}
# 'num' is the number of '(open|close)' lines output by 1 systemtap
# process.
#
# Note that executing this here preloads the cache with the script for
# the stap invocations in the loop below.
set num 0
spawn stap -e "$script" -c "cat /etc/hosts > /dev/null"
expect {
-timeout 60
-re {^(open|close)\r\n} {
incr num
exp_continue
}
}
catch {close}; catch {wait}
set spawn_ids {}
for { set i 0 } { $i < $process_num } { incr i } {
spawn stap -e "$script" -c "cat /etc/hosts > /dev/null"
lappend spawn_ids $spawn_id
}
if {[gen_load] == 0} then {
pass "$test - load generation"
} else {
fail "$test - load generation"
}
# 'num_sum' is the number of '(open|close)' lines output by
# all the spawned systemtap processes.
set num_sum 0
foreach id $spawn_ids {
expect {
-i $id -timeout 60
-i $id -re {^(open|close)\r\n} {
incr num_sum
exp_continue
}
}
catch {close -i $id}; catch {wait -i $id}
}
# If we got all the output, 'num' (output lines by 1 process) *
# 'process_num' (number of processes) should equal 'num_sum' (output
# lines by all processes)
if {$num * $process_num != $num_sum} {
fail "$test - ($num * $process_num) != $num_sum"
} else {
pass $test
}
|