提交 889815fa 编写于 作者: L Lukáš Doktor

utils.cpu: Custom detection of arm

Difference between aarch32/64 is fairly simple, let's detect it
ourselves instead of relying on "machine.platform".
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 c1d0ae5f
......@@ -136,12 +136,17 @@ def get_cpu_arch():
cpuinfo = _get_cpu_info()
for (pattern, arch) in cpu_table:
if _list_matches(cpuinfo, pattern):
# ARM is a special situation, which matches both 32 bits
# (v7) and 64 bits (v8).
if arch == 'arm':
arm_v8_arch_name = 'aarch64'
if arm_v8_arch_name == platform.machine():
return arm_v8_arch_name
# ARM is a special situation, which matches both 32 bits
# (v7) and 64 bits (v8).
for line in cpuinfo:
if line.startswith(b"CPU architecture"):
version = int(line.split(b':', 1)[1])
if version >= 8:
return 'aarch64'
else:
# For historical reasons return arm
return 'arm'
return arch
return platform.machine()
......
......@@ -521,9 +521,8 @@ CPU variant : 0x1
CPU part : 0x0a1
CPU revision : 1
"""
with mock.patch('avocado.utils.cpu.platform.machine', return_value='aarch64'):
with mock.patch('avocado.utils.cpu.open',
return_value=self._get_file_mock(cpu_output)):
with mock.patch('avocado.utils.cpu.open',
return_value=self._get_file_mock(cpu_output)):
self.assertEqual(cpu.get_cpu_arch(), "aarch64")
@unittest.skipUnless(recent_mock(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册