Debian Codegraph @

testsuite/systemtap.pass1-4/buildok-interactive.exp

raw
1 set self buildok
2 set test_suffix "(interactive)"
3
4 if {! [readline_p]} { untested "${self} ${test_suffix}"; return }
5
6 # Since we need a clean cache directory, we'll use a temporary
7 # systemtap directory and cache (add user name so make check and
8 # sudo make installcheck don't clobber each others)
9 set local_systemtap_dir [exec pwd]/.cache_test-[exec whoami]
10 exec /bin/rm -rf $local_systemtap_dir
11 if [info exists env(SYSTEMTAP_DIR)] {
12 set old_systemtap_dir $env(SYSTEMTAP_DIR)
13 }
14 set env(SYSTEMTAP_DIR) $local_systemtap_dir
15
16 #exp_internal 1
17 set rc [stapi_start "-vp4"]
18 if {$rc} { return }
19
20 set effective_uid [exec /usr/bin/id -u]
21
22 foreach file [lsort [glob -nocomplain $srcdir/$self/*.stp]] {
23 set test "${self}/[file tail $file]"
24 set full_test "${test} ${test_suffix}"
25
26 # Set default flags
27 set guru_mode 0
28 set suppress_warnings 0
29 set panic_warnings 0
30 set timing 0
31 set unoptimized 0
32
33 # Most of the buildok test cases use '#! stap ...'. Try to read
34 # this information.
35 set f [open $file r]
36 set firstbits [gets $f]
37 close $f
38 if [regexp -line {\#! stap (.*)} $firstbits -> stap_args] {
39 verbose -log "running the equivalent of 'stap $stap_args $file'"
40 # Parse arguments.
41 set arg_fail 0
42 set skip_test 0
43 set last_pass "4"
44 foreach arg $stap_args {
45 if {[ string index $arg 0 ] != "-" } { break }
46 set ch_idx 1
47 while {1} {
48 set opt_ch [ string index $arg $ch_idx ]
49 if { $opt_ch == "" } { break }
50 incr ch_idx
51 switch -- $opt_ch {
52 p {
53 # We're already doing p4. Ignore this option
54 # as long as the next character is '4'.
55 set opt_ch [ string index $arg $ch_idx ]
56 incr ch_idx
57 if { $opt_ch != "4" } {
58 set last_pass $opt_ch
59 break
60 }
61 continue
62 }
63 g { set guru_mode 1; continue }
64 t { set timing 1; continue }
65 w { set suppress_warnings 1; continue }
66 W { set panic_warnings 1; continue }
67 u { set unoptimized 1; continue }
68 - {
69 # Handle long arguments ("--FOO") by testing
70 # the whole argument.
71 switch -regexp -- $arg {
72 {^--compatible=.*} {
73 # We can't handle the '--compatible'
74 # option. Once the library scripts
75 # have been read, they are "set" at a
76 # particular version and can't be
77 # changed on the fly.
78 set skip_test 1
79 verbose -log "unsupported option '${arg}'"
80 }
81 default { set arg_fail 1 }
82 }
83 if {$arg_fail} {
84 verbose -log "unknown long argument '${arg}'"
85 }
86 break
87 }
88 default {
89 verbose -log "unknown argument '${opt_ch}'"
90 set arg_fail 1
91 break
92 }
93 }
94 }
95 }
96 if {$arg_fail} {
97 fail "${full_test} - arg parsing"
98 continue
99 } elseif {$skip_test} {
100 untested "${full_test} - unsupported option"
101 continue
102 } else {
103 pass "${full_test} - arg parsing"
104 }
105 if {$last_pass != "4"} {
106 untested "$full_test - last pass isn't 4 ($last_pass)"
107 continue
108 }
109 } else {
110 # If "stap" wasn't on the first line of the script, this isn't
111 # a systemtap script, but a shell script that will run
112 # systemtap. We'll have to skip these.
113 untested "$full_test - shell script"
114 continue
115 }
116
117 # We need to "clean up" from our last run. First, delete the last
118 # script.
119 set rc [stapi_test_question "delete" "Delete entire script.*y or n.*" "y"]
120
121 # Set all the flags, based on the arg parsing above.
122 if {!$rc} {set rc [stapi_test_no_output "set guru_mode $guru_mode"] }
123 if {!$rc} {set rc [stapi_test_no_output \
124 "set suppress_warnings $suppress_warnings"] }
125 if {!$rc} {set rc [stapi_test_no_output \
126 "set panic_warnings $panic_warnings"] }
127 if {!$rc} {set rc [stapi_test_no_output "set timing $timing"] }
128 if {!$rc} {set rc [stapi_test_no_output \
129 "set unoptimized $unoptimized"] }
130 switch -- $rc {
131 0 { pass "${full_test} - reset" }
132 1 { fail "${full_test} - reset"; break }
133 -1 { fail "${full_test} - reset: crashed"; break }
134 }
135
136 # Now try to load the script. If the "load" command reports any
137 # output, the script didn't load properly.
138 set rc [stapi_test_no_output "load $file"]
139 switch $rc {
140 0 { pass "${full_test} - load" }
141 1 { fail "${full_test} - load"; continue }
142 -1 { fail "${full_test} - load: crashed"; break }
143 }
144
145 # Now try to compile the script by issuing the "run" command.
146 verbose -log "Running $file"
147 set rc [stapi_run_batch]
148 if {$rc < 0} {
149 switch -- $rc {
150 -1 { fail "${full_test} - compile: crashed" }
151 -2 { fail "${full_test} - compile timeout" }
152 default { fail "${full_test} - unknown error" }
153 }
154 break
155 }
156
157 # Use setup_kfail <pr number> <target triplet> for known bugs.
158 #
159 # (Note that tcl doesn't like comments directly inside the switch
160 # statement, but comments can go in sub-blocks.)
161 switch -- $test {
162 buildok/memory-write_shared_copy.stp {
163 if {$rc == 1} { setup_kfail 1155 *-*-* } }
164
165 buildok/memory-mmap.stp -
166 buildok/memory-write_shared_copy.stp -
167 buildok/networking-change_rx_flag.stp -
168 buildok/nfs-fop.check_flags.stp -
169 buildok/scheduler-cpu_off.stp -
170 buildok/scheduler-cpu_on.stp -
171 buildok/scheduler-ctxswitch.stp -
172 buildok/scheduler-migrate.stp -
173 buildok/signal-check_ignored.stp -
174 buildok/signal-handle.stp -
175 buildok/tty-resize.stp {
176 # (Note that if a test fails because of debuginfo-quality
177 # problems, don't kfail a tapset's entire test. Extract
178 # the failing probe/function's test into a new file and
179 # kfail that.)
180 #
181 # Use setup_kfail GCC <target triplet> for
182 # debuginfo-quality problems.
183 if {$rc == 1} { setup_kfail GCC *-*-* } }
184
185 buildok/per-process-syscall.stp -
186 buildok/utrace.stp {
187 # Use setup_kfail UTRACE <target triplet> for systems
188 # without utrace.
189 if {$rc == 1 && ![utrace_p]} { setup_kfail UTRACE *-*-*} }
190
191 buildok/fortyfour.stp -
192 buildok/map_probe_cond.stp -
193 buildok/pretty-uprobes.stp -
194 buildok/pretty-uprobes.stp -
195 buildok/ucontext-symbols-embedded.stp -
196 buildok/ucontext-unwind-embedded.stp {
197 # Use setup_kfail UPROBES <target triplet> for systems
198 # without uprobes. (ia64 has utrace, but not uprobes.)
199 if {$rc == 1 && ![uprobes_p]} { setup_kfail UPROBES *-*-* } }
200
201 buildok/twentyeightprime.stp {
202 # Use setup_kfail UPROBES <target triplet> for systems
203 # without uprobes. (ia64 has utrace, but not uprobes.)
204 if {$rc == 1 && ![uprobes_p]} { setup_kfail UPROBES *-*-* }
205
206 # Use setup_kfail INODE_UPROBES <target triplet> for
207 # systems with inode uprobes, where absolute probes don't
208 # work.
209 if {$rc == 1 && [inode_uprobes_p]} {
210 setup_kfail INODE_UPROBES *-*-* }
211 }
212
213 buildok/context-symbols-embedded.stp -
214 buildok/context-unwind-embedded.stp {
215 # Use setup_kfail UNWIND <target triplet> for systems
216 # with an unsupported dwarf unwind architecture
217 if {$rc == 1 && [istarget ia64-*-*]} {
218 setup_kfail UNWIND ia64-*-* } }
219
220 buildok/fortyseven.stp {
221 if {$rc == 1} { setup_kfail 15065 *-*-* } }
222
223 buildok/stap_staticmarkers-detailed.stp {
224 # Use setup_kfail ROOT_ONLY for tests that must be run as
225 # root.
226 #
227 # In the case of stap_staticmarkers-detailed.stp, it
228 # probes "staprun", which is only readable by root.
229 if {$rc != 0 && $effective_uid != 0} {
230 setup_kfail ROOT_ONLY *-*-* }
231
232 # Use setup_kfail UPROBES <target triplet> for systems
233 # without uprobes. (ia64 has utrace, but not uprobes.)
234 if {$rc != 0 && ![uprobes_p]} { setup_kfail UPROBES *-*-* }
235 }
236
237 buildok/hwbkpt.stp {
238 if {$rc != 0 && ![hwbkpt_probes_p]} { setup_kfail HWBKPT *-*-* } }
239 }
240 switch -- $rc {
241 0 { pass "${full_test} - compile" }
242 1 { fail "${full_test} - compile"; continue }
243 2 { fail "${full_test} - compile: cache used"; continue }
244 }
245
246 # If we're here, then the previous compilation worked. Compile the
247 # script again, making sure the cache was used.
248 verbose -log "Running $file again"
249 set rc [stapi_run_batch 1]
250 switch -- $rc {
251 -1 { fail "${full_test} - cached compile: crashed"; break }
252 0 { pass "${full_test} - cached compile" }
253 1 { fail "${full_test} - cached compile" }
254 2 { fail "${full_test} - cached compile: no cache use" }
255 }
256 }
257
258 # Cleanup.
259 stapi_exit
260 exec /bin/rm -rf $local_systemtap_dir
261 if [info exists old_systemtap_dir] {
262 set env(SYSTEMTAP_DIR) $old_systemtap_dir
263 } else {
264 unset env(SYSTEMTAP_DIR)
265 }