mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
tests/auth_log: Refactor waitForMessages() to use nextMessage()
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 14 23:55:42 UTC 2023 on atb-devel-224
This commit is contained in:
parent
67da91ef16
commit
9b0a71bd30
@ -113,23 +113,16 @@ class AuthLogTestBase(samba.tests.TestCase):
|
||||
until all the logging messages have been received.
|
||||
"""
|
||||
|
||||
def completed(messages):
|
||||
for message in messages:
|
||||
if self.isRemote(message) and isLastExpectedMessage(message):
|
||||
return True
|
||||
return False
|
||||
|
||||
self.connection = connection
|
||||
|
||||
start_time = time.time()
|
||||
while not completed(self.context["messages"]):
|
||||
self.msg_ctx.loop_once(0.1)
|
||||
if time.time() - start_time > 1:
|
||||
self.connection = None
|
||||
messages = []
|
||||
while True:
|
||||
try:
|
||||
msg = self.nextMessage()
|
||||
except NoMessageException:
|
||||
return []
|
||||
|
||||
self.connection = None
|
||||
return list(filter(self.isRemote, self.context["messages"]))
|
||||
messages.append(msg)
|
||||
if isLastExpectedMessage(msg):
|
||||
return messages
|
||||
|
||||
def nextMessage(self, msgFilter=None):
|
||||
"""Return the next relevant message, or throw a NoMessageException."""
|
||||
|
Loading…
Reference in New Issue
Block a user