[Rpm-maint] [PATCH] Add two testcases for generating debugsource packages.

Mark Wielaard mark at klomp.org
Fri Jul 28 12:11:22 UTC 2017


These tests define _debugsource_packages and check a debugsource package
is created that contains the source of the program created.

Without the fix to make sure that debugsourcefiles.list is generated in
the build dir the second testcase will fail with:
error: Could not open %files file

Signed-off-by: Mark Wielaard <mark at klomp.org>
---
 tests/Makefile.am              |  1 +
 tests/data/SPECS/hello-cd.spec | 29 ++++++++++++++++++++
 tests/rpmbuild.at              | 62 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)
 create mode 100644 tests/data/SPECS/hello-cd.spec

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b962e4a..09239ba 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -78,6 +78,7 @@ EXTRA_DIST += data/SRPMS/hello-1.0-1.src.rpm
 EXTRA_DIST += data/SOURCES/hello.c
 EXTRA_DIST += data/SPECS/hello-attr-buildid.spec
 EXTRA_DIST += data/SPECS/hello-config-buildid.spec
+EXTRA_DIST += data/SPECS/hello-cd.spec
 EXTRA_DIST += data/keys/rpm.org-rsa-2048-test.pub
 EXTRA_DIST += data/keys/rpm.org-rsa-2048-test.secret
 
diff --git a/tests/data/SPECS/hello-cd.spec b/tests/data/SPECS/hello-cd.spec
new file mode 100644
index 0000000..ab1e300
--- /dev/null
+++ b/tests/data/SPECS/hello-cd.spec
@@ -0,0 +1,29 @@
+Name:           test
+Version:        1.0
+Release:        1
+Summary:        Test
+
+License:        Public Domain
+URL:            https://fedoraproject.org
+Source:         hello.c
+
+%description
+%{summary}.
+
+%prep
+%autosetup -c -D -T
+cp -a %{S:0} .
+
+%build
+gcc -g hello.c -o hello
+
+%install
+mkdir -p %{buildroot}/bin
+install -D -p -m 0755 -t %{buildroot}/bin hello
+# Pretend we need to do something in /tmp
+cd /tmp
+
+%files
+%attr(644,root,root) /bin/hello
+
+%changelog
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 3200fb2..3f41652 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -838,3 +838,65 @@ 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
+
+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 \
+  --define "_debugsource_packages 1" \
+  -ba "${abs_srcdir}"/data/SPECS/hello2.spec
+
+# Unpack the debuginfo rpms 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*/
+],
+[0],
+[hello.c
+],
+[ignore])
+AT_CLEANUP
+
+# ------------------------------
+# Check that defining _debugsource_packages creates -debugsource package
+# even if %install changes the working directory (debugsourcefiles.list
+# should be in expected build dir).
+AT_SETUP([rpmbuild debugsource debugsourcefiles.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
+
+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 \
+  --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
-- 
1.8.3.1



More information about the Rpm-maint mailing list