Source: tpm2-abrmd
Version: 1.3.1-1
Severity: minor
Tags: patch

While testing the upstream patch for tpm2-abrmd's FTBFS against recent
GLib (see separate bug), I happened to notice a patch that disables one
unit test, which requires a D-Bus session bus.

It's true that autobuilder environments do not usually have a D-Bus
session bus. However, dbus >= 1.8 comes with the dbus-run-session tool,
which starts a temporary session bus: it is designed to be used in
automated tests and similar environments. If you wrap the build-time
tests with dbus-run-session, as in the attached patch, then you don't
need to disable test coverage.

I have checked that the attached patch works in sbuild (when combined
with applying the upstream patch for the FTBFS with recent GLib).

Ideally, the build-time tests would be altered upstream to start their
own temporary session bus, for example by using dbus-run-session (like
the dbus-python source package does) or by starting a dbus-daemon as
a subprocess.

Regards,
    smcv
>From 1e96aef7bc661e1657c4bc8d06555f923c25deab Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Thu, 4 Oct 2018 23:12:59 +0100
Subject: [PATCH] Use dbus-run-session to give unit tests a temporary session
 bus

This means that tss2-tcti-tabrmd_unit does not have to be skipped.
---
 debian/control                                |  1 +
 ...2-remove-unit-test-needs-dbus-daemon.patch | 19 -------------------
 debian/patches/series                         |  1 -
 debian/rules                                  |  5 +++++
 4 files changed, 6 insertions(+), 20 deletions(-)
 delete mode 100644 debian/patches/0002-remove-unit-test-needs-dbus-daemon.patch

diff --git a/debian/control b/debian/control
index 19b15d2..50afa23 100644
--- a/debian/control
+++ b/debian/control
@@ -6,6 +6,7 @@ Uploaders: Ying-Chun Liu (PaulLiu) <paul...@debian.org>
 Build-Depends: autoconf,
                autoconf-archive,
                automake,
+               dbus <!nocheck>,
                debhelper (>= 11),
                libcmocka-dev,
                libdbus-1-dev,
diff --git a/debian/patches/0002-remove-unit-test-needs-dbus-daemon.patch b/debian/patches/0002-remove-unit-test-needs-dbus-daemon.patch
deleted file mode 100644
index 8f2837e..0000000
--- a/debian/patches/0002-remove-unit-test-needs-dbus-daemon.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-Description: Remove some unit test requires dbus to be run.
- On build servers there's no dbus running. We shouldn't start the service
- and connected to dbus. Thus we remove unit tests that requires dbus.
-Author: Ying-Chun Liu (PaulLiu) <paul...@debian.org>
-Forwarded: not-needed
-Last-Update: 2018-05-02
-
-Index: tpm2-abrmd/Makefile.am
-===================================================================
---- tpm2-abrmd.orig/Makefile.am
-+++ tpm2-abrmd/Makefile.am
-@@ -38,7 +38,6 @@ TESTS_UNIT = \
-     test/thread_unit \
-     test/tpm2-command_unit \
-     test/tpm2-response_unit \
--    test/tss2-tcti-tabrmd_unit \
-     test/tss2-tcti-echo_unit \
-     test/util_unit
- if TCTI_DEVICE
diff --git a/debian/patches/series b/debian/patches/series
index 763fea8..5151d6c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1 @@
 0001-Since-Debian-source-package-did-not-contain-.git-fil.patch
-0002-remove-unit-test-needs-dbus-daemon.patch
diff --git a/debian/rules b/debian/rules
index 3a6df7a..cb64ccb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -17,5 +17,10 @@ override_dh_autoreconf:
 override_dh_auto_configure:
 	dh_auto_configure -- --enable-unit
 
+override_dh_auto_test:
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+	dbus-run-session -- dh_auto_test
+endif
+
 override_dh_missing:
 	dh_missing --fail-missing
-- 
2.19.0

Reply via email to