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