From 5cfe3c8e81f6de8f6f7737ae0b12bc8e6d7790d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@redhat.com>
Date: Thu, 28 Feb 2013 16:54:41 +0100
Subject: [PATCH] Create %check section working.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Run upstream unit tests.
* rpmbuild shouldn’t fail when tests fail.
* Make better reporting.

Signed-off-by: Matěj Cepl <mcepl@redhat.com>
---
 dbus.spec | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/dbus.spec b/dbus.spec
index 99d753e..1110a52 100644
--- a/dbus.spec
+++ b/dbus.spec
@@ -5,6 +5,8 @@
 
 %define dbus_user_uid           81
 
+%define common_build_args --enable-libaudit --enable-selinux=yes --with-init-scripts=redhat --with-system-pid-file=%{_localstatedir}/run/messagebus.pid --with-dbus-user=dbus --libdir=/%{_lib} --bindir=/bin --sysconfdir=/etc --exec-prefix=/ --libexecdir=/%{_lib}/dbus-1
+
 Summary: D-BUS message bus
 Name: dbus
 Epoch: 1
@@ -91,11 +93,11 @@ in this separate package so server systems need not install X.
 autoreconf -f -i
 
 %build
-COMMON_ARGS="--enable-libaudit --enable-selinux=yes --with-init-scripts=redhat --with-system-pid-file=%{_localstatedir}/run/messagebus.pid --with-dbus-user=dbus --libdir=/%{_lib} --bindir=/bin --sysconfdir=/etc --exec-prefix=/ --libexecdir=/%{_lib}/dbus-1"
-
 # leave verbose mode so people can debug their apps but make sure to
 # turn it off on stable releases with --disable-verbose-mode
-%configure $COMMON_ARGS --disable-tests --disable-asserts --enable-doxygen-docs --enable-xml-docs --with-systemdsystemunitdir=/lib/systemd/system/
+%configure %{common_build_args} --disable-tests --disable-asserts \
+    --enable-doxygen-docs --enable-xml-docs --disable-verbose-mode \
+    --with-systemdsystemunitdir=/lib/systemd/system/
 make
 
 %install
@@ -136,6 +138,22 @@ mkdir -p %{buildroot}/var/lib/dbus
 %clean
 rm -rf %{buildroot}
 
+%check
+make clean
+%configure %{common_build_args} --enable-tests  --enable-installed-tests \
+  --enable-asserts --with-systemdsystemunitdir=/lib/systemd/system/
+make
+
+TESTS_FAILED=0
+make check || TESTS_FAILED=1
+
+echo -n "*********************** UPSTREAM TESTS "
+if [ $TESTS_FAILED -eq 0 ] ; then
+  echo "PASS."
+else
+  echo "FAIL."
+fi
+
 %pre
 # Add the "dbus" user and group
 /usr/sbin/groupadd -r -g %{dbus_user_uid} dbus 2>/dev/null || :
-- 
1.8.1

