Debian Codegraph @

rpython/jit/backend/arm/test/test_detect.py

raw symbols SCIP
1 import py
2 from rpython.tool.udir import udir
3 from rpython.jit.backend.arm.detect import detect_arch_version, getauxval
4
5 cpuinfo = "Processor : ARMv%d-compatible processor rev 7 (v6l)"""
6 cpuinfo2 = """processor : 0
7 vendor_id : GenuineIntel
8 cpu family : 6
9 model : 23
10 model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz
11 stepping : 10
12 microcode : 0xa07
13 cpu MHz : 2997.000
14 cache size : 6144 KB
15 physical id : 0
16 siblings : 2
17 core id : 0
18 cpu cores : 2
19 apicid : 0
20 initial apicid : 0
21 fpu : yes
22 fpu_exception : yes
23 cpuid level : 13
24 wp : yes
25 flags : fpu vme ...
26 bogomips : 5993.08
27 clflush size : 64
28 cache_alignment : 64
29 address sizes : 36 bits physical, 48 bits virtual
30 power management:
31 """
32 # From a Marvell Armada 370/XP
33 auxv = (
34 '\x10\x00\x00\x00\xd7\xa8\x1e\x00\x06\x00\x00\x00\x00\x10\x00\x00\x11\x00'
35 '\x00\x00d\x00\x00\x00\x03\x00\x00\x004\x00\x01\x00\x04\x00\x00\x00 \x00'
36 '\x00\x00\x05\x00\x00\x00\t\x00\x00\x00\x07\x00\x00\x00\x00\xe0\xf3\xb6'
37 '\x08\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00t\xcf\x04\x00\x0b\x00\x00'
38 '\x000\x0c\x00\x00\x0c\x00\x00\x000\x0c\x00\x00\r\x00\x00\x000\x0c\x00\x00'
39 '\x0e\x00\x00\x000\x0c\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00'
40 '\x00\x8a\xf3\x87\xbe\x1a\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\xec'
41 '\xff\x87\xbe\x0f\x00\x00\x00\x9a\xf3\x87\xbe\x00\x00\x00\x00\x00\x00\x00'
42 '\x00'
43 )
44
45
46 def write_cpuinfo(info):
47 filepath = udir.join('get_arch_version')
48 filepath.write(info)
49 return str(filepath)
50
51
52 def test_detect_arch_version():
53 # currently supported cases
54 for i in (6, 7, ):
55 filepath = write_cpuinfo(cpuinfo % i)
56 assert detect_arch_version(filepath) == i
57 # unsupported cases
58 assert detect_arch_version(write_cpuinfo(cpuinfo % 8)) == 7
59 py.test.raises(ValueError,
60 'detect_arch_version(write_cpuinfo(cpuinfo % 5))')
61 assert detect_arch_version(write_cpuinfo(cpuinfo2)) == 6
62
63
64 def test_getauxval_no_neon():
65 path = udir.join('auxv')
66 path.write(auxv, 'wb')
67 AT_HWCAP = 16
68 assert getauxval(AT_HWCAP, filename=str(path)) == 2009303