summaryrefslogtreecommitdiff
path: root/tests/rpmbuild.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rpmbuild.at')
-rw-r--r--tests/rpmbuild.at1176
1 files changed, 1171 insertions, 5 deletions
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 7661e35f5..5e0b0d492 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -51,6 +51,22 @@ run rpmbuild \
[ignore])
AT_CLEANUP
+AT_SETUP([rpmbuild --short-circuit -bl])
+AT_KEYWORDS([build])
+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 -bi "${abs_srcdir}"/data/SPECS/hello.spec &> /dev/null
+run rpmbuild --quiet -bl --short-circuit "${abs_srcdir}"/data/SPECS/hello.spec
+],
+[0],
+[],
+[])
+AT_CLEANUP
+
# ------------------------------
# Check if tar unpacking works
AT_SETUP([rpmbuild -tb <tar with bad spec>])
@@ -95,7 +111,7 @@ runroot rpmbuild \
runroot rpm -qp --qf \
"\n[%{filemodes:perms} %-8{fileusername} %-8{filegroupname} %{filenames}\n]"\
- "${TOPDIR}"/RPMS/noarch/attrtest-1.0-1.noarch.rpm
+ /build/RPMS/noarch/attrtest-1.0-1.noarch.rpm
]],
[0],
[
@@ -135,7 +151,7 @@ rm -rf ${TOPDIR}
runroot rpmbuild \
-bb --quiet /data/SPECS/hlinktest.spec
-runroot rpm -i "${TOPDIR}"/RPMS/noarch/hlinktest-1.0-1.noarch.rpm
+runroot rpm -i /build/RPMS/noarch/hlinktest-1.0-1.noarch.rpm
runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]%{longsize}\n" hlinktest
runroot rpm -V --nouser --nogroup hlinktest
@@ -143,17 +159,59 @@ ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l
],
[0],
-[1 /foo/copyllo
+[2 /foo/aaaa
+1 /foo/copyllo
4 /foo/hello
4 /foo/hello-bar
4 /foo/hello-foo
4 /foo/hello-world
-78
+2 /foo/zzzz
+87
1
],
[])
AT_CLEANUP
+AT_SETUP([rpmbuild unpackaged files])
+AT_KEYWORDS([build])
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+rm -rf ${TOPDIR}
+
+runroot rpmbuild \
+ -bb --quiet --with unpackaged_files /data/SPECS/hlinktest.spec
+],
+[1],
+[],
+[error: Installed (but unpackaged) file(s) found:
+ /toot
+ Installed (but unpackaged) file(s) found:
+ /toot
+])
+AT_CLEANUP
+
+# rpm doesn't detect unpackaged directories but should, really
+AT_SETUP([rpmbuild unpackaged directories])
+AT_KEYWORDS([build])
+AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+rm -rf ${TOPDIR}
+
+runroot rpmbuild \
+ -bb --quiet --with unpackaged_dirs /data/SPECS/hlinktest.spec
+],
+[1],
+[],
+[error: Installed (but unpackaged) file(s) found:
+ /zoo
+ Installed (but unpackaged) file(s) found:
+ /zoo
+])
+AT_CLEANUP
+
AT_SETUP([rpmbuild glob])
AT_KEYWORDS([build])
AT_CHECK([
@@ -164,7 +222,7 @@ rm -rf ${TOPDIR}
runroot rpmbuild -bb --quiet /data/SPECS/globtest.spec
runroot rpm -qp \
--qf "[[%{filemodes:perms} %{filenames}\n]]" \
- "${TOPDIR}"/RPMS/noarch/globtest-1.0-1.noarch.rpm
+ /build/RPMS/noarch/globtest-1.0-1.noarch.rpm
],
[0],
[-rw-r--r-- /opt/globtest/baf
@@ -185,3 +243,1111 @@ lrwxrwxrwx /opt/globtest/linkgood
],
[])
AT_CLEANUP
+
+AT_SETUP([rpmbuild prefixpostfix])
+AT_KEYWORDS([build])
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+rm -rf ${TOPDIR}
+
+runroot rpmbuild -bb --quiet \
+ /data/SPECS/prefixtest.spec
+runroot rpm -qp \
+ --qf "[[%{filemodes:perms} %{filenames}\n]]" \
+ /build/RPMS/noarch/prefixtest-1.0-1.noarch.rpm
+],
+[0],
+[-rw-r--r-- /opt/prefixtest/ba
+drwxr-xr-x /opt/prefixtest/ban
+-rw-r--r-- /opt/prefixtest/bi
+drwxr-xr-x /opt/prefixtest/bin
+drwxr-xr-x /opt/prefixtest/bon
+drwxr-xr-x /opt/prefixtest/foo
+-rw-r--r-- /opt/prefixtest/foo/one
+-rw-r--r-- /opt/prefixtest/foo/three
+-rw-r--r-- /opt/prefixtest/foo/two
+lrwxrwxrwx /opt/prefixtest/linkbad
+lrwxrwxrwx /opt/prefixtest/linkgood
+-rw-r--r-- /opt/prefixtest/weird%name
+-rw-r--r-- /opt/prefixtest/zab
+-rw-r--r-- /opt/prefixtest/zeb
+-rw-r--r-- /opt/prefixtest/zib
+],
+[])
+AT_CLEANUP
+
+# ------------------------------
+# Check if weak and reverse requires can be built
+AT_SETUP([Weak and reverse requires])
+AT_KEYWORDS([build])
+AT_CHECK([
+
+runroot rpmbuild -bb --quiet \
+ --define "pkg weakdeps" \
+ --define "recs foo > 1.2.3" \
+ --define "sugs bar >= 0.1.2" \
+ --define "sups baz" \
+ --define "ens zap = 3" \
+ /data/SPECS/deptest.spec
+
+runroot rpm -qp --recommends /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
+runroot rpm -qp --suggests /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
+runroot rpm -qp --supplements /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
+runroot rpm -qp --enhances /build/RPMS/noarch/deptest-weakdeps-1.0-1.noarch.rpm
+],
+[0],
+[foo > 1.2.3
+bar >= 0.1.2
+baz
+zap = 3
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Test BuildRequire functionality
+AT_SETUP([Build requires])
+AT_KEYWORDS([build])
+AT_CHECK([
+
+runroot rpmbuild -bb --quiet \
+ --define "pkg buildreq" \
+ --define "buildreqs foo > 1.2.3" \
+ /data/SPECS/deptest.spec
+],
+[1],
+[],
+[error: Failed build dependencies:
+ foo > 1.2.3 is needed by deptest-buildreq-1.0-1.noarch
+])
+AT_CLEANUP
+
+AT_SETUP([Dependency generation])
+AT_KEYWORDS([build])
+AT_CHECK([
+
+runroot rpmbuild -bb --quiet \
+ /data/SPECS/filedep.spec
+echo Requires:
+runroot rpm -qp --requires /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
+echo Provides:
+runroot rpm -qp --provides /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
+echo Filerequires:
+runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEREQUIRE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
+echo Fileprovides:
+runroot rpm -qp --qf '[["%{FILENAMES}\t%{FILEPROVIDE}"\n]]' /build/RPMS/noarch/filedep-1.0-1.noarch.rpm
+],
+[0],
+[Requires:
+/bin/f00f
+/bin/sh
+rpmlib(CompressedFileNames) <= 3.0.4-1
+rpmlib(FileDigests) <= 4.6.0-1
+rpmlib(PayloadFilesHavePrefix) <= 4.0-1
+Provides:
+filedep = 1.0-1
+Filerequires:
+"/etc/foo.conf "
+"/usr/bin/bar /bin/f00f"
+"/usr/bin/foo /bin/sh"
+"/usr/share/doc/filedep "
+"/usr/share/doc/filedep/README "
+Fileprovides:
+"/etc/foo.conf "
+"/usr/bin/bar "
+"/usr/bin/foo "
+"/usr/share/doc/filedep "
+"/usr/share/doc/filedep/README "
+],
+[])
+AT_CLEANUP
+
+
+# ------------------------------
+# Test spec query functionality
+AT_SETUP([rpmspec query 1])
+AT_KEYWORDS([build])
+AT_CHECK([
+
+runroot rpmspec -q \
+ --define "pkg dep" \
+ --define "reqs foo > 1.2.3 bar <= 2.3" \
+ --requires \
+ /data/SPECS/deptest.spec
+],
+[0],
+[bar <= 2.3
+foo > 1.2.3
+],
+[])
+
+AT_CLEANUP
+
+# ------------------------------
+# archive sanity check
+AT_SETUP([rpmbuild archive sanity])
+AT_KEYWORDS([build])
+AT_CHECK([
+rm -rf ${TOPDIR}
+
+runroot rpmbuild \
+ -bb --quiet /data/SPECS/attrtest.spec
+
+runroot rpm2cpio \
+ /build/RPMS/noarch/attrtest-1.0-1.noarch.rpm > /tmp/attrtest.cpio
+],
+[0],
+[],
+[])
+AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild creates the minisymtab section in the main hello binary
+AT_SETUP([rpmbuild debuginfo minisymtab])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+
+# Use macros.debug to generate a debuginfo package.
+export CFLAGS="-g"
+rundebug rpmbuild --quiet \
+ --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
+
+# Extract the main package and inspect the hello binary
+# It should contain .gnu_debugdata, but not the full .symtab
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
+test -f ./usr/local/bin/hello || exit 1
+readelf -S ./usr/local/bin/hello |\
+ grep -q .gnu_debugdata; test $? == 0 || exit 1
+readelf -S ./usr/local/bin/hello \
+ | grep -q .symtab; test $? == 1 || exit 1
+
+# And the opposite for the debuginfo package
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
+readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
+ | grep -q .gnu_debugdata; test $? == 1 || exit 1
+readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
+ | grep -q .symtab; test $? == 0 || exit 1
+],
+[0],
+[],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check if rpmbuild doesn't create the minisymtab section if we keep symtab
+# Some package might want to use strip -g to keep the symbol table and only
+# but the debug symbols/info in the debuginfo package.
+AT_SETUP([rpmbuild debuginfo minisymtab strip -g])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+
+# Use macros.debug to generate a debuginfo package.
+export CFLAGS="-g"
+rundebug rpmbuild --quiet \
+ --define="_find_debuginfo_opts -g" \
+ --rebuild "${abs_srcdir}"/data/SRPMS/hello-1.0-1.src.rpm
+
+# Extract the main package and inspect the hello binary
+# It should contain .symtab (because of strip -g), so doesn't .gnu_debugdata.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm | cpio -diu
+test -f ./usr/local/bin/hello || exit 1
+readelf -S ./usr/local/bin/hello \
+ | grep -q .gnu_debugdata; test $? == 1 || exit 1
+readelf -S ./usr/local/bin/hello \
+ | grep -q .symtab; test $? == 0 || exit 1
+
+# The debuginfo package should contain neither. The .symtab is NOBITS.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+test -f ./usr/lib/debug/usr/local/bin/hello*.debug || exit 1
+readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
+ | grep -q .gnu_debugdata; test $? == 1 || exit 1
+readelf -S ./usr/lib/debug/usr/local/bin/hello*.debug \
+ | grep .symtab | grep -q NOBITS; test $? == 0 || exit 1
+],
+[0],
+[],
+[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.
+# Test the case without unique debug file names.
+AT_SETUP([rpmbuild debuginfo dwz])
+AT_KEYWORDS([build] [debuginfo] [dwz])
+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
+
+rundebug rpmbuild --quiet \
+ --undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
+ -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
+
+hello_file_debug=./usr/lib/debug/usr/local/bin/hello.debug
+hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2.debug
+hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
+test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
+test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
+test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
+
+# 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
+hello_file=./usr/local/bin/hello
+hello2_file=./usr/local/bin/hello2
+test -f $hello_file || echo "no hello file: $hello_file"
+test -f $hello2_file || echo "no hello2 file: $hello2_file"
+
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+
+test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
+test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
+
+# 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 $hello_file)
+canonid1debug=$(readlink -f ${id1file}.debug)
+canondebug1=$(readlink -f $hello_file_debug)
+
+test "$canonid1file" = "$canonfile1" \
+ || echo "canonid1file: $canonid1file != $canonfile1"
+test "$canonid1debug" = "$canondebug1" \
+ || echo "canonid1debug: $canonid1debug != $canondebug1"
+
+id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
+canonid2file=$(readlink -f ${id2file})
+canonfile2=$(readlink -f $hello2_file)
+canonid2debug=$(readlink -f ${id2file}.debug)
+canondebug2=$(readlink -f $hello2_file_debug)
+
+test "$canonid2file" = "$canonfile2" \
+ || echo "canonid2: $canonid2file != $canonfile2"
+test "$canonid2debug" = "$canondebug2" \
+ || echo "canonid2debug: $canonid2debug" != "$canondebug2"
+
+# 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 $hello_file_debug \
+ | grep '[ 0]' | cut -c13-)
+multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
+ | grep '[ 0]' | cut -c13-)
+
+test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
+
+canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
+canonmultifile=$(readlink -f $hello_multi_file)
+
+test "$canonmultiref" = "$canonmultifile" \
+ || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
+],
+[0],
+[],
+[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.
+# Test with unique debug file names.
+AT_SETUP([rpmbuild debuginfo dwz unique debug names])
+AT_KEYWORDS([build] [debuginfo] [dwz])
+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
+
+rundebug rpmbuild --quiet \
+ --define "_unique_debug_names 1" \
+ -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
+
+hello_file_debug=./usr/lib/debug/usr/local/bin/hello-*.debug
+hello2_file_debug=./usr/lib/debug/usr/local/bin/hello2-*.debug
+hello_multi_file=./usr/lib/debug/.dwz/hello2-1.0-1.*
+test -f $hello_file_debug || echo "no hello debug file: $hello_file_debug"
+test -f $hello2_file_debug || echo "no hello2 debug file: $hello2_file_debug"
+test -f $hello_multi_file || echo "no dwz multi file: $hello_multi_file"
+
+# 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
+hello_file=./usr/local/bin/hello
+hello2_file=./usr/local/bin/hello2
+test -f $hello_file || echo "no hello file: $hello_file"
+test -f $hello2_file || echo "no hello2 file: $hello2_file"
+
+id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id1debug=$(file $hello_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+id2debug=$(file $hello2_file_debug | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
+
+test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
+test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
+
+# 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 $hello_file)
+canonid1debug=$(readlink -f ${id1file}.debug)
+canondebug1=$(readlink -f $hello_file_debug)
+
+test "$canonid1file" = "$canonfile1" \
+ || echo "canonid1file: $canonid1file != $canonfile1"
+test "$canonid1debug" = "$canondebug1" \
+ || echo "canonid1debug: $canonid1debug != $canondebug1"
+
+id2file="./usr/lib/debug/.build-id/${id2:0:2}/${id2:2}"
+canonid2file=$(readlink -f ${id2file})
+canonfile2=$(readlink -f $hello2_file)
+canonid2debug=$(readlink -f ${id2file}.debug)
+canondebug2=$(readlink -f $hello2_file_debug)
+
+test "$canonid2file" = "$canonfile2" \
+ || echo "canonid2: $canonid2file != $canonfile2"
+test "$canonid2debug" = "$canondebug2" \
+ || echo "canonid2debug: $canonid2debug" != "$canondebug2"
+
+# 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 $hello_file_debug \
+ | grep '[ 0]' | cut -c13-)
+multiref2=$(readelf --string-dump=.gnu_debugaltlink $hello2_file_debug \
+ | grep '[ 0]' | cut -c13-)
+
+test "$multiref1" = "$multiref2" || echo "multiref: $multiref1 != $multiref2"
+
+canonmultiref=$(readlink -f $(dirname $canondebug1)/$multiref1)
+canonmultifile=$(readlink -f $hello_multi_file)
+
+test "$canonmultiref" = "$canonmultifile" \
+ || echo "canonmultiref: $canonmultiref" != "$canonmultifile"
+],
+[0],
+[],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that old style gnu_debuglink CRC checksums are correct even after
+# using dwz to compress the debuginfo files.
+AT_SETUP([rpmbuild debuginfo dwz gnu_debuglink crc])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the main and debuginfo rpms so we can check binaries and .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
+ | cpio -diu
+
+# Check that dwz has ran and a multi file has been produced
+test -f ./usr/lib/debug/.dwz/hello2-1.0-1.* || exit 1
+
+# Run sepdbugcrcfix on the binaries, both should have correct CRC already.
+${abs_top_builddir}/sepdebugcrcfix ./usr/lib/debug \
+ ./usr/local/bin/hello ./usr/local/bin/hello2 | grep CRC32 | cut -f2 -d:
+],
+[0],
+[ Updated 0 CRC32s, 2 CRC32s did match.
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that an implicit suid binary get included with the suid bit set.
+# We explicitly build with all debug.macros to test those helpers.
+AT_SETUP([rpmbuild implicit suid binary])
+AT_KEYWORDS([build] [debuginfo] [dwz] [suid])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ -ba "${abs_srcdir}"/data/SPECS/hello2-suid.spec
+
+# Unpack rpm so we can check the included binaries.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# List all binaries with suid bit set (should be one, hello).
+echo "suid:"
+find usr -executable -type f -perm /4000
+# List all binaries without suid bit set (should also be one, hello2).
+echo "no-suid:"
+find usr -executable -type f \! -perm /4000
+],
+[0],
+[suid:
+usr/local/bin/hello
+no-suid:
+usr/local/bin/hello2
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a GDB index is included when requested.
+AT_SETUP([rpmbuild debuginfo gdb index included])
+AT_KEYWORDS([build] [debuginfo] [gdb])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_include_gdb_index 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that gdb-add-index has ran and a .gdb_index section has been added
+readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep gdb_index | cut -c8-17
+],
+[0],
+[.gdb_index
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a GDB index is NOT included when not requested.
+AT_SETUP([rpmbuild debuginfo no gdb index included])
+AT_KEYWORDS([build] [debuginfo] [gdb])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --undefine "_include_gdb_index" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that gdb-add-index has not ran and no .gdb_index section has been added
+readelf -S ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep gdb_index | cut -c8-17
+],
+[0],
+[],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a debug source is in a "unique" directory when requested.
+AT_SETUP([rpmbuild debuginfo unique debug src dir])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Note that the spec defines hello2 as name, but the source is hello-1.0.
+# Disable dwz to make debuginfo path rewrite checking easier.
+rundebug rpmbuild --quiet \
+ --undefine "_find_debuginfo_dwz_opts" \
+ --define "_unique_debug_srcs 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that the source path is "unique"
+# Drop the final arch prefix to make the test arch-independent.
+ls ./usr/src/debug/ | cut -f1,2 -d\.
+
+# Check that the source path has been rewritten in the .debug file.
+# Drop the final arch prefix to make the test arch-independent.
+readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep comp_dir | sed -e 's/\t$//' | cut -f5- -d/ | cut -f1,2 -d\.
+],
+[0],
+[hello2-1.0-1
+hello2-1.0-1
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that a debug source is NOT in a "unique" directory when not requested.
+# It will be in the "build directory" name under /usr/src/debug.
+AT_SETUP([rpmbuild debuginfo no unique debug src dir])
+AT_KEYWORDS([build] [debuginfo])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+# Note that the spec defines hello2 as name, but the source is hello-1.0.
+# Disable dwz to make debuginfo path rewrite checking easier.
+rundebug rpmbuild --quiet \
+ --undefine "_find_debuginfo_dwz_opts" \
+ --undefine "_unique_debug_srcs" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms so we can check the .debug files.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that the source path is "unique"
+ls ./usr/src/debug/
+
+# Check that the source path has been rewritten in the .debug file.
+readelf --debug-dump=info ./usr/lib/debug/usr/local/bin/hello2*.debug \
+ | grep comp_dir | sed -e 's/\t$//' | cut -f5- -d/
+],
+[0],
+[hello-1.0
+hello-1.0
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debugsource_packages creates -debugsource package
+AT_SETUP([rpmbuild debugsource])
+AT_KEYWORDS([build] [debuginfo] [debugsource])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Build a package that has some debuginfo
+cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_debugsource_packages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debugsource rpm so we can check the sources are there.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debugsource-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that hello.c is there.
+ls ./usr/src/debug/hello2-1.0*/
+
+# The debuginfo package should recommend the debugsource package (ignore arch).
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+],
+[0],
+[hello.c
+Recommends: hello2-debugsource(ignore-arch) = 1.0-1
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debugsource_packages creates -debugsource package
+# even if %install changes the working directory (debugsources.list
+# should be in expected build dir).
+AT_SETUP([rpmbuild debugsource debugsources.list path])
+AT_KEYWORDS([build] [debuginfo] [debugsource])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_debugsource_packages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/hello-cd.spec
+
+# Unpack the debuginfo rpms so we can check the sources are there.
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debugsource-1.0-1.*.rpm \
+ | cpio -diu --quiet
+
+# Check that hello.c is there.
+ls ./usr/src/debug/test-1.0*/
+],
+[0],
+[hello.c
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that undefining _debuginfo_subpackages creates one single -debuginfo.
+AT_SETUP([rpmbuild debuginfo subpackages single])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
+ --undefine "_debugsource_packages" \
+ --undefine "_debuginfo_subpackages" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
+
+# Check that there is just one debuginfo package.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# Which contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+],
+[0],
+[1
+hello debug exists
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debuginfo_subpackages creates multiple -debuginfos.
+AT_SETUP([rpmbuild debuginfo subpackages multiple])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --undefine "_unique_debug_names" \
+ --undefine "_unique_debug_srcs" \
+ --undefine "_debugsource_packages" \
+ --define "_debuginfo_subpackages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
+
+# Check that there are 3 debuginfo packages.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# First contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+
+# Second contains hello2.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello2 debug exists"
+else
+ echo "No hello2: $debug_name"
+fi
+
+# No debugsource package, so sources are in the main debuginfo package.
+# Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+
+# Third contains hello3.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello3 debug exists"
+else
+ echo "No hello3: $debug_name"
+fi
+
+# No debugsource package, so sources are in the main debuginfo package.
+# Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+],
+[0],
+[3
+hello debug exists
+hello2 debug exists
+Recommends: test-debuginfo(ignore-arch) = 1.0-1
+hello3 debug exists
+Recommends: test-debuginfo(ignore-arch) = 1.0-1
+],
+[ignore])
+AT_CLEANUP
+# ------------------------------
+# Check that defining _debuginfo_subpackages creates multiple -debuginfos.
+# With unique debug and source names
+AT_SETUP([rpmbuild debuginfo subpackages multiple unique])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --undefine "_debugsource_packages" \
+ --define "_debuginfo_subpackages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
+
+# Check that there are 3 debuginfo packages.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# First contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+
+# Second contains hello2.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello2 debug exists"
+else
+ echo "No hello2: $debug_name"
+fi
+
+# No debugsource package, so sources are in the main debuginfo package.
+# Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+
+# Third contains hello3.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello3 debug exists"
+else
+ echo "No hello3: $debug_name"
+fi
+
+# No debugsource package, so sources are in the main debuginfo package.
+# Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+],
+[0],
+[3
+hello debug exists
+hello2 debug exists
+Recommends: test-debuginfo(ignore-arch) = 1.0-1
+hello3 debug exists
+Recommends: test-debuginfo(ignore-arch) = 1.0-1
+],
+[ignore])
+AT_CLEANUP
+# ------------------------------
+# Check that defining _debuginfo_subpackages creates multiple -debuginfos.
+# Unique with debugsources.
+AT_SETUP([rpmbuild debuginfo subpackages multiple unique debugsource])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --define "_debugsource_packages 1" \
+ --define "_debuginfo_subpackages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages.spec
+
+# Check that there are 3 debuginfo packages.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# First contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+
+# Sources are in debugsource package. Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+
+# Second contains hello2.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello2 debug exists"
+else
+ echo "No hello2: $debug_name"
+fi
+
+# Sources are in debugsource package. Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+
+# Third contains hello3.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello3 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello3 debug exists"
+else
+ echo "No hello3: $debug_name"
+fi
+
+# Sources are in debugsource package. Make sure it is recommended.
+echo -n "Recommends: "
+run rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/'
+],
+[0],
+[3
+hello debug exists
+Recommends: test-debugsource(ignore-arch) = 1.0-1
+hello2 debug exists
+Recommends: test-debugsource(ignore-arch) = 1.0-1
+hello3 debug exists
+Recommends: test-debugsource(ignore-arch) = 1.0-1
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debuginfo_subpackages works with excluded files.
+AT_SETUP([rpmbuild debuginfo subpackages multiple excluded])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --define "_debugsource_packages 1" \
+ --define "_debuginfo_subpackages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages-exclude.spec
+
+# Check that there are 2 debuginfo packages.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# First contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+
+# Second contains hello2.debug but NOT hello3.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello2 | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello2 debug exists"
+else
+ echo "No hello2: $debug_name"
+fi
+
+if test -f ./usr/lib/debug/bin/hello3*; then
+ echo "hello3 debug exists"
+else
+ echo "No hello3 debug"
+fi
+],
+[0],
+[2
+hello debug exists
+hello2 debug exists
+No hello3 debug
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debuginfo_subpackages works with RemovePathPostfixes.
+AT_SETUP([rpmbuild debuginfo subpackages multiple excluded])
+AT_KEYWORDS([build] [debuginfo] [debugsubpackage] [debugsource])
+AT_CHECK([
+rm -rf ${TOPDIR}
+AS_MKDIR_P(${TOPDIR}/SOURCES)
+
+# Setup sources
+cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
+
+rundebug rpmbuild --quiet \
+ --define "_unique_debug_names 1" \
+ --define "_unique_debug_srcs 1" \
+ --define "_debugsource_packages 1" \
+ --define "_debuginfo_subpackages 1" \
+ -ba "${abs_srcdir}"/data/SPECS/test-subpackages-pathpostfixes.spec
+
+# Check that there are 2 debuginfo packages.
+ls ${abs_builddir}/testing/build/RPMS/*/*debuginfo*rpm | wc --lines
+
+# First contains hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello debug exists"
+else
+ echo "No hello: $debug_name"
+fi
+
+# remove it, we are going to check the other debuginfo package.
+rm ./bin/hello
+rm ./usr/lib/debug/bin/$debug_name
+orig_debugname=$debugname
+
+# Second contains hello.foobar.debug but NOT hello.debug
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \
+ | cpio -diu --quiet
+# Extract the debug name from the exe (.gnu_debuglink section, first string)
+debug_name=$(readelf -p .gnu_debuglink ./bin/hello | grep hello | cut -c13-)
+
+rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm \
+ | cpio -diu --quiet
+if test -f ./usr/lib/debug/bin/$debug_name; then
+ echo "hello.foobar debug exists"
+else
+ echo "No hello2: $debug_name"
+fi
+
+if test -f ./usr/lib/debug/bin/$orig_debugname; then
+ echo "$orig_debugname exists"
+else
+ echo "No hello.debug"
+fi
+],
+[0],
+[2
+hello debug exists
+hello.foobar debug exists
+No hello.debug
+],
+[ignore])
+AT_CLEANUP