conman:  Fix a flaky test.

Previously, there was code that would run conman until it updated its
cached interface state, and then until it scanned.  But occasionally
the scan would happen before or during the main loop iteration which
updated the interfaces, in which case run_until_scan would never
terminate.

This fixes the issue by adding a run_until_* function which combines
the two.

Change-Id: I520a6ae1fb65cdfa5ff8a865a232d8cfaf3112af
diff --git a/conman/connection_manager_test.py b/conman/connection_manager_test.py
index 646d114..0e342b0 100755
--- a/conman/connection_manager_test.py
+++ b/conman/connection_manager_test.py
@@ -387,6 +387,13 @@
     while wifi_scan_counter == wifi.wifi_scan_counter:
       self.run_once()
 
+  def run_until_interface_update_and_scan(self, band):
+    wifi = self.wifi_for_band(band)
+    wifi_scan_counter = wifi.wifi_scan_counter
+    self.run_until_interface_update()
+    while wifi_scan_counter == wifi.wifi_scan_counter:
+      self.run_once()
+
   def has_status_files(self, files):
     return not set(files) - set(os.listdir(self._status_dir))
 
@@ -566,8 +573,7 @@
   c.delete_wlan_config('2.4')
   c.run_once()
   wvtest.WVFAIL(c.has_status_files([status.P.CONNECTED_TO_WLAN]))
-  c.run_until_interface_update()
-  c.run_until_scan('2.4')
+  c.run_until_interface_update_and_scan('2.4')
   c.run_until_interface_update()
   wvtest.WVPASS(c.has_status_files([status.P.CONNECTED_TO_OPEN]))
   wvtest.WVPASSEQ(c.last_provisioning_attempt.ssid, 's3')