Files
chromium_depot_tools/tests/detect_host_arch_test.py
Nico Weber d4da7ca919 gclient: Correctly set host_cpu to arm64 on arm macs
platform.machine() is 'arm64' on arm macs, and the `.startswith('arm')`
branch converted that to 'arm' before this CL.

Bug: 1103236,1190880
Change-Id: Idd75a724f059ecd2dd873737e4998fe9bc937e04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2779414
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
2021-03-22 18:32:24 +00:00

57 lines
1.6 KiB
Python

#!/usr/bin/env vpython3
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import platform
import sys
import unittest
if sys.version_info.major == 2:
import mock
else:
from unittest import mock
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import detect_host_arch
class DetectHostArchTest(unittest.TestCase):
def setUp(self):
super(DetectHostArchTest, self).setUp()
mock.patch('platform.machine').start()
mock.patch('platform.processor').start()
mock.patch('platform.architecture').start()
self.addCleanup(mock.patch.stopall)
def testHostArch(self):
test_cases = [
('ia86', '', [''], 'x86'),
('i86pc', '', [''], 'x86'),
('x86_64', '', [''], 'x64'),
('amd64', '', [''], 'x64'),
('x86_64', '', ['32bit'], 'x86'),
('amd64', '', ['32bit'], 'x86'),
('arm', '', [''], 'arm'),
('aarch64', '', [''], 'arm64'),
('aarch64', '', ['32bit'], 'arm'),
('arm64', '', [''], 'arm64'),
('mips64', '', [''], 'mips64'),
('mips', '', [''], 'mips'),
('ppc', '', [''], 'ppc'),
('foo', 'powerpc', [''], 'ppc'),
('s390', '', [''], 's390'),
]
for machine, processor, arch, expected in test_cases:
platform.machine.return_value = machine
platform.processor.return_value = processor
platform.architecture.return_value = arch
self.assertEqual(expected, detect_host_arch.HostArch())
if __name__ == '__main__':
unittest.main()