From 9f5b790800f5a379f3e5fd53b9ade5f19a567734 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 30 May 2022 17:27:07 +0300 Subject: py: unittests: Fix test_sleep() Waiting for 0.5 secs and expecting that the requests have been completed is... bad. Fix the test case by using cam.read_event() as a blocking wait, and wait until we have received all the requests that we queued. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- test/py/unittests.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test/py') diff --git a/test/py/unittests.py b/test/py/unittests.py index 426efb06..45b35223 100755 --- a/test/py/unittests.py +++ b/test/py/unittests.py @@ -161,7 +161,7 @@ class AllocatorTestMethods(CameraTesterBase): class SimpleCaptureMethods(CameraTesterBase): - def test_sleep(self): + def test_blocking(self): cm = self.cm cam = self.cam @@ -207,11 +207,17 @@ class SimpleCaptureMethods(CameraTesterBase): reqs = None gc.collect() - time.sleep(0.5) + reqs = [] - reqs = cm.get_ready_requests() + while True: + cm.read_event() - self.assertTrue(len(reqs) == num_bufs) + ready_reqs = cm.get_ready_requests() + + reqs += ready_reqs + + if len(reqs) == num_bufs: + break for i, req in enumerate(reqs): self.assertTrue(i == req.cookie) -- cgit v1.2.1