From a76f039b26099081a07a2b3a76e96c49c3599bc4 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Mon, 15 Jul 2019 14:28:16 +0200 Subject: nm.py autopkgtest: Improved timers of the main loops further. --- debian/tests/nm.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'debian/tests') diff --git a/debian/tests/nm.py b/debian/tests/nm.py index 8316e087..d9b58b70 100755 --- a/debian/tests/nm.py +++ b/debian/tests/nm.py @@ -277,21 +277,25 @@ class NetworkManagerTest(network_test_base.NetworkTestBase): if (self.timeout_tag > 0): GLib.source_remove(self.timeout_tag) self.timeout_tag = 0 - if (not self.cancel.is_cancelled()): + try: self.cb_conn = \ self.nmclient.add_and_activate_connection_finish(res) + except gi.repository.GLib.Error as e: + # Check if the error is "Operation was cancelled" + if (e.domain != "g-io-error-quark" or e.code != 19): + self.fail("add_and_activate_connection failed: %s (%s, %d)" % + (e.message, e.domain, e.code)) ml.quit() def timeout_cb(): - self.cancel.cancel() self.timeout_tag = -1 + self.cancel.cancel() ml.quit() return GLib.SOURCE_REMOVE self.nmclient.add_and_activate_connection_async(partial_conn, self.nmdev_w, ap.get_path(), self.cancel, add_activate_cb, None) self.timeout_tag = GLib.timeout_add_seconds(300, timeout_cb) ml.run() - self.cancel.reset() if (self.timeout_tag < 0): self.timeout_tag = 0 self.fail('Main loop for adding connection timed out!') @@ -696,21 +700,25 @@ Logs are in '%s'. When done, exit the shell. if (self.timeout_tag > 0): GLib.source_remove(self.timeout_tag) self.timeout_tag = 0 - if (not self.cancel.is_cancelled()): + try: self.cb_conn = \ self.nmclient.add_and_activate_connection_finish(res) + except gi.repository.GLib.Error as e: + # Check if the error is "Operation was cancelled" + if (e.domain != "g-io-error-quark" or e.code != 19): + self.fail("add_and_activate_connection failed: %s (%s, %d)" % + (e.message, e.domain, e.code)) ml.quit() def timeout_cb(): - self.cancel.cancel() self.timeout_tag = -1 + self.cancel.cancel() ml.quit() return GLib.SOURCE_REMOVE self.nmclient.add_and_activate_connection_async(partial_conn, self.nmdev_e, None, self.cancel, add_activate_cb, None) self.timeout_tag = GLib.timeout_add_seconds(300, timeout_cb) ml.run() - self.cancel.reset() if (self.timeout_tag < 0): self.timeout_tag = 0 self.fail('Main loop for adding connection timed out!') -- cgit 1.3.0-6-gf8a5