File: private.exp

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (222 lines) | stat: -rw-r--r-- 6,803 bytes parent folder | download | duplicates (6)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Test the private keyword feature

set test "private"

# Setup
file mkdir "$test"
file copy "$srcdir/$subdir/${test}.stp" "$test"
cd "$test"

foreach runtime [get_runtime_list] {
    if {$runtime == ""} {set runtime kernel}

    # Subtest
    set subtest "$test private-variable-basic"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe oneshot \{println(gtest1_getter(), \",\", gtest2_getter())\}}"
    expect {
        -timeout 160
        -re {^3,7\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test private-variable-illegal-access"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe oneshot \{println(gtest1)\}}"
    expect {
        -timeout 160
        -re {semantic error: unresolved type : identifier 'gtest1'} {
            incr __counter
            exp_continue
        }
        -re {^[^\r\n]+\r\n} {
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}


    # Subtest
    set subtest "$test private-function-basic"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe oneshot \{println(getthree())\}}"
    expect {
        -timeout 160
        -re {^3\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test private-function-illegal-access"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe oneshot \{println(three())\}}"
    expect {
        -timeout 160
        -re {semantic error: unresolved function[^\r\n]+identifier 'three' at} {
            incr __counter
            exp_continue
        }
        -re {^[^\r\n]+\r\n} {
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test global-variable-access"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe oneshot \{println(myglobal)\}}"
    expect {
        -timeout 160
        -re {^11\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test global-variable-access-override"
    set __counter 0
    eval spawn "stap --runtime=$runtime -G myglobal=12 -I . -e {probe oneshot \{println(myglobal)\}}"
    expect {
        -timeout 160
        -re {^12\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    # NB: Some kernels fail to load the module, but some just printk that
    # they're ignoring unknown parameters and continue anyway.  stapdyn also
    # just warns and continues, so treat either hard error or unmodified pt
    # output as a test PASS.
    set subtest "$test private-variable-override-denied"
    set __counter 0
    eval spawn "stap --runtime=$runtime -G pt=12 -e {private pt=13; probe oneshot \{println(pt)\}}"
    expect {
        -timeout 160
        -re {^ERROR: Couldn't insert module[^\r\n]+Unknown symbol in module\r\n} {
            incr __counter
            exp_continue
        }
        -re {^stapdyn: WARNING: Ignoring unknown module option 'pt'\r\n} {
            exp_continue
        }
        -re {^13\r\n} {
            incr __counter
            exp_continue
        }
        -re {^[^\r\n]+\r\n} {
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test private-function-in-user-script"
    set __counter 0
    eval spawn "stap --runtime=$runtime -e {private function foo() { println(42) } probe oneshot \{ foo() \}}"
    expect {
        -timeout 160
        -re {^42\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    set subtest "$test multiple-private-global-var-decl"
    set __counter 0
    eval spawn "stap --runtime=$runtime -e {private varA = 41, varB = 42 probe oneshot \{ println(varA, varB) \}}"
    expect {
        -timeout 160
        -re {^4142\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    if {$runtime != "dyninst"} {
        set subtest "$test PR13721-workaround-test"
        set __counter 0
        eval spawn "stap --runtime=$runtime -e {private addr probe begin\{addr\[AF_INET()\]=\"addr\" exit()\}}"
        expect {
            -timeout 160
            -re {^addr\[2\]="addr"\r\n} {
                incr __counter
                exp_continue
            }
            timeout {fail "$subtest (timeout)"}
        }
        catch {close}; catch {wait}
        if {$__counter == 1} {pass $subtest} else {fail $subtest}
    }

    # Subtest
    # PR20307 Make sure a private global variable (defined in a tapset)
    # is resolvable within a probe alias (from that same tapset).
    set subtest "$test PR20307-private-variable-in-tapset-probe-alias"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe foo \{println(f) exit()\}}"
    expect {
        -timeout 160
        -re {^7\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}

    # Subtest
    # Analogy to the above, but for a private global function.
    set subtest "$test private-function-in-tapset-probe-alias"
    set __counter 0
    eval spawn "stap --runtime=$runtime -I . -e {probe bar \{println(g) exit()\}}"
    expect {
        -timeout 160
        -re {^3\r\n} {
            incr __counter
            exp_continue
        }
        timeout {fail "$subtest (timeout)"}
    }
    catch {close}; catch {wait}
    if {$__counter == 1} {pass $subtest} else {fail $subtest}
}

# Cleanup
cd ..
file delete -force "$test"