Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
| 2 | |
| 3 | #include <cpuinfo.h> |
| 4 | #include <cpuinfo-mock.h> |
| 5 | |
| 6 | |
| 7 | TEST(PROCESSORS, count) { |
| 8 | ASSERT_EQ(8, cpuinfo_get_processors_count()); |
| 9 | } |
| 10 | |
| 11 | TEST(PROCESSORS, non_null) { |
| 12 | ASSERT_TRUE(cpuinfo_get_processors()); |
| 13 | } |
| 14 | |
| 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 | |
| 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 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame^] | 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 | |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 114 | TEST(CORES, count) { |
| 115 | ASSERT_EQ(8, cpuinfo_get_cores_count()); |
| 116 | } |
| 117 | |
| 118 | TEST(CORES, non_null) { |
| 119 | ASSERT_TRUE(cpuinfo_get_cores()); |
| 120 | } |
| 121 | |
| 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 | |
| 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 | |
| 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 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame^] | 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 | |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 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 | |
| 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 | |
| 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 | |
| 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 | |
Marat Dukhan | 575a630 | 2018-03-10 14:38:49 -0800 | [diff] [blame] | 183 | TEST(CORES, DISABLED_frequency) { |
| 184 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 185 | ASSERT_EQ(UINT64_C(2016000000), cpuinfo_get_core(i)->frequency); |
| 186 | } |
| 187 | } |
| 188 | |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 189 | TEST(PACKAGES, count) { |
| 190 | ASSERT_EQ(1, cpuinfo_get_packages_count()); |
| 191 | } |
| 192 | |
| 193 | TEST(PACKAGES, name) { |
| 194 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 195 | ASSERT_EQ("Qualcomm MSM8953", |
| 196 | std::string(cpuinfo_get_package(i)->name, |
| 197 | strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); |
| 198 | } |
| 199 | } |
| 200 | |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 201 | TEST(PACKAGES, gpu_name) { |
| 202 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 203 | ASSERT_EQ("Qualcomm Adreno 506", |
| 204 | std::string(cpuinfo_get_package(i)->gpu_name, |
| 205 | strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX))); |
| 206 | } |
| 207 | } |
| 208 | |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 209 | TEST(PACKAGES, processor_start) { |
| 210 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 211 | ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | TEST(PACKAGES, processor_count) { |
| 216 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 217 | ASSERT_EQ(8, cpuinfo_get_package(i)->processor_count); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | TEST(PACKAGES, core_start) { |
| 222 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 223 | ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | TEST(PACKAGES, core_count) { |
| 228 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 229 | ASSERT_EQ(8, cpuinfo_get_package(i)->core_count); |
| 230 | } |
| 231 | } |
| 232 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame^] | 233 | TEST(PACKAGES, cluster_start) { |
| 234 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 235 | ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | TEST(PACKAGES, cluster_count) { |
| 240 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 241 | ASSERT_EQ(2, cpuinfo_get_package(i)->cluster_count); |
| 242 | } |
| 243 | } |
| 244 | |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 245 | TEST(ISA, thumb) { |
| 246 | #if CPUINFO_ARCH_ARM |
| 247 | ASSERT_TRUE(cpuinfo_has_arm_thumb()); |
| 248 | #elif CPUINFO_ARCH_ARM64 |
| 249 | ASSERT_FALSE(cpuinfo_has_arm_thumb()); |
| 250 | #endif |
| 251 | } |
| 252 | |
| 253 | TEST(ISA, thumb2) { |
| 254 | #if CPUINFO_ARCH_ARM |
| 255 | ASSERT_TRUE(cpuinfo_has_arm_thumb2()); |
| 256 | #elif CPUINFO_ARCH_ARM64 |
| 257 | ASSERT_FALSE(cpuinfo_has_arm_thumb2()); |
| 258 | #endif |
| 259 | } |
| 260 | |
| 261 | TEST(ISA, armv5e) { |
| 262 | #if CPUINFO_ARCH_ARM |
| 263 | ASSERT_TRUE(cpuinfo_has_arm_v5e()); |
| 264 | #elif CPUINFO_ARCH_ARM64 |
| 265 | ASSERT_FALSE(cpuinfo_has_arm_v5e()); |
| 266 | #endif |
| 267 | } |
| 268 | |
| 269 | TEST(ISA, armv6) { |
| 270 | #if CPUINFO_ARCH_ARM |
| 271 | ASSERT_TRUE(cpuinfo_has_arm_v6()); |
| 272 | #elif CPUINFO_ARCH_ARM64 |
| 273 | ASSERT_FALSE(cpuinfo_has_arm_v6()); |
| 274 | #endif |
| 275 | } |
| 276 | |
| 277 | TEST(ISA, armv6k) { |
| 278 | #if CPUINFO_ARCH_ARM |
| 279 | ASSERT_TRUE(cpuinfo_has_arm_v6k()); |
| 280 | #elif CPUINFO_ARCH_ARM64 |
| 281 | ASSERT_FALSE(cpuinfo_has_arm_v6k()); |
| 282 | #endif |
| 283 | } |
| 284 | |
| 285 | TEST(ISA, armv7) { |
| 286 | #if CPUINFO_ARCH_ARM |
| 287 | ASSERT_TRUE(cpuinfo_has_arm_v7()); |
| 288 | #elif CPUINFO_ARCH_ARM64 |
| 289 | ASSERT_FALSE(cpuinfo_has_arm_v7()); |
| 290 | #endif |
| 291 | } |
| 292 | |
| 293 | TEST(ISA, armv7mp) { |
| 294 | #if CPUINFO_ARCH_ARM |
| 295 | ASSERT_TRUE(cpuinfo_has_arm_v7mp()); |
| 296 | #elif CPUINFO_ARCH_ARM64 |
| 297 | ASSERT_FALSE(cpuinfo_has_arm_v7mp()); |
| 298 | #endif |
| 299 | } |
| 300 | |
| 301 | TEST(ISA, idiv) { |
| 302 | ASSERT_TRUE(cpuinfo_has_arm_idiv()); |
| 303 | } |
| 304 | |
| 305 | TEST(ISA, vfpv2) { |
| 306 | ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); |
| 307 | } |
| 308 | |
| 309 | TEST(ISA, vfpv3) { |
| 310 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); |
| 311 | } |
| 312 | |
| 313 | TEST(ISA, vfpv3_d32) { |
| 314 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); |
| 315 | } |
| 316 | |
| 317 | TEST(ISA, vfpv3_fp16) { |
| 318 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); |
| 319 | } |
| 320 | |
| 321 | TEST(ISA, vfpv3_fp16_d32) { |
| 322 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); |
| 323 | } |
| 324 | |
| 325 | TEST(ISA, vfpv4) { |
| 326 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); |
| 327 | } |
| 328 | |
| 329 | TEST(ISA, vfpv4_d32) { |
| 330 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); |
| 331 | } |
| 332 | |
| 333 | TEST(ISA, wmmx) { |
| 334 | ASSERT_FALSE(cpuinfo_has_arm_wmmx()); |
| 335 | } |
| 336 | |
| 337 | TEST(ISA, wmmx2) { |
| 338 | ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); |
| 339 | } |
| 340 | |
| 341 | TEST(ISA, neon) { |
| 342 | ASSERT_TRUE(cpuinfo_has_arm_neon()); |
| 343 | } |
| 344 | |
| 345 | TEST(ISA, neon_fp16) { |
| 346 | ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); |
| 347 | } |
| 348 | |
| 349 | TEST(ISA, neon_fma) { |
| 350 | ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); |
| 351 | } |
| 352 | |
| 353 | TEST(ISA, atomics) { |
| 354 | ASSERT_FALSE(cpuinfo_has_arm_atomics()); |
| 355 | } |
| 356 | |
| 357 | TEST(ISA, neon_rdm) { |
| 358 | ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); |
| 359 | } |
| 360 | |
| 361 | TEST(ISA, fp16_arith) { |
| 362 | ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); |
| 363 | } |
| 364 | |
| 365 | TEST(ISA, jscvt) { |
| 366 | ASSERT_FALSE(cpuinfo_has_arm_jscvt()); |
| 367 | } |
| 368 | |
| 369 | TEST(ISA, fcma) { |
| 370 | ASSERT_FALSE(cpuinfo_has_arm_fcma()); |
| 371 | } |
| 372 | |
| 373 | TEST(ISA, aes) { |
| 374 | ASSERT_TRUE(cpuinfo_has_arm_aes()); |
| 375 | } |
| 376 | |
| 377 | TEST(ISA, sha1) { |
| 378 | ASSERT_TRUE(cpuinfo_has_arm_sha1()); |
| 379 | } |
| 380 | |
| 381 | TEST(ISA, sha2) { |
| 382 | ASSERT_TRUE(cpuinfo_has_arm_sha2()); |
| 383 | } |
| 384 | |
| 385 | TEST(ISA, pmull) { |
| 386 | ASSERT_TRUE(cpuinfo_has_arm_pmull()); |
| 387 | } |
| 388 | |
| 389 | TEST(ISA, crc32) { |
| 390 | ASSERT_TRUE(cpuinfo_has_arm_crc32()); |
| 391 | } |
| 392 | |
| 393 | TEST(L1I, count) { |
| 394 | ASSERT_EQ(8, cpuinfo_get_l1i_caches_count()); |
| 395 | } |
| 396 | |
| 397 | TEST(L1I, non_null) { |
| 398 | ASSERT_TRUE(cpuinfo_get_l1i_caches()); |
| 399 | } |
| 400 | |
| 401 | TEST(L1I, size) { |
| 402 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 403 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | TEST(L1I, associativity) { |
| 408 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 409 | ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | TEST(L1I, sets) { |
| 414 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 415 | ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, |
| 416 | 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); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | TEST(L1I, partitions) { |
| 421 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 422 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | TEST(L1I, line_size) { |
| 427 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 428 | ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | TEST(L1I, flags) { |
| 433 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 434 | ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | TEST(L1I, processors) { |
| 439 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 440 | ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); |
| 441 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | TEST(L1D, count) { |
| 446 | ASSERT_EQ(8, cpuinfo_get_l1d_caches_count()); |
| 447 | } |
| 448 | |
| 449 | TEST(L1D, non_null) { |
| 450 | ASSERT_TRUE(cpuinfo_get_l1d_caches()); |
| 451 | } |
| 452 | |
| 453 | TEST(L1D, size) { |
| 454 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 455 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1d_cache(i)->size); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | TEST(L1D, associativity) { |
| 460 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 461 | ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | TEST(L1D, sets) { |
| 466 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 467 | ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, |
| 468 | 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); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | TEST(L1D, partitions) { |
| 473 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 474 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | TEST(L1D, line_size) { |
| 479 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 480 | ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | TEST(L1D, flags) { |
| 485 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 486 | ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | TEST(L1D, processors) { |
| 491 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 492 | ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); |
| 493 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | TEST(L2, count) { |
| 498 | ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); |
| 499 | } |
| 500 | |
| 501 | TEST(L2, non_null) { |
| 502 | ASSERT_TRUE(cpuinfo_get_l2_caches()); |
| 503 | } |
| 504 | |
| 505 | TEST(L2, size) { |
| 506 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 507 | switch (i) { |
| 508 | case 0: |
| 509 | ASSERT_EQ(1024 * 1024, cpuinfo_get_l2_cache(i)->size); |
| 510 | break; |
| 511 | case 1: |
| 512 | ASSERT_EQ(512 * 1024, cpuinfo_get_l2_cache(i)->size); |
| 513 | break; |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | TEST(L2, associativity) { |
| 519 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 520 | ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | TEST(L2, sets) { |
| 525 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 526 | ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, |
| 527 | 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); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | TEST(L2, partitions) { |
| 532 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 533 | ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | TEST(L2, line_size) { |
| 538 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 539 | ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | TEST(L2, flags) { |
| 544 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 545 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | TEST(L2, processors) { |
| 550 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 551 | switch (i) { |
| 552 | case 0: |
| 553 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); |
| 554 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
| 555 | break; |
| 556 | case 1: |
| 557 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_start); |
| 558 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
| 559 | break; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | TEST(L3, none) { |
| 565 | ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); |
| 566 | ASSERT_FALSE(cpuinfo_get_l3_caches()); |
| 567 | } |
| 568 | |
| 569 | TEST(L4, none) { |
| 570 | ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); |
| 571 | ASSERT_FALSE(cpuinfo_get_l4_caches()); |
| 572 | } |
| 573 | |
| 574 | #include <xiaomi-redmi-note-4.h> |
| 575 | |
| 576 | int main(int argc, char* argv[]) { |
| 577 | #if CPUINFO_ARCH_ARM |
| 578 | cpuinfo_set_hwcap(UINT32_C(0x0037B0D6)); |
| 579 | cpuinfo_set_hwcap2(UINT32_C(0x0000001F)); |
| 580 | #elif CPUINFO_ARCH_ARM64 |
| 581 | cpuinfo_set_hwcap(UINT32_C(0x000000FF)); |
| 582 | #endif |
| 583 | cpuinfo_mock_filesystem(filesystem); |
| 584 | #ifdef __ANDROID__ |
| 585 | cpuinfo_mock_android_properties(properties); |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 586 | cpuinfo_mock_gl_renderer("Adreno (TM) 506"); |
Marat Dukhan | a5fda23 | 2017-12-04 16:08:25 -0800 | [diff] [blame] | 587 | #endif |
| 588 | cpuinfo_initialize(); |
| 589 | ::testing::InitGoogleTest(&argc, argv); |
| 590 | return RUN_ALL_TESTS(); |
| 591 | } |