|
|
|
@ -1478,3 +1478,38 @@ class InternalTests(unittest.TestCase): |
|
|
|
|
with self.subTest(test, has_define=True), mock_trial(test): |
|
|
|
|
actual = mesonbuild.environment.detect_cpu_family({}) |
|
|
|
|
self.assertEqual(actual, expected) |
|
|
|
|
|
|
|
|
|
def test_detect_cpu(self) -> None: |
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager |
|
|
|
|
def mock_trial(value: str) -> T.Iterable[None]: |
|
|
|
|
"""Mock all of the ways we could get the trial at once.""" |
|
|
|
|
mocked = mock.Mock(return_value=value) |
|
|
|
|
|
|
|
|
|
with mock.patch('mesonbuild.environment.detect_windows_arch', mocked), \ |
|
|
|
|
mock.patch('mesonbuild.environment.platform.processor', mocked), \ |
|
|
|
|
mock.patch('mesonbuild.environment.platform.machine', mocked): |
|
|
|
|
yield |
|
|
|
|
|
|
|
|
|
cases = [ |
|
|
|
|
('amd64', 'x86_64'), |
|
|
|
|
('x64', 'x86_64'), |
|
|
|
|
('i86pc', 'x86_64'), |
|
|
|
|
('earm', 'arm'), |
|
|
|
|
('mips64el', 'mips64'), |
|
|
|
|
('mips64', 'mips64'), |
|
|
|
|
('mips', 'mips'), |
|
|
|
|
('mipsel', 'mips'), |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
with mock.patch('mesonbuild.environment.any_compiler_has_define', mock.Mock(return_value=False)): |
|
|
|
|
for test, expected in cases: |
|
|
|
|
with self.subTest(test, has_define=False), mock_trial(test): |
|
|
|
|
actual = mesonbuild.environment.detect_cpu({}) |
|
|
|
|
self.assertEqual(actual, expected) |
|
|
|
|
|
|
|
|
|
with mock.patch('mesonbuild.environment.any_compiler_has_define', mock.Mock(return_value=True)): |
|
|
|
|
for test, expected in [('x86_64', 'i686'), ('aarch64', 'arm')]: |
|
|
|
|
with self.subTest(test, has_define=True), mock_trial(test): |
|
|
|
|
actual = mesonbuild.environment.detect_cpu({}) |
|
|
|
|
self.assertEqual(actual, expected) |
|
|
|
|