[gnome-settings-daemon/wip/claudio/CI] tests: LD_PRELOAD ASan library when address sanitize is enabled



commit c7e5caf3a85172b911a27283f066e78f866b4b18
Author: Benjamin Berg <bberg redhat com>
Date:   Tue Feb 5 16:41:32 2019 +0100

    tests: LD_PRELOAD ASan library when address sanitize is enabled
    
    This is required because umockdev is also preloaded

 plugins/power/meson.build | 16 ++++++++++------
 plugins/power/test.py     |  5 +++++
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/plugins/power/meson.build b/plugins/power/meson.build
index 7d111099..81ec4ba4 100644
--- a/plugins/power/meson.build
+++ b/plugins/power/meson.build
@@ -124,12 +124,16 @@ gsdpowerenums_py = custom_target(
 
 test_py = find_program('test.py')
 
-envs = [
-#  'G_DEBUG=fatal_warnings',
-  'BUILDDIR=' + meson.current_build_dir(),
-  'TOP_BUILDDIR=' + meson.build_root(),
-  'LD_PRELOAD=libumockdev-preload.so.0',
-]
+envs = environment()
+#envs.prepend('G_DEBUG', 'fatal-warnings')
+envs.set('BUILDDIR', meson.current_build_dir())
+envs.set('TOP_BUILDDIR', meson.build_root())
+envs.set('LD_PRELOAD', 'libumockdev-preload.so.0')
+
+if get_option('b_sanitize').split(',').contains('address')
+  # libasan needs to be loaded first; so we need to explicitly preload it
+  envs.set('POWER_LD_PRELOAD', 'libasan.so.5')
+endif
 
 foreach i : [ 1, 2, 3, 4, 5, 6, 7, 8 ]
   test(
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 57be628e..b9873579 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -118,6 +118,11 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
 
         # Use dummy script as testing backlight helper
         env['GSD_BACKLIGHT_HELPER'] = os.path.join (project_root, 'plugins', 'power', 
'test-backlight-helper')
+        if 'POWER_LD_PRELOAD' in env:
+            if 'LD_PRELOAD' in env and env['LD_PRELOAD']:
+                env['LD_PRELOAD'] = ':'.join((env['POWER_LD_PRELOAD'], env['LD_PRELOAD']))
+            else:
+                env['LD_PRELOAD'] = env['POWER_LD_PRELOAD']
 
         self.daemon = subprocess.Popen(
             [os.path.join(builddir, 'gsd-power'), '--verbose'],


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]