1 #include <gtest/gtest.h>
2
3 #include <cpuinfo.h>
4 #include <cpuinfo-mock.h>
5
6
TEST(PROCESSORS,count)7 TEST(PROCESSORS, count) {
8 ASSERT_EQ(4, cpuinfo_get_processors_count());
9 }
10
TEST(PROCESSORS,non_null)11 TEST(PROCESSORS, non_null) {
12 ASSERT_TRUE(cpuinfo_get_processors());
13 }
14
TEST(PROCESSORS,smt_id)15 TEST(PROCESSORS, smt_id) {
16 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
17 ASSERT_EQ(0, cpuinfo_get_processor(i)->smt_id);
18 }
19 }
20
TEST(PROCESSORS,core)21 TEST(PROCESSORS, core) {
22 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
23 ASSERT_EQ(cpuinfo_get_core(i), cpuinfo_get_processor(i)->core);
24 }
25 }
26
TEST(PROCESSORS,cluster)27 TEST(PROCESSORS, cluster) {
28 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
29 ASSERT_EQ(cpuinfo_get_cluster(0), cpuinfo_get_processor(i)->cluster);
30 }
31 }
32
TEST(PROCESSORS,package)33 TEST(PROCESSORS, package) {
34 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
35 ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_processor(i)->package);
36 }
37 }
38
TEST(PROCESSORS,linux_id)39 TEST(PROCESSORS, linux_id) {
40 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
41 ASSERT_EQ(i, cpuinfo_get_processor(i)->linux_id);
42 }
43 }
44
TEST(PROCESSORS,l1i)45 TEST(PROCESSORS, l1i) {
46 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
47 ASSERT_EQ(cpuinfo_get_l1i_cache(i), cpuinfo_get_processor(i)->cache.l1i);
48 }
49 }
50
TEST(PROCESSORS,l1d)51 TEST(PROCESSORS, l1d) {
52 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
53 ASSERT_EQ(cpuinfo_get_l1d_cache(i), cpuinfo_get_processor(i)->cache.l1d);
54 }
55 }
56
TEST(PROCESSORS,l2)57 TEST(PROCESSORS, l2) {
58 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
59 ASSERT_EQ(cpuinfo_get_l2_cache(0), cpuinfo_get_processor(i)->cache.l2);
60 }
61 }
62
TEST(PROCESSORS,l3)63 TEST(PROCESSORS, l3) {
64 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
65 ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l3);
66 }
67 }
68
TEST(PROCESSORS,l4)69 TEST(PROCESSORS, l4) {
70 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
71 ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l4);
72 }
73 }
74
TEST(CORES,count)75 TEST(CORES, count) {
76 ASSERT_EQ(4, cpuinfo_get_cores_count());
77 }
78
TEST(CORES,non_null)79 TEST(CORES, non_null) {
80 ASSERT_TRUE(cpuinfo_get_cores());
81 }
82
TEST(CORES,processor_start)83 TEST(CORES, processor_start) {
84 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
85 ASSERT_EQ(i, cpuinfo_get_core(i)->processor_start);
86 }
87 }
88
TEST(CORES,processor_count)89 TEST(CORES, processor_count) {
90 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
91 ASSERT_EQ(1, cpuinfo_get_core(i)->processor_count);
92 }
93 }
94
TEST(CORES,core_id)95 TEST(CORES, core_id) {
96 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
97 ASSERT_EQ(i, cpuinfo_get_core(i)->core_id);
98 }
99 }
100
TEST(CORES,cluster)101 TEST(CORES, cluster) {
102 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
103 ASSERT_EQ(cpuinfo_get_cluster(0), cpuinfo_get_core(i)->cluster);
104 }
105 }
106
TEST(CORES,package)107 TEST(CORES, package) {
108 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
109 ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_core(i)->package);
110 }
111 }
112
TEST(CORES,vendor)113 TEST(CORES, vendor) {
114 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
115 ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_core(i)->vendor);
116 }
117 }
118
TEST(CORES,uarch)119 TEST(CORES, uarch) {
120 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
121 ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_core(i)->uarch);
122 }
123 }
124
TEST(CORES,midr)125 TEST(CORES, midr) {
126 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
127 ASSERT_EQ(UINT32_C(0x410FD030), cpuinfo_get_core(i)->midr);
128 }
129 }
130
TEST(CORES,DISABLED_frequency)131 TEST(CORES, DISABLED_frequency) {
132 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
133 ASSERT_EQ(UINT64_C(1209600000), cpuinfo_get_core(i)->frequency);
134 }
135 }
136
TEST(CLUSTERS,count)137 TEST(CLUSTERS, count) {
138 ASSERT_EQ(1, cpuinfo_get_clusters_count());
139 }
140
TEST(CLUSTERS,non_null)141 TEST(CLUSTERS, non_null) {
142 ASSERT_TRUE(cpuinfo_get_clusters());
143 }
144
TEST(CLUSTERS,processor_start)145 TEST(CLUSTERS, processor_start) {
146 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
147 ASSERT_EQ(0, cpuinfo_get_cluster(i)->processor_start);
148 }
149 }
150
TEST(CLUSTERS,processor_count)151 TEST(CLUSTERS, processor_count) {
152 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
153 ASSERT_EQ(4, cpuinfo_get_cluster(i)->processor_count);
154 }
155 }
156
TEST(CLUSTERS,core_start)157 TEST(CLUSTERS, core_start) {
158 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
159 ASSERT_EQ(0, cpuinfo_get_cluster(i)->core_start);
160 }
161 }
162
TEST(CLUSTERS,core_count)163 TEST(CLUSTERS, core_count) {
164 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
165 ASSERT_EQ(4, cpuinfo_get_cluster(i)->core_count);
166 }
167 }
168
TEST(CLUSTERS,cluster_id)169 TEST(CLUSTERS, cluster_id) {
170 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
171 ASSERT_EQ(i, cpuinfo_get_cluster(i)->cluster_id);
172 }
173 }
174
TEST(CLUSTERS,package)175 TEST(CLUSTERS, package) {
176 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
177 ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_cluster(i)->package);
178 }
179 }
180
TEST(CLUSTERS,vendor)181 TEST(CLUSTERS, vendor) {
182 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
183 ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_cluster(i)->vendor);
184 }
185 }
186
TEST(CLUSTERS,uarch)187 TEST(CLUSTERS, uarch) {
188 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
189 ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_cluster(i)->uarch);
190 }
191 }
192
TEST(CLUSTERS,midr)193 TEST(CLUSTERS, midr) {
194 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
195 ASSERT_EQ(UINT32_C(0x410FD030), cpuinfo_get_cluster(i)->midr);
196 }
197 }
198
TEST(CLUSTERS,DISABLED_frequency)199 TEST(CLUSTERS, DISABLED_frequency) {
200 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
201 ASSERT_EQ(UINT64_C(1209600000), cpuinfo_get_cluster(i)->frequency);
202 }
203 }
204
TEST(PACKAGES,count)205 TEST(PACKAGES, count) {
206 ASSERT_EQ(1, cpuinfo_get_packages_count());
207 }
208
TEST(PACKAGES,name)209 TEST(PACKAGES, name) {
210 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
211 ASSERT_EQ("Qualcomm MSM8916",
212 std::string(cpuinfo_get_package(i)->name,
213 strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX)));
214 }
215 }
216
TEST(PACKAGES,processor_start)217 TEST(PACKAGES, processor_start) {
218 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
219 ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start);
220 }
221 }
222
TEST(PACKAGES,processor_count)223 TEST(PACKAGES, processor_count) {
224 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
225 ASSERT_EQ(4, cpuinfo_get_package(i)->processor_count);
226 }
227 }
228
TEST(PACKAGES,core_start)229 TEST(PACKAGES, core_start) {
230 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
231 ASSERT_EQ(0, cpuinfo_get_package(i)->core_start);
232 }
233 }
234
TEST(PACKAGES,core_count)235 TEST(PACKAGES, core_count) {
236 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
237 ASSERT_EQ(4, cpuinfo_get_package(i)->core_count);
238 }
239 }
240
TEST(PACKAGES,cluster_start)241 TEST(PACKAGES, cluster_start) {
242 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
243 ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start);
244 }
245 }
246
TEST(PACKAGES,cluster_count)247 TEST(PACKAGES, cluster_count) {
248 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
249 ASSERT_EQ(1, cpuinfo_get_package(i)->cluster_count);
250 }
251 }
252
TEST(ISA,thumb)253 TEST(ISA, thumb) {
254 #if CPUINFO_ARCH_ARM
255 ASSERT_TRUE(cpuinfo_has_arm_thumb());
256 #elif CPUINFO_ARCH_ARM64
257 ASSERT_FALSE(cpuinfo_has_arm_thumb());
258 #endif
259 }
260
TEST(ISA,thumb2)261 TEST(ISA, thumb2) {
262 #if CPUINFO_ARCH_ARM
263 ASSERT_TRUE(cpuinfo_has_arm_thumb2());
264 #elif CPUINFO_ARCH_ARM64
265 ASSERT_FALSE(cpuinfo_has_arm_thumb2());
266 #endif
267 }
268
TEST(ISA,armv5e)269 TEST(ISA, armv5e) {
270 #if CPUINFO_ARCH_ARM
271 ASSERT_TRUE(cpuinfo_has_arm_v5e());
272 #elif CPUINFO_ARCH_ARM64
273 ASSERT_FALSE(cpuinfo_has_arm_v5e());
274 #endif
275 }
276
TEST(ISA,armv6)277 TEST(ISA, armv6) {
278 #if CPUINFO_ARCH_ARM
279 ASSERT_TRUE(cpuinfo_has_arm_v6());
280 #elif CPUINFO_ARCH_ARM64
281 ASSERT_FALSE(cpuinfo_has_arm_v6());
282 #endif
283 }
284
TEST(ISA,armv6k)285 TEST(ISA, armv6k) {
286 #if CPUINFO_ARCH_ARM
287 ASSERT_TRUE(cpuinfo_has_arm_v6k());
288 #elif CPUINFO_ARCH_ARM64
289 ASSERT_FALSE(cpuinfo_has_arm_v6k());
290 #endif
291 }
292
TEST(ISA,armv7)293 TEST(ISA, armv7) {
294 #if CPUINFO_ARCH_ARM
295 ASSERT_TRUE(cpuinfo_has_arm_v7());
296 #elif CPUINFO_ARCH_ARM64
297 ASSERT_FALSE(cpuinfo_has_arm_v7());
298 #endif
299 }
300
TEST(ISA,armv7mp)301 TEST(ISA, armv7mp) {
302 #if CPUINFO_ARCH_ARM
303 ASSERT_TRUE(cpuinfo_has_arm_v7mp());
304 #elif CPUINFO_ARCH_ARM64
305 ASSERT_FALSE(cpuinfo_has_arm_v7mp());
306 #endif
307 }
308
TEST(ISA,idiv)309 TEST(ISA, idiv) {
310 ASSERT_TRUE(cpuinfo_has_arm_idiv());
311 }
312
TEST(ISA,vfpv2)313 TEST(ISA, vfpv2) {
314 ASSERT_FALSE(cpuinfo_has_arm_vfpv2());
315 }
316
TEST(ISA,vfpv3)317 TEST(ISA, vfpv3) {
318 ASSERT_TRUE(cpuinfo_has_arm_vfpv3());
319 }
320
TEST(ISA,vfpv3_d32)321 TEST(ISA, vfpv3_d32) {
322 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32());
323 }
324
TEST(ISA,vfpv3_fp16)325 TEST(ISA, vfpv3_fp16) {
326 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16());
327 }
328
TEST(ISA,vfpv3_fp16_d32)329 TEST(ISA, vfpv3_fp16_d32) {
330 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32());
331 }
332
TEST(ISA,vfpv4)333 TEST(ISA, vfpv4) {
334 ASSERT_TRUE(cpuinfo_has_arm_vfpv4());
335 }
336
TEST(ISA,vfpv4_d32)337 TEST(ISA, vfpv4_d32) {
338 ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32());
339 }
340
TEST(ISA,wmmx)341 TEST(ISA, wmmx) {
342 ASSERT_FALSE(cpuinfo_has_arm_wmmx());
343 }
344
TEST(ISA,wmmx2)345 TEST(ISA, wmmx2) {
346 ASSERT_FALSE(cpuinfo_has_arm_wmmx2());
347 }
348
TEST(ISA,neon)349 TEST(ISA, neon) {
350 ASSERT_TRUE(cpuinfo_has_arm_neon());
351 }
352
TEST(ISA,neon_fp16)353 TEST(ISA, neon_fp16) {
354 ASSERT_TRUE(cpuinfo_has_arm_neon_fp16());
355 }
356
TEST(ISA,neon_fma)357 TEST(ISA, neon_fma) {
358 ASSERT_TRUE(cpuinfo_has_arm_neon_fma());
359 }
360
TEST(ISA,atomics)361 TEST(ISA, atomics) {
362 ASSERT_FALSE(cpuinfo_has_arm_atomics());
363 }
364
TEST(ISA,neon_rdm)365 TEST(ISA, neon_rdm) {
366 ASSERT_FALSE(cpuinfo_has_arm_neon_rdm());
367 }
368
TEST(ISA,fp16_arith)369 TEST(ISA, fp16_arith) {
370 ASSERT_FALSE(cpuinfo_has_arm_fp16_arith());
371 }
372
TEST(ISA,neon_fp16_arith)373 TEST(ISA, neon_fp16_arith) {
374 ASSERT_FALSE(cpuinfo_has_arm_neon_fp16_arith());
375 }
376
TEST(ISA,neon_dot)377 TEST(ISA, neon_dot) {
378 ASSERT_FALSE(cpuinfo_has_arm_neon_dot());
379 }
380
TEST(ISA,jscvt)381 TEST(ISA, jscvt) {
382 ASSERT_FALSE(cpuinfo_has_arm_jscvt());
383 }
384
TEST(ISA,fcma)385 TEST(ISA, fcma) {
386 ASSERT_FALSE(cpuinfo_has_arm_fcma());
387 }
388
TEST(ISA,aes)389 TEST(ISA, aes) {
390 ASSERT_FALSE(cpuinfo_has_arm_aes());
391 }
392
TEST(ISA,sha1)393 TEST(ISA, sha1) {
394 ASSERT_FALSE(cpuinfo_has_arm_sha1());
395 }
396
TEST(ISA,sha2)397 TEST(ISA, sha2) {
398 ASSERT_FALSE(cpuinfo_has_arm_sha2());
399 }
400
TEST(ISA,pmull)401 TEST(ISA, pmull) {
402 ASSERT_FALSE(cpuinfo_has_arm_pmull());
403 }
404
TEST(ISA,crc32)405 TEST(ISA, crc32) {
406 #if CPUINFO_ARCH_ARM
407 ASSERT_FALSE(cpuinfo_has_arm_crc32());
408 #elif CPUINFO_ARCH_ARM64
409 ASSERT_TRUE(cpuinfo_has_arm_crc32());
410 #endif
411 }
412
TEST(L1I,count)413 TEST(L1I, count) {
414 ASSERT_EQ(4, cpuinfo_get_l1i_caches_count());
415 }
416
TEST(L1I,non_null)417 TEST(L1I, non_null) {
418 ASSERT_TRUE(cpuinfo_get_l1i_caches());
419 }
420
TEST(L1I,size)421 TEST(L1I, size) {
422 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
423 ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size);
424 }
425 }
426
TEST(L1I,associativity)427 TEST(L1I, associativity) {
428 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
429 ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity);
430 }
431 }
432
TEST(L1I,sets)433 TEST(L1I, sets) {
434 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
435 ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size,
436 cpuinfo_get_l1i_cache(i)->sets * cpuinfo_get_l1i_cache(i)->line_size * cpuinfo_get_l1i_cache(i)->partitions * cpuinfo_get_l1i_cache(i)->associativity);
437 }
438 }
439
TEST(L1I,partitions)440 TEST(L1I, partitions) {
441 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
442 ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions);
443 }
444 }
445
TEST(L1I,line_size)446 TEST(L1I, line_size) {
447 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
448 ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size);
449 }
450 }
451
TEST(L1I,flags)452 TEST(L1I, flags) {
453 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
454 ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags);
455 }
456 }
457
TEST(L1I,processors)458 TEST(L1I, processors) {
459 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
460 ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start);
461 ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count);
462 }
463 }
464
TEST(L1D,count)465 TEST(L1D, count) {
466 ASSERT_EQ(4, cpuinfo_get_l1d_caches_count());
467 }
468
TEST(L1D,non_null)469 TEST(L1D, non_null) {
470 ASSERT_TRUE(cpuinfo_get_l1d_caches());
471 }
472
TEST(L1D,size)473 TEST(L1D, size) {
474 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
475 ASSERT_EQ(32 * 1024, cpuinfo_get_l1d_cache(i)->size);
476 }
477 }
478
TEST(L1D,associativity)479 TEST(L1D, associativity) {
480 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
481 ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity);
482 }
483 }
484
TEST(L1D,sets)485 TEST(L1D, sets) {
486 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
487 ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size,
488 cpuinfo_get_l1d_cache(i)->sets * cpuinfo_get_l1d_cache(i)->line_size * cpuinfo_get_l1d_cache(i)->partitions * cpuinfo_get_l1d_cache(i)->associativity);
489 }
490 }
491
TEST(L1D,partitions)492 TEST(L1D, partitions) {
493 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
494 ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions);
495 }
496 }
497
TEST(L1D,line_size)498 TEST(L1D, line_size) {
499 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
500 ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size);
501 }
502 }
503
TEST(L1D,flags)504 TEST(L1D, flags) {
505 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
506 ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags);
507 }
508 }
509
TEST(L1D,processors)510 TEST(L1D, processors) {
511 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
512 ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start);
513 ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count);
514 }
515 }
516
TEST(L2,count)517 TEST(L2, count) {
518 ASSERT_EQ(1, cpuinfo_get_l2_caches_count());
519 }
520
TEST(L2,non_null)521 TEST(L2, non_null) {
522 ASSERT_TRUE(cpuinfo_get_l2_caches());
523 }
524
TEST(L2,size)525 TEST(L2, size) {
526 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
527 ASSERT_EQ(512 * 1024, cpuinfo_get_l2_cache(i)->size);
528 }
529 }
530
TEST(L2,associativity)531 TEST(L2, associativity) {
532 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
533 ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity);
534 }
535 }
536
TEST(L2,sets)537 TEST(L2, sets) {
538 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
539 ASSERT_EQ(cpuinfo_get_l2_cache(i)->size,
540 cpuinfo_get_l2_cache(i)->sets * cpuinfo_get_l2_cache(i)->line_size * cpuinfo_get_l2_cache(i)->partitions * cpuinfo_get_l2_cache(i)->associativity);
541 }
542 }
543
TEST(L2,partitions)544 TEST(L2, partitions) {
545 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
546 ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions);
547 }
548 }
549
TEST(L2,line_size)550 TEST(L2, line_size) {
551 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
552 ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size);
553 }
554 }
555
TEST(L2,flags)556 TEST(L2, flags) {
557 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
558 ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags);
559 }
560 }
561
TEST(L2,processors)562 TEST(L2, processors) {
563 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
564 ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start);
565 ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count);
566 }
567 }
568
TEST(L3,none)569 TEST(L3, none) {
570 ASSERT_EQ(0, cpuinfo_get_l3_caches_count());
571 ASSERT_FALSE(cpuinfo_get_l3_caches());
572 }
573
TEST(L4,none)574 TEST(L4, none) {
575 ASSERT_EQ(0, cpuinfo_get_l4_caches_count());
576 ASSERT_FALSE(cpuinfo_get_l4_caches());
577 }
578
579 #include <oppo-a37.h>
580
main(int argc,char * argv[])581 int main(int argc, char* argv[]) {
582 #if CPUINFO_ARCH_ARM
583 cpuinfo_set_hwcap(UINT32_C(0x0027B0D6));
584 cpuinfo_set_hwcap2(UINT32_C(0x00000000));
585 #elif CPUINFO_ARCH_ARM64
586 cpuinfo_set_hwcap(UINT32_C(0x00000087));
587 #endif
588 cpuinfo_mock_filesystem(filesystem);
589 #ifdef __ANDROID__
590 cpuinfo_mock_android_properties(properties);
591 #endif
592 cpuinfo_initialize();
593 ::testing::InitGoogleTest(&argc, argv);
594 return RUN_ALL_TESTS();
595 }
596