| 1 |
set test "sdt_misc" |
| 2 |
|
| 3 |
# Test miscellaneous features of .mark probes |
| 4 |
# 1. Test executable built with dtrace generated header file |
| 5 |
# 2. Test attaching to a running process |
| 6 |
# 3. Test passing various C types to .mark probes |
| 7 |
# 4. Test probe in shared object |
| 8 |
# 5. Test attaching to a running process with markers in a shared object |
| 9 |
# 6. Test .mark probe wildcard matching |
| 10 |
# 7. Test V3 $$parms support |
| 11 |
|
| 12 |
set v_flags {{-DSTAP_SDT_V1} {-DSTAP_SDT_V2} {-DSTAP_SDT_V3}} |
| 13 |
set pbtype_mssgs {{V1_uprobe} {V2_uprobe} {V3_uprobe}} |
| 14 |
set pbtype_flags {{additional_flags=-g} {} {}} |
| 15 |
set fail_count 0 |
| 16 |
|
| 17 |
proc cleanup_handler { verbose } { |
| 18 |
global pbtype_mssgs |
| 19 |
global fail_count |
| 20 |
if { $verbose == 0 && $fail_count == 0 } { |
| 21 |
foreach x $pbtype_mssgs { |
| 22 |
catch {exec rm -f libsdt_${x}.so libsdt_${x}_shared.so \ |
| 23 |
sdt_misc_${x}.x sdt_misc_${x}_loop.x \ |
| 24 |
sdt_misc_${x}_shared.x sdt_misc_${x}_loop_shared.x \ |
| 25 |
sdt_misc_${x}.x sdt_misc_${x}_compatibility.x \ |
| 26 |
sdt_misc_${x}_types.x libsdt_${x}_loop.so } |
| 27 |
} |
| 28 |
catch {exec rm -f sdt_misc_.c sdt_misc_.h sdt_misc_.o sdt_types.x \ |
| 29 |
,semclean ,semout} |
| 30 |
} else { |
| 31 |
verbose -log "kept sdt_misc*.* test files due to failing tests" |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
# Start with a clean slate |
| 36 |
cleanup_handler 0 |
| 37 |
|
| 38 |
# Compile a C program to use as the user-space probing target |
| 39 |
set stap_path $env(SYSTEMTAP_PATH)/stap |
| 40 |
set sup_dpath "[pwd]/sdt_misc_.d" |
| 41 |
set sup_hpath "[pwd]/sdt_misc_.h" |
| 42 |
set sup_opath "[pwd]/sdt_misc_.o" |
| 43 |
|
| 44 |
# Iterate pbtype_flags |
| 45 |
for {set i 0} {$i < [llength $pbtype_flags]} {incr i} { |
| 46 |
set v_flag [lindex $v_flags $i] |
| 47 |
set pbtype_flag "[lindex $pbtype_flags $i] additional_flags=$v_flag" |
| 48 |
set pbtype_mssg [lindex $pbtype_mssgs $i] |
| 49 |
set sup_exepath "[pwd]/sdt_misc_$pbtype_mssg.x" |
| 50 |
|
| 51 |
# Run dtrace |
| 52 |
|
| 53 |
if {[installtest_p]} { |
| 54 |
set dtrace $env(SYSTEMTAP_PATH)/dtrace |
| 55 |
} else { |
| 56 |
set dtrace ../dtrace |
| 57 |
} |
| 58 |
|
| 59 |
verbose -log "$dtrace $v_flag --types -h -s $srcdir/$subdir/sdt_misc_.d" |
| 60 |
if {[catch {exec $dtrace $v_flag --types -h -s \ |
| 61 |
$srcdir/$subdir/sdt_misc_.d} res]} { |
| 62 |
verbose -log "unable to run $dtrace: $res" |
| 63 |
} |
| 64 |
verbose -log "$dtrace $v_flag --types -G -s $srcdir/$subdir/sdt_misc_.d" |
| 65 |
if {[catch {exec $dtrace $v_flag --types -G -s \ |
| 66 |
$srcdir/$subdir/sdt_misc_.d} res]} { |
| 67 |
verbose -log "unable to run $dtrace: $res" |
| 68 |
} |
| 69 |
if {[file exists $sup_hpath] && [file exists $sup_opath]} then { |
| 70 |
pass "$test dtrace $pbtype_mssg" |
| 71 |
} else { |
| 72 |
incr fail_count |
| 73 |
fail "$test dtrace $pbtype_mssg" |
| 74 |
cleanup_handler $verbose |
| 75 |
return |
| 76 |
} |
| 77 |
|
| 78 |
set sup_flags [sdt_includes] |
| 79 |
set sup_flags "$sup_flags additional_flags=-Wall" |
| 80 |
set sup_flags "$sup_flags additional_flags=-Werror" |
| 81 |
set sup_flags "$sup_flags additional_flags=$sup_opath" |
| 82 |
set sup_flags "$sup_flags additional_flags=-I. $pbtype_flag" |
| 83 |
set res [target_compile $srcdir/$subdir/sdt_misc.c $sup_exepath \ |
| 84 |
executable $sup_flags] |
| 85 |
if { $res != "" } { |
| 86 |
incr fail_count |
| 87 |
verbose "target_compile failed: $res" 2 |
| 88 |
fail "$test compiling $pbtype_mssg" |
| 89 |
cleanup_handler $verbose |
| 90 |
return |
| 91 |
} else { |
| 92 |
pass "$test compiling $pbtype_mssg" |
| 93 |
} |
| 94 |
|
| 95 |
if {![installtest_p]} { |
| 96 |
untested $test |
| 97 |
cleanup_handler $verbose |
| 98 |
return |
| 99 |
} |
| 100 |
|
| 101 |
# 1. Test executable built with dtrace generated header file |
| 102 |
|
| 103 |
foreach runtime [get_runtime_list] { |
| 104 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 105 |
continue } |
| 106 |
set test_xtra "" |
| 107 |
if {$runtime != ""} { |
| 108 |
set test_xtra " ($runtime)" |
| 109 |
verbose -log "spawn $stap_path --runtime=$runtime -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath" |
| 110 |
spawn $stap_path --runtime=$runtime -c $sup_exepath \ |
| 111 |
$srcdir/$subdir/sdt_misc.stp $sup_exepath |
| 112 |
} elseif {[uprobes_p]} { |
| 113 |
verbose -log "spawn $stap_path -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath" |
| 114 |
spawn $stap_path -c $sup_exepath $srcdir/$subdir/sdt_misc.stp \ |
| 115 |
$sup_exepath |
| 116 |
} else { |
| 117 |
untested "$test ${pbtype_mssg}" |
| 118 |
continue |
| 119 |
} |
| 120 |
set ok 0 |
| 121 |
expect { |
| 122 |
-timeout 180 |
| 123 |
-re {In test_probe_2 probe 0x2} { incr ok; exp_continue } |
| 124 |
-re {In test_probe_0 probe 0x3} { incr ok; exp_continue } |
| 125 |
-re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { |
| 126 |
incr ok; exp_continue } |
| 127 |
-re {In test_probe_4 dtrace probe 0x[0-9a-f]} { incr ok; exp_continue } |
| 128 |
-re {In test_probe_1 probe 0x0} { incr ok; exp_continue } |
| 129 |
timeout { fail "$test (timeout)" } |
| 130 |
eof { } |
| 131 |
} |
| 132 |
catch {close}; catch {wait} |
| 133 |
|
| 134 |
if {$ok == 6} { |
| 135 |
pass "$test ${pbtype_mssg}${test_xtra}" |
| 136 |
} else { |
| 137 |
if {[istarget "arm*-*-*"] && $pbtype_mssg == "V2_uprobe"} { |
| 138 |
xfail "$test ($ok) ${pbtype_mssg}${test_xtra}" |
| 139 |
} else { |
| 140 |
incr fail_count |
| 141 |
fail "$test ($ok) ${pbtype_mssg}${test_xtra}" |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
# 2. Test attaching to a running process |
| 147 |
|
| 148 |
set loop_flags "$sup_flags additional_flags=-DLOOP" |
| 149 |
set loop_exepath "[pwd]/sdt_misc_${pbtype_mssg}_loop.x" |
| 150 |
set res [target_compile $srcdir/$subdir/sdt_misc.c $loop_exepath \ |
| 151 |
executable $loop_flags] |
| 152 |
if { $res != "" } { |
| 153 |
incr fail_count |
| 154 |
verbose "target_compile failed: $res" 2 |
| 155 |
fail "$test compiling $pbtype_mssg -DLOOP" |
| 156 |
cleanup_handler $verbose |
| 157 |
return |
| 158 |
} else { |
| 159 |
pass "$test compiling $pbtype_mssg -DLOOP" |
| 160 |
} |
| 161 |
|
| 162 |
foreach runtime [get_runtime_list] { |
| 163 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 164 |
continue } |
| 165 |
set test_xtra "" |
| 166 |
if {$runtime != ""} { |
| 167 |
set test_xtra " ($runtime)" |
| 168 |
|
| 169 |
if {$runtime == "dyninst"} { |
| 170 |
# With --runtime=dyninst these tests will fail since |
| 171 |
# the dyninst runtime needs a target executable |
| 172 |
# (either '-c exe' or '-x pid'). So, skip these tests |
| 173 |
# to speed up test execution. |
| 174 |
xfail "$test ${pbtype_mssg}${test_xtra} attach" |
| 175 |
continue |
| 176 |
} |
| 177 |
|
| 178 |
# This is perhaps a wee bit clumsy |
| 179 |
verbose -log "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 180 |
$stap_path --runtime=$runtime $srcdir/$subdir/sdt_misc.stp $loop_exepath >| ,semout ; \ |
| 181 |
/bin/kill -SIGINT \$TEST" |
| 182 |
catch {system "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 183 |
$stap_path --runtime=$runtime $srcdir/$subdir/sdt_misc.stp $loop_exepath >| ,semout ; \ |
| 184 |
/bin/kill -SIGINT \$TEST"} |
| 185 |
} elseif {[uprobes_p]} { |
| 186 |
# This is perhaps a wee bit clumsy |
| 187 |
verbose -log "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 188 |
$stap_path $srcdir/$subdir/sdt_misc.stp $loop_exepath >| ,semout ; \ |
| 189 |
/bin/kill -SIGINT \$TEST" |
| 190 |
catch {system "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 191 |
$stap_path $srcdir/$subdir/sdt_misc.stp $loop_exepath >| ,semout ; \ |
| 192 |
/bin/kill -SIGINT \$TEST"} |
| 193 |
} else { |
| 194 |
untested "$test $pbtype_mssg attach" |
| 195 |
continue |
| 196 |
} |
| 197 |
|
| 198 |
set ok 0 |
| 199 |
set ko 0 |
| 200 |
spawn cat ,semout |
| 201 |
expect { |
| 202 |
-re {In test_probe_2 probe 0x2} { incr ok; exp_continue } |
| 203 |
-re {In test_probe_0 probe 0x3} { incr ok; exp_continue } |
| 204 |
-re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { |
| 205 |
incr ok; exp_continue } |
| 206 |
-re {In test_probe_4 dtrace probe 0x[0-9a-f]} { |
| 207 |
incr ok; exp_continue } |
| 208 |
-re {In test_probe_1 probe 0x0} { incr ok; exp_continue } |
| 209 |
eof { } |
| 210 |
} |
| 211 |
catch {close}; catch {wait} |
| 212 |
|
| 213 |
if {$ok == 6} { |
| 214 |
pass "$test ${pbtype_mssg}${test_xtra} attach" |
| 215 |
} else { |
| 216 |
if {[istarget "arm*-*-*"] && $pbtype_mssg == "V2_uprobe"} { |
| 217 |
xfail "$test ($ok) ${pbtype_mssg}${test_xtra} attach" |
| 218 |
} else { |
| 219 |
incr fail_count |
| 220 |
fail "$test ($ok) ${pbtype_mssg}${test_xtra} attach" |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
set ok 0 |
| 225 |
spawn cat ,semclean |
| 226 |
expect { |
| 227 |
-timeout 180 |
| 228 |
-re {PASS} { incr ok; exp_continue } |
| 229 |
-re {FAIL} { incr ko; exp_continue } |
| 230 |
timeout { fail "$test (timeout)" } |
| 231 |
eof { } |
| 232 |
} |
| 233 |
catch {close}; catch {wait} |
| 234 |
|
| 235 |
if {$ok == 4 && $ko == 0} { |
| 236 |
pass "$test ${pbtype_mssg}${test_xtra} epilogue" |
| 237 |
} else { |
| 238 |
incr fail_count |
| 239 |
fail "$test ($ok) ${pbtype_mssg}${test_xtra} epilogue" |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
# 3. Test passing various C types to .mark probes |
| 244 |
|
| 245 |
# same set of flags as sdt.exp |
| 246 |
set extra_type_flags {{additional_flags=-O2} |
| 247 |
{additional_flags=-O3} |
| 248 |
{additional_flags=-std=c89} |
| 249 |
{additional_flags=-std=c99} |
| 250 |
{additional_flags=-std=gnu99} |
| 251 |
{c++ additional_flags=-std=c++98 additional_flags=-x \ |
| 252 |
additional_flags=c++} |
| 253 |
{c++ additional_flags=-std=gnu++98 additional_flags=-x \ |
| 254 |
additional_flags=c++} |
| 255 |
{c++ additional_flags=-std=c++0x additional_flags=-x \ |
| 256 |
additional_flags=c++} |
| 257 |
{c++ additional_flags=-std=gnu++0x additional_flags=-x \ |
| 258 |
additional_flags=c++} |
| 259 |
} |
| 260 |
set extra_type_mssgs {-O2 -O3 c89 c99 gnu99 c++98 gnu++98 c++0x gnu++0x} |
| 261 |
# __STDC_VERSION__ could be used, but g++ has no equivalent |
| 262 |
set has_long_long {{} {} additional_flags=-DNO_LONG_LONG {} {} \ |
| 263 |
additional_flags=-DNO_LONG_LONG \ |
| 264 |
additional_flags=-DNO_LONG_LONG {} {}} |
| 265 |
set type_xfail {1 1 0 0 0 0 0 0 0} |
| 266 |
set type_pedantics_idx {1 1 2 2 2 2 2 2 2} |
| 267 |
# don't compile -O2 -O3 with -pedantic |
| 268 |
set type_pedantics {{} additional_flags=-pedantic} |
| 269 |
set type_pedantic_mssgs {{} -pedantic} |
| 270 |
|
| 271 |
for {set j 0} {$j < [llength $extra_type_flags]} {incr j} { |
| 272 |
set extra_type_mssg [lindex $extra_type_mssgs $j] |
| 273 |
|
| 274 |
for {set p 0} {$p < [lindex $type_pedantics_idx $j]} {incr p} { |
| 275 |
set type_pedantic_mssg [lindex $type_pedantic_mssgs $p] |
| 276 |
set type_flags "[sdt_includes] additional_flags=-Wall additional_flags=-Werror" |
| 277 |
set type_flags "$type_flags additional_flags=-I. $pbtype_flag" |
| 278 |
set type_flags "$type_flags [lindex $extra_type_flags $j] [lindex $type_pedantics $p] [lindex $has_long_long $j]" |
| 279 |
if {![istarget "i*86-*-*"] && ![istarget "arm*-*-*"] && ![istarget "aarch64-*-*"]} { |
| 280 |
set type_flags "$type_flags additional_flags=-m64" |
| 281 |
} |
| 282 |
set test_suffix "$pbtype_mssg $extra_type_mssg $type_pedantic_mssg" |
| 283 |
|
| 284 |
# On ARM these tests are known to fail with timeout for V1 |
| 285 |
# and V2 probes. Skip them altogether to speed execution. |
| 286 |
if {[istarget "arm*-*-*"] \ |
| 287 |
&& ($pbtype_mssg == "V1_uprobe" || $pbtype_mssg == "V2_uprobe")} { |
| 288 |
xfail "$test types $test_suffix" |
| 289 |
continue |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
set res [target_compile $srcdir/$subdir/sdt_types.c \ |
| 294 |
sdt_types.x executable $type_flags] |
| 295 |
if { $res != "" } { |
| 296 |
verbose "target_compile failed: $res" 2 |
| 297 |
# -std=gnu++0x and -std=c++0x are not universally accepted |
| 298 |
if {[string first "unrecognized command line option" $res] == -1} { |
| 299 |
incr fail_count |
| 300 |
fail "$test compiling types $test_suffix" |
| 301 |
} else { |
| 302 |
untested "$test compiling types $test_suffix" |
| 303 |
} |
| 304 |
untested "$test types $test_suffix" |
| 305 |
continue ; # type_pedantics_idx |
| 306 |
} else { |
| 307 |
pass "$test compiling types $test_suffix" |
| 308 |
} |
| 309 |
|
| 310 |
foreach runtime [get_runtime_list] { |
| 311 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 312 |
continue } |
| 313 |
set test_xtra "" |
| 314 |
if {$runtime != ""} { |
| 315 |
set test_xtra " ($runtime)" |
| 316 |
verbose -log "spawn $stap_path --runtime=$runtime -g -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x # $pbtype_mssg $extra_type_mssg" |
| 317 |
spawn $stap_path --runtime=$runtime -g -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x |
| 318 |
} elseif {[uprobes_p]} { |
| 319 |
verbose -log "spawn $stap_path -g -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x # $pbtype_mssg $extra_type_mssg" |
| 320 |
spawn $stap_path -g -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x |
| 321 |
} else { |
| 322 |
untested "$test types $test_suffix" |
| 323 |
continue |
| 324 |
} |
| 325 |
set test_suffix "${pbtype_mssg}${test_xtra} $extra_type_mssg $type_pedantic_mssg" |
| 326 |
|
| 327 |
set ok 0 |
| 328 |
set notok 0 |
| 329 |
set fail "" |
| 330 |
set uns_notok 0 |
| 331 |
set float_notok 0 |
| 332 |
expect { |
| 333 |
-timeout 180 |
| 334 |
# i386 unsigned may xfail because of sign extension |
| 335 |
# but fail anything else |
| 336 |
-re {^sdt_types PASS: [^\r]*\r\n} { incr ok; exp_continue } |
| 337 |
-indices -re {^sdt_types FAIL: ([^\r ]*)[^\r]*\r\n} { |
| 338 |
set s $expect_out(1,string); |
| 339 |
if {[regexp "unsigned" $s] && [istarget "i*86-*-*"]} { |
| 340 |
incr uns_notok } |
| 341 |
if {[regexp "float" $s] || [regexp "double" $s]} { |
| 342 |
incr float_notok } |
| 343 |
incr notok; set fail "$fail $s"; exp_continue } |
| 344 |
-re {^[^\r]*\r\n} { incr notok; exp_continue } |
| 345 |
timeout { fail "$test types (timeout) $test_suffix" } |
| 346 |
eof { } |
| 347 |
} |
| 348 |
catch {close}; catch {wait} |
| 349 |
|
| 350 |
if { $notok != 0 || $ok == 0} { |
| 351 |
if { $notok == $float_notok } { |
| 352 |
# Ignore float failures for V1, V2, and dyninst |
| 353 |
if { $pbtype_mssg != "V3_uprobe" || $runtime == "dyninst" } { |
| 354 |
pass "$test types $test_suffix" |
| 355 |
} else { |
| 356 |
incr fail_count |
| 357 |
fail "$test types $fail $test_suffix" |
| 358 |
} |
| 359 |
} elseif { [lindex $type_xfail $j] || $notok == $uns_notok } { |
| 360 |
xfail "$test types $fail $test_suffix" |
| 361 |
} else { |
| 362 |
incr fail_count |
| 363 |
fail "$test types $fail $test_suffix" |
| 364 |
} |
| 365 |
} else { |
| 366 |
pass "$test types $test_suffix" |
| 367 |
} |
| 368 |
} |
| 369 |
} ; # end type_pedantics_idx |
| 370 |
} ; # end extra_type_flags |
| 371 |
|
| 372 |
# 4. Test probe in shared object |
| 373 |
|
| 374 |
set sup41_flags "$sup_flags additional_flags=-shared" |
| 375 |
set sup41_flags "$sup41_flags additional_flags=-fPIC" |
| 376 |
set sup41_flags "$sup41_flags additional_flags=-DNO_MAIN" |
| 377 |
set sup_sopath "[pwd]/libsdt_$pbtype_mssg.so" |
| 378 |
set sup_exepath "[pwd]/sdt_misc_${pbtype_mssg}_shared.x" |
| 379 |
set res0 [target_compile $srcdir/$subdir/sdt_misc.c $sup_sopath \ |
| 380 |
executable $sup41_flags ] |
| 381 |
set sup42_flags "additional_flags=-Wl,-rpath,[pwd]" |
| 382 |
set sup42_flags "$sup42_flags additional_flags=-L[pwd] additional_flags=-lsdt_${pbtype_mssg}" |
| 383 |
set sup42_flags "$sup42_flags additional_flags=-DONLY_MAIN" |
| 384 |
set res [target_compile $srcdir/$subdir/sdt_misc.c $sup_exepath \ |
| 385 |
executable $sup42_flags ] |
| 386 |
if { $res0 != "" || $res != "" } { |
| 387 |
incr fail_count |
| 388 |
verbose "target_compile failed: $res0 $res" 2 |
| 389 |
fail "$test compiling -shared $pbtype_mssg" |
| 390 |
cleanup_handler $verbose |
| 391 |
return |
| 392 |
} else { |
| 393 |
pass "$test compiling -shared $pbtype_mssg" |
| 394 |
} |
| 395 |
|
| 396 |
foreach runtime [get_runtime_list] { |
| 397 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 398 |
continue } |
| 399 |
set test_xtra "" |
| 400 |
if {$runtime != ""} { |
| 401 |
set test_xtra " ($runtime)" |
| 402 |
verbose -log "spawn $stap_path --runtime=$runtime -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath $sup_sopath" |
| 403 |
spawn $stap_path --runtime=$runtime -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath $sup_sopath |
| 404 |
} elseif {[uprobes_p]} { |
| 405 |
verbose -log "spawn $stap_path -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath $sup_sopath" |
| 406 |
spawn $stap_path -c $sup_exepath $srcdir/$subdir/sdt_misc.stp $sup_exepath $sup_sopath |
| 407 |
} else { |
| 408 |
untested "$test shared $pbtype_mssg" |
| 409 |
continue |
| 410 |
} |
| 411 |
set ok 0 |
| 412 |
expect { |
| 413 |
-timeout 180 |
| 414 |
-re {In test_probe_2 probe 0x2} { incr ok; exp_continue } |
| 415 |
-re {In test_probe_0 probe 0x3} { incr ok; exp_continue } |
| 416 |
-re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { |
| 417 |
incr ok; exp_continue } |
| 418 |
-re {In test_probe_4 dtrace probe 0x[0-9a-f]} { incr ok; exp_continue } |
| 419 |
-re {In test_probe_1 probe 0x0} { incr ok; exp_continue } |
| 420 |
timeout { fail "$test (timeout)" } |
| 421 |
eof { } |
| 422 |
} |
| 423 |
catch {close}; catch {wait} |
| 424 |
|
| 425 |
if {$ok == 6} { |
| 426 |
pass "$test shared ${pbtype_mssg}${test_xtra}" |
| 427 |
} else { |
| 428 |
if {[istarget "arm*-*-*"] && $pbtype_mssg == "V2_uprobe"} { |
| 429 |
xfail "$test ($ok) shared ${pbtype_mssg}${test_xtra}" |
| 430 |
} else { |
| 431 |
incr fail_count |
| 432 |
fail "$test ($ok) shared ${pbtype_mssg}${test_xtra}" |
| 433 |
} |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
# 5. Test attaching to a running process with markers in a shared object |
| 438 |
|
| 439 |
set supl_flags "$sup41_flags additional_flags=-DLOOP" |
| 440 |
set supl_sopath "[pwd]/libsdt_${pbtype_mssg}_loop.so" |
| 441 |
set res0 [target_compile $srcdir/$subdir/sdt_misc.c $supl_sopath \ |
| 442 |
executable $supl_flags ] |
| 443 |
set loop_flags [sdt_includes] |
| 444 |
set loop_flags "$loop_flags additional_flags=-I. $pbtype_flag" |
| 445 |
set loop_flags "$loop_flags additional_flags=-DLOOP" |
| 446 |
set loop_flags "$loop_flags additional_flags=-DONLY_MAIN" |
| 447 |
set loop_flags "$loop_flags additional_flags=-Wl,-rpath,[pwd]" |
| 448 |
set loop_flags "$loop_flags additional_flags=-L[pwd] additional_flags=-lsdt_${pbtype_mssg}_loop" |
| 449 |
set loop_exepath "[pwd]/sdt_misc_${pbtype_mssg}_loop_shared.x" |
| 450 |
set res [target_compile $srcdir/$subdir/sdt_misc.c $loop_exepath \ |
| 451 |
executable $loop_flags] |
| 452 |
set test_suffix "$pbtype_mssg -DLOOP with markers in a shared object" |
| 453 |
if { $res != "" } { |
| 454 |
incr fail_count |
| 455 |
verbose "target_compile failed: $res" 2 |
| 456 |
fail "$test compiling $test_suffix" |
| 457 |
cleanup_handler $verbose |
| 458 |
return |
| 459 |
} else { |
| 460 |
pass "$test compiling $test_suffix" |
| 461 |
} |
| 462 |
|
| 463 |
foreach runtime [get_runtime_list] { |
| 464 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 465 |
continue } |
| 466 |
set test_xtra "" |
| 467 |
if {$runtime != ""} { |
| 468 |
set test_xtra " ($runtime)" |
| 469 |
|
| 470 |
if {$runtime == "dyninst"} { |
| 471 |
# With --runtime=dyninst these tests will fail since |
| 472 |
# the dyninst runtime needs a target executable |
| 473 |
# (either '-c exe' or '-x pid'). So, skip these tests |
| 474 |
# to speed up test execution. |
| 475 |
xfail "$test ${pbtype_mssg}${test_xtra} shared attach" |
| 476 |
continue |
| 477 |
} |
| 478 |
|
| 479 |
# This is perhaps a wee bit clumsy |
| 480 |
verbose -log "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 481 |
$stap_path --runtime=$runtime $srcdir/$subdir/sdt_misc.stp $loop_exepath $supl_sopath >| ,semout ; \ |
| 482 |
/bin/kill -SIGINT \$TEST" |
| 483 |
catch {system "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 484 |
$stap_path --runtime=$runtime $srcdir/$subdir/sdt_misc.stp $loop_exepath $supl_sopath >| ,semout ; \ |
| 485 |
/bin/kill -SIGINT \$TEST"} |
| 486 |
} elseif {[uprobes_p]} { |
| 487 |
# This is perhaps a wee bit clumsy |
| 488 |
verbose -log "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 489 |
$stap_path $srcdir/$subdir/sdt_misc.stp $loop_exepath $supl_sopath >| ,semout ; \ |
| 490 |
/bin/kill -SIGINT \$TEST" |
| 491 |
catch {system "$loop_exepath > ,semclean 2>&1 & TEST=\$! ; \ |
| 492 |
$stap_path $srcdir/$subdir/sdt_misc.stp $loop_exepath $supl_sopath >| ,semout ; \ |
| 493 |
/bin/kill -SIGINT \$TEST"} |
| 494 |
} else { |
| 495 |
untested "$test $pbtype_mssg shared attach" |
| 496 |
continue |
| 497 |
} |
| 498 |
|
| 499 |
set ok 0 |
| 500 |
set ko 0 |
| 501 |
spawn cat ,semout |
| 502 |
expect { |
| 503 |
-re {In test_probe_2 probe 0x2} { incr ok; exp_continue } |
| 504 |
-re {In test_probe_0 probe 0x3} { incr ok; exp_continue } |
| 505 |
-re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { |
| 506 |
incr ok; exp_continue } |
| 507 |
-re {In test_probe_4 dtrace probe 0x[0-9a-f]} { |
| 508 |
incr ok; exp_continue } |
| 509 |
-re {In test_probe_1 probe 0x0} { incr ok; exp_continue } |
| 510 |
eof { } |
| 511 |
} |
| 512 |
catch {close}; catch {wait} |
| 513 |
|
| 514 |
if {$ok == 6} { |
| 515 |
pass "$test ${pbtype_mssg}${test_xtra} shared attach" |
| 516 |
} else { |
| 517 |
if {[istarget "arm*-*-*"] && $pbtype_mssg == "V2_uprobe"} { |
| 518 |
xfail "$test ($ok) ${pbtype_mssg}${test_xtra} shared attach" |
| 519 |
} else { |
| 520 |
incr fail_count |
| 521 |
fail "$test ($ok) ${pbtype_mssg}${test_xtra} shared attach" |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
set ok 0 |
| 526 |
spawn cat ,semclean |
| 527 |
expect { |
| 528 |
-timeout 180 |
| 529 |
-re {PASS} { incr ok; exp_continue } |
| 530 |
-re {FAIL} { incr ko; exp_continue } |
| 531 |
timeout { fail "$test (timeout)" } |
| 532 |
eof { } |
| 533 |
} |
| 534 |
catch {close}; catch {wait} |
| 535 |
|
| 536 |
if {$ok == 4 && $ko == 0} { |
| 537 |
pass "$test ${pbtype_mssg}${test_xtra} shared shared epilogue" |
| 538 |
} else { |
| 539 |
incr fail_count |
| 540 |
fail "$test ($ok) ${pbtype_mssg}${test_xtra} shared epilogue" |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
# 6. Test .mark probe wildcard matching |
| 545 |
|
| 546 |
set ok 0 |
| 547 |
if {[uprobes_p]} { |
| 548 |
verbose -log "spawn $stap_path -L \"process(\"./sdt_types.x\").mark(\"*\")" |
| 549 |
spawn $stap_path -L "process(\"./sdt_types.x\").mark(\"*\")" |
| 550 |
expect { |
| 551 |
-timeout 180 |
| 552 |
-re {mark\(\"[a-z_]+\"\) .arg1:long .arg2:long .arg3:long .arg4:long .arg5:long .arg6:long .arg7:long .arg8:long\n} { incr ok; exp_continue } |
| 553 |
-re {mark\(\"[a-z_]+\"\) .arg1:long .arg2:long\n} { |
| 554 |
incr ok; exp_continue } |
| 555 |
-re {mark\(\"[a-z_]+\"\) .arg1:long\n} { incr ok; exp_continue } |
| 556 |
-re {mark\(\"[a-z_]+\"\)} { incr ok; exp_continue } |
| 557 |
timeout { fail "$test (timeout)" } |
| 558 |
eof { } |
| 559 |
} |
| 560 |
catch {close}; catch {wait} |
| 561 |
|
| 562 |
# PR10245: match the __ one here |
| 563 |
spawn $stap_path -l "process(\"./sdt_types.x\").mark(\"*-*-*\")" |
| 564 |
expect { |
| 565 |
-timeout 180 |
| 566 |
-re {mark\(\"[a-z_]+\"\)} { incr ok; exp_continue } |
| 567 |
timeout { fail "$test (timeout)" } |
| 568 |
eof { } |
| 569 |
} |
| 570 |
catch {close}; catch {wait} |
| 571 |
|
| 572 |
if { $ok == 53 || $ok == 50 \ |
| 573 |
|| (($ok == 44 || $ok == 41 ) && ([istarget "i*86-*-*"] \ |
| 574 |
|| [istarget "arm*-*-*"]))} { |
| 575 |
pass "$test wildcard $pbtype_mssg" |
| 576 |
} else { |
| 577 |
incr fail_count |
| 578 |
fail "$test wildcard ($ok) $pbtype_mssg" |
| 579 |
} |
| 580 |
} else { |
| 581 |
untested "$test wildcard $pbtype_mssg" |
| 582 |
} |
| 583 |
|
| 584 |
} ; # end pbtype_flags |
| 585 |
|
| 586 |
|
| 587 |
# 7. Test V3 $$parms support |
| 588 |
|
| 589 |
foreach runtime [get_runtime_list] { |
| 590 |
if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} { |
| 591 |
continue } |
| 592 |
set test_xtra "" |
| 593 |
if {$runtime != ""} { |
| 594 |
set test_xtra " ($runtime)" |
| 595 |
verbose -log "spawn $stap_path --runtime=$runtime -c ./sdt_misc_V3_uprobe.x -e \"probe process(\"./sdt_misc_V3_uprobe.x\").mark(\"test_probe_5\") {printf(\"%s %s %s\\n\", \$\$provider, \$\$name, \$\$parms)}\"" |
| 596 |
spawn $stap_path --runtime=$runtime -c ./sdt_misc_V3_uprobe.x -e "probe process(\"./sdt_misc_V3_uprobe.x\").mark(\"test_probe_3\") {printf(\"%s %s %s\\n\", \$\$provider, \$\$name, \$\$parms)}" |
| 597 |
} elseif {[uprobes_p]} { |
| 598 |
verbose -log "spawn $stap_path -c ./sdt_misc_V3_uprobe.x -e \"probe process(\"./sdt_misc_V3_uprobe.x\").mark(\"test_probe_5\") {printf(\"%s %s %s\\n\", \$\$provider, \$\$name, \$\$parms)}\"" |
| 599 |
spawn $stap_path -c ./sdt_misc_V3_uprobe.x -e "probe process(\"./sdt_misc_V3_uprobe.x\").mark(\"test_probe_3\") {printf(\"%s %s %s\\n\", \$\$provider, \$\$name, \$\$parms)}" |
| 600 |
} else { |
| 601 |
untested "$test \$\$parms" |
| 602 |
continue |
| 603 |
} |
| 604 |
set ok 0 |
| 605 |
expect { |
| 606 |
-timeout 180 |
| 607 |
-re {sdt_misc test_probe_3 \$arg1=0x3 \$arg2=0x[0-9a-f][0-9a-f]} { |
| 608 |
incr ok; exp_continue } |
| 609 |
timeout { fail "$test (timeout)" } |
| 610 |
eof { } |
| 611 |
} |
| 612 |
catch {close}; catch {wait} |
| 613 |
|
| 614 |
if {$ok == 1} { |
| 615 |
pass "$test \$\$parms${test_xtra}" |
| 616 |
} else { |
| 617 |
incr fail_count |
| 618 |
fail "$test ($ok) \$\$parms${test_xtra}" |
| 619 |
} |
| 620 |
} |
| 621 |
|
| 622 |
cleanup_handler $verbose |