Patch Detail
Show a patch.
GET /api/patches/8397/?format=api
{ "id": 8397, "url": "https://patchwork.libcamera.org/api/patches/8397/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8397/", "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": "<20200624140752.46066-1-paul.elder@ideasonboard.com>", "date": "2020-06-24T14:07:52", "name": "[libcamera-devel,RFC] tests: v4l2_compat: Add test for v4l2_compat", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "fd121199b5e426314953e5dc06a5953a055dfa60", "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/8397/mbox/", "series": [ { "id": 1040, "url": "https://patchwork.libcamera.org/api/series/1040/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1040", "date": "2020-06-24T14:07:52", "name": "[libcamera-devel,RFC] tests: v4l2_compat: Add test for v4l2_compat", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1040/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8397/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8397/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 405EA603B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2020 16:08:05 +0200 (CEST)", "from jade.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AB6EE2A8;\n\tWed, 24 Jun 2020 16:08:03 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"KsrhjH8z\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593007684;\n\tbh=wszgkFq4gcok6T05cDdnH7zkCuemj1ujwaMIKbv9kX0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=KsrhjH8z++Qy6bMnY7Hd7FMMiZ2SfPwQfz63EPrAjKVzp16czvfMntmUwjDHqKPb8\n\tJAvjmvkZmQ7qyVOdO3rnIpX48Gwb55oBspeABE6G+qXnVMsn3UjrIKznE62dR2Ul+b\n\tcEgTqlJI4kmGz06jBNoOZ2PaK0HLBQpUWCpr5W1s=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 24 Jun 2020 23:07:52 +0900", "Message-Id": "<20200624140752.46066-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH] 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>", "X-List-Received-Date": "Wed, 24 Jun 2020 14:08:05 -0000" }, "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 test/meson.build | 1 +\n test/v4l2_compat/meson.build | 10 +++\n test/v4l2_compat/v4l2_compat_test.py | 125 +++++++++++++++++++++++++++\n 3 files changed, 136 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 a868813..591920f 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..a67aac4\n--- /dev/null\n+++ b/test/v4l2_compat/meson.build\n@@ -0,0 +1,10 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+pymod = import('python')\n+py3 = pymod.find_installation('python3')\n+\n+v4l2_compat_test = files('v4l2_compat_test.py')\n+\n+test('v4l2_compat_test', py3,\n+ args : v4l2_compat_test,\n+ suite : 'v4l2_compat')\ndiff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py\nnew file mode 100755\nindex 0000000..f56db4e\n--- /dev/null\n+++ b/test/v4l2_compat/v4l2_compat_test.py\n@@ -0,0 +1,125 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2019, 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 os\n+import re\n+from shutil import which\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 find_file(name, path):\n+ for root, dirs, files in os.walk(path):\n+ if name in files:\n+ return os.path.join(root, name)\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(cmd, args=\"\", env={}):\n+ try:\n+ with open(os.devnull, 'w') as devnull:\n+ output = subprocess.check_output(f\"{cmd} {args}\", shell=True, env=env, stderr=devnull)\n+ except subprocess.CalledProcessError as err:\n+ output = err.output\n+ return 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+ output = run_with_stdout(v4l2_compliance, f\"-s -d {device}\", {\"LD_PRELOAD\": v4l2_compat})\n+ result = extract_result(output[-2])\n+ if result[\"driver\"] != \"libcamera\":\n+ return TestSkip\n+\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():\n+ v4l2_compliance = which(\"v4l2-compliance\")\n+ if v4l2_compliance is None:\n+ print(\"v4l2-compliance is not available\")\n+ return TestSkip\n+\n+ v4l2_ctl = which(\"v4l2-ctl\")\n+ if v4l2_ctl is None:\n+ print(\"v4l2-ctl is not available\")\n+ return TestSkip\n+\n+ v4l2_compat = find_file(\"v4l2-compat.so\", \".\")\n+ if v4l2_compat is None:\n+ print(\"v4l2-compat.so is not built\")\n+ return TestSkip\n+\n+ dev_nodes = grep(\"video\", os.listdir(\"/dev\"))\n+ dev_nodes = list(map(lambda s: f\"/dev/{s}\", dev_nodes))\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, f\"-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+ sys.exit(main())\n", "prefixes": [ "libcamera-devel", "RFC" ] }