autotests: Add IWD.wait utility for sleeping inside tests

This commit is contained in:
Andrew Zaborowski 2017-05-14 04:10:06 +02:00 committed by Denis Kenzior
parent b1d0dbc3e4
commit 920e79b32c
1 changed files with 11 additions and 0 deletions

View File

@ -589,6 +589,17 @@ class IWD(AsyncOpAbstract):
+ str(max_wait) + ' sec')
GLib.source_remove(timeout)
def wait(self, time):
self._wait_timed_out = False
def wait_timeout_cb():
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)
@staticmethod
def clear_storage():
os.system('rm -rf ' + IWD_STORAGE_DIR + '/*')