diff options
| author | Mark Wielaard <mark@klomp.org> | 2025-06-12 23:27:50 +0200 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2025-06-20 21:07:29 +0200 |
| commit | a6ba284ccd9ca3ab6a948ab9a58acfefede75b12 (patch) | |
| tree | 49cd2b3264fdea16bd88cfeebbf11d827d97593e | |
| parent | PR32760: find-debuginfo: handle static libraries (diff) | |
Add basic find-debuginfo script tests
Covers basic find-debuginfo script functionality. Checks .debug files are generated by eu-strip, .gnu_debugdata is generated, .gdb_index is added by gdb-add-index, dwz multi file is created and all debugsources are found, also does parallel runs. Skips dwz testing if .debug_addr is generated (since dwz currently doesn't handle that). * configure.ac: Check whether -gdwarf-5 produced DWARF5 .debug_addr. * tests/atlocal.in: Add DWARF_5_DEBUGADDR. * tests/Makefile.am (TESTSUITE_AT): Add find-debuginfo.at. * tests/testsuite.at: m4_include find-debuginfo.at. * tests/find-debuginfo.at: Add 5 basic variants of find-debuginfo test. Signed-off-by: Mark Wielaard <mark@klomp.org>
| -rw-r--r-- | configure.ac | 13 | ||||
| -rw-r--r-- | tests/atlocal.in | 1 | ||||
| -rw-r--r-- | tests/find-debuginfo.at | 323 |
3 files changed, 332 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index 47771d4..5b8f961 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -126,6 +126,19 @@ CFLAGS="$save_CFLAGS" | |||
| 126 | DWARF_5_DEBUGLINE=$ac_cv_dwarf_5_debugline | 126 | DWARF_5_DEBUGLINE=$ac_cv_dwarf_5_debugline |
| 127 | AC_SUBST([DWARF_5_DEBUGLINE]) | 127 | AC_SUBST([DWARF_5_DEBUGLINE]) |
| 128 | 128 | ||
| 129 | AC_CACHE_CHECK([whether -gdwarf-5 produced DWARF5 .debug_addr], ac_cv_dwarf_5_debugaddr, [dnl | ||
| 130 | save_CFLAGS="$CFLAGS" | ||
| 131 | CFLAGS="-gdwarf-5" | ||
| 132 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i=0;]],[[/* empty main */]])], | ||
| 133 | [if $READELF -S conftest.o 2>&1 | grep -F ".debug_addr" > /dev/null 2>&1; \ | ||
| 134 | then ac_cv_dwarf_5_debugaddr=yes; \ | ||
| 135 | else ac_cv_dwarf_5_debugaddr=no; fi], | ||
| 136 | ac_cv_dwarf_5_debugaddr=no) | ||
| 137 | CFLAGS="$save_CFLAGS" | ||
| 138 | ]) | ||
| 139 | DWARF_5_DEBUGADDR=$ac_cv_dwarf_5_debugaddr | ||
| 140 | AC_SUBST([DWARF_5_DEBUGADDR]) | ||
| 141 | |||
| 129 | AC_CACHE_CHECK([whether gcc supports -gz=none], ac_cv_gz_none, [dnl | 142 | AC_CACHE_CHECK([whether gcc supports -gz=none], ac_cv_gz_none, [dnl |
| 130 | save_CFLAGS="$CFLAGS" | 143 | save_CFLAGS="$CFLAGS" |
| 131 | CFLAGS="-gz=none" | 144 | CFLAGS="-gz=none" |
diff --git a/tests/atlocal.in b/tests/atlocal.in index 2f2ff4a..51feadb 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in | |||
| @@ -17,4 +17,5 @@ GDWARF_5_FLAG=@GDWARF_5_FLAG@ | |||
| 17 | GZ_NONE_FLAG=@GZ_NONE_FLAG@ | 17 | GZ_NONE_FLAG=@GZ_NONE_FLAG@ |
| 18 | GZ_ZLIB_FLAG=@GZ_ZLIB_FLAG@ | 18 | GZ_ZLIB_FLAG=@GZ_ZLIB_FLAG@ |
| 19 | DWARF_5_DEBUGLINE=@DWARF_5_DEBUGLINE@ | 19 | DWARF_5_DEBUGLINE=@DWARF_5_DEBUGLINE@ |
| 20 | DWARF_5_DEBUGADDR=@DWARF_5_DEBUGADDR@ | ||
| 20 | DEBUG_MACRO_FLAG=@DEBUG_MACRO_FLAG@ | 21 | DEBUG_MACRO_FLAG=@DEBUG_MACRO_FLAG@ |
diff --git a/tests/find-debuginfo.at b/tests/find-debuginfo.at index a0c0988..5552ce1 100644 --- a/tests/find-debuginfo.at +++ b/tests/find-debuginfo.at | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | # debugedit.at: Tests for the find-debuginfo tool | 1 | # find-debuginfo.at: Tests for the find-debuginfo script |
| 2 | # | 2 | # |
| 3 | # Copyright (C) 2025 Red Hat Inc. | 3 | # Copyright (C) 2025 Red Hat Inc. |
| 4 | # Copyright (C) 2025 Mark J. Wielaard <mark@klomp.org> | ||
| 4 | # | 5 | # |
| 5 | # This program is free software; you can redistribute it and/or modify | 6 | # This program is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
| @@ -18,7 +19,10 @@ | |||
| 18 | # Recommended usage for verbose logging to the console: | 19 | # Recommended usage for verbose logging to the console: |
| 19 | # make check TESTSUITEFLAGS=-v | 20 | # make check TESTSUITEFLAGS=-v |
| 20 | 21 | ||
| 22 | # Tests for scripts/find-debuginfo.in | ||
| 21 | AT_BANNER([find-debuginfo]) | 23 | AT_BANNER([find-debuginfo]) |
| 24 | |||
| 25 | # Show which find-debuginfo script we are testing | ||
| 22 | AT_TESTED([find-debuginfo]) | 26 | AT_TESTED([find-debuginfo]) |
| 23 | 27 | ||
| 24 | m4_define([BUILDO],[[ | 28 | m4_define([BUILDO],[[ |
| @@ -29,8 +33,9 @@ echo built "$1/dupe.o" | |||
| 29 | ]]) | 33 | ]]) |
| 30 | 34 | ||
| 31 | 35 | ||
| 36 | # Check find-debuginfo --help doesn't crash and burn | ||
| 32 | AT_SETUP([find-debuginfo help]) | 37 | AT_SETUP([find-debuginfo help]) |
| 33 | AT_KEYWORDS([find-debuginfo] [find-debuginfo]) | 38 | AT_KEYWORDS([find-debuginfo] [help]) |
| 34 | AT_CHECK([find-debuginfo --help],[0],[ignore],[ignore]) | 39 | AT_CHECK([find-debuginfo --help],[0],[ignore],[ignore]) |
| 35 | AT_CLEANUP | 40 | AT_CLEANUP |
| 36 | 41 | ||
| @@ -60,9 +65,6 @@ AT_CHECK([test `wc -l < stdout` -eq 4],[0],[ignore],[ignore]) | |||
| 60 | # expect original source tree refs | 65 | # expect original source tree refs |
| 61 | AT_CHECK([$READELF --debug-dump=line subdir_build/dupes.a | grep `pwd`], [0], [stdout], [ignore]) | 66 | AT_CHECK([$READELF --debug-dump=line subdir_build/dupes.a | grep `pwd`], [0], [stdout], [ignore]) |
| 62 | 67 | ||
| 63 | # (which is not everpresent) | ||
| 64 | AT_TESTED([find-debuginfo]) | ||
| 65 | |||
| 66 | # run conversion, under bash -x tracing for fuller testing log | 68 | # run conversion, under bash -x tracing for fuller testing log |
| 67 | AT_CHECK([[env RPM_BUILD_DIR=${PWD} RPM_BUILD_ROOT=${PWD} RPM_PACKAGE_NAME=pkg RPM_PACKAGE_VERSION=ver RPM_PACKAGE_RELEASE=rel RPM_ARCH=arch \ | 69 | AT_CHECK([[env RPM_BUILD_DIR=${PWD} RPM_BUILD_ROOT=${PWD} RPM_PACKAGE_NAME=pkg RPM_PACKAGE_VERSION=ver RPM_PACKAGE_RELEASE=rel RPM_ARCH=arch \ |
| 68 | bash -x `type -p find-debuginfo` -S sourcefiles.list -v ${PWD}/subdir_build]], [0], [stdout], [ignore]) | 70 | bash -x `type -p find-debuginfo` -S sourcefiles.list -v ${PWD}/subdir_build]], [0], [stdout], [ignore]) |
| @@ -79,5 +81,316 @@ AT_CHECK([$READELF --debug-dump=line subdir_build/dupes.a | grep /usr/src/debug] | |||
| 79 | 81 | ||
| 80 | # no traces of old source tree | 82 | # no traces of old source tree |
| 81 | AT_CHECK([$READELF --debug-dump=line subdir_build/dupes.a | grep `pwd`], [1], [stdout], [stderr]) | 83 | AT_CHECK([$READELF --debug-dump=line subdir_build/dupes.a | grep `pwd`], [1], [stdout], [stderr]) |
| 84 | AT_CLEANUP | ||
| 85 | |||
| 86 | # Helper to create some test binaries | ||
| 87 | m4_define([FIND_DEBUGINFO_PKG_BUILD_SETUP],[[ | ||
| 88 | mkdir subdir_build | ||
| 89 | cp "${abs_srcdir}"/data/SOURCES/foo.c subdir_build | ||
| 90 | cp "${abs_srcdir}"/data/SOURCES/bar.c subdir_build | ||
| 91 | cp "${abs_srcdir}"/data/SOURCES/foobar.h subdir_build | ||
| 92 | cp "${abs_srcdir}"/data/SOURCES/baz.c subdir_build | ||
| 93 | cd subdir_build | ||
| 94 | # Three almost identical binaries | ||
| 95 | # so dwz has something to put into the alt file | ||
| 96 | $CC $CFLAGS -g3 -I. -o foo foo.c bar.c baz.c | ||
| 97 | $CC $CFLAGS -g3 -I. -o bar bar.c baz.c foo.c | ||
| 98 | $CC $CFLAGS -g3 -I. -o baz baz.c foo.c bar.c | ||
| 99 | cd .. | ||
| 100 | ]]) | ||
| 82 | 101 | ||
| 102 | # Run find-debuginfo on a small build without any fancy options | ||
| 103 | AT_SETUP([find-debuginfo sources]) | ||
| 104 | AT_KEYWORDS([find-debuginfo] [sources]) | ||
| 105 | FIND_DEBUGINFO_PKG_BUILD_SETUP | ||
| 106 | # Sanity check the binaries have debug sections | ||
| 107 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [0], [ignore], []) | ||
| 108 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [0], [ignore], []) | ||
| 109 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [0], [ignore], []) | ||
| 110 | # We need to set some environment variables for running find-debuginfo | ||
| 111 | # normally set by rpmbuild. | ||
| 112 | # | ||
| 113 | # run debugedit and collect source files for binaries in subdir_build | ||
| 114 | AT_CHECK([env RPM_BUILD_DIR=${PWD} \ | ||
| 115 | RPM_BUILD_ROOT=${PWD} \ | ||
| 116 | RPM_PACKAGE_NAME=pkg \ | ||
| 117 | RPM_PACKAGE_VERSION=ver \ | ||
| 118 | RPM_PACKAGE_RELEASE=rel \ | ||
| 119 | RPM_ARCH=arch \ | ||
| 120 | find-debuginfo ${PWD}/subdir_build], | ||
| 121 | [0], [stdout], []) | ||
| 122 | # Make sure all three binaries are processed | ||
| 123 | AT_CHECK([grep "Extracting debug info from 3 files" stdout], [0], [ignore], []) | ||
| 124 | # debug sections should have been removed | ||
| 125 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [1], [ignore], []) | ||
| 126 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [1], [ignore], []) | ||
| 127 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [1], [ignore], []) | ||
| 128 | # Now there are .debug files with those .debug_ sections | ||
| 129 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep debug_], | ||
| 130 | [0], [ignore], []) | ||
| 131 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep debug_], | ||
| 132 | [0], [ignore], []) | ||
| 133 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep debug_], | ||
| 134 | [0], [ignore], []) | ||
| 135 | # Check all sources are listed in debugsources.list | ||
| 136 | AT_DATA([expout], | ||
| 137 | [subdir_build/ | ||
| 138 | subdir_build/bar.c | ||
| 139 | subdir_build/baz.c | ||
| 140 | subdir_build/foo.c | ||
| 141 | subdir_build/foobar.h | ||
| 142 | ]) | ||
| 143 | AT_CHECK([cat subdir_build/debugsources.list | tr '\0' '\n' | sort -u], | ||
| 144 | [0], [expout], []) | ||
| 145 | AT_CLEANUP | ||
| 146 | |||
| 147 | # Run find-debuginfo on a small build and check all parts ran | ||
| 148 | AT_SETUP([find-debuginfo sources debugdata gdb-index]) | ||
| 149 | AT_KEYWORDS([find-debuginfo] [sources] [debugdata] [gdb-index]) | ||
| 150 | FIND_DEBUGINFO_PKG_BUILD_SETUP | ||
| 151 | # Sanity check the binaries have debug sections | ||
| 152 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [0], [ignore], []) | ||
| 153 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [0], [ignore], []) | ||
| 154 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [0], [ignore], []) | ||
| 155 | # We need to set some environment variables for running find-debuginfo | ||
| 156 | # normally set by rpmbuild. | ||
| 157 | # | ||
| 158 | # generate .gnu_debugdata (-m), .gdb_index (-i) for binaries in subdir_build. | ||
| 159 | AT_CHECK([env RPM_BUILD_DIR=${PWD} \ | ||
| 160 | RPM_BUILD_ROOT=${PWD} \ | ||
| 161 | RPM_PACKAGE_NAME=pkg \ | ||
| 162 | RPM_PACKAGE_VERSION=ver \ | ||
| 163 | RPM_PACKAGE_RELEASE=rel \ | ||
| 164 | RPM_ARCH=arch \ | ||
| 165 | find-debuginfo -m -i ${PWD}/subdir_build], | ||
| 166 | [0], [stdout], []) | ||
| 167 | # Make sure all three binaries are processed | ||
| 168 | AT_CHECK([grep "Extracting debug info from 3 files" stdout], [0], [ignore], []) | ||
| 169 | # debug sections should have been removed | ||
| 170 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [1], [ignore], []) | ||
| 171 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [1], [ignore], []) | ||
| 172 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [1], [ignore], []) | ||
| 173 | # But they now have a .gnu_debugdata section | ||
| 174 | AT_CHECK([$READELF -S subdir_build/foo | grep gnu_debugdata], | ||
| 175 | [0], [ignore], []) | ||
| 176 | AT_CHECK([$READELF -S subdir_build/bar | grep gnu_debugdata], | ||
| 177 | [0], [ignore], []) | ||
| 178 | AT_CHECK([$READELF -S subdir_build/baz | grep gnu_debugdata], | ||
| 179 | [0], [ignore], []) | ||
| 180 | # There are .debug files with those .debug_ sections | ||
| 181 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep debug_], | ||
| 182 | [0], [ignore], []) | ||
| 183 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep debug_], | ||
| 184 | [0], [ignore], []) | ||
| 185 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep debug_], | ||
| 186 | [0], [ignore], []) | ||
| 187 | # The .debug files should also have a .gdb_index sections | ||
| 188 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep gdb_index], | ||
| 189 | [0], [ignore], []) | ||
| 190 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep gdb_index], | ||
| 191 | [0], [ignore], []) | ||
| 192 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep gdb_index], | ||
| 193 | [0], [ignore], []) | ||
| 194 | # Check all sources are listed in debugsources.list | ||
| 195 | AT_DATA([expout], | ||
| 196 | [subdir_build/ | ||
| 197 | subdir_build/bar.c | ||
| 198 | subdir_build/baz.c | ||
| 199 | subdir_build/foo.c | ||
| 200 | subdir_build/foobar.h | ||
| 201 | ]) | ||
| 202 | AT_CHECK([cat subdir_build/debugsources.list | tr '\0' '\n' | sort -u], | ||
| 203 | [0], [expout], []) | ||
| 204 | AT_CLEANUP | ||
| 205 | |||
| 206 | # Run find-debuginfo on a small build and check all parts ran | ||
| 207 | # Same as above but run in parallel (-j) | ||
| 208 | AT_SETUP([find-debuginfo sources debugdata gdb-index jobs]) | ||
| 209 | AT_KEYWORDS([find-debuginfo] [sources] [debugdata] [gdb-index] [jobs]) | ||
| 210 | FIND_DEBUGINFO_PKG_BUILD_SETUP | ||
| 211 | # Sanity check the binaries have debug sections | ||
| 212 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [0], [ignore], []) | ||
| 213 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [0], [ignore], []) | ||
| 214 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [0], [ignore], []) | ||
| 215 | # We need to set some environment variables for running find-debuginfo | ||
| 216 | # normally set by rpmbuild. | ||
| 217 | # | ||
| 218 | # generate .gnu_debugdata (-m), .gdb_index (-i) for binaries in subdir_build. | ||
| 219 | AT_CHECK([env RPM_BUILD_DIR=${PWD} \ | ||
| 220 | RPM_BUILD_ROOT=${PWD} \ | ||
| 221 | RPM_PACKAGE_NAME=pkg \ | ||
| 222 | RPM_PACKAGE_VERSION=ver \ | ||
| 223 | RPM_PACKAGE_RELEASE=rel \ | ||
| 224 | RPM_ARCH=arch \ | ||
| 225 | find-debuginfo -m -i -j6 ${PWD}/subdir_build], | ||
| 226 | [0], [stdout], []) | ||
| 227 | # Make sure all three binaries are processed | ||
| 228 | AT_CHECK([grep "Extracting debug info from 3 files" stdout], [0], [ignore], []) | ||
| 229 | # debug sections should have been removed | ||
| 230 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [1], [ignore], []) | ||
| 231 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [1], [ignore], []) | ||
| 232 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [1], [ignore], []) | ||
| 233 | # But they now have a .gnu_debugdata section | ||
| 234 | AT_CHECK([$READELF -S subdir_build/foo | grep gnu_debugdata], | ||
| 235 | [0], [ignore], []) | ||
| 236 | AT_CHECK([$READELF -S subdir_build/bar | grep gnu_debugdata], | ||
| 237 | [0], [ignore], []) | ||
| 238 | AT_CHECK([$READELF -S subdir_build/baz | grep gnu_debugdata], | ||
| 239 | [0], [ignore], []) | ||
| 240 | # There are .debug files with those .debug_ sections | ||
| 241 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep debug_], | ||
| 242 | [0], [ignore], []) | ||
| 243 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep debug_], | ||
| 244 | [0], [ignore], []) | ||
| 245 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep debug_], | ||
| 246 | [0], [ignore], []) | ||
| 247 | # The .debug files should also have a .gdb_index sections | ||
| 248 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep gdb_index], | ||
| 249 | [0], [ignore], []) | ||
| 250 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep gdb_index], | ||
| 251 | [0], [ignore], []) | ||
| 252 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep gdb_index], | ||
| 253 | [0], [ignore], []) | ||
| 254 | # Check all sources are listed in debugsources.list | ||
| 255 | AT_DATA([expout], | ||
| 256 | [subdir_build/ | ||
| 257 | subdir_build/bar.c | ||
| 258 | subdir_build/baz.c | ||
| 259 | subdir_build/foo.c | ||
| 260 | subdir_build/foobar.h | ||
| 261 | ]) | ||
| 262 | AT_CHECK([cat subdir_build/debugsources.list | tr '\0' '\n' | sort -u], | ||
| 263 | [0], [expout], []) | ||
| 264 | AT_CLEANUP | ||
| 265 | |||
| 266 | # Run find-debuginfo on a small build and check all parts ran | ||
| 267 | # Same as above, but now with dwz (but without -j) | ||
| 268 | AT_SETUP([find-debuginfo sources debugdata gdb-index dwz]) | ||
| 269 | AT_KEYWORDS([find-debuginfo] [sources] [debugdata] [gdb-index] [dwz]) | ||
| 270 | # At the moment dwz doesn't support .debug_addr | ||
| 271 | AT_SKIP_IF([test "$DWARF_5_DEBUGADDR" = "yes"]) | ||
| 272 | FIND_DEBUGINFO_PKG_BUILD_SETUP | ||
| 273 | # Sanity check the binaries have debug sections | ||
| 274 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [0], [ignore], []) | ||
| 275 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [0], [ignore], []) | ||
| 276 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [0], [ignore], []) | ||
| 277 | # We need to set some environment variables for running find-debuginfo | ||
| 278 | # normally set by rpmbuild. | ||
| 279 | # | ||
| 280 | # generate .gnu_debugdata (-m), .gdb_index (-i) and run dwz (--run-dwz) | ||
| 281 | # for binaries in subdir_build. | ||
| 282 | AT_CHECK([env RPM_BUILD_DIR=${PWD} \ | ||
| 283 | RPM_BUILD_ROOT=${PWD} \ | ||
| 284 | RPM_PACKAGE_NAME=pkg \ | ||
| 285 | RPM_PACKAGE_VERSION=ver \ | ||
| 286 | RPM_PACKAGE_RELEASE=rel \ | ||
| 287 | RPM_ARCH=arch \ | ||
| 288 | find-debuginfo -m -i --run-dwz ${PWD}/subdir_build], | ||
| 289 | [0], [stdout], []) | ||
| 290 | # Make sure all three binaries are processed | ||
| 291 | AT_CHECK([grep "Extracting debug info from 3 files" stdout], [0], [ignore], []) | ||
| 292 | AT_CHECK([grep "DWARF-compressing 3 files" stdout], [0], [ignore], []) | ||
| 293 | # debug sections should have been removed | ||
| 294 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [1], [ignore], []) | ||
| 295 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [1], [ignore], []) | ||
| 296 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [1], [ignore], []) | ||
| 297 | # But they now have a .gnu_debugdata section | ||
| 298 | AT_CHECK([$READELF -S subdir_build/foo | grep gnu_debugdata], | ||
| 299 | [0], [ignore], []) | ||
| 300 | AT_CHECK([$READELF -S subdir_build/bar | grep gnu_debugdata], | ||
| 301 | [0], [ignore], []) | ||
| 302 | AT_CHECK([$READELF -S subdir_build/baz | grep gnu_debugdata], | ||
| 303 | [0], [ignore], []) | ||
| 304 | # There are .debug files with those .debug_ sections | ||
| 305 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep debug_], | ||
| 306 | [0], [ignore], []) | ||
| 307 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep debug_], | ||
| 308 | [0], [ignore], []) | ||
| 309 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep debug_], | ||
| 310 | [0], [ignore], []) | ||
| 311 | # The .debug files should also have a .gdb_index sections | ||
| 312 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep gdb_index], | ||
| 313 | [0], [ignore], []) | ||
| 314 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep gdb_index], | ||
| 315 | [0], [ignore], []) | ||
| 316 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep gdb_index], | ||
| 317 | [0], [ignore], []) | ||
| 318 | # There should also be a dwz multi file now | ||
| 319 | AT_CHECK([test -f usr/lib/debug/.dwz/pkg-ver-rel.arch], [0], [], []) | ||
| 320 | # Check all sources are listed in debugsources.list | ||
| 321 | AT_DATA([expout], | ||
| 322 | [subdir_build/ | ||
| 323 | subdir_build/bar.c | ||
| 324 | subdir_build/baz.c | ||
| 325 | subdir_build/foo.c | ||
| 326 | subdir_build/foobar.h | ||
| 327 | ]) | ||
| 328 | AT_CHECK([cat subdir_build/debugsources.list | tr '\0' '\n' | sort -u], | ||
| 329 | [0], [expout], []) | ||
| 330 | AT_CLEANUP | ||
| 331 | |||
| 332 | # Run find-debuginfo on a small build and check all parts ran | ||
| 333 | # Same as above plus doing -j jobs | ||
| 334 | AT_SETUP([find-debuginfo sources debugdata gdb-index dwz jobs]) | ||
| 335 | AT_KEYWORDS([find-debuginfo] [sources] [debugdata] [gdb-index] [dwz] [jobs]) | ||
| 336 | # At the moment dwz doesn't support .debug_addr | ||
| 337 | AT_SKIP_IF([test "$DWARF_5_DEBUGADDR" = "yes"]) | ||
| 338 | FIND_DEBUGINFO_PKG_BUILD_SETUP | ||
| 339 | # Sanity check the binaries have debug sections | ||
| 340 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [0], [ignore], []) | ||
| 341 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [0], [ignore], []) | ||
| 342 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [0], [ignore], []) | ||
| 343 | # We need to set some environment variables for running find-debuginfo | ||
| 344 | # normally set by rpmbuild. | ||
| 345 | # | ||
| 346 | # generate .gnu_debugdata (-m), .gdb_index (-i) and run dwz (--run-dwz) | ||
| 347 | # in parallel (-j6) for binaries in subdir_build. | ||
| 348 | AT_CHECK([env RPM_BUILD_DIR=${PWD} \ | ||
| 349 | RPM_BUILD_ROOT=${PWD} \ | ||
| 350 | RPM_PACKAGE_NAME=pkg \ | ||
| 351 | RPM_PACKAGE_VERSION=ver \ | ||
| 352 | RPM_PACKAGE_RELEASE=rel \ | ||
| 353 | RPM_ARCH=arch \ | ||
| 354 | find-debuginfo -m -i --run-dwz -j6 ${PWD}/subdir_build], | ||
| 355 | [0], [stdout], []) | ||
| 356 | # Make sure all three binaries are processed | ||
| 357 | AT_CHECK([grep "Extracting debug info from 3 files" stdout], [0], [ignore], []) | ||
| 358 | AT_CHECK([grep "DWARF-compressing 3 files" stdout], [0], [ignore], []) | ||
| 359 | # debug sections should have been removed | ||
| 360 | AT_CHECK([$READELF -S subdir_build/foo | grep debug_], [1], [ignore], []) | ||
| 361 | AT_CHECK([$READELF -S subdir_build/bar | grep debug_], [1], [ignore], []) | ||
| 362 | AT_CHECK([$READELF -S subdir_build/baz | grep debug_], [1], [ignore], []) | ||
| 363 | # But they now have a .gnu_debugdata section | ||
| 364 | AT_CHECK([$READELF -S subdir_build/foo | grep gnu_debugdata], | ||
| 365 | [0], [ignore], []) | ||
| 366 | AT_CHECK([$READELF -S subdir_build/bar | grep gnu_debugdata], | ||
| 367 | [0], [ignore], []) | ||
| 368 | AT_CHECK([$READELF -S subdir_build/baz | grep gnu_debugdata], | ||
| 369 | [0], [ignore], []) | ||
| 370 | # There are .debug files with those .debug_ sections | ||
| 371 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep debug_], | ||
| 372 | [0], [ignore], []) | ||
| 373 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep debug_], | ||
| 374 | [0], [ignore], []) | ||
| 375 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep debug_], | ||
| 376 | [0], [ignore], []) | ||
| 377 | # The .debug files should also have a .gdb_index sections | ||
| 378 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/foo.debug | grep gdb_index], | ||
| 379 | [0], [ignore], []) | ||
| 380 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/bar.debug | grep gdb_index], | ||
| 381 | [0], [ignore], []) | ||
| 382 | AT_CHECK([$READELF -S usr/lib/debug/subdir_build/baz.debug | grep gdb_index], | ||
| 383 | [0], [ignore], []) | ||
| 384 | # There should also be a dwz multi file now | ||
| 385 | AT_CHECK([test -f usr/lib/debug/.dwz/pkg-ver-rel.arch], [0], [], []) | ||
| 386 | # Check all sources are listed in debugsources.list | ||
| 387 | AT_DATA([expout], | ||
| 388 | [subdir_build/ | ||
| 389 | subdir_build/bar.c | ||
| 390 | subdir_build/baz.c | ||
| 391 | subdir_build/foo.c | ||
| 392 | subdir_build/foobar.h | ||
| 393 | ]) | ||
| 394 | AT_CHECK([cat subdir_build/debugsources.list | tr '\0' '\n' | sort -u], | ||
| 395 | [0], [expout], []) | ||
| 83 | AT_CLEANUP | 396 | AT_CLEANUP |
