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
|
set test "sdt_buildid"
set pbtype_flags {{additional_flags=-g} {} {}}
set fail_count 0
# Compile a C program to use as the user-space probing target
set stap_path $env(SYSTEMTAP_PATH)/stap
set sup_dpath "[pwd]/sdt_buildid_.d"
set sup_hpath "[pwd]/sdt_buildid_.h"
set sup_opath "[pwd]/sdt_buildid_.o"
# Run dtrace
if {[installtest_p]} {
set dtrace $env(SYSTEMTAP_PATH)/dtrace
} else {
set dtrace ../dtrace
}
verbose -log "$dtrace --types -h -s $srcdir/$subdir/sdt_buildid_.d"
if {[catch {exec $dtrace --types -h -s \
$srcdir/$subdir/sdt_buildid_.d} res]} {
verbose -log "unable to run $dtrace: $res"
}
verbose -log "$dtrace --types -G -s $srcdir/$subdir/sdt_buildid_.d"
if {[catch {exec $dtrace --types -G -s \
$srcdir/$subdir/sdt_buildid_.d} res]} {
verbose -log "unable to run $dtrace: $res"
}
if {[file exists $sup_hpath] && [file exists $sup_opath]} then {
pass "$test dtrace"
} else {
incr fail_count
fail "$test dtrace"
return
}
set sup_flags [sdt_includes]
set sup_flags "$sup_flags additional_flags=-Wall"
set sup_flags "$sup_flags additional_flags=-Werror"
set sup_flags "$sup_flags additional_flags=$sup_opath"
set sup_flags "$sup_flags additional_flags=-I."
set sup_exepath "[pwd]/sdt_buildid.x"
set res [target_compile $srcdir/$subdir/sdt_buildid.c $sup_exepath \
executable $sup_flags]
if { $res != "" } {
incr fail_count
verbose "target_compile failed: $res" 2
fail "$test compiling"
return
} else {
pass "$test compiling"
}
set sup41_flags "$sup_flags additional_flags=-shared"
set sup41_flags "$sup41_flags additional_flags=-fPIC"
set sup41_flags "$sup41_flags additional_flags=-DNO_MAIN"
set sup_sopath "[pwd]/libsdt_buildid.so"
set sup_exe2path "[pwd]/sdt_buildid_shared.x"
set res0 [target_compile $srcdir/$subdir/sdt_buildid.c $sup_sopath \
executable $sup41_flags ]
set sup42_flags "additional_flags=-Wl,-rpath,[pwd]"
set sup42_flags "$sup42_flags additional_flags=-L[pwd] additional_flags=-lsdt_buildid"
set sup42_flags "$sup42_flags additional_flags=-DONLY_MAIN"
set res [target_compile $srcdir/$subdir/sdt_buildid.c $sup_exe2path \
executable $sup42_flags ]
if { $res0 != "" || $res != "" } {
incr fail_count
verbose "target_compile failed: $res0 $res" 2
fail "$test compiling -shared"
return
} else {
pass "$test compiling -shared"
}
catch { exec eu-readelf -n $sup_exepath | grep Build.ID | awk "{print \$NF}" } bid1
catch { exec eu-readelf -n $sup_sopath | grep Build.ID | awk "{print \$NF}" } bidso
catch { exec eu-readelf -n $sup_exe2path | grep Build.ID | awk "{print \$NF}" } bid2
verbose -log "buildid: $sup_exepath $bid1"
verbose -log "buildid: $sup_sopath $bidso"
verbose -log "buildid: $sup_exe2path $bid2"
# though we won't use the $bid2
if {![installtest_p]} {
untested $test
return
}
# To test via build-id, we need a debuginfod server to scan the testsuite build
# directory.
if [catch {exec /usr/bin/which debuginfod} debuginfod] then {
untested "$test debuginfod"
} else {
set port [expr {10000 + int(rand()*10000)}]
spawn $debuginfod -p $port -d tmp.sqlite -F .
set debuginfod_pid [exp_pid $spawn_id]
# give it time to scan the build directory
sleep 10
# XXX: we could expect some verbose traffic
if [info exists env(DEBUGINFOD_URLS)] {
set env(DEBUGINFOD_URLS) "http://localhost:$port $env(DEBUGINFOD_URLS)"
} else {
set env(DEBUGINFOD_URLS) "http://localhost:$port"
}
verbose -log "started debuginfod on port $port"
set subtest "$test debuginfod buildid-exe buildid-solib"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $bid1 $bidso
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test debuginfod buildid-exe path-solib"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $bid1 $sup_sopath
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test debuginfod path-exe buildid-solib"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $sup_exepath $bidso
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test debuginfod buildid-solib"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $bidso
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test debuginfod buildid-exe"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $bid1
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
kill -INT $debuginfod_pid
}
set subtest "$test non-buildid both"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $sup_exepath $sup_sopath
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test non-buildid exe"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $sup_exepath
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exepath; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
set subtest "$test non-buildid solib"
spawn $stap_path $srcdir/$subdir/sdt_buildid.stp $sup_sopath
set ok 0
expect {
-timeout 240
-re {^Count [0-9]*[02468][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
-re {^Count [0-9]*[13579][^\r\n]*\r\n} { incr ok; exec $sup_exe2path; exp_continue }
eof { }
timeout { }
}
catch {close}; catch {wait}
if {$ok > 6} then { pass $subtest } else { fail $subtest }
return
|