Debian Codegraph @

testsuite/systemtap.stress/parallel_exec.exp

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