Patch Detail
Show a patch.
GET /api/patches/8435/?format=api
{ "id": 8435, "url": "https://patchwork.libcamera.org/api/patches/8435/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8435/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200626082208.122802-1-paul.elder@ideasonboard.com>", "date": "2020-06-26T08:22:08", "name": "[libcamera-devel,v2] tests: v4l2_compat: Add test for v4l2_compat", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "572f3d65ffd1370a81a1cbdba9dac4563d59a2dc", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8435/mbox/", "series": [ { "id": 1043, "url": "https://patchwork.libcamera.org/api/series/1043/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1043", "date": "2020-06-26T08:22:08", "name": "[libcamera-devel,v2] tests: v4l2_compat: Add test for v4l2_compat", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1043/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8435/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8435/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D3322C0109\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Jun 2020 08:22:23 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 42AB0609C8;\n\tFri, 26 Jun 2020 10:22:23 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C941609C2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Jun 2020 10:22:21 +0200 (CEST)", "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D16272E;\n\tFri, 26 Jun 2020 10:22:19 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LIdunkmS\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593159740;\n\tbh=/qiylYW5NpQ4sYaX1RqypT9ZWEazQ1lJv4rhGT+EDpM=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=LIdunkmS993Xeor3AUohQlbTtOADvKE+p3QMWSVGfOnGaX8khnvp58cq2EXJQTwe4\n\tNV0KzbOxcGlUtXDz8DjMzf8qtI4gGN765w9jly8/tJBosetVnpPl6XsEHVMbwBCdWr\n\t+/BvDK2K2nv5jHIkWyIYRXq/CXNM92V4itrVk34Q=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 26 Jun 2020 17:22:08 +0900", "Message-Id": "<20200626082208.122802-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2] tests: v4l2_compat: Add test for\n\tv4l2_compat", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Test the V4L2 compatibility layer by running v4l2-compliance -s on every\n/dev/video* device.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNote that as of v2, the tests will fail if the tester has a camera\nsupported by libcamera that has unsupported formats, since they will\ncause a floating point exception. So I don't think this should be merged\nuntil that is fixed, otherwise we might get nasty test failures in\nbisection.\n\nChanges in v2:\n- change all strings to single-quote\n- simplify meson.build\n- get path to v4l2-compat.so from cli arg, rather than running custom find()\n - remove find_file()\n- extend test timeout to 60 seconds (from default of 30)\n- don't run v4l2-compliance subprocesses in shell\n- check if v4l2-compliance runs are killed by signal (eg. the known\n SIGABRT due to floating point exception)\n- move the check to see if libcamera supports the camera to v4l2-ctl\n instead of v4l2-compliance (in v1 we only checked if the pipeline was\n supported with v4l2-ctl)\n---\n test/meson.build | 1 +\n test/v4l2_compat/meson.build | 10 +++\n test/v4l2_compat/v4l2_compat_test.py | 127 +++++++++++++++++++++++++++\n 3 files changed, 138 insertions(+)\n create mode 100644 test/v4l2_compat/meson.build\n create mode 100755 test/v4l2_compat/v4l2_compat_test.py", "diff": "diff --git a/test/meson.build b/test/meson.build\nindex 7808a26..f41d6e7 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -12,6 +12,7 @@ subdir('pipeline')\n subdir('process')\n subdir('serialization')\n subdir('stream')\n+subdir('v4l2_compat')\n subdir('v4l2_subdevice')\n subdir('v4l2_videodevice')\n \ndiff --git a/test/v4l2_compat/meson.build b/test/v4l2_compat/meson.build\nnew file mode 100644\nindex 0000000..5b29de7\n--- /dev/null\n+++ b/test/v4l2_compat/meson.build\n@@ -0,0 +1,10 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+if is_variable('v4l2_compat')\n+ v4l2_compat_test = files('v4l2_compat_test.py')\n+\n+ test('v4l2_compat_test', v4l2_compat_test,\n+ args : v4l2_compat,\n+ suite : 'v4l2_compat',\n+ timeout : 60)\n+endif\ndiff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py\nnew file mode 100755\nindex 0000000..6c028e7\n--- /dev/null\n+++ b/test/v4l2_compat/v4l2_compat_test.py\n@@ -0,0 +1,127 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2020, Google Inc.\n+#\n+# Author: Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# v4l2_compat_test.py - Test the V4L2 compatibility layer\n+\n+import glob\n+import os\n+import re\n+import shutil\n+import signal\n+import subprocess\n+import sys\n+\n+TestPass = 0\n+TestFail = -1\n+TestSkip = 77\n+\n+\n+supported_pipelines = [\n+ 'uvcvideo',\n+ 'vimc',\n+]\n+\n+\n+def grep(exp, arr):\n+ return [s for s in arr if re.search(exp, s)]\n+\n+\n+def run_with_stdout(*args, env={}):\n+ try:\n+ with open(os.devnull, 'w') as devnull:\n+ output = subprocess.check_output(args, env=env, stderr=devnull)\n+ ret = 0\n+ except subprocess.CalledProcessError as err:\n+ output = err.output\n+ ret = err.returncode\n+ return ret, output.decode('utf-8').split('\\n')\n+\n+\n+def extract_result(result):\n+ res = result.split(', ')\n+ ret = {}\n+ ret['total'] = int(res[0].split(': ')[-1])\n+ ret['succeeded'] = int(res[1].split(': ')[-1])\n+ ret['failed'] = int(res[2].split(': ')[-1])\n+ ret['warnings'] = int(res[3].split(': ')[-1])\n+ ret['device'] = res[0].split()[4].strip(':')\n+ ret['driver'] = res[0].split()[2]\n+ return ret\n+\n+\n+def print_output_arr(output_arr):\n+ print('\\n'.join(output_arr))\n+\n+\n+def test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, base_driver):\n+ ret, output = run_with_stdout(v4l2_compliance, '-s', '-d', device, env={'LD_PRELOAD': v4l2_compat})\n+ # TODO fix format so that we don't die from floating point exceptions\n+ if ret < 0:\n+ print_output_arr(output)\n+ print(f'Test for {device} terminated due to signal {signal.Signals(-ret).name}')\n+ return TestFail\n+\n+ result = extract_result(output[-2])\n+ if result['failed'] == 0:\n+ return TestPass\n+\n+ # vimc will fail s_fmt because it only supports framesizes that are\n+ # multiples of 3\n+ if base_driver == 'vimc' and result['failed'] <= 1:\n+ failures = grep('fail', output)\n+ if re.search('S_FMT cannot handle an invalid format', failures[0]) is None:\n+ print_output_arr(output)\n+ return TestFail\n+ return TestPass\n+\n+ print_output_arr(output)\n+ return TestFail\n+\n+\n+def main(v4l2_compat):\n+ v4l2_compliance = shutil.which('v4l2-compliance')\n+ if v4l2_compliance is None:\n+ print('v4l2-compliance is not available')\n+ return TestSkip\n+\n+ v4l2_ctl = shutil.which('v4l2-ctl')\n+ if v4l2_ctl is None:\n+ print('v4l2-ctl is not available')\n+ return TestSkip\n+\n+ dev_nodes = glob.glob('/dev/video*')\n+ if len(dev_nodes) == 0:\n+ print('no video nodes available to test with')\n+ return TestSkip\n+\n+ failed = []\n+ for device in dev_nodes:\n+ _, out = run_with_stdout(v4l2_ctl, '-D', '-d', device, env={'LD_PRELOAD': v4l2_compat})\n+ driver = grep('Driver name', out)[0].split(':')[-1].strip()\n+ if driver != \"libcamera\":\n+ continue\n+\n+ _, out = run_with_stdout(v4l2_ctl, '-D', '-d', device)\n+ driver = grep('Driver name', out)[0].split(':')[-1].strip()\n+ if driver not in supported_pipelines:\n+ continue\n+\n+ ret = test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, driver)\n+ if ret == TestFail:\n+ failed.append(device)\n+\n+ if len(failed) > 0:\n+ print(f'Failed {len(failed)} tests:')\n+ for device in failed:\n+ print(f'- {device}')\n+\n+ return TestPass if not failed else TestFail\n+\n+\n+if __name__ == '__main__':\n+ if len(sys.argv) < 2:\n+ sys.exit(TestSkip)\n+ sys.exit(main(sys.argv[1]))\n", "prefixes": [ "libcamera-devel", "v2" ] }