summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/alternatives.exp
blob: 673f34266c108e145baa3df871ccef8a82ee2592 (plain)
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
# alternatives.exp
#
# 2 simple tests:
#
# LOCAL1: makes sure that when a probe is compiled that accesses a
# non-existent local variable, the local variables that do exist are
# listed as alternatives.
#
# STRUCT1: makes sure that when a probe is compiled that accesses a
# non-existent structure member, the structure members that do exist
# are listed as alternatives.
#
# Note that the tests don't check if the correct alternatives are
# listed, but that some alternatives are listed.

set local1_script {
    probe kernel.function("sys_getrlimit") { x = $z; }
}

set struct1_script {
    probe kernel.function("sys_getrlimit") { rlim_cur = $rlim->rlim_cud; }
}

proc stap_run_alternatives {args} {
    set alternatives_found 0
    verbose -log "starting $args"
    eval spawn $args
    expect { 
	-re {semantic error: .+ \(alternatives: [a-zA-Z_]}
	    { set alternatives_found 1 }
        -re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue } 
        eof { }
        timeout { exp_continue } 
    }
    set results [wait]
    verbose -log "wait results: $results"
    return $alternatives_found
}

set test "LOCAL1"
set rc [stap_run_alternatives stap -vu -p2 -e $local1_script]
if {$rc == 1} { pass $test } else { fail $test }

set test "STRUCT1"
set rc [stap_run_alternatives stap -vu -p2 -e $struct1_script]
if {$rc == 1} { pass $test } else { fail $test }