diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-12-02 15:05:37 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-12-03 13:08:42 -0800 |
commit | 75c1874bb3adbe96ba2a6cab64d471e27ca712c7 (patch) | |
tree | 51813fd13d9c1e1c1d09d6d340311e3ccd52bb07 /run_unittests.py | |
parent | 8091b4c7448ca467bbfff22283beaa702533f177 (diff) | |
download | meson-75c1874bb3adbe96ba2a6cab64d471e27ca712c7.zip meson-75c1874bb3adbe96ba2a6cab64d471e27ca712c7.tar.gz meson-75c1874bb3adbe96ba2a6cab64d471e27ca712c7.tar.bz2 |
run_unittests: Add unittests for ld overriding
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index bf91613..feb3ee8 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5723,6 +5723,43 @@ c = ['{0}'] self.build() self.run_tests() + def _check_ld(self, check: str, name: str, lang: str, expected: str) -> None: + if is_sunos(): + raise unittest.SkipTest('Solaris currently cannot override the linker.') + if not shutil.which(check): + raise unittest.SkipTest('Could not find {}.'.format(check)) + with mock.patch.dict(os.environ, {'LD': name}): + env = get_fake_env() + comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) + if lang != 'rust' and comp.use_linker_args('foo') == []: + raise unittest.SkipTest( + 'Compiler {} does not support using alternative linkers'.format(comp.id)) + self.assertEqual(comp.linker.id, expected) + + def test_ld_environment_variable_bfd(self): + self._check_ld('ld.bfd', 'bfd', 'c', 'GNU ld.bfd') + + def test_ld_environment_variable_gold(self): + self._check_ld('ld.gold', 'gold', 'c', 'GNU ld.gold') + + def test_ld_environment_variable_lld(self): + self._check_ld('ld.lld', 'lld', 'c', 'lld') + + def test_ld_environment_variable_rust(self): + self._check_ld('ld.gold', 'gold', 'rust', 'GNU ld.gold') + + def test_ld_environment_variable_cpp(self): + self._check_ld('ld.gold', 'gold', 'cpp', 'GNU ld.gold') + + def test_ld_environment_variable_objc(self): + self._check_ld('ld.gold', 'gold', 'objc', 'GNU ld.gold') + + def test_ld_environment_variable_objcpp(self): + self._check_ld('ld.gold', 'gold', 'objcpp', 'GNU ld.gold') + + def test_ld_environment_variable_fortran(self): + self._check_ld('ld.gold', 'gold', 'fortran', 'GNU ld.gold') + def should_run_cross_arm_tests(): return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm') |