[libcamera-devel] test: v4l2_compat: Add --verbose argument
diff mbox series

Message ID 20220115164434.30763-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 6b160d91f9fee914fa16e6f36c6384930bea2a5d
Delegated to: Laurent Pinchart
Headers show
Series
  • [libcamera-devel] test: v4l2_compat: Add --verbose argument
Related show

Commit Message

Laurent Pinchart Jan. 15, 2022, 4:44 p.m. UTC
Add a -v/--verbose argument to the v4l2_compat test to print the output
of v4l2-compliance, even when the test passes. This can be useful when
debugging.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/v4l2_compat/v4l2_compat_test.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Paul Elder Jan. 17, 2022, 6:24 a.m. UTC | #1
Hi Laurent,

On Sat, Jan 15, 2022 at 06:44:34PM +0200, Laurent Pinchart wrote:
> Add a -v/--verbose argument to the v4l2_compat test to print the output
> of v4l2-compliance, even when the test passes. This can be useful when
> debugging.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  test/v4l2_compat/v4l2_compat_test.py | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py
> index 29c25974c1c9..a77585fc2f49 100755
> --- a/test/v4l2_compat/v4l2_compat_test.py
> +++ b/test/v4l2_compat/v4l2_compat_test.py
> @@ -65,7 +65,7 @@ def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
>  
>      result = extract_result(output[-2])
>      if result['failed'] == 0:
> -        return TestPass, None
> +        return TestPass, output
>  
>      # vimc will fail s_fmt because it only supports framesizes that are
>      # multiples of 3
> @@ -73,7 +73,7 @@ def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
>          failures = grep('fail', output)
>          if re.search('S_FMT cannot handle an invalid format', failures[0]) is None:
>              return TestFail, output
> -        return TestPass, None
> +        return TestPass, output
>  
>      return TestFail, output
>  
> @@ -82,6 +82,8 @@ def main(argv):
>      parser = argparse.ArgumentParser()
>      parser.add_argument('-a', '--all', action='store_true',
>                          help='Test all available cameras')
> +    parser.add_argument('-v', '--verbose', action='store_true',
> +                        help='Make the output verbose')
>      parser.add_argument('v4l2_compat', type=str,
>                          help='Path to v4l2-compat.so')
>      args = parser.parse_args(argv[1:])
> @@ -146,9 +148,12 @@ def main(argv):
>          if ret == TestFail:
>              failed.append(device)
>              print('failed')
> -            print('\n'.join(msg))
>          else:
>              print('success')
> +
> +        if ret == TestFail or args.verbose:
> +            print('\n'.join(msg))
> +
>          drivers_tested[driver] = True
>  
>      if len(drivers_tested) == 0:
> -- 
> Regards,
> 
> Laurent Pinchart
>
Kieran Bingham Jan. 17, 2022, 11:10 a.m. UTC | #2
Quoting Laurent Pinchart (2022-01-15 16:44:34)
> Add a -v/--verbose argument to the v4l2_compat test to print the output
> of v4l2-compliance, even when the test passes. This can be useful when
> debugging.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This sounds reasonable to me, particularly as this script is used as a
standalone test tool.


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

> ---
>  test/v4l2_compat/v4l2_compat_test.py | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py
> index 29c25974c1c9..a77585fc2f49 100755
> --- a/test/v4l2_compat/v4l2_compat_test.py
> +++ b/test/v4l2_compat/v4l2_compat_test.py
> @@ -65,7 +65,7 @@ def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
>  
>      result = extract_result(output[-2])
>      if result['failed'] == 0:
> -        return TestPass, None
> +        return TestPass, output
>  
>      # vimc will fail s_fmt because it only supports framesizes that are
>      # multiples of 3
> @@ -73,7 +73,7 @@ def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
>          failures = grep('fail', output)
>          if re.search('S_FMT cannot handle an invalid format', failures[0]) is None:
>              return TestFail, output
> -        return TestPass, None
> +        return TestPass, output
>  
>      return TestFail, output
>  
> @@ -82,6 +82,8 @@ def main(argv):
>      parser = argparse.ArgumentParser()
>      parser.add_argument('-a', '--all', action='store_true',
>                          help='Test all available cameras')
> +    parser.add_argument('-v', '--verbose', action='store_true',
> +                        help='Make the output verbose')
>      parser.add_argument('v4l2_compat', type=str,
>                          help='Path to v4l2-compat.so')
>      args = parser.parse_args(argv[1:])
> @@ -146,9 +148,12 @@ def main(argv):
>          if ret == TestFail:
>              failed.append(device)
>              print('failed')
> -            print('\n'.join(msg))
>          else:
>              print('success')
> +
> +        if ret == TestFail or args.verbose:
> +            print('\n'.join(msg))
> +
>          drivers_tested[driver] = True
>  
>      if len(drivers_tested) == 0:
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py
index 29c25974c1c9..a77585fc2f49 100755
--- a/test/v4l2_compat/v4l2_compat_test.py
+++ b/test/v4l2_compat/v4l2_compat_test.py
@@ -65,7 +65,7 @@  def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
 
     result = extract_result(output[-2])
     if result['failed'] == 0:
-        return TestPass, None
+        return TestPass, output
 
     # vimc will fail s_fmt because it only supports framesizes that are
     # multiples of 3
@@ -73,7 +73,7 @@  def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):
         failures = grep('fail', output)
         if re.search('S_FMT cannot handle an invalid format', failures[0]) is None:
             return TestFail, output
-        return TestPass, None
+        return TestPass, output
 
     return TestFail, output
 
@@ -82,6 +82,8 @@  def main(argv):
     parser = argparse.ArgumentParser()
     parser.add_argument('-a', '--all', action='store_true',
                         help='Test all available cameras')
+    parser.add_argument('-v', '--verbose', action='store_true',
+                        help='Make the output verbose')
     parser.add_argument('v4l2_compat', type=str,
                         help='Path to v4l2-compat.so')
     args = parser.parse_args(argv[1:])
@@ -146,9 +148,12 @@  def main(argv):
         if ret == TestFail:
             failed.append(device)
             print('failed')
-            print('\n'.join(msg))
         else:
             print('success')
+
+        if ret == TestFail or args.verbose:
+            print('\n'.join(msg))
+
         drivers_tested[driver] = True
 
     if len(drivers_tested) == 0: