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