Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 08/16] auto-t: iwd.py: fix multiple timeout cleanup issues
Date: Thu, 27 Aug 2020 10:32:21 -0700	[thread overview]
Message-ID: <20200827173229.26466-8-prestwoj@gmail.com> (raw)
In-Reply-To: <20200827173229.26466-1-prestwoj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3539 bytes --]

There were a few more places where the GLib timeout was not being
removed which could cause the IWD object to hang around longer than
expected causing problems for subsequent tests.
---
 autotests/util/iwd.py | 51 +++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 37daaeef..113039b6 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -948,15 +948,18 @@ class IWD(AsyncOpAbstract):
             self._wait_timed_out = True
             return False
 
-        timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
-        context = mainloop.get_context()
-        while not eval(condition_str):
-            context.iteration(may_block=True)
-            if self._wait_timed_out and os.environ['IWD_TEST_TIMEOUTS'] == 'on':
-                raise TimeoutError('[' + condition_str + ']'\
-                                   ' condition was not met in '\
-                                   + str(max_wait) + ' sec')
-        GLib.source_remove(timeout)
+        try:
+            timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
+            context = mainloop.get_context()
+            while not eval(condition_str):
+                context.iteration(may_block=True)
+                if self._wait_timed_out and ctx.args.gdb == 'None':
+                    raise TimeoutError('[' + condition_str + ']'\
+                                       ' condition was not met in '\
+                                       + str(max_wait) + ' sec')
+        finally:
+            if not self._wait_timed_out:
+                GLib.source_remove(timeout)
 
     def wait(self, time):
         self._wait_timed_out = False
@@ -964,10 +967,14 @@ class IWD(AsyncOpAbstract):
             self._wait_timed_out = True
             return False
 
-        GLib.timeout_add(int(time * 1000), wait_timeout_cb)
-        context = mainloop.get_context()
-        while not self._wait_timed_out:
-            context.iteration(may_block=True)
+        try:
+            timeout = GLib.timeout_add(int(time * 1000), wait_timeout_cb)
+            context = mainloop.get_context()
+            while not self._wait_timed_out:
+                context.iteration(may_block=True)
+        finally:
+            if not self._wait_timed_out:
+                GLib.source_remove(timeout)
 
     @staticmethod
     def clear_storage():
@@ -1013,14 +1020,16 @@ class IWD(AsyncOpAbstract):
             self._wait_timed_out = True
             return False
 
-        timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
-        context = mainloop.get_context()
-        while len(self._devices) < wait_to_appear:
-            context.iteration(may_block=True)
-            if self._wait_timed_out:
-                raise TimeoutError('IWD has no associated devices')
-
-        GLib.source_remove(timeout)
+        try:
+            timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
+            context = mainloop.get_context()
+            while len(self._devices) < wait_to_appear:
+                context.iteration(may_block=True)
+                if self._wait_timed_out:
+                    raise TimeoutError('IWD has no associated devices')
+        finally:
+            if not self._wait_timed_out:
+                GLib.source_remove(timeout)
 
         return list(self._devices.values())
 
-- 
2.21.1

  parent reply	other threads:[~2020-08-27 17:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 17:32 [PATCH 01/16] hwsim: return radio ID on create James Prestwood
2020-08-27 17:32 ` [PATCH 02/16] auto-t: prepare autotests for test-runner re-write James Prestwood
2020-08-27 17:32 ` [PATCH 03/16] auto-t: introduce pure python " James Prestwood
2020-08-27 17:32 ` [PATCH 04/16] auto-t: hostapd.py: update to work with test-runner rewrite James Prestwood
2020-08-27 17:32 ` [PATCH 05/16] auto-t: testutil.py: " James Prestwood
2020-08-27 17:32 ` [PATCH 06/16] auto-t: ofono.py: fix timeout cleanup and wait for service James Prestwood
2020-08-27 17:32 ` [PATCH 07/16] auto-t: iwd.py: update to work with test-runner rewrite James Prestwood
2020-08-27 17:32 ` James Prestwood [this message]
2020-08-27 17:32 ` [PATCH 09/16] auto-t: remove wiphy.py James Prestwood
2020-08-27 17:32 ` [PATCH 10/16] auto-t: fix hidden network test James Prestwood
2020-08-27 17:32 ` [PATCH 11/16] auto-t: fix testSAE autoconnect_test.py James Prestwood
2020-08-27 17:32 ` [PATCH 12/16] auto-t: skip ofono tests if ofonod isn't running James Prestwood
2020-08-27 17:32 ` [PATCH 13/16] auto-t: replace hard-coded interfaces James Prestwood
2020-08-27 17:32 ` [PATCH 14/16] auto-t: remove device.wait_for_connected James Prestwood
2020-08-27 17:32 ` [PATCH 15/16] tools: post test-runner rewrite cleanup James Prestwood
2020-08-27 17:32 ` [PATCH 16/16] doc: update test runner docs James Prestwood
2020-08-27 20:08 ` [PATCH 01/16] hwsim: return radio ID on create Denis Kenzior
2020-08-27 20:21   ` James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200827173229.26466-8-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox