Debian Codegraph @

tests/test_linux_odroid_xu3_arm_32.py

raw
1
2
3 import unittest
4 from cpuinfo import *
5 import helpers
6
7
8 class MockDataSource:
9 bits = '32bit'
10 cpu_count = 8
11 is_windows = False
12 arch_string_raw = 'armv7l'
13 uname_string_raw = ''
14 can_cpuid = False
15
16 @staticmethod
17 def has_proc_cpuinfo():
18 return True
19
20 @staticmethod
21 def has_lscpu():
22 return True
23
24 @staticmethod
25 def has_cpufreq_info():
26 return True
27
28 @staticmethod
29 def cat_proc_cpuinfo():
30 returncode = 0
31 output = r'''
32 processor : 0
33 model name : ARMv7 Processor rev 3 (v7l)
34 BogoMIPS : 84.00
35 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
36 CPU implementer : 0x41
37 CPU architecture: 7
38 CPU variant : 0x0
39 CPU part : 0xc07
40 CPU revision : 3
41
42 processor : 1
43 model name : ARMv7 Processor rev 3 (v7l)
44 BogoMIPS : 84.00
45 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
46 CPU implementer : 0x41
47 CPU architecture: 7
48 CPU variant : 0x0
49 CPU part : 0xc07
50 CPU revision : 3
51
52 processor : 2
53 model name : ARMv7 Processor rev 3 (v7l)
54 BogoMIPS : 84.00
55 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
56 CPU implementer : 0x41
57 CPU architecture: 7
58 CPU variant : 0x0
59 CPU part : 0xc07
60 CPU revision : 3
61
62 processor : 3
63 model name : ARMv7 Processor rev 3 (v7l)
64 BogoMIPS : 84.00
65 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
66 CPU implementer : 0x41
67 CPU architecture: 7
68 CPU variant : 0x0
69 CPU part : 0xc07
70 CPU revision : 3
71
72 processor : 4
73 model name : ARMv7 Processor rev 3 (v7l)
74 BogoMIPS : 36.00
75 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
76 CPU implementer : 0x41
77 CPU architecture: 7
78 CPU variant : 0x2
79 CPU part : 0xc0f
80 CPU revision : 3
81
82 processor : 5
83 model name : ARMv7 Processor rev 3 (v7l)
84 BogoMIPS : 36.00
85 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
86 CPU implementer : 0x41
87 CPU architecture: 7
88 CPU variant : 0x2
89 CPU part : 0xc0f
90 CPU revision : 3
91
92 processor : 6
93 model name : ARMv7 Processor rev 3 (v7l)
94 BogoMIPS : 36.00
95 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
96 CPU implementer : 0x41
97 CPU architecture: 7
98 CPU variant : 0x2
99 CPU part : 0xc0f
100 CPU revision : 3
101
102 processor : 7
103 model name : ARMv7 Processor rev 3 (v7l)
104 BogoMIPS : 36.00
105 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
106 CPU implementer : 0x41
107 CPU architecture: 7
108 CPU variant : 0x2
109 CPU part : 0xc0f
110 CPU revision : 3
111
112 Hardware : ODROID-XU3
113 Revision : 0100
114 Serial : 0000000000000000
115
116
117 '''
118 return returncode, output
119
120 @staticmethod
121 def lscpu():
122 returncode = 0
123 output = r'''
124 Architecture: armv7l
125 Byte Order: Little Endian
126 CPU(s): 8
127 On-line CPU(s) list: 0-7
128 Thread(s) per core: 1
129 Core(s) per socket: 4
130 Socket(s): 2
131 Model name: ARMv7 Processor rev 3 (v7l)
132 CPU max MHz: 1400.0000
133 CPU min MHz: 200.0000
134
135 '''
136 return returncode, output
137
138 @staticmethod
139 def cpufreq_info():
140 returncode = 0
141 output = r'''
142 cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
143 Report errors and bugs to [email protected], please.
144 analyzing CPU 0:
145 driver: exynos_cpufreq
146 CPUs which run at the same hardware frequency: 0 1 2 3
147 CPUs which need to have their frequency coordinated by software: 0 1 2 3
148 maximum transition latency: 100.0 us.
149 hardware limits: 200 MHz - 1.40 GHz
150 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
151 current policy: frequency should be within 200 MHz and 1.40 GHz.
152 The governor "interactive" may decide which speed to use
153 within this range.
154 current CPU frequency is 1.40 GHz (asserted by call to hardware).
155 cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901)
156 analyzing CPU 1:
157 driver: exynos_cpufreq
158 CPUs which run at the same hardware frequency: 0 1 2 3
159 CPUs which need to have their frequency coordinated by software: 0 1 2 3
160 maximum transition latency: 100.0 us.
161 hardware limits: 200 MHz - 1.40 GHz
162 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
163 current policy: frequency should be within 200 MHz and 1.40 GHz.
164 The governor "interactive" may decide which speed to use
165 within this range.
166 current CPU frequency is 1.40 GHz (asserted by call to hardware).
167 cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901)
168 analyzing CPU 2:
169 driver: exynos_cpufreq
170 CPUs which run at the same hardware frequency: 0 1 2 3
171 CPUs which need to have their frequency coordinated by software: 0 1 2 3
172 maximum transition latency: 100.0 us.
173 hardware limits: 200 MHz - 1.40 GHz
174 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
175 current policy: frequency should be within 200 MHz and 1.40 GHz.
176 The governor "interactive" may decide which speed to use
177 within this range.
178 current CPU frequency is 1.40 GHz (asserted by call to hardware).
179 cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901)
180 analyzing CPU 3:
181 driver: exynos_cpufreq
182 CPUs which run at the same hardware frequency: 0 1 2 3
183 CPUs which need to have their frequency coordinated by software: 0 1 2 3
184 maximum transition latency: 100.0 us.
185 hardware limits: 200 MHz - 1.40 GHz
186 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
187 current policy: frequency should be within 200 MHz and 1.40 GHz.
188 The governor "interactive" may decide which speed to use
189 within this range.
190 current CPU frequency is 1.40 GHz (asserted by call to hardware).
191 cpufreq stats: 1.40 GHz:33.77%, 1.30 GHz:0.04%, 1.20 GHz:0.03%, 1.10 GHz:0.02%, 1000 MHz:0.03%, 900 MHz:0.04%, 800 MHz:0.06%, 700 MHz:0.10%, 600 MHz:0.13%, 500 MHz:0.19%, 400 MHz:0.31%, 300 MHz:2.09%, 200 MHz:63.20% (880901)
192 analyzing CPU 4:
193 driver: exynos_cpufreq
194 CPUs which run at the same hardware frequency: 4 5 6 7
195 CPUs which need to have their frequency coordinated by software: 4 5 6 7
196 maximum transition latency: 100.0 us.
197 hardware limits: 200 MHz - 2.00 GHz
198 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
199 current policy: frequency should be within 200 MHz and 2.00 GHz.
200 The governor "interactive" may decide which speed to use
201 within this range.
202 current CPU frequency is 2.00 GHz (asserted by call to hardware).
203 cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653)
204 analyzing CPU 5:
205 driver: exynos_cpufreq
206 CPUs which run at the same hardware frequency: 4 5 6 7
207 CPUs which need to have their frequency coordinated by software: 4 5 6 7
208 maximum transition latency: 100.0 us.
209 hardware limits: 200 MHz - 2.00 GHz
210 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
211 current policy: frequency should be within 200 MHz and 2.00 GHz.
212 The governor "interactive" may decide which speed to use
213 within this range.
214 current CPU frequency is 2.00 GHz (asserted by call to hardware).
215 cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653)
216 analyzing CPU 6:
217 driver: exynos_cpufreq
218 CPUs which run at the same hardware frequency: 4 5 6 7
219 CPUs which need to have their frequency coordinated by software: 4 5 6 7
220 maximum transition latency: 100.0 us.
221 hardware limits: 200 MHz - 2.00 GHz
222 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
223 current policy: frequency should be within 200 MHz and 2.00 GHz.
224 The governor "interactive" may decide which speed to use
225 within this range.
226 current CPU frequency is 2.00 GHz (asserted by call to hardware).
227 cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653)
228 analyzing CPU 7:
229 driver: exynos_cpufreq
230 CPUs which run at the same hardware frequency: 4 5 6 7
231 CPUs which need to have their frequency coordinated by software: 4 5 6 7
232 maximum transition latency: 100.0 us.
233 hardware limits: 200 MHz - 2.00 GHz
234 available cpufreq governors: interactive, conservative, ondemand, powersave, performance
235 current policy: frequency should be within 200 MHz and 2.00 GHz.
236 The governor "interactive" may decide which speed to use
237 within this range.
238 current CPU frequency is 2.00 GHz (asserted by call to hardware).
239 cpufreq stats: 2.00 GHz:22.57%, 1.90 GHz:0.02%, 1.80 GHz:0.01%, 1.70 GHz:0.02%, 1.60 GHz:0.09%, 1.50 GHz:0.11%, 1.40 GHz:0.01%, 1.30 GHz:0.00%, 1.20 GHz:0.01%, 1.10 GHz:0.00%, 1000 MHz:0.00%, 900 MHz:0.13%, 800 MHz:0.00%, 700 MHz:0.01%, 600 MHz:0.01%, 500 MHz:0.03%, 400 MHz:0.14%, 300 MHz:0.18%, 200 MHz:76.65% (316653)
240
241 '''
242 return returncode, output
243
244
245 class TestLinux_Odroid_XU3_arm_32(unittest.TestCase):
246 def setUp(self):
247 helpers.backup_data_source(cpuinfo)
248 helpers.monkey_patch_data_source(cpuinfo, MockDataSource)
249
250 def tearDown(self):
251 helpers.restore_data_source(cpuinfo)
252
253 '''
254 Make sure calls return the expected number of fields.
255 '''
256 def test_returns(self):
257 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_registry()))
258 self.assertEqual(4, len(cpuinfo._get_cpu_info_from_cpufreq_info()))
259 self.assertEqual(5, len(cpuinfo._get_cpu_info_from_lscpu()))
260 self.assertEqual(3, len(cpuinfo._get_cpu_info_from_proc_cpuinfo()))
261 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysctl()))
262 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_kstat()))
263 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_dmesg()))
264 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()))
265 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_ibm_pa_features()))
266 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_sysinfo()))
267 self.assertEqual(0, len(cpuinfo._get_cpu_info_from_cpuid()))
268 self.assertEqual(14, len(cpuinfo._get_cpu_info_internal()))
269
270 def test_get_cpu_info_from_cpufreq_info(self):
271 info = cpuinfo._get_cpu_info_from_cpufreq_info()
272
273 self.assertEqual('1.4000 GHz', info['hz_advertised_friendly'])
274 self.assertEqual('1.4000 GHz', info['hz_actual_friendly'])
275 self.assertEqual((1400000000, 0), info['hz_advertised'])
276 self.assertEqual((1400000000, 0), info['hz_actual'])
277
278 def test_get_cpu_info_from_lscpu(self):
279 info = cpuinfo._get_cpu_info_from_lscpu()
280
281 self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand_raw'])
282 self.assertEqual('1.4000 GHz', info['hz_advertised_friendly'])
283 self.assertEqual('1.4000 GHz', info['hz_actual_friendly'])
284 self.assertEqual((1400000000, 0), info['hz_advertised'])
285 self.assertEqual((1400000000, 0), info['hz_actual'])
286
287 def test_get_cpu_info_from_proc_cpuinfo(self):
288 info = cpuinfo._get_cpu_info_from_proc_cpuinfo()
289
290 self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand_raw'])
291 self.assertEqual('ODROID-XU3', info['hardware_raw'])
292
293 self.assertEqual(
294 ['edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp',
295 'thumb', 'tls', 'vfp', 'vfpv3', 'vfpv4' ],
296 info['flags']
297 )
298
299 def test_all(self):
300 info = cpuinfo._get_cpu_info_internal()
301
302 self.assertEqual('ARMv7 Processor rev 3 (v7l)', info['brand_raw'])
303 self.assertEqual('ODROID-XU3', info['hardware_raw'])
304 self.assertEqual('1.4000 GHz', info['hz_advertised_friendly'])
305 self.assertEqual('1.4000 GHz', info['hz_actual_friendly'])
306 self.assertEqual((1400000000, 0), info['hz_advertised'])
307 self.assertEqual((1400000000, 0), info['hz_actual'])
308 self.assertEqual('ARM_7', info['arch'])
309 self.assertEqual(32, info['bits'])
310 self.assertEqual(8, info['count'])
311
312 self.assertEqual('armv7l', info['arch_string_raw'])
313
314 self.assertEqual(
315 ['edsp', 'fastmult', 'half', 'idiva', 'idivt', 'neon', 'swp',
316 'thumb', 'tls', 'vfp', 'vfpv3', 'vfpv4' ],
317 info['flags']
318 )