| 1 |
# debuginfod_probe.exp |
| 2 |
# |
| 3 |
# Checks to see that the debuginfod.process(PATH).** probes |
| 4 |
# are working |
| 5 |
|
| 6 |
set test "debuginfod_probe" |
| 7 |
|
| 8 |
set stap_path $env(SYSTEMTAP_PATH)/stap |
| 9 |
|
| 10 |
catch {exec /usr/bin/which debuginfod} debuginfod |
| 11 |
|
| 12 |
# Check to see if the 'debuginfod_find_metadata' symbol can be found i.e the |
| 13 |
# version of debuginfod supports metadata querying |
| 14 |
set found_metadata_symbol [catch {exec /usr/bin/objdump -t $debuginfod | /usr/bin/grep "debuginfod_find_metadata"}] |
| 15 |
set found_jsonc [catch {exec pkg-config json-c}] |
| 16 |
|
| 17 |
if {"$debuginfod" == "" || $found_metadata_symbol != 0 || $found_jsonc != 0} then { |
| 18 |
untested "$test" |
| 19 |
} else { |
| 20 |
# Uncomment for test debugging |
| 21 |
# log_user 1 |
| 22 |
|
| 23 |
set port [expr {10000 + int(rand()*10000)}] |
| 24 |
set temp_dir [file join "/tmp/staptest" [pid]] |
| 25 |
catch {exec mkdir -p $temp_dir} |
| 26 |
verbose -log "The temp test directory is $temp_dir" |
| 27 |
|
| 28 |
# Set the cache location to be in the temp test dir |
| 29 |
set env(XDG_CACHE_HOME) $temp_dir |
| 30 |
set env(DEBUGINFOD_URLS) "" |
| 31 |
|
| 32 |
spawn $debuginfod -p $port -R "$srcdir/$subdir/debuginfod_probe.rpm" -d ":memory:" |
| 33 |
set debuginfod_pid [exp_pid $spawn_id] |
| 34 |
# give it time to scan the build directory |
| 35 |
wait_n_secs 5 |
| 36 |
|
| 37 |
set env(DEBUGINFOD_URLS) "http://localhost:$port" |
| 38 |
verbose -log "started debuginfod on server $env(DEBUGINFOD_URLS)" |
| 39 |
|
| 40 |
# Test 1a: No globbing |
| 41 |
set subtest "$test basic" |
| 42 |
set systemtap_script { |
| 43 |
probe |
| 44 |
debuginfod |
| 45 |
.process("/usr/local/bin/hello") |
| 46 |
.function("main") |
| 47 |
{ printf("HelloWorld\n") } |
| 48 |
} |
| 49 |
spawn sh -c "$stap_path -ve \'$systemtap_script\' -p2 2>&1" |
| 50 |
wait_n_secs 5 |
| 51 |
set pass 0 |
| 52 |
expect { |
| 53 |
-timeout 5 |
| 54 |
-re {.*process\(\"f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2\"\).function\(\"main\"\)*} { incr pass } |
| 55 |
eof { } |
| 56 |
timeout { fail "$subtest (timeout)" } |
| 57 |
} |
| 58 |
catch {close}; catch {wait} |
| 59 |
if {$pass == 1} then { pass $subtest } else { fail $subtest } |
| 60 |
|
| 61 |
# Test 1b: Globbing |
| 62 |
set subtest "$test globbing" |
| 63 |
set systemtap_script { |
| 64 |
probe |
| 65 |
debuginfod |
| 66 |
.process("/usr/*/*/he???") |
| 67 |
.function("main") |
| 68 |
{ printf("HelloWorld\n") } |
| 69 |
} |
| 70 |
spawn sh -c "$stap_path -ve \'$systemtap_script\' -p2 2>&1" |
| 71 |
wait_n_secs 5 |
| 72 |
set pass 0 |
| 73 |
expect { |
| 74 |
-timeout 5 |
| 75 |
-re {.*process\(\"f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2\"\).function\(\"main\"\)*} { incr pass } |
| 76 |
eof { } |
| 77 |
timeout { fail "$subtest (timeout)" } |
| 78 |
} |
| 79 |
catch {close}; catch {wait} |
| 80 |
if {$pass == 1} then { pass $subtest } else { fail $subtest } |
| 81 |
|
| 82 |
# Test 1c: nonexistent path |
| 83 |
set subtest "$test nonexistent path" |
| 84 |
set systemtap_script { |
| 85 |
probe |
| 86 |
debuginfod |
| 87 |
.process("/usr/bin/world") |
| 88 |
.function("main") |
| 89 |
{ printf("HelloWorld\n") } |
| 90 |
} |
| 91 |
spawn $stap_path -ve $systemtap_script |
| 92 |
set pass 0 |
| 93 |
expect { |
| 94 |
-timeout 10 |
| 95 |
-re {.*semantic error: can't retrieve buildids from debuginfod.*} { incr pass } |
| 96 |
timeout { fail "$subtest (timeout)" } |
| 97 |
} |
| 98 |
catch {close}; catch {wait} |
| 99 |
if {$pass == 1} then { pass $subtest } else { fail $subtest } |
| 100 |
|
| 101 |
# Test 1d: package |
| 102 |
set subtest "$test package" |
| 103 |
set systemtap_script { |
| 104 |
probe |
| 105 |
debuginfod |
| 106 |
.archive("*probe*") |
| 107 |
.process("/usr/local/bin/hello") |
| 108 |
.function("main") |
| 109 |
{ printf("HelloWorld\n") } |
| 110 |
} |
| 111 |
spawn sh -c "$stap_path -ve \'$systemtap_script\' -p2 2>&1" |
| 112 |
wait_n_secs 5 |
| 113 |
set pass 0 |
| 114 |
expect { |
| 115 |
-timeout 5 |
| 116 |
-re {.*process\(\"f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2\"\).function\(\"main\"\)*} { incr pass } |
| 117 |
eof { } |
| 118 |
timeout { fail "$subtest (timeout)" } |
| 119 |
} |
| 120 |
catch {close}; catch {wait} |
| 121 |
if {$pass == 1} then { pass $subtest } else { fail $subtest } |
| 122 |
|
| 123 |
# Cleanup |
| 124 |
catch { exec rm -rf "/tmp/staptest" } |
| 125 |
kill -INT $debuginfod_pid |
| 126 |
} |