Patch Detail
Show a patch.
GET /api/1.1/patches/18049/?format=api
{ "id": 18049, "url": "https://patchwork.libcamera.org/api/1.1/patches/18049/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18049/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20221222010132.22177-3-laurent.pinchart@ideasonboard.com>", "date": "2022-12-22T01:01:30", "name": "[libcamera-devel,v1,2/4] test: v4l2_compat: Enable test with ASan", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "4212c8a050d228b6f83a4f3169c603cbe3682459", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18049/mbox/", "series": [ { "id": 3686, "url": "https://patchwork.libcamera.org/api/1.1/series/3686/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3686", "date": "2022-12-22T01:01:28", "name": "test: Various unit test cleanups", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3686/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18049/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18049/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 AFB77C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Dec 2022 01:01:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 63BE8633B8;\n\tThu, 22 Dec 2022 02:01:44 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B041633B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Dec 2022 02:01:42 +0100 (CET)", "from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CC667471\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Dec 2022 02:01:41 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671670904;\n\tbh=wqj7E2inHEDN5kZWOdHcoml+x1X29nEtxC0dV0UpiRs=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=f7mX4wfpCoCL+kGcJTN6cOeUu3cxWGxlEjNm6KCSwsPbIE5+yl+geYSyyCNhfkQ/Q\n\tSalZEvQCIhSElpz/3MTKXIne8HnDyRGh2InW4XKtuycdbyz9FkXDvh1wwYfhBAXJVZ\n\tQbA7h0qd2taYhMMsrsygCvivu/nNk74k6k+bWArtEu6zpSfG7NW+Va4RHpWLosCmo+\n\tcTOp7dIfWVVe31JSVQlLoNk+2WCrznKpPWkQZz/u3NnP6Es27ZRgM2QArqJYzpeJC+\n\tkryQ+FTeEDmKB8Xi0yTev1yZVa1DSnPdsHVzJ/iRWaPjQhcxGq3pS2WZc5chW2e/AQ\n\tb62fCwF0qMDLw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1671670902;\n\tbh=wqj7E2inHEDN5kZWOdHcoml+x1X29nEtxC0dV0UpiRs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Mu8H8tqKFEsnqWeqtl/62RHSZM4ZvyZuDyX1gSnpnpetuAOsaEzLpXnkP+iwtNi0w\n\tRUkWT2ilH0y7JQ1Cr3WEqoYxqI+hIuz+TABA2yw0eKMhmr3A+puH2eIIiPF0uP4uCx\n\tnlG6DLiQwOrgrmjOPGwp0/pzOdeSMZlay1Ht1j28=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Mu8H8tqK\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 22 Dec 2022 03:01:30 +0200", "Message-Id": "<20221222010132.22177-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.38.2", "In-Reply-To": "<20221222010132.22177-1-laurent.pinchart@ideasonboard.com>", "References": "<20221222010132.22177-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v1 2/4] test: v4l2_compat: Enable test\n\twith ASan", "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>", "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When libcamera is compiled with the address sanitizer enabled, the\nv4l2_compat test generates failures in the link order runtime check, as\nthe host v4l2-ctl and v4l2-compliance tools are not (generally) linked\nto ASan. For this reason, the test is disabled, which sadly shrinks test\ncoverage.\n\nFix this by loading the ASan runtime using LD_PRELOAD. This needs to be\ndone from within the v4l2_compat_test.py Python script, as the Python\ninterpreter itself leaks memory and would cause test failures if run\nwith ASan.\n\nTo LD_PRELOAD the ASan runtime, the path to the binary needs to be\nknown. gcc gives us a generic way to get the path, but that doesn't work\nwith clang as the ASan runtime file name depends on the clang version\nand target architecture. We thus have to keep the v4l2_compat test\ndisabled with ASan is enabled and libcamera is compiled with clang.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/meson.build | 16 ++++++++++++++++\n test/v4l2_compat/meson.build | 21 ++++++++++++++-------\n test/v4l2_compat/v4l2_compat_test.py | 18 +++++++++++++-----\n 3 files changed, 43 insertions(+), 12 deletions(-)", "diff": "diff --git a/test/meson.build b/test/meson.build\nindex 05a54d5cad2f..19726f37421d 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -7,6 +7,22 @@ endif\n \n test_enabled = true\n \n+# When ASan is enabled, find the path to the ASan runtime needed by multiple\n+# tests. This currently works with gcc only, as clang uses different file names\n+# depending on the compiler version and target architecture.\n+asan_enabled = false\n+asan_runtime_missing = false\n+\n+if get_option('b_sanitize').contains('address')\n+ asan_enabled = true\n+\n+ if cc.get_id() == 'gcc'\n+ asan_runtime = run_command(cc, '-print-file-name=libasan.so', check : true).stdout().strip()\n+ else\n+ asan_runtime_missing = true\n+ endif\n+endif\n+\n subdir('libtest')\n \n subdir('camera')\ndiff --git a/test/v4l2_compat/meson.build b/test/v4l2_compat/meson.build\nindex 10c4675286b3..da2e7a6d9045 100644\n--- a/test/v4l2_compat/meson.build\n+++ b/test/v4l2_compat/meson.build\n@@ -4,19 +4,26 @@ if not is_variable('v4l2_compat')\n subdir_done()\n endif\n \n-# If ASan is enabled, the link order runtime check will fail as v4l2-ctl and\n-# v4l2-compliance are not linked to ASan. Skip the test in that case.\n-#\n-# TODO: Find a way to LD_PRELOAD the ASan dynamic library instead, in a\n-# cross-platform way with support for both gcc and clang.\n+# If ASan is enabled but the ASan runtime shared library missing,\n+# v4l2_compat_test.py won't be able to LD_PRELOAD it, resulting in a link order\n+# runtime check failure as v4l2-ctl and v4l2-compliance are not linked to ASan.\n+# Skip the test in that case.\n \n-if get_option('b_sanitize').contains('address')\n+if asan_runtime_missing\n+ warning('Unable to get path to ASan runtime, v4l2_compat test disabled')\n subdir_done()\n endif\n \n v4l2_compat_test = files('v4l2_compat_test.py')\n+v4l2_compat_args = []\n+\n+if asan_enabled\n+ v4l2_compat_args += ['-s', asan_runtime]\n+endif\n+\n+v4l2_compat_args += [v4l2_compat]\n \n test('v4l2_compat_test', v4l2_compat_test,\n- args : v4l2_compat,\n+ args : v4l2_compat_args,\n suite : 'v4l2_compat',\n timeout : 60)\ndiff --git a/test/v4l2_compat/v4l2_compat_test.py b/test/v4l2_compat/v4l2_compat_test.py\nindex a77585fc2f49..bd89d4962c16 100755\n--- a/test/v4l2_compat/v4l2_compat_test.py\n+++ b/test/v4l2_compat/v4l2_compat_test.py\n@@ -57,8 +57,8 @@ def extract_result(result):\n return ret\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+def test_v4l2_compliance(v4l2_compliance, ld_preload, device, base_driver):\n+ ret, output = run_with_stdout(v4l2_compliance, '-s', '-d', device, env={'LD_PRELOAD': ld_preload})\n if ret < 0:\n output.append(f'Test for {device} terminated due to signal {signal.Signals(-ret).name}')\n return TestFail, output\n@@ -82,13 +82,21 @@ def main(argv):\n parser = argparse.ArgumentParser()\n parser.add_argument('-a', '--all', action='store_true',\n help='Test all available cameras')\n+ parser.add_argument('-s', '--sanitizer', type=str,\n+ help='Path to the address sanitizer (ASan) runtime')\n parser.add_argument('-v', '--verbose', action='store_true',\n help='Make the output verbose')\n parser.add_argument('v4l2_compat', type=str,\n help='Path to v4l2-compat.so')\n args = parser.parse_args(argv[1:])\n \n- v4l2_compat = args.v4l2_compat\n+ # Compute the LD_PRELOAD value by first loading ASan (if specified) and\n+ # then the V4L2 compat layer.\n+ ld_preload = []\n+ if args.sanitizer:\n+ ld_preload.append(args.sanitizer)\n+ ld_preload.append(args.v4l2_compat)\n+ ld_preload = ':'.join(ld_preload)\n \n v4l2_compliance = shutil.which('v4l2-compliance')\n if v4l2_compliance is None:\n@@ -118,7 +126,7 @@ def main(argv):\n failed = []\n drivers_tested = {}\n for device in dev_nodes:\n- ret, out = run_with_stdout(v4l2_ctl, '-D', '-d', device, env={'LD_PRELOAD': v4l2_compat})\n+ ret, out = run_with_stdout(v4l2_ctl, '-D', '-d', device, env={'LD_PRELOAD': ld_preload})\n if ret < 0:\n failed.append(device)\n print(f'v4l2-ctl failed on {device} with v4l2-compat')\n@@ -144,7 +152,7 @@ def main(argv):\n continue\n \n print(f'Testing {device} with {driver} driver... ', end='')\n- ret, msg = test_v4l2_compliance(v4l2_compliance, v4l2_compat, device, driver)\n+ ret, msg = test_v4l2_compliance(v4l2_compliance, ld_preload, device, driver)\n if ret == TestFail:\n failed.append(device)\n print('failed')\n", "prefixes": [ "libcamera-devel", "v1", "2/4" ] }