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(i % 2, 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 / 2), 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 ASSERT_EQ(cpuinfo_get_cluster(i / 2), cpuinfo_get_processor(i)->cluster); 30 } 31 } 32 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 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 45 TEST(PROCESSORS, l1i) { 46 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { 47 ASSERT_EQ(cpuinfo_get_l1i_cache(i / 2), cpuinfo_get_processor(i)->cache.l1i); 48 } 49 } 50 51 TEST(PROCESSORS, l1d) { 52 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { 53 ASSERT_EQ(cpuinfo_get_l1d_cache(i / 2), cpuinfo_get_processor(i)->cache.l1d); 54 } 55 } 56 57 TEST(PROCESSORS, l2) { 58 for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { 59 ASSERT_EQ(cpuinfo_get_l2_cache(i / 2), cpuinfo_get_processor(i)->cache.l2); 60 } 61 } 62 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 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 75 TEST(CORES, count) { 76 ASSERT_EQ(2, cpuinfo_get_cores_count()); 77 } 78 79 TEST(CORES, non_null) { 80 ASSERT_TRUE(cpuinfo_get_cores()); 81 } 82 83 TEST(CORES, processor_start) { 84 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 85 ASSERT_EQ(i * 2, cpuinfo_get_core(i)->processor_start); 86 } 87 } 88 89 TEST(CORES, processor_count) { 90 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 91 ASSERT_EQ(2, cpuinfo_get_core(i)->processor_count); 92 } 93 } 94 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 101 TEST(CORES, cluster) { 102 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 103 ASSERT_EQ(cpuinfo_get_cluster(i), cpuinfo_get_core(i)->cluster); 104 } 105 } 106 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 113 TEST(CORES, vendor) { 114 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 115 ASSERT_EQ(cpuinfo_vendor_intel, cpuinfo_get_core(i)->vendor); 116 } 117 } 118 119 TEST(CORES, uarch) { 120 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 121 ASSERT_EQ(cpuinfo_uarch_saltwell, cpuinfo_get_core(i)->uarch); 122 } 123 } 124 125 TEST(CORES, cpuid) { 126 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 127 ASSERT_EQ(UINT32_C(0x00030651), cpuinfo_get_core(i)->cpuid); 128 } 129 } 130 131 TEST(CORES, DISABLED_frequency) { 132 for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { 133 ASSERT_EQ(UINT64_C(1600000000), cpuinfo_get_core(i)->frequency); 134 } 135 } 136 137 TEST(CLUSTERS, count) { 138 ASSERT_EQ(2, cpuinfo_get_clusters_count()); 139 } 140 141 TEST(CLUSTERS, non_null) { 142 ASSERT_TRUE(cpuinfo_get_clusters()); 143 } 144 145 TEST(CLUSTERS, processor_start) { 146 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 147 ASSERT_EQ(i * 2, cpuinfo_get_cluster(i)->processor_start); 148 } 149 } 150 151 TEST(CLUSTERS, processor_count) { 152 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 153 ASSERT_EQ(2, cpuinfo_get_cluster(i)->processor_count); 154 } 155 } 156 157 TEST(CLUSTERS, core_start) { 158 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 159 ASSERT_EQ(i, cpuinfo_get_cluster(i)->core_start); 160 } 161 } 162 163 TEST(CLUSTERS, core_count) { 164 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 165 ASSERT_EQ(1, cpuinfo_get_cluster(i)->core_count); 166 } 167 } 168 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 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 181 TEST(CLUSTERS, vendor) { 182 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 183 ASSERT_EQ(cpuinfo_vendor_intel, cpuinfo_get_cluster(i)->vendor); 184 } 185 } 186 187 TEST(CLUSTERS, uarch) { 188 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 189 ASSERT_EQ(cpuinfo_uarch_saltwell, cpuinfo_get_cluster(i)->uarch); 190 } 191 } 192 193 TEST(CLUSTERS, cpuid) { 194 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 195 ASSERT_EQ(UINT32_C(0x00030651), cpuinfo_get_cluster(i)->cpuid); 196 } 197 } 198 199 TEST(CLUSTERS, DISABLED_frequency) { 200 for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { 201 ASSERT_EQ(UINT64_C(1600000000), cpuinfo_get_cluster(i)->frequency); 202 } 203 } 204 205 TEST(PACKAGES, count) { 206 ASSERT_EQ(1, cpuinfo_get_packages_count()); 207 } 208 209 TEST(PACKAGES, non_null) { 210 ASSERT_TRUE(cpuinfo_get_packages()); 211 } 212 213 TEST(PACKAGES, name) { 214 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 215 ASSERT_EQ("Intel Atom Z2560", 216 std::string(cpuinfo_get_package(i)->name, 217 strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); 218 } 219 } 220 221 TEST(PACKAGES, processor_start) { 222 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 223 ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); 224 } 225 } 226 227 TEST(PACKAGES, processor_count) { 228 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 229 ASSERT_EQ(4, cpuinfo_get_package(i)->processor_count); 230 } 231 } 232 233 TEST(PACKAGES, core_start) { 234 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 235 ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); 236 } 237 } 238 239 TEST(PACKAGES, core_count) { 240 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 241 ASSERT_EQ(2, cpuinfo_get_package(i)->core_count); 242 } 243 } 244 245 TEST(PACKAGES, cluster_start) { 246 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 247 ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start); 248 } 249 } 250 251 TEST(PACKAGES, cluster_count) { 252 for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { 253 ASSERT_EQ(2, cpuinfo_get_package(i)->cluster_count); 254 } 255 } 256 257 TEST(ISA, rdtsc) { 258 ASSERT_TRUE(cpuinfo_has_x86_rdtsc()); 259 } 260 261 TEST(ISA, rdtscp) { 262 ASSERT_FALSE(cpuinfo_has_x86_rdtscp()); 263 } 264 265 TEST(ISA, rdpid) { 266 ASSERT_FALSE(cpuinfo_has_x86_rdpid()); 267 } 268 269 TEST(ISA, clzero) { 270 ASSERT_FALSE(cpuinfo_has_x86_clzero()); 271 } 272 273 TEST(ISA, mwait) { 274 ASSERT_TRUE(cpuinfo_has_x86_mwait()); 275 } 276 277 TEST(ISA, mwaitx) { 278 ASSERT_FALSE(cpuinfo_has_x86_mwaitx()); 279 } 280 281 TEST(ISA, fxsave) { 282 ASSERT_TRUE(cpuinfo_has_x86_fxsave()); 283 } 284 285 TEST(ISA, xsave) { 286 ASSERT_FALSE(cpuinfo_has_x86_xsave()); 287 } 288 289 TEST(ISA, fpu) { 290 ASSERT_TRUE(cpuinfo_has_x86_fpu()); 291 } 292 293 TEST(ISA, mmx) { 294 ASSERT_TRUE(cpuinfo_has_x86_mmx()); 295 } 296 297 TEST(ISA, mmx_plus) { 298 ASSERT_TRUE(cpuinfo_has_x86_mmx_plus()); 299 } 300 301 TEST(ISA, three_d_now) { 302 ASSERT_FALSE(cpuinfo_has_x86_3dnow()); 303 } 304 305 TEST(ISA, three_d_now_plus) { 306 ASSERT_FALSE(cpuinfo_has_x86_3dnow_plus()); 307 } 308 309 TEST(ISA, three_d_now_geode) { 310 ASSERT_FALSE(cpuinfo_has_x86_3dnow_geode()); 311 } 312 313 TEST(ISA, prefetch) { 314 ASSERT_FALSE(cpuinfo_has_x86_prefetch()); 315 } 316 317 TEST(ISA, prefetchw) { 318 ASSERT_FALSE(cpuinfo_has_x86_prefetchw()); 319 } 320 321 TEST(ISA, prefetchwt1) { 322 ASSERT_FALSE(cpuinfo_has_x86_prefetchwt1()); 323 } 324 325 TEST(ISA, daz) { 326 ASSERT_TRUE(cpuinfo_has_x86_daz()); 327 } 328 329 TEST(ISA, sse) { 330 ASSERT_TRUE(cpuinfo_has_x86_sse()); 331 } 332 333 TEST(ISA, sse2) { 334 ASSERT_TRUE(cpuinfo_has_x86_sse2()); 335 } 336 337 TEST(ISA, sse3) { 338 ASSERT_TRUE(cpuinfo_has_x86_sse3()); 339 } 340 341 TEST(ISA, ssse3) { 342 ASSERT_TRUE(cpuinfo_has_x86_ssse3()); 343 } 344 345 TEST(ISA, sse4_1) { 346 ASSERT_FALSE(cpuinfo_has_x86_sse4_1()); 347 } 348 349 TEST(ISA, sse4_2) { 350 ASSERT_FALSE(cpuinfo_has_x86_sse4_2()); 351 } 352 353 TEST(ISA, sse4a) { 354 ASSERT_FALSE(cpuinfo_has_x86_sse4a()); 355 } 356 357 TEST(ISA, misaligned_sse) { 358 ASSERT_FALSE(cpuinfo_has_x86_misaligned_sse()); 359 } 360 361 TEST(ISA, avx) { 362 ASSERT_FALSE(cpuinfo_has_x86_avx()); 363 } 364 365 TEST(ISA, fma3) { 366 ASSERT_FALSE(cpuinfo_has_x86_fma3()); 367 } 368 369 TEST(ISA, fma4) { 370 ASSERT_FALSE(cpuinfo_has_x86_fma4()); 371 } 372 373 TEST(ISA, xop) { 374 ASSERT_FALSE(cpuinfo_has_x86_xop()); 375 } 376 377 TEST(ISA, f16c) { 378 ASSERT_FALSE(cpuinfo_has_x86_f16c()); 379 } 380 381 TEST(ISA, avx2) { 382 ASSERT_FALSE(cpuinfo_has_x86_avx2()); 383 } 384 385 TEST(ISA, avx512f) { 386 ASSERT_FALSE(cpuinfo_has_x86_avx512f()); 387 } 388 389 TEST(ISA, avx512pf) { 390 ASSERT_FALSE(cpuinfo_has_x86_avx512pf()); 391 } 392 393 TEST(ISA, avx512er) { 394 ASSERT_FALSE(cpuinfo_has_x86_avx512er()); 395 } 396 397 TEST(ISA, avx512cd) { 398 ASSERT_FALSE(cpuinfo_has_x86_avx512cd()); 399 } 400 401 TEST(ISA, avx512dq) { 402 ASSERT_FALSE(cpuinfo_has_x86_avx512dq()); 403 } 404 405 TEST(ISA, avx512bw) { 406 ASSERT_FALSE(cpuinfo_has_x86_avx512bw()); 407 } 408 409 TEST(ISA, avx512vl) { 410 ASSERT_FALSE(cpuinfo_has_x86_avx512vl()); 411 } 412 413 TEST(ISA, avx512ifma) { 414 ASSERT_FALSE(cpuinfo_has_x86_avx512ifma()); 415 } 416 417 TEST(ISA, avx512vbmi) { 418 ASSERT_FALSE(cpuinfo_has_x86_avx512vbmi()); 419 } 420 421 TEST(ISA, avx512vpopcntdq) { 422 ASSERT_FALSE(cpuinfo_has_x86_avx512vpopcntdq()); 423 } 424 425 TEST(ISA, avx512_4vnniw) { 426 ASSERT_FALSE(cpuinfo_has_x86_avx512_4vnniw()); 427 } 428 429 TEST(ISA, avx512_4fmaps) { 430 ASSERT_FALSE(cpuinfo_has_x86_avx512_4fmaps()); 431 } 432 433 TEST(ISA, hle) { 434 ASSERT_FALSE(cpuinfo_has_x86_hle()); 435 } 436 437 TEST(ISA, rtm) { 438 ASSERT_FALSE(cpuinfo_has_x86_rtm()); 439 } 440 441 TEST(ISA, xtest) { 442 ASSERT_FALSE(cpuinfo_has_x86_xtest()); 443 } 444 445 TEST(ISA, mpx) { 446 ASSERT_FALSE(cpuinfo_has_x86_mpx()); 447 } 448 449 TEST(ISA, cmov) { 450 ASSERT_TRUE(cpuinfo_has_x86_cmov()); 451 } 452 453 TEST(ISA, cmpxchg8b) { 454 ASSERT_TRUE(cpuinfo_has_x86_cmpxchg8b()); 455 } 456 457 TEST(ISA, cmpxchg16b) { 458 ASSERT_FALSE(cpuinfo_has_x86_cmpxchg16b()); 459 } 460 461 TEST(ISA, clwb) { 462 ASSERT_FALSE(cpuinfo_has_x86_clwb()); 463 } 464 465 TEST(ISA, movbe) { 466 ASSERT_TRUE(cpuinfo_has_x86_movbe()); 467 } 468 469 TEST(ISA, lahf_sahf) { 470 ASSERT_TRUE(cpuinfo_has_x86_lahf_sahf()); 471 } 472 473 TEST(ISA, lzcnt) { 474 ASSERT_FALSE(cpuinfo_has_x86_lzcnt()); 475 } 476 477 TEST(ISA, popcnt) { 478 ASSERT_FALSE(cpuinfo_has_x86_popcnt()); 479 } 480 481 TEST(ISA, tbm) { 482 ASSERT_FALSE(cpuinfo_has_x86_tbm()); 483 } 484 485 TEST(ISA, bmi) { 486 ASSERT_FALSE(cpuinfo_has_x86_bmi()); 487 } 488 489 TEST(ISA, bmi2) { 490 ASSERT_FALSE(cpuinfo_has_x86_bmi2()); 491 } 492 493 TEST(ISA, adx) { 494 ASSERT_FALSE(cpuinfo_has_x86_adx()); 495 } 496 497 TEST(ISA, aes) { 498 ASSERT_FALSE(cpuinfo_has_x86_aes()); 499 } 500 501 TEST(ISA, pclmulqdq) { 502 ASSERT_FALSE(cpuinfo_has_x86_pclmulqdq()); 503 } 504 505 TEST(ISA, rdrand) { 506 ASSERT_FALSE(cpuinfo_has_x86_rdrand()); 507 } 508 509 TEST(ISA, rdseed) { 510 ASSERT_FALSE(cpuinfo_has_x86_rdseed()); 511 } 512 513 TEST(ISA, sha) { 514 ASSERT_FALSE(cpuinfo_has_x86_sha()); 515 } 516 517 TEST(L1I, count) { 518 ASSERT_EQ(2, cpuinfo_get_l1i_caches_count()); 519 } 520 521 TEST(L1I, non_null) { 522 ASSERT_TRUE(cpuinfo_get_l1i_caches()); 523 } 524 525 TEST(L1I, size) { 526 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 527 ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size); 528 } 529 } 530 531 TEST(L1I, associativity) { 532 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 533 ASSERT_EQ(8, cpuinfo_get_l1i_cache(i)->associativity); 534 } 535 } 536 537 TEST(L1I, sets) { 538 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 539 ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, 540 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); 541 } 542 } 543 544 TEST(L1I, partitions) { 545 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 546 ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); 547 } 548 } 549 550 TEST(L1I, line_size) { 551 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 552 ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); 553 } 554 } 555 556 TEST(L1I, flags) { 557 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 558 ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); 559 } 560 } 561 562 TEST(L1I, processors) { 563 for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { 564 ASSERT_EQ(i * 2, cpuinfo_get_l1i_cache(i)->processor_start); 565 ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->processor_count); 566 } 567 } 568 569 TEST(L1D, count) { 570 ASSERT_EQ(2, cpuinfo_get_l1d_caches_count()); 571 } 572 573 TEST(L1D, non_null) { 574 ASSERT_TRUE(cpuinfo_get_l1d_caches()); 575 } 576 577 TEST(L1D, size) { 578 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 579 ASSERT_EQ(24 * 1024, cpuinfo_get_l1d_cache(i)->size); 580 } 581 } 582 583 TEST(L1D, associativity) { 584 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 585 ASSERT_EQ(6, cpuinfo_get_l1d_cache(i)->associativity); 586 } 587 } 588 589 TEST(L1D, sets) { 590 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 591 ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, 592 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); 593 } 594 } 595 596 TEST(L1D, partitions) { 597 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 598 ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); 599 } 600 } 601 602 TEST(L1D, line_size) { 603 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 604 ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); 605 } 606 } 607 608 TEST(L1D, flags) { 609 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 610 ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); 611 } 612 } 613 614 TEST(L1D, processors) { 615 for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { 616 ASSERT_EQ(i * 2, cpuinfo_get_l1d_cache(i)->processor_start); 617 ASSERT_EQ(2, cpuinfo_get_l1d_cache(i)->processor_count); 618 } 619 } 620 621 TEST(L2, count) { 622 ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); 623 } 624 625 TEST(L2, non_null) { 626 ASSERT_TRUE(cpuinfo_get_l2_caches()); 627 } 628 629 TEST(L2, size) { 630 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 631 ASSERT_EQ(512 * 1024, cpuinfo_get_l2_cache(i)->size); 632 } 633 } 634 635 TEST(L2, associativity) { 636 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 637 ASSERT_EQ(8, cpuinfo_get_l2_cache(i)->associativity); 638 } 639 } 640 641 TEST(L2, sets) { 642 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 643 ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, 644 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); 645 } 646 } 647 648 TEST(L2, partitions) { 649 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 650 ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); 651 } 652 } 653 654 TEST(L2, line_size) { 655 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 656 ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); 657 } 658 } 659 660 TEST(L2, flags) { 661 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 662 ASSERT_EQ(CPUINFO_CACHE_UNIFIED, cpuinfo_get_l2_cache(i)->flags); 663 } 664 } 665 666 TEST(L2, processors) { 667 for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { 668 ASSERT_EQ(i * 2, cpuinfo_get_l2_cache(i)->processor_start); 669 ASSERT_EQ(2, cpuinfo_get_l2_cache(i)->processor_count); 670 } 671 } 672 673 TEST(L3, none) { 674 ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); 675 ASSERT_FALSE(cpuinfo_get_l3_caches()); 676 } 677 678 TEST(L4, none) { 679 ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); 680 ASSERT_FALSE(cpuinfo_get_l4_caches()); 681 } 682 683 #include <zenfone-2e.h> 684 685 int main(int argc, char* argv[]) { 686 cpuinfo_mock_filesystem(filesystem); 687 cpuinfo_mock_set_cpuid(cpuid_dump, sizeof(cpuid_dump) / sizeof(cpuinfo_mock_cpuid)); 688 cpuinfo_initialize(); 689 ::testing::InitGoogleTest(&argc, argv); 690 return RUN_ALL_TESTS(); 691 } 692