[libcamera-devel,v3,13/17] py: unittests.py: Use new events support
diff mbox series

Message ID 20220701084521.31831-14-tomi.valkeinen@ideasonboard.com
State Superseded
Headers show
Series
  • Python bindings event handling
Related show

Commit Message

Tomi Valkeinen July 1, 2022, 8:45 a.m. UTC
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 test/py/unittests.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Laurent Pinchart Aug. 18, 2022, 9:01 p.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Fri, Jul 01, 2022 at 11:45:17AM +0300, Tomi Valkeinen wrote:

A commit message would be nice.

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  test/py/unittests.py | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/test/py/unittests.py b/test/py/unittests.py
> index 794e46be..fab791d1 100755
> --- a/test/py/unittests.py
> +++ b/test/py/unittests.py
> @@ -201,9 +201,9 @@ class SimpleCaptureMethods(CameraTesterBase):
>              if not events:
>                  continue
>  
> -            ready_reqs = cm.get_ready_requests()
> -
> -            reqs += ready_reqs
> +            for ev in cm.get_events():
> +                self.assertEqual(ev.type, libcam.Event.Type.RequestCompleted)

We'll get test failures if a camera is connected while the test is
running, or if any other type of event occurs. That's something we need
to solve, but I'm fine if you want to delay that a bit.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +                reqs.append(ev.request)
>  
>              if len(reqs) == num_bufs:
>                  break
> @@ -267,9 +267,9 @@ class SimpleCaptureMethods(CameraTesterBase):
>          while running:
>              events = sel.select()
>              for key, _ in events:
> -                ready_reqs = cm.get_ready_requests()
> -
> -                reqs += ready_reqs
> +                for ev in cm.get_events():
> +                    self.assertEqual(ev.type, libcam.Event.Type.RequestCompleted)
> +                    reqs.append(ev.request)
>  
>                  if len(reqs) == num_bufs:
>                      running = False
Tomi Valkeinen Aug. 26, 2022, 12:33 p.m. UTC | #2
On 19/08/2022 00:01, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Fri, Jul 01, 2022 at 11:45:17AM +0300, Tomi Valkeinen wrote:
> 
> A commit message would be nice.
> 
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> ---
>>   test/py/unittests.py | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/test/py/unittests.py b/test/py/unittests.py
>> index 794e46be..fab791d1 100755
>> --- a/test/py/unittests.py
>> +++ b/test/py/unittests.py
>> @@ -201,9 +201,9 @@ class SimpleCaptureMethods(CameraTesterBase):
>>               if not events:
>>                   continue
>>   
>> -            ready_reqs = cm.get_ready_requests()
>> -
>> -            reqs += ready_reqs
>> +            for ev in cm.get_events():
>> +                self.assertEqual(ev.type, libcam.Event.Type.RequestCompleted)
> 
> We'll get test failures if a camera is connected while the test is
> running, or if any other type of event occurs. That's something we need
> to solve, but I'm fine if you want to delay that a bit.

That is true, but... Maybe that can be considered a valid thing to fail 
on. Unittests need to expect a certain kind of running environment, and 
I think it's a valid requirement that cameras are not being attached and 
removed while the tests are running.

  Tomi

Patch
diff mbox series

diff --git a/test/py/unittests.py b/test/py/unittests.py
index 794e46be..fab791d1 100755
--- a/test/py/unittests.py
+++ b/test/py/unittests.py
@@ -201,9 +201,9 @@  class SimpleCaptureMethods(CameraTesterBase):
             if not events:
                 continue
 
-            ready_reqs = cm.get_ready_requests()
-
-            reqs += ready_reqs
+            for ev in cm.get_events():
+                self.assertEqual(ev.type, libcam.Event.Type.RequestCompleted)
+                reqs.append(ev.request)
 
             if len(reqs) == num_bufs:
                 break
@@ -267,9 +267,9 @@  class SimpleCaptureMethods(CameraTesterBase):
         while running:
             events = sel.select()
             for key, _ in events:
-                ready_reqs = cm.get_ready_requests()
-
-                reqs += ready_reqs
+                for ev in cm.get_events():
+                    self.assertEqual(ev.type, libcam.Event.Type.RequestCompleted)
+                    reqs.append(ev.request)
 
                 if len(reqs) == num_bufs:
                     running = False