[libcamera-devel] tests: v4l2_compat: Fix v4l2-compliance and v4l2-ctl version parsing

Message ID 20200715142957.24603-1-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] tests: v4l2_compat: Fix v4l2-compliance and v4l2-ctl version parsing
Related show

Commit Message

Paul Elder July 15, 2020, 2:29 p.m. UTC
v4l2-compliance originally printed the SHA before the version, leading
to the indexing that was used previously. Now that the version is
printed before the SHA, the indexing is incorrect. Fix this.

Although v4l2-ctl doesn't suffer the same issue, it is more correct to
use the zeroth index like the v4l2-compliance version check now does, so
fix that as well.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 test/v4l2_compat/v4l2_compat_test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart July 16, 2020, 12:56 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Wed, Jul 15, 2020 at 11:29:57PM +0900, Paul Elder wrote:
> v4l2-compliance originally printed the SHA before the version, leading
> to the indexing that was used previously. Now that the version is
> printed before the SHA, the indexing is incorrect. Fix this.
> 
> Although v4l2-ctl doesn't suffer the same issue, it is more correct to
> use the zeroth index like the v4l2-compliance version check now does, so
> fix that as well.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  test/v4l2_compat/v4l2_compat_test.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py
> index b054fe6..9867ece 100755
> --- a/test/v4l2_compat/v4l2_compat_test.py
> +++ b/test/v4l2_compat/v4l2_compat_test.py
> @@ -94,7 +94,7 @@ def main(argv):
>          return TestSkip
>  
>      ret, out = run_with_stdout(v4l2_compliance, '--version')
> -    if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION):
> +    if (ret != 0 or version.parse(out[0].split()[-1]) < MIN_V4L_UTILS_VERSION):

We could also grep for the line containing the version, in case the
v4l2-compliance and v4l2-ctl tool get later extended with more output
for --version. Up to you.

By the way, you don't need the outer parentheses.

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

>          print('v4l2-compliance version >= 1.21.0 required')
>          return TestSkip
>  
> @@ -104,7 +104,7 @@ def main(argv):
>          return TestSkip
>  
>      ret, out = run_with_stdout(v4l2_ctl, '--version')
> -    if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION):
> +    if (ret != 0 or version.parse(out[0].split()[-1]) < MIN_V4L_UTILS_VERSION):
>          print('v4l2-ctl version >= 1.21.0 required')
>          return TestSkip
>

Patch

diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py
index b054fe6..9867ece 100755
--- a/test/v4l2_compat/v4l2_compat_test.py
+++ b/test/v4l2_compat/v4l2_compat_test.py
@@ -94,7 +94,7 @@  def main(argv):
         return TestSkip
 
     ret, out = run_with_stdout(v4l2_compliance, '--version')
-    if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION):
+    if (ret != 0 or version.parse(out[0].split()[-1]) < MIN_V4L_UTILS_VERSION):
         print('v4l2-compliance version >= 1.21.0 required')
         return TestSkip
 
@@ -104,7 +104,7 @@  def main(argv):
         return TestSkip
 
     ret, out = run_with_stdout(v4l2_ctl, '--version')
-    if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION):
+    if (ret != 0 or version.parse(out[0].split()[-1]) < MIN_V4L_UTILS_VERSION):
         print('v4l2-ctl version >= 1.21.0 required')
         return TestSkip