Debian Codegraph @

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

raw
1 # alternatives.exp
2 #
3 # 2 simple tests:
4 #
5 # LOCAL1: makes sure that when a probe is compiled that accesses a
6 # non-existent local variable, the local variables that do exist are
7 # listed as alternatives.
8 #
9 # STRUCT1: makes sure that when a probe is compiled that accesses a
10 # non-existent structure member, the structure members that do exist
11 # are listed as alternatives.
12 #
13 # Note that the tests don't check if the correct alternatives are
14 # listed, but that some alternatives are listed.
15
16 set local1_script {
17 probe kernel.function("vfs_write") { ret = $z; }
18 }
19
20 set struct1_script {
21 probe kernel.function("vfs_write") { f_pos = $file->f_po; }
22 }
23
24 proc stap_run_alternatives {args} {
25 set alternatives_found 0
26 verbose -log "starting $args"
27 eval spawn $args
28 expect {
29 -timeout 60
30 -re {semantic error: .+ \(alternatives: \$?[a-zA-Z_]} {incr alternatives_found; exp_continue}
31 -re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue }
32 eof { verbose -log "EOF" }
33 timeout { verbose -log "TIMEOUT" }
34 }
35 catch { close }
36 set results [wait]
37 verbose -log "wait results: $results"
38 return $alternatives_found
39 }
40
41 set test "LOCAL1"
42 set rc [stap_run_alternatives stap -u -p2 -e $local1_script]
43 if {$rc >= 1} { pass $test } else { fail "$test ($rc)" }
44
45 set test "STRUCT1"
46 set rc [stap_run_alternatives stap -u -p2 -e $struct1_script]
47 if {$rc >= 1} { pass $test } else { fail "$test ($rc)" }