From e71d1dc6c3d500b8d7efe45ec77b4b22b1efa1a6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 7 May 2025 08:26:01 +0200 Subject: [PATCH] unittests: add test for CFLAGS in linker command line Signed-off-by: Paolo Bonzini --- unittests/linuxliketests.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 6b896d73f..376c3959e 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -985,6 +985,22 @@ class LinuxlikeTests(BasePlatformTests): got_rpath = get_rpath(os.path.join(yonder_prefix, 'bin/rpathified')) self.assertEqual(got_rpath, yonder_libdir, rpath_format) + @skip_if_not_base_option('b_sanitize') + def test_env_cflags_ldflags(self): + if is_cygwin(): + raise SkipTest('asan not available on Cygwin') + if is_openbsd(): + raise SkipTest('-fsanitize=address is not supported on OpenBSD') + + testdir = os.path.join(self.common_test_dir, '1 trivial') + env = {'CFLAGS': '-fsanitize=address', 'LDFLAGS': '-I.'} + self.init(testdir, override_envvars=env) + self.build() + compdb = self.get_compdb() + for i in compdb: + self.assertIn("-fsanitize=address", i["command"]) + self.wipe() + @skip_if_not_base_option('b_sanitize') def test_pch_with_address_sanitizer(self): if is_cygwin():