From patchwork Sat Jul 11 05:45:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8743 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A4CB8BD790 for ; Sat, 11 Jul 2020 05:46:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AABF6054D; Sat, 11 Jul 2020 07:46:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AN8zFADM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B24CB6048D for ; Sat, 11 Jul 2020 07:46:08 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 174302FD; Sat, 11 Jul 2020 07:46:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594446368; bh=IciX0hrfxfxJipLb+66/lAKIlKcQYWDX/b/91Ar6P+0=; h=From:To:Cc:Subject:Date:From; b=AN8zFADMOtVWpYubDzxGd1RkEpv2/YZOzlUQIwQYD2Fph9B1RAyZ9JYb/SaOQeUG6 eznVqbNByJZ+om7Nt5DvN0fE4/2a05s6eIF83JKpuAVWuebYLrupbqSyW7B+/LStaG YQP5bCv7RUAIEM2YWsPBXxL+/BBRrqp/XOHcp2TI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Sat, 11 Jul 2020 14:45:54 +0900 Message-Id: <20200711054555.495244-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] tests: v4l2_compat: Prettify failure output X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When a test is being run on a video device, there is output like so: Testing /dev/video0 with uvcvideo driver... and when it succeeds, "success" is appended: Testing /dev/video0 with uvcvideo driver... success On failure, however, the output of v4l2-compliance is printed before "failure" is printed, resulting in the first line of the v4l2-compliance output to be printed on the same line as the message: Testing /dev/video2 with uvcvideo driver... v4l2-compliance SHA: not available, 64 bits failure Refactor the code to make "failure" print before the output of the test, to prettify the output upon failure.. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v2: - refactor code instead of just moving the print failure statement --- test/v4l2_compat/v4l2_compat_test.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py index 99b3d5a..8aca222 100755 --- a/test/v4l2_compat/v4l2_compat_test.py +++ b/test/v4l2_compat/v4l2_compat_test.py @@ -54,32 +54,25 @@ def extract_result(result): return ret -def print_output_arr(output_arr): - print('\n'.join(output_arr)) - - def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver): ret, output = run_with_stdout(v4l2_compliance, '-s', '-d', device, env={'LD_PRELOAD': v4l2_compat}) if ret < 0: - print_output_arr(output) - print(f'Test for {device} terminated due to signal {signal.Signals(-ret).name}') - return TestFail + output.append(f'Test for {device} terminated due to signal {signal.Signals(-ret).name}') + return TestFail, output result = extract_result(output[-2]) if result['failed'] == 0: - return TestPass + return TestPass, None # vimc will fail s_fmt because it only supports framesizes that are # multiples of 3 if base_driver == 'vimc' and result['failed'] == 1: failures = grep('fail', output) if re.search('S_FMT cannot handle an invalid format', failures[0]) is None: - print_output_arr(output) - return TestFail - return TestPass + return TestFail, output + return TestPass, None - print_output_arr(output) - return TestFail + return TestFail, output def main(argv): @@ -132,10 +125,11 @@ def main(argv): continue print(f'Testing {device} with {driver} driver... ', end='') - ret = test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, driver) + ret, msg = test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, driver) if ret == TestFail: failed.append(device) print('failed') + print('\n'.join(msg)) else: print('success') drivers_tested[driver] = True From patchwork Sat Jul 11 05:45:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8744 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C509FBD790 for ; Sat, 11 Jul 2020 05:46:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8E55860553; Sat, 11 Jul 2020 07:46:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aFhINSe8"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BDE806054E for ; Sat, 11 Jul 2020 07:46:10 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0507D2FD; Sat, 11 Jul 2020 07:46:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594446370; bh=M9FDyUefJPqH2kTAEvEuIO46D+x5nddX4WcUn43ZHJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aFhINSe8hsYMGbtU0iwBlHu0K2Ps/rXQGmszFMX4FHAnV8hR57ZmmrdDaEtxkCtrJ GaU1tYFRPgzvXTLz0Sx1vobAuwMNdT1si2XiY1in3O91Cyu31xT02JNH0Lo5j0rLAr k2f9nIAfRF+3+qJEI/b0dUKorRLPtqg9BnrEqnzE= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Sat, 11 Jul 2020 14:45:55 +0900 Message-Id: <20200711054555.495244-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200711054555.495244-1-paul.elder@ideasonboard.com> References: <20200711054555.495244-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] tests: v4l2_compat: Check v4l2-compliance and v4l2-ctl versions X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" v4l2-compliance and v4l2-ctl with version 1.20 and before will fail with v4l2-compat. Check the versions of v4l2-compliance and v4l2-ctl before continuing. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v2: - actually check the version number --- test/v4l2_compat/v4l2_compat_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py index 8aca222..b054fe6 100755 --- a/test/v4l2_compat/v4l2_compat_test.py +++ b/test/v4l2_compat/v4l2_compat_test.py @@ -9,12 +9,15 @@ import argparse import glob import os +from packaging import version import re import shutil import signal import subprocess import sys +MIN_V4L_UTILS_VERSION = version.parse("1.21.0") + TestPass = 0 TestFail = -1 TestSkip = 77 @@ -90,11 +93,21 @@ def main(argv): print('v4l2-compliance is not available') return TestSkip + ret, out = run_with_stdout(v4l2_compliance, '--version') + if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION): + print('v4l2-compliance version >= 1.21.0 required') + return TestSkip + v4l2_ctl = shutil.which('v4l2-ctl') if v4l2_ctl is None: print('v4l2-ctl is not available') return TestSkip + ret, out = run_with_stdout(v4l2_ctl, '--version') + if (ret != 0 or version.parse(out[-2].split()[-1]) < MIN_V4L_UTILS_VERSION): + print('v4l2-ctl version >= 1.21.0 required') + return TestSkip + dev_nodes = glob.glob('/dev/video*') if len(dev_nodes) == 0: print('no video nodes available to test with')