| 1 |
set test pthreadprobes |
| 2 |
if {! [installtest_p]} { untested $test; return } |
| 3 |
if {! [uprobes_p]} { untested "$test"; return } |
| 4 |
|
| 5 |
# compile the testcase |
| 6 |
catch {exec gcc -g -o $test $srcdir/$subdir/$test.c -lpthread -lrt} err |
| 7 |
if {$err != "" && [file exists $test]} then { |
| 8 |
fail "$test compile $err" |
| 9 |
} else { |
| 10 |
# find the location of the pthread library |
| 11 |
catch {exec /usr/bin/ldd $test | grep -E {^\s*libpthread.so} | awk {{print $3}} } pthread |
| 12 |
} |
| 13 |
|
| 14 |
# First thing, do we have a version of glibc with the probes?? |
| 15 |
set cmd [concat -L process(\"$pthread\").mark(\"pthread_create\")] |
| 16 |
if {[catch {exec stap $cmd } res2]} { |
| 17 |
# can happen on systems without pthread probes in glibc, so don't complain |
| 18 |
untested "$test" |
| 19 |
return |
| 20 |
} else { |
| 21 |
pass "$test" |
| 22 |
} |
| 23 |
|
| 24 |
# The "cond_timedwait" mark doesn't exist in some versions of glibc |
| 25 |
# (such as RHEL7 ppc64), so figure out if it exists in this |
| 26 |
# glibc. Notice that that probe is optional in the script below. |
| 27 |
set cmd [concat -L process(\"$pthread\").mark(\"cond_timedwait\")] |
| 28 |
set cond_timedwait_available 0 |
| 29 |
if {![catch {exec stap $cmd } res2]} { |
| 30 |
set cond_timedwait_available 1 |
| 31 |
} |
| 32 |
|
| 33 |
# Now we exercise every probe available |
| 34 |
set script $srcdir/$subdir/$test.stp |
| 35 |
|
| 36 |
foreach runtime [get_runtime_list] { |
| 37 |
set test_name $test |
| 38 |
if {$runtime != ""} { |
| 39 |
# Suppress warnings (-w) because dyninst can't place some probes, and the WARNINGs |
| 40 |
# make tcl catch return non-zero. This way we'll still get individual results. |
| 41 |
verbose -log "Running: stap -u -w --runtime=$runtime $script $pthread -c ./$test" |
| 42 |
set rc [catch {exec stap -w --runtime=$runtime $script $pthread -c ./$test } res3] |
| 43 |
lappend test_name "($runtime)" |
| 44 |
} else { |
| 45 |
verbose -log "Running: stap -u $script $pthread -c ./$test" |
| 46 |
set rc [catch {exec stap $script $pthread -c ./$test } res3] |
| 47 |
} |
| 48 |
verbose -log "$res3" |
| 49 |
|
| 50 |
# error executing? |
| 51 |
if {$rc} { |
| 52 |
fail "$test_name (rc=$rc)" |
| 53 |
exec rm -f $test |
| 54 |
return |
| 55 |
} |
| 56 |
|
| 57 |
set cond_broadcast_correct 0 |
| 58 |
set cond_destroy_correct 0 |
| 59 |
set cond_init_correct 0 |
| 60 |
set cond_signal_correct 0 |
| 61 |
set cond_timedwait_correct 0 |
| 62 |
set cond_wait_correct 0 |
| 63 |
set mutex_acquired_correct 0 |
| 64 |
set mutex_destroy_correct 0 |
| 65 |
set mutex_entry_correct 0 |
| 66 |
set mutex_init_correct 0 |
| 67 |
set mutex_release_correct 0 |
| 68 |
set mutex_timedlock_acquired_correct 0 |
| 69 |
set mutex_timedlock_entry_correct 0 |
| 70 |
set pthread_create_correct 0 |
| 71 |
set pthread_join_correct 0 |
| 72 |
set pthread_join_ret_correct 0 |
| 73 |
set pthread_start_correct 0 |
| 74 |
set rdlock_entry_correct 0 |
| 75 |
set rwlock_destroy_correct 0 |
| 76 |
set wrlock_entry_correct 0 |
| 77 |
|
| 78 |
# make sure the numbers match |
| 79 |
foreach line $res3 { |
| 80 |
if {[regexp {cond_broadcast=[1-9]} $line]} { |
| 81 |
set cond_broadcast_correct 1 |
| 82 |
} |
| 83 |
if {[regexp "cond_destroy=0" $line]} { |
| 84 |
set cond_destroy_correct 1 |
| 85 |
} |
| 86 |
if {[regexp "cond_init=3" $line]} { |
| 87 |
set cond_init_correct 1 |
| 88 |
} |
| 89 |
if {[regexp {cond_signal=[1-9]} $line]} { |
| 90 |
set cond_signal_correct 1 |
| 91 |
} |
| 92 |
|
| 93 |
# Handle optional 'cond_timedwait'. |
| 94 |
if {[regexp {cond_timedwait=([01])} $line matched sub1]} { |
| 95 |
if {[expr $cond_timedwait_available && $sub1] \ |
| 96 |
|| [expr !$cond_timedwait_available && !$sub1]} { |
| 97 |
set cond_timedwait_correct 1 |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if {[regexp {cond_wait=[1-9]} $line]} { |
| 102 |
set cond_wait_correct 1 |
| 103 |
} |
| 104 |
if {[regexp {mutex_acquired=([1-9][0-9]+)} $line]} { |
| 105 |
set mutex_acquired_correct 1 |
| 106 |
} |
| 107 |
if {[regexp "mutex_destroy=1" $line]} { |
| 108 |
set mutex_destroy_correct 1 |
| 109 |
} |
| 110 |
if {[regexp {mutex_entry=([1-9][0-9]+)} $line]} { |
| 111 |
set mutex_entry_correct 1 |
| 112 |
} |
| 113 |
if {[regexp "mutex_init=3" $line]} { |
| 114 |
set mutex_init_correct 1 |
| 115 |
} |
| 116 |
if {[regexp {mutex_release=([1-9][0-9]+)} $line]} { |
| 117 |
set mutex_release_correct 1 |
| 118 |
} |
| 119 |
# pthread_mutex_timedlock is called with a timeout of 1 second in a |
| 120 |
# loop while the mutex is held by the other thread for about 5 seconds |
| 121 |
# resulting in a couple of entries resulting in a ETIMEDOUT before it |
| 122 |
# is actually acquired. Expect 2 till 6 tries before success. |
| 123 |
if {[regexp {mutex_timedlock_entry=[2-6]} $line]} { |
| 124 |
set mutex_timedlock_entry_correct 1 |
| 125 |
} |
| 126 |
if {[regexp "mutex_timedlock_acquired=1" $line]} { |
| 127 |
set mutex_timedlock_acquired_correct 1 |
| 128 |
} |
| 129 |
if {[regexp "pthread_create=6" $line]} { |
| 130 |
set pthread_create_correct 1 |
| 131 |
} |
| 132 |
if {[regexp "pthread_join=4" $line]} { |
| 133 |
set pthread_join_correct 1 |
| 134 |
} |
| 135 |
if {[regexp "pthread_join_ret=4" $line]} { |
| 136 |
set pthread_join_ret_correct 1 |
| 137 |
} |
| 138 |
if {[regexp "pthread_start=6" $line]} { |
| 139 |
set pthread_start_correct 1 |
| 140 |
} |
| 141 |
if {[regexp {rdlock_entry=[1-9][0-9]*} $line]} { |
| 142 |
set rdlock_entry_correct 1 |
| 143 |
} |
| 144 |
if {[regexp "rwlock_destroy=0" $line]} { |
| 145 |
set rwlock_destroy_correct 1 |
| 146 |
} |
| 147 |
if {[regexp {wrlock_entry=[1-9]} $line]} { |
| 148 |
set wrlock_entry_correct 1 |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
if { $cond_broadcast_correct == 0 } { |
| 153 |
fail "$test_name cond_broadcast" |
| 154 |
} else { |
| 155 |
pass "$test_name cond_broadcast" |
| 156 |
} |
| 157 |
|
| 158 |
if { $cond_destroy_correct == 0 } { |
| 159 |
fail "$test_name cond_destroy" |
| 160 |
} else { |
| 161 |
pass "$test_name cond_destroy" |
| 162 |
} |
| 163 |
|
| 164 |
if { $cond_init_correct == 0 } { |
| 165 |
fail "$test_name cond_init" |
| 166 |
} else { |
| 167 |
pass "$test_name cond_init" |
| 168 |
} |
| 169 |
|
| 170 |
if { $cond_signal_correct == 0 } { |
| 171 |
fail "$test_name cond_signal" |
| 172 |
} else { |
| 173 |
pass "$test_name cond_signal" |
| 174 |
} |
| 175 |
|
| 176 |
if { $cond_timedwait_correct == 0 } { |
| 177 |
fail "$test_name cond_timedwait" |
| 178 |
} else { |
| 179 |
pass "$test_name cond_timedwait" |
| 180 |
} |
| 181 |
|
| 182 |
if { $cond_wait_correct == 0 } { |
| 183 |
fail "$test_name cond_wait" |
| 184 |
} else { |
| 185 |
pass "$test_name cond_wait" |
| 186 |
} |
| 187 |
|
| 188 |
if { $mutex_acquired_correct == 0 } { |
| 189 |
fail "$test_name mutex_acquired" |
| 190 |
} else { |
| 191 |
pass "$test_name mutex_acquired" |
| 192 |
} |
| 193 |
|
| 194 |
if { $mutex_destroy_correct == 0 } { |
| 195 |
fail "$test_name mutex_destroy" |
| 196 |
} else { |
| 197 |
pass "$test_name mutex_destroy" |
| 198 |
} |
| 199 |
|
| 200 |
if { $mutex_entry_correct == 0 } { |
| 201 |
fail "$test_name mutex_entry" |
| 202 |
} else { |
| 203 |
pass "$test_name mutex_entry" |
| 204 |
} |
| 205 |
|
| 206 |
if { $mutex_init_correct == 0 } { |
| 207 |
fail "$test_name mutex_init" |
| 208 |
} else { |
| 209 |
pass "$test_name mutex_init" |
| 210 |
} |
| 211 |
|
| 212 |
if { $mutex_release_correct == 0 } { |
| 213 |
fail "$test_name mutex_release" |
| 214 |
} else { |
| 215 |
pass "$test_name mutex_release" |
| 216 |
} |
| 217 |
|
| 218 |
if { $mutex_timedlock_acquired_correct == 0 } { |
| 219 |
fail "$test_name mutex_timedlock_acquired" |
| 220 |
} else { |
| 221 |
pass "$test_name mutex_timedlock_acquired" |
| 222 |
} |
| 223 |
|
| 224 |
if { $mutex_timedlock_entry_correct == 0 } { |
| 225 |
fail "$test_name mutex_timedlock_entry" |
| 226 |
} else { |
| 227 |
pass "$test_name mutex_timedlock_entry" |
| 228 |
} |
| 229 |
|
| 230 |
if { $pthread_create_correct == 0 } { |
| 231 |
fail "$test_name pthread_create" |
| 232 |
} else { |
| 233 |
pass "$test_name pthread_create" |
| 234 |
} |
| 235 |
|
| 236 |
if { $pthread_join_correct == 0 } { |
| 237 |
fail "$test_name pthread_join" |
| 238 |
} else { |
| 239 |
pass "$test_name pthread_join" |
| 240 |
} |
| 241 |
|
| 242 |
if { $pthread_join_ret_correct == 0 } { |
| 243 |
fail "$test_name pthread_join_ret" |
| 244 |
} else { |
| 245 |
pass "$test_name pthread_join_ret" |
| 246 |
} |
| 247 |
|
| 248 |
if { $pthread_start_correct == 0 } { |
| 249 |
fail "$test_name pthread_start" |
| 250 |
} else { |
| 251 |
pass "$test_name pthread_start" |
| 252 |
} |
| 253 |
|
| 254 |
if { $rdlock_entry_correct == 0 } { |
| 255 |
fail "$test_name rdlock_entry" |
| 256 |
} else { |
| 257 |
pass "$test_name rdlock_entry" |
| 258 |
} |
| 259 |
|
| 260 |
if { $rwlock_destroy_correct == 0 } { |
| 261 |
fail "$test_name rwlock_destroy" |
| 262 |
} else { |
| 263 |
pass "$test_name rwlock_destroy" |
| 264 |
} |
| 265 |
|
| 266 |
if { $wrlock_entry_correct == 0 } { |
| 267 |
fail "$test_name wrlock_entry" |
| 268 |
} else { |
| 269 |
pass "$test_name wrlock_entry" |
| 270 |
} |
| 271 |
} |
| 272 |
exec rm -f $test |