Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/valid_pid.exp

raw
1 set test_scripts {
2 "probe process(\$1).syscall{exit();}"
3 "probe process(\$1).begin{exit();}"
4 "probe process(\$1).end{exit();}"
5 "probe process(\$1).thread.begin{exit();}"
6 "probe process(\$1).function(\"main\"){exit();}"
7 "probe process(\$1).mark(\"*\"){exit();}"
8 "probe process(\$1).plt(\"*\"){exit();}"
9 "probe process(\$1).provider(\"*\").mark(\"*\"){exit();}"
10
11 "probe process.begin{exit();}"
12 "probe process.end{exit();}"
13 "probe process.thread.begin{exit();}"
14 "probe process.function(\"main\"){exit();}"
15 "probe process.plt(\"*\"){exit();}"
16 "probe process.mark(\"*\"){exit();}"
17 "probe process.provider(\"*\").mark(\"*\"){exit();}"
18
19 "probe process(\$1).statement(200){exit();}"
20 }
21
22 spawn stap -e "probe begin{}"
23 set exe_id $spawn_id
24 set valid_pid [exp_pid -i $exe_id]
25 verbose -log "valid pid is: $valid_pid"
26
27 # pids are: invalid, valid
28 set pids "1234567890 $valid_pid"
29
30 foreach test_script $test_scripts {
31 foreach pid $pids {
32 verbose -log "PID under test is $pid"
33 if {(([regexp {insn} $test_script] || [regexp {statement} $test_script]) || ![uprobes_p]) || ([regexp {plt} $test_script] && ![plt_probes_p])} {
34 untested "script: $test_script"
35 continue
36 } else {
37 if { [regexp {1} $test_script] } {
38 spawn stap -p2 -e $test_script $pid
39 } else {
40 spawn stap -p2 -e $test_script -x $pid
41 }
42 }
43 set exe_id2 $spawn_id
44 expect {
45 -re {semantic error: [ A-Za-z]*pid[ A-Za-z]*} { if {$pid != $valid_pid } { pass "$test_script" } else { fail "$test_script" } }
46 -re {semantic error: [ A-Za-z]*cannot find executable[ A-Za-z]*} { if {(([regexp {function} $test_script] || [regexp {plt} $test_script]) || [regexp {mark} $test_script]) && $pid != $valid_pid} { pass "$test_script" } }
47 # only checking that a semantic error about a pid is not raised
48 # when a valid pid is given. don't really care if other errors are
49 # thrown
50 eof { if {$pid == $valid_pid } { pass "$test_script" } else { fail "$test_script" } }
51 }
52 catch { close -i $exe_id2 }; catch { wait -i $exe_id2 }
53 }
54 }
55
56 kill -INT -[exp_pid -i $exe_id] 2
57 catch { close -i $exe_id }; catch { wait -i $exe_id }