blob: e53d2ddb6ffa27cb994e35d67898e368468a8365 [file] [log] [blame]
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -07001#include <gtest/gtest.h>
2
3#include <cpuinfo.h>
4#include <cpuinfo-mock.h>
5
6
7TEST(PROCESSORS, count) {
Marat Dukhan30401972017-09-26 18:35:52 -07008 ASSERT_EQ(4, cpuinfo_get_processors_count());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -07009}
10
11TEST(PROCESSORS, non_null) {
Marat Dukhan30401972017-09-26 18:35:52 -070012 ASSERT_TRUE(cpuinfo_get_processors());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -070013}
14
Marat Dukhan2d37dc42017-09-25 01:32:37 -070015TEST(PROCESSORS, smt_id) {
Marat Dukhan30401972017-09-26 18:35:52 -070016 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
17 ASSERT_EQ(0, cpuinfo_get_processor(i)->smt_id);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -070018 }
19}
20
Marat Dukhan2d37dc42017-09-25 01:32:37 -070021TEST(PROCESSORS, core) {
Marat Dukhan30401972017-09-26 18:35:52 -070022 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
23 ASSERT_EQ(cpuinfo_get_core(i), cpuinfo_get_processor(i)->core);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070024 }
25}
26
Marat Dukhan2b307932018-03-18 16:15:36 -070027TEST(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
Marat Dukhan2d37dc42017-09-25 01:32:37 -070033TEST(PROCESSORS, package) {
Marat Dukhan30401972017-09-26 18:35:52 -070034 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
35 ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_processor(i)->package);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -070036 }
37}
38
Marat Dukhan846c1782017-09-13 09:47:26 -070039TEST(PROCESSORS, linux_id) {
Marat Dukhan30401972017-09-26 18:35:52 -070040 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
41 ASSERT_EQ(i, cpuinfo_get_processor(i)->linux_id);
Marat Dukhan846c1782017-09-13 09:47:26 -070042 }
43}
44
Marat Dukhan2d37dc42017-09-25 01:32:37 -070045TEST(PROCESSORS, l1i) {
Marat Dukhan30401972017-09-26 18:35:52 -070046 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);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070048 }
49}
50
51TEST(PROCESSORS, l1d) {
Marat Dukhan30401972017-09-26 18:35:52 -070052 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);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070054 }
55}
56
57TEST(PROCESSORS, l2) {
Marat Dukhan30401972017-09-26 18:35:52 -070058 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);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070060 }
61}
62
63TEST(PROCESSORS, l3) {
Marat Dukhan30401972017-09-26 18:35:52 -070064 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
65 ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l3);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070066 }
67}
68
69TEST(PROCESSORS, l4) {
Marat Dukhan30401972017-09-26 18:35:52 -070070 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) {
71 ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l4);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070072 }
73}
74
Marat Dukhan7073e832017-09-24 22:23:55 -070075TEST(CORES, count) {
Marat Dukhan30401972017-09-26 18:35:52 -070076 ASSERT_EQ(4, cpuinfo_get_cores_count());
Marat Dukhan7073e832017-09-24 22:23:55 -070077}
78
Marat Dukhan2d37dc42017-09-25 01:32:37 -070079TEST(CORES, non_null) {
Marat Dukhan30401972017-09-26 18:35:52 -070080 ASSERT_TRUE(cpuinfo_get_cores());
Marat Dukhan2d37dc42017-09-25 01:32:37 -070081}
82
Marat Dukhan7073e832017-09-24 22:23:55 -070083TEST(CORES, processor_start) {
Marat Dukhan30401972017-09-26 18:35:52 -070084 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
85 ASSERT_EQ(i, cpuinfo_get_core(i)->processor_start);
Marat Dukhan7073e832017-09-24 22:23:55 -070086 }
87}
88
89TEST(CORES, processor_count) {
Marat Dukhan30401972017-09-26 18:35:52 -070090 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
91 ASSERT_EQ(1, cpuinfo_get_core(i)->processor_count);
Marat Dukhan7073e832017-09-24 22:23:55 -070092 }
93}
94
Marat Dukhan2d37dc42017-09-25 01:32:37 -070095TEST(CORES, core_id) {
Marat Dukhan30401972017-09-26 18:35:52 -070096 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
97 ASSERT_EQ(i, cpuinfo_get_core(i)->core_id);
Marat Dukhan2d37dc42017-09-25 01:32:37 -070098 }
99}
100
Marat Dukhan2b307932018-03-18 16:15:36 -0700101TEST(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
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700107TEST(CORES, package) {
Marat Dukhan30401972017-09-26 18:35:52 -0700108 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
109 ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_core(i)->package);
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700110 }
111}
112
113TEST(CORES, vendor) {
Marat Dukhan30401972017-09-26 18:35:52 -0700114 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
115 ASSERT_EQ(cpuinfo_vendor_qualcomm, cpuinfo_get_core(i)->vendor);
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700116 }
117}
118
119TEST(CORES, uarch) {
Marat Dukhan30401972017-09-26 18:35:52 -0700120 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
121 ASSERT_EQ(cpuinfo_uarch_krait, cpuinfo_get_core(i)->uarch);
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700122 }
123}
124
125TEST(CORES, midr) {
Marat Dukhan30401972017-09-26 18:35:52 -0700126 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
127 ASSERT_EQ(UINT32_C(0x513F06F1), cpuinfo_get_core(i)->midr);
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700128 }
129}
130
Marat Dukhan575a6302018-03-10 14:38:49 -0800131TEST(CORES, DISABLED_frequency) {
132 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) {
133 ASSERT_EQ(UINT64_C(2649600000), cpuinfo_get_core(i)->frequency);
134 }
135}
136
Marat Dukhandbc78402018-03-18 22:49:35 -0700137TEST(CLUSTERS, count) {
138 ASSERT_EQ(1, cpuinfo_get_clusters_count());
139}
140
141TEST(CLUSTERS, non_null) {
142 ASSERT_TRUE(cpuinfo_get_clusters());
143}
144
145TEST(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
151TEST(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
157TEST(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
163TEST(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
169TEST(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
175TEST(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
181TEST(CLUSTERS, vendor) {
182 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
183 ASSERT_EQ(cpuinfo_vendor_qualcomm, cpuinfo_get_cluster(i)->vendor);
184 }
185}
186
187TEST(CLUSTERS, uarch) {
188 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
189 ASSERT_EQ(cpuinfo_uarch_krait, cpuinfo_get_cluster(i)->uarch);
190 }
191}
192
193TEST(CLUSTERS, midr) {
194 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
195 ASSERT_EQ(UINT32_C(0x513F06F1), cpuinfo_get_cluster(i)->midr);
196 }
197}
198
199TEST(CLUSTERS, DISABLED_frequency) {
200 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) {
201 ASSERT_EQ(UINT64_C(2649600000), cpuinfo_get_cluster(i)->frequency);
202 }
203}
204
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700205TEST(PACKAGES, count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700206 ASSERT_EQ(1, cpuinfo_get_packages_count());
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700207}
208
209TEST(PACKAGES, name) {
Marat Dukhan30401972017-09-26 18:35:52 -0700210 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700211 ASSERT_EQ("Qualcomm APQ8084",
Marat Dukhan30401972017-09-26 18:35:52 -0700212 std::string(cpuinfo_get_package(i)->name,
213 strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX)));
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700214 }
215}
216
Marat Dukhanfd0f3ef2017-12-18 17:45:18 -0800217TEST(PACKAGES, gpu_name) {
218 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
219 ASSERT_EQ("Qualcomm Adreno 420",
220 std::string(cpuinfo_get_package(i)->gpu_name,
221 strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX)));
222 }
223}
224
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700225TEST(PACKAGES, processor_start) {
Marat Dukhan30401972017-09-26 18:35:52 -0700226 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
227 ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start);
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700228 }
229}
230
231TEST(PACKAGES, processor_count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700232 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
233 ASSERT_EQ(4, cpuinfo_get_package(i)->processor_count);
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700234 }
235}
236
237TEST(PACKAGES, core_start) {
Marat Dukhan30401972017-09-26 18:35:52 -0700238 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
239 ASSERT_EQ(0, cpuinfo_get_package(i)->core_start);
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700240 }
241}
242
243TEST(PACKAGES, core_count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700244 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
245 ASSERT_EQ(4, cpuinfo_get_package(i)->core_count);
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700246 }
247}
248
Marat Dukhan2b307932018-03-18 16:15:36 -0700249TEST(PACKAGES, cluster_start) {
250 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
251 ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start);
252 }
253}
254
255TEST(PACKAGES, cluster_count) {
256 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) {
257 ASSERT_EQ(1, cpuinfo_get_package(i)->cluster_count);
258 }
259}
260
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700261TEST(ISA, thumb) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700262 ASSERT_TRUE(cpuinfo_has_arm_thumb());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700263}
264
265TEST(ISA, thumb2) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700266 ASSERT_TRUE(cpuinfo_has_arm_thumb2());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700267}
268
269TEST(ISA, armv5e) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700270 ASSERT_TRUE(cpuinfo_has_arm_v5e());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700271}
272
273TEST(ISA, armv6) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700274 ASSERT_TRUE(cpuinfo_has_arm_v6());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700275}
276
277TEST(ISA, armv6k) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700278 ASSERT_TRUE(cpuinfo_has_arm_v6k());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700279}
280
281TEST(ISA, armv7) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700282 ASSERT_TRUE(cpuinfo_has_arm_v7());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700283}
284
285TEST(ISA, armv7mp) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700286 ASSERT_TRUE(cpuinfo_has_arm_v7mp());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700287}
288
289TEST(ISA, idiv) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700290 ASSERT_TRUE(cpuinfo_has_arm_idiv());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700291}
292
293TEST(ISA, vfpv2) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700294 ASSERT_FALSE(cpuinfo_has_arm_vfpv2());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700295}
296
297TEST(ISA, vfpv3) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700298 ASSERT_TRUE(cpuinfo_has_arm_vfpv3());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700299}
300
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700301TEST(ISA, vfpv3_d32) {
302 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700303}
304
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700305TEST(ISA, vfpv3_fp16) {
306 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700307}
308
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700309TEST(ISA, vfpv3_fp16_d32) {
310 ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32());
311}
312
313TEST(ISA, vfpv4) {
314 ASSERT_TRUE(cpuinfo_has_arm_vfpv4());
315}
316
317TEST(ISA, vfpv4_d32) {
318 ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700319}
320
321TEST(ISA, wmmx) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700322 ASSERT_FALSE(cpuinfo_has_arm_wmmx());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700323}
324
325TEST(ISA, wmmx2) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700326 ASSERT_FALSE(cpuinfo_has_arm_wmmx2());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700327}
328
329TEST(ISA, neon) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700330 ASSERT_TRUE(cpuinfo_has_arm_neon());
331}
332
333TEST(ISA, neon_fp16) {
334 ASSERT_TRUE(cpuinfo_has_arm_neon_fp16());
335}
336
337TEST(ISA, neon_fma) {
338 ASSERT_TRUE(cpuinfo_has_arm_neon_fma());
339}
340
341TEST(ISA, atomics) {
342 ASSERT_FALSE(cpuinfo_has_arm_atomics());
343}
344
345TEST(ISA, neon_rdm) {
346 ASSERT_FALSE(cpuinfo_has_arm_neon_rdm());
347}
348
349TEST(ISA, fp16_arith) {
350 ASSERT_FALSE(cpuinfo_has_arm_fp16_arith());
351}
352
353TEST(ISA, jscvt) {
354 ASSERT_FALSE(cpuinfo_has_arm_jscvt());
355}
356
357TEST(ISA, fcma) {
358 ASSERT_FALSE(cpuinfo_has_arm_fcma());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700359}
360
361TEST(ISA, aes) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700362 ASSERT_FALSE(cpuinfo_has_arm_aes());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700363}
364
365TEST(ISA, sha1) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700366 ASSERT_FALSE(cpuinfo_has_arm_sha1());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700367}
368
369TEST(ISA, sha2) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700370 ASSERT_FALSE(cpuinfo_has_arm_sha2());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700371}
372
373TEST(ISA, pmull) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700374 ASSERT_FALSE(cpuinfo_has_arm_pmull());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700375}
376
377TEST(ISA, crc32) {
Marat Dukhaneb3025f2017-09-26 12:57:41 -0700378 ASSERT_FALSE(cpuinfo_has_arm_crc32());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700379}
380
381TEST(L1I, count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700382 ASSERT_EQ(4, cpuinfo_get_l1i_caches_count());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700383}
384
385TEST(L1I, non_null) {
Marat Dukhan30401972017-09-26 18:35:52 -0700386 ASSERT_TRUE(cpuinfo_get_l1i_caches());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700387}
388
389TEST(L1I, size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700390 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
391 ASSERT_EQ(16 * 1024, cpuinfo_get_l1i_cache(i)->size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700392 }
393}
394
395TEST(L1I, associativity) {
Marat Dukhan30401972017-09-26 18:35:52 -0700396 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
397 ASSERT_EQ(4, cpuinfo_get_l1i_cache(i)->associativity);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700398 }
399}
400
401TEST(L1I, sets) {
Marat Dukhan30401972017-09-26 18:35:52 -0700402 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
403 ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size,
404 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);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700405 }
406}
407
408TEST(L1I, partitions) {
Marat Dukhan30401972017-09-26 18:35:52 -0700409 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
410 ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700411 }
412}
413
414TEST(L1I, line_size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700415 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
416 ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700417 }
418}
419
420TEST(L1I, flags) {
Marat Dukhan30401972017-09-26 18:35:52 -0700421 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
422 ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700423 }
424}
425
426TEST(L1I, processors) {
Marat Dukhan30401972017-09-26 18:35:52 -0700427 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) {
428 ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start);
429 ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700430 }
431}
432
433TEST(L1D, count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700434 ASSERT_EQ(4, cpuinfo_get_l1d_caches_count());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700435}
436
437TEST(L1D, non_null) {
Marat Dukhan30401972017-09-26 18:35:52 -0700438 ASSERT_TRUE(cpuinfo_get_l1d_caches());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700439}
440
441TEST(L1D, size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700442 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
443 ASSERT_EQ(16 * 1024, cpuinfo_get_l1d_cache(i)->size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700444 }
445}
446
447TEST(L1D, associativity) {
Marat Dukhan30401972017-09-26 18:35:52 -0700448 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
449 ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700450 }
451}
452
453TEST(L1D, sets) {
Marat Dukhan30401972017-09-26 18:35:52 -0700454 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
455 ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size,
456 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);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700457 }
458}
459
460TEST(L1D, partitions) {
Marat Dukhan30401972017-09-26 18:35:52 -0700461 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
462 ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700463 }
464}
465
466TEST(L1D, line_size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700467 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
468 ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700469 }
470}
471
472TEST(L1D, flags) {
Marat Dukhan30401972017-09-26 18:35:52 -0700473 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
474 ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700475 }
476}
477
478TEST(L1D, processors) {
Marat Dukhan30401972017-09-26 18:35:52 -0700479 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) {
480 ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start);
481 ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700482 }
483}
484
485TEST(L2, count) {
Marat Dukhan30401972017-09-26 18:35:52 -0700486 ASSERT_EQ(1, cpuinfo_get_l2_caches_count());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700487}
488
489TEST(L2, non_null) {
Marat Dukhan30401972017-09-26 18:35:52 -0700490 ASSERT_TRUE(cpuinfo_get_l2_caches());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700491}
492
493TEST(L2, size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700494 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
495 ASSERT_EQ(2 * 1024 * 1024, cpuinfo_get_l2_cache(i)->size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700496 }
497}
498
499TEST(L2, associativity) {
Marat Dukhan30401972017-09-26 18:35:52 -0700500 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
501 ASSERT_EQ(8, cpuinfo_get_l2_cache(i)->associativity);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700502 }
503}
504
505TEST(L2, sets) {
Marat Dukhan30401972017-09-26 18:35:52 -0700506 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
507 ASSERT_EQ(cpuinfo_get_l2_cache(i)->size,
508 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);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700509 }
510}
511
512TEST(L2, partitions) {
Marat Dukhan30401972017-09-26 18:35:52 -0700513 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
514 ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700515 }
516}
517
518TEST(L2, line_size) {
Marat Dukhan30401972017-09-26 18:35:52 -0700519 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
520 ASSERT_EQ(128, cpuinfo_get_l2_cache(i)->line_size);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700521 }
522}
523
524TEST(L2, flags) {
Marat Dukhan30401972017-09-26 18:35:52 -0700525 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
526 ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700527 }
528}
529
530TEST(L2, processors) {
Marat Dukhan30401972017-09-26 18:35:52 -0700531 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) {
532 ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start);
533 ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count);
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700534 }
535}
536
537TEST(L3, none) {
Marat Dukhan30401972017-09-26 18:35:52 -0700538 ASSERT_EQ(0, cpuinfo_get_l3_caches_count());
539 ASSERT_FALSE(cpuinfo_get_l3_caches());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700540}
541
542TEST(L4, none) {
Marat Dukhan30401972017-09-26 18:35:52 -0700543 ASSERT_EQ(0, cpuinfo_get_l4_caches_count());
544 ASSERT_FALSE(cpuinfo_get_l4_caches());
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700545}
546
547#include <nexus6.h>
548
549int main(int argc, char* argv[]) {
Marat Dukhan63a7a6b2017-11-29 15:11:56 -0800550#if CPUINFO_ARCH_ARM
551 cpuinfo_set_hwcap(UINT32_C(0x0007B0D7));
552#endif
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700553 cpuinfo_mock_filesystem(filesystem);
Marat Dukhan5659d292017-09-12 23:21:03 -0700554#ifdef __ANDROID__
555 cpuinfo_mock_android_properties(properties);
Marat Dukhanfd0f3ef2017-12-18 17:45:18 -0800556 cpuinfo_mock_gl_renderer("Adreno (TM) 420");
Marat Dukhan5659d292017-09-12 23:21:03 -0700557#endif
Marat Dukhan8dd5ffc2017-08-11 00:05:50 -0700558 cpuinfo_initialize();
559 ::testing::InitGoogleTest(&argc, argv);
560 return RUN_ALL_TESTS();
Marat Dukhan30401972017-09-26 18:35:52 -0700561}