From patchwork Thu Dec 22 01:01:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 18050 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 1D56CC3213 for ; Thu, 22 Dec 2022 01:01:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D967D633BB; Thu, 22 Dec 2022 02:01:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671670905; bh=zQIClbYdYiQSRYHSWNfLXgH4Jd0Gt7Ham3eOMOnVLTw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QUBh+hTfq39uSz3IPYut/OaWcRvgt/yb/nArWXYL56QOOWPzCpoeBnUYQCQsP4S7G 6wDrqYrKXrPoO99iF0dDurROuUhyL5Btbv3YuU3npr8JNwwXiS7VZ1vCwh7AjPVeMY w1WlYKgZfN0uoMoDoCswbiHXAo3dNWnzy17sUBl5GOViCdk7swo/WbDy4bzCI2nkoG +d0hpQxxle57doxBskNEi2MpC8iaxC1WhxJI0j42oRgEiQnrAZNNQlgjyEg5g7h7u4 mH/92wfihI2ZtxlKImPcsgw+XgcqD8NWDsTB7xDDwiPC5XtM3D8NEsdB/uYV9e63Pl VSE6hS0qF3TWw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36297633B7 for ; Thu, 22 Dec 2022 02:01:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aQ74h6tc"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B0903903 for ; Thu, 22 Dec 2022 02:01:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671670903; bh=zQIClbYdYiQSRYHSWNfLXgH4Jd0Gt7Ham3eOMOnVLTw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aQ74h6tcwxt3luLWaMHtkYhSmhVcWjceT4Ra33Am0C1zy48O995S/1s9ricZlYMrP Y1nyTwMMs0RXzXHzowClCTgFv8uySaT1kmjkgCdYccUcb3hmBRd3Xb4niF3RmhZOLZ QszLex7aDHxVrj4mI3B6sPs0+QAulMU4AnNLZZ7I= To: libcamera-devel@lists.libcamera.org Date: Thu, 22 Dec 2022 03:01:31 +0200 Message-Id: <20221222010132.22177-4-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 Subject: [libcamera-devel] [PATCH v1 3/4] test: py: Fix test failure when ASan is enabled 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the address sanitizer is enabled, the Python unit tests fail due to the link order runtime check as the Python interpreter is (generally) not linked to ASan. Fix this by LD_PRELOAD'ing the ASan runtime. We have to disable the leak detector as the Python interpreter itself leaks memory, which would result in test failures. To LD_PRELOAD the ASan runtime, the path to the binary needs to be known. gcc gives us a generic way to get the path, but that doesn't work with clang as the ASan runtime file name depends on the clang version and target architecture. We thus have to keep the Python test disabled with ASan is enabled and libcamera is compiled with clang. Signed-off-by: Laurent Pinchart Acked-by: Umang Jain Reviewed-by: Paul Elder --- test/py/meson.build | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/py/meson.build b/test/py/meson.build index 2affdbd491a3..639f173594a8 100644 --- a/test/py/meson.build +++ b/test/py/meson.build @@ -4,14 +4,29 @@ if not pycamera_enabled subdir_done() endif +# If ASan is enabled, the link order runtime check will fail as Python is not +# linked to ASan. LD_PRELOAD the ASAn runtime if available, or skip the test +# otherwise. + +if asan_runtime_missing + warning('Unable to get path to ASan runtime, Python test disabled') + subdir_done() +endif + pymod = import('python') py3 = pymod.find_installation('python3') pypathdir = meson.project_build_root() / 'src' / 'py' +py_env = ['PYTHONPATH=' + pypathdir] + +if asan_enabled + # Disable leak detection as the Python interpreter is full of leaks. + py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0'] +endif test('pyunittests', py3, args : files('unittests.py'), - env : ['PYTHONPATH=' + pypathdir], + env : py_env, suite : 'pybindings', is_parallel : false)