test: py: Fix log level restore in SimpleTestMethods()
diff mbox series

Message ID 20241105000703.22037-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 876730d805bb48ac0b458f557b09f66eb0c694d5
Headers show
Series
  • test: py: Fix log level restore in SimpleTestMethods()
Related show

Commit Message

Laurent Pinchart Nov. 5, 2024, 12:07 a.m. UTC
The SimpleTestMethods() function tests that incorrect calls to the
Camera.acquire() method raise an exception. Before doing so, it sets the
log level for the Camera category to FATAL, in order to avoid showing
misleading errors in the test log, and then restores the log level to
ERROR after running the test. ERROR is however not the default log
level. Restore the log level to INFO instead, in order to avoid losing
log messages in subsequent tests.

Fixes: 06cb7130c4fa ("py: Add unittests.py")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/py/unittests.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: f028b09b7becf4e7847112b2e8044e5e30e01c58

Comments

Kieran Bingham Nov. 5, 2024, 10:17 a.m. UTC | #1
Quoting Laurent Pinchart (2024-11-05 00:07:03)
> The SimpleTestMethods() function tests that incorrect calls to the
> Camera.acquire() method raise an exception. Before doing so, it sets the
> log level for the Camera category to FATAL, in order to avoid showing
> misleading errors in the test log, and then restores the log level to
> ERROR after running the test. ERROR is however not the default log
> level. Restore the log level to INFO instead, in order to avoid losing
> log messages in subsequent tests.
> 
> Fixes: 06cb7130c4fa ("py: Add unittests.py")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  test/py/unittests.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/test/py/unittests.py b/test/py/unittests.py
> index 1caea98eb946..8cb850d4e71c 100755
> --- a/test/py/unittests.py
> +++ b/test/py/unittests.py
> @@ -66,7 +66,7 @@ class SimpleTestMethods(BaseTestCase):
>          libcam.log_set_level('Camera', 'FATAL')

Perhaps log_set_level should return the previous level for restoration ?

>          with self.assertRaises(RuntimeError):
>              cam.acquire()
> -        libcam.log_set_level('Camera', 'ERROR')
> +        libcam.log_set_level('Camera', 'INFO')

But this is fine...


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>  
>          cam.release()
>  
> 
> base-commit: f028b09b7becf4e7847112b2e8044e5e30e01c58
> -- 
> Regards,
> 
> Laurent Pinchart
>
Tomi Valkeinen Nov. 5, 2024, 10:23 a.m. UTC | #2
Hi,

On 05/11/2024 12:17, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2024-11-05 00:07:03)
>> The SimpleTestMethods() function tests that incorrect calls to the
>> Camera.acquire() method raise an exception. Before doing so, it sets the
>> log level for the Camera category to FATAL, in order to avoid showing
>> misleading errors in the test log, and then restores the log level to
>> ERROR after running the test. ERROR is however not the default log
>> level. Restore the log level to INFO instead, in order to avoid losing
>> log messages in subsequent tests.
>>
>> Fixes: 06cb7130c4fa ("py: Add unittests.py")
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>>   test/py/unittests.py | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/test/py/unittests.py b/test/py/unittests.py
>> index 1caea98eb946..8cb850d4e71c 100755
>> --- a/test/py/unittests.py
>> +++ b/test/py/unittests.py
>> @@ -66,7 +66,7 @@ class SimpleTestMethods(BaseTestCase):
>>           libcam.log_set_level('Camera', 'FATAL')
> 
> Perhaps log_set_level should return the previous level for restoration ?

Do we have means to get the current level?

> 
>>           with self.assertRaises(RuntimeError):
>>               cam.acquire()
>> -        libcam.log_set_level('Camera', 'ERROR')
>> +        libcam.log_set_level('Camera', 'INFO')
> 
> But this is fine...
> 
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

  Tomi

> 
>>   
>>           cam.release()
>>   
>>
>> base-commit: f028b09b7becf4e7847112b2e8044e5e30e01c58
>> -- 
>> Regards,
>>
>> Laurent Pinchart
>>
Laurent Pinchart Nov. 5, 2024, 10:42 a.m. UTC | #3
On Tue, Nov 05, 2024 at 12:23:23PM +0200, Tomi Valkeinen wrote:
> On 05/11/2024 12:17, Kieran Bingham wrote:
> > Quoting Laurent Pinchart (2024-11-05 00:07:03)
> >> The SimpleTestMethods() function tests that incorrect calls to the
> >> Camera.acquire() method raise an exception. Before doing so, it sets the
> >> log level for the Camera category to FATAL, in order to avoid showing
> >> misleading errors in the test log, and then restores the log level to
> >> ERROR after running the test. ERROR is however not the default log
> >> level. Restore the log level to INFO instead, in order to avoid losing
> >> log messages in subsequent tests.
> >>
> >> Fixes: 06cb7130c4fa ("py: Add unittests.py")
> >> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >> ---
> >>   test/py/unittests.py | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/test/py/unittests.py b/test/py/unittests.py
> >> index 1caea98eb946..8cb850d4e71c 100755
> >> --- a/test/py/unittests.py
> >> +++ b/test/py/unittests.py
> >> @@ -66,7 +66,7 @@ class SimpleTestMethods(BaseTestCase):
> >>           libcam.log_set_level('Camera', 'FATAL')
> > 
> > Perhaps log_set_level should return the previous level for restoration ?
> 
> Do we have means to get the current level?

No we don't. I thought about adding that, but then decided to let
someone else do it if they really need it :-)

> >>           with self.assertRaises(RuntimeError):
> >>               cam.acquire()
> >> -        libcam.log_set_level('Camera', 'ERROR')
> >> +        libcam.log_set_level('Camera', 'INFO')
> > 
> > But this is fine...
> > 
> > 
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> 
> >>   
> >>           cam.release()
> >>   
> >>
> >> base-commit: f028b09b7becf4e7847112b2e8044e5e30e01c58

Patch
diff mbox series

diff --git a/test/py/unittests.py b/test/py/unittests.py
index 1caea98eb946..8cb850d4e71c 100755
--- a/test/py/unittests.py
+++ b/test/py/unittests.py
@@ -66,7 +66,7 @@  class SimpleTestMethods(BaseTestCase):
         libcam.log_set_level('Camera', 'FATAL')
         with self.assertRaises(RuntimeError):
             cam.acquire()
-        libcam.log_set_level('Camera', 'ERROR')
+        libcam.log_set_level('Camera', 'INFO')
 
         cam.release()