summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-06-14 17:07:09 +0200
committerFlorian Festi <ffesti@redhat.com>2016-07-29 18:28:53 +0200
commit6b3b435fa644522197003460a96cd11253b1494d (patch)
tree641c29a4f8ae48967a04c933baadcff29aa52f0d /tests
parentb33a41da3689c4a803986eb95e5875e0dff36259 (diff)
downloadrpm-6b3b435fa644522197003460a96cd11253b1494d.tar.gz
Add dwz debuginfo compression support.
Support for dwz compression has been in Fedora since a couple of years. https://fedoraproject.org/wiki/Features/DwarfCompressor The original find-debuginfo.sh patch was written by Jakub Jelinek. https://bugzilla.redhat.com/show_bug.cgi?id=833311 The new testcase using the macros.debug was added by me. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/data/SPECS/hello2.spec62
-rw-r--r--tests/rpmbuild.at78
2 files changed, 140 insertions, 0 deletions
diff --git a/tests/data/SPECS/hello2.spec b/tests/data/SPECS/hello2.spec
new file mode 100644
index 000000000..01777af5b
--- /dev/null
+++ b/tests/data/SPECS/hello2.spec
@@ -0,0 +1,62 @@
+Summary: hello2 -- double hello, world rpm
+Name: hello2
+Version: 1.0
+Release: 1
+Group: Utilities
+License: GPL
+Distribution: RPM test suite.
+Vendor: Red Hat Software
+Packager: Red Hat Software <bugs@redhat.com>
+URL: http://www.redhat.com
+Source0: hello-1.0.tar.gz
+Patch0: hello-1.0-modernize.patch
+Excludearch: lsi
+Excludeos: cpm
+Provides: hi
+Conflicts: goodbye
+Obsoletes: howdy
+Prefix: /usr
+
+%description
+Simple rpm demonstration.
+
+%prep
+%setup -q -n hello-1.0
+%patch0 -p1 -b .modernize
+
+%build
+make CFLAGS="-g -O1"
+mv hello hello2
+make CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2"
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/usr/local/bin
+make DESTDIR=$RPM_BUILD_ROOT install
+cp hello2 $RPM_BUILD_ROOT/usr/local/bin/
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+
+%post
+
+%preun
+
+%postun
+
+%files
+%defattr(-,root,root)
+%doc FAQ
+#%readme README
+#%license COPYING
+%attr(0751,root,root) /usr/local/bin/hello
+%attr(0751,root,root) /usr/local/bin/hello2
+
+%changelog
+* Wed May 18 2016 Mark Wielaard <mjw@redhat.com>
+- Add hello2 for dwz testing support.
+
+* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com>
+- create.
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 3c32842ab..2fea1b621 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -381,3 +381,81 @@ readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
[],
[ignore])
AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild runs dwz and generates a multi file that with shared
+# debuginfo. This is simply the hello example with one binary build twice
+# so dwz has enough slightly similar debug data.
+AT_SETUP([rpmbuild debuginfo dwz])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+run rpmbuild --quiet \
+ --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \
+ --rcfile=${abs_top_builddir}/rpmrc \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# The debuginfo package should contain a .debug file for each binary
+# and a dwz multi file that contains the shared debuginfo between them.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+test -f ./usr/lib/debug/usr/local/bin/hello.debug || exit 1
+test -f ./usr/lib/debug/usr/local/bin/hello2.debug || exit 1
+test -f ./usr/lib/debug/.dwz/hello2-1.0-1.* || exit 1
+
+# Make sure the main package binaries contain the correct build-ids
+# linking them to the debug packages.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
+ | cpio -diu
+id1=$(file ./usr/local/bin/hello | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2=$(file ./usr/local/bin/hello2 | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id1debug=$(file ./usr/lib/debug/usr/local/bin/hello.debug \
+ | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+id2debug=$(file ./usr/lib/debug/usr/local/bin/hello2.debug \
+ | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+idmulti=$(file ./usr/lib/debug/.dwz/hello2-1.0-1.* \
+ | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
+
+test "$id1" = "$id1debug" || exit 1
+test "$id2" = "$id2debug" || exit 1
+
+# The build-id files should link to the .debug files.
+id1file="./usr/lib/debug/.build-id/${id1:0:2}/${id1:2}"
+canonid1file=$(readlink -f ${id1file})
+canonfile1=$(readlink -f ./usr/local/bin/hello)
+canonid1debug=$(readlink -f ${id1file}.debug)
+canondebug1=$(readlink -f ./usr/lib/debug/usr/local/bin/hello.debug)
+
+test "$canonid1file" = "$canonfile1" || exit 1
+test "$canonid1debug" = "$canondebug1" || exit 1
+
+id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
+canonid2file=$(readlink -f ${id1file})
+canonfile2=$(readlink -f ./usr/local/bin/hello)
+canonid2debug=$(readlink -f ${id1file}.debug)
+canondebug2=$(readlink -f ./usr/lib/debug/usr/local/bin/hello.debug)
+
+test "$canonid2file" = "$canonfile2" || exit 1
+test "$canonid2debug" = "$canondebug2" || exit 1
+
+# Both .debug files should point to the dwz multi file.
+# It would be nice to also test that they contain the correct dwz build-id
+# but that is a bit hard to grep out of the section data.
+multiref1=$(readelf --string-dump=.gnu_debugaltlink ./usr/lib/debug/usr/local/bin/hello.debug | grep '[ 0]' | cut -c13-)
+multiref2=$(readelf --string-dump=.gnu_debugaltlink ./usr/lib/debug/usr/local/bin/hello2.debug | grep '[ 0]' | cut -c13-)
+
+test "$multiref1" = "$multiref2" || exit 1
+
+canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
+canonmultifile=$(readlink -f ./usr/lib/debug/.dwz/hello2-1.0-1.*)
+
+test "$canonmultiref" = "$canonmultifile" || exit 1
+],
+[0],
+[],
+[ignore])
+AT_CLEANUP