Debian Codegraph @

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

raw
1 set test "onoffprobe"
2 if {![installtest_p]} { untested $test; return }
3
4 spawn stap $srcdir/$subdir/$test.stp
5 set pid $spawn_id
6 set ok 0
7
8 proc advance {} {
9 global test
10 global expect_out
11 global ok
12 global modname
13 set procfs_file "/proc/systemtap/$modname/switch"
14
15 pass "$test $expect_out(1,string)"
16
17 # If this is the first time, wait until the procfs file exists
18 # (for up to 10 seconds).
19 if {$ok == 0} {
20 set i 0
21 while {![file exists $procfs_file]} {
22 sleep 1
23 incr i
24 if {$i >= 10} { break }
25 }
26 # If the procfs file still doesn't exist, fail.
27 if {![file exists $procfs_file]} {
28 fail "$test (missing procfs file)"
29 }
30 }
31
32 incr ok
33 if {[file exists $procfs_file]} { exec echo $ok > $procfs_file }
34 exec echo dummy > /dev/null
35 exp_continue
36 }
37
38 expect {
39 -timeout 240
40 -re {(begin1 probed): ([^\r\n]+)\r\n}
41 { set modname "$expect_out(2,string)"; advance }
42 -re "(function return probed)\r\n" { advance }
43 -re "(function entry probed)\r\n" { advance }
44 -re "(timer probed)\r\n" { advance }
45 -re "(profile probed)\r\n" { advance }
46 -re "(alias\.one\.a and alias\.one and alias\.\* probed)\r\n" { advance }
47 -re "(alias\.one\.b and alias\.one and alias\.\* probed)\r\n" { advance }
48 -re "(alias\.two and alias\.\* probed)\r\n" { advance }
49 timeout {
50 fail "$test (timeout)"
51 kill -INT -[exp_pid]
52 }
53 eof { }
54 }
55
56 kill -INT -[exp_pid] 2
57 catch {close}; catch {wait}
58 if {$ok != 8} {fail "conditional probes ($ok)"}