File: test_detect.py

package info (click to toggle)
pypy 2.4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 86,992 kB
  • ctags: 170,715
  • sloc: python: 1,030,417; ansic: 43,437; cpp: 5,241; asm: 5,169; sh: 458; makefile: 408; xml: 231; lisp: 45
file content (48 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import py
from rpython.tool.udir import udir
from rpython.jit.backend.arm.detect import detect_arch_version

cpuinfo = "Processor : ARMv%d-compatible processor rev 7 (v6l)"""
cpuinfo2 = """processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
stepping        : 10
microcode       : 0xa07
cpu MHz         : 2997.000
cache size      : 6144 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme ...
bogomips        : 5993.08
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
"""

def write_cpuinfo(info):
    filepath = udir.join('get_arch_version')
    filepath.write(info)
    return str(filepath)


def test_detect_arch_version():
    # currently supported cases
    for i in (6, 7, ):
        filepath = write_cpuinfo(cpuinfo % i)
        assert detect_arch_version(filepath) == i
    # unsupported cases
    assert detect_arch_version(write_cpuinfo(cpuinfo % 8)) == 7
    py.test.raises(ValueError,
            'detect_arch_version(write_cpuinfo(cpuinfo % 5))')
    assert detect_arch_version(write_cpuinfo(cpuinfo2)) == 6