From d630f122f72e292c6be75194e44279b86c132db3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Dalleau?=
 <frederic.dalleau@collabora.co.uk>
Date: Thu, 6 Oct 2016 10:27:08 +0000
Subject: [PATCH] bluez-hfp: Ensure that process_next isn't called twice
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When the profile list are parsed process_next is called. It is also
caled when the pairing is terminated. When only one profile was
discovered, the only task in process_q would be popped at first
process_next() call. The second call would find an empty process_q
and quit the mainloop without executing the test.

This patch arrange the pairing and non pairing tests so they are
symmetrical. The call to tester.get_device is synchronous.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: Frédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D4561
---
 bluez/bluez-hfp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bluez/bluez-hfp b/bluez/bluez-hfp
index 9c1c3cc9..6609cb3e 100755
--- a/bluez/bluez-hfp
+++ b/bluez/bluez-hfp
@@ -59,8 +59,6 @@ class HfpAgDeviceProfileTester(DeviceProfileTester):
         if 'HFP AG' in profiles:
             process_q.append(self.test_hfp_ag)
 
-        process_next()
-
     def test_hfp_ag(self):
         TEST_START("HFP AG")
 
@@ -210,8 +208,12 @@ if __name__ == "__main__":
         TEST_START('Pairing Responder')
         tester.start_pairing_responder(test2_cb)
 
+    def skiptest():
+        tester.get_device()
+        process_next()
+
     if options.skip_pair:
-        process_q.append(tester.get_device)
+        process_q.append(skiptest)
     else:
         process_q.append(test1)
         process_q.append(test2)
-- 
GitLab