Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [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 | b589f1f | 2017-10-19 12:02:00 -0700 | [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 | b589f1f | 2017-10-19 12:02:00 -0700 | [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 | switch (i) { |
| 174 | case 0: |
| 175 | case 1: |
| 176 | case 2: |
| 177 | case 3: |
| 178 | ASSERT_EQ(cpuinfo_uarch_cortex_a73, cpuinfo_get_core(i)->uarch); |
| 179 | break; |
| 180 | case 4: |
| 181 | case 5: |
| 182 | case 6: |
| 183 | case 7: |
| 184 | ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_core(i)->uarch); |
| 185 | break; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | TEST(CORES, midr) { |
| 191 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 192 | switch (i) { |
| 193 | case 0: |
| 194 | case 1: |
| 195 | case 2: |
| 196 | case 3: |
| 197 | ASSERT_EQ(UINT32_C(0x410FD091), cpuinfo_get_core(i)->midr); |
| 198 | break; |
| 199 | case 4: |
| 200 | case 5: |
| 201 | case 6: |
| 202 | case 7: |
| 203 | ASSERT_EQ(UINT32_C(0x410FD034), cpuinfo_get_core(i)->midr); |
| 204 | break; |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
Marat Dukhan | 575a630 | 2018-03-10 14:38:49 -0800 | [diff] [blame] | 209 | TEST(CORES, DISABLED_frequency) { |
| 210 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 211 | switch (i) { |
| 212 | case 0: |
| 213 | case 1: |
| 214 | case 2: |
| 215 | case 3: |
| 216 | ASSERT_EQ(UINT64_C(2362000000), cpuinfo_get_core(i)->frequency); |
| 217 | break; |
| 218 | case 4: |
| 219 | case 5: |
| 220 | case 6: |
| 221 | case 7: |
| 222 | ASSERT_EQ(UINT64_C(1844000000), cpuinfo_get_core(i)->frequency); |
| 223 | break; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
Marat Dukhan | dbc7840 | 2018-03-18 22:49:35 -0700 | [diff] [blame^] | 228 | TEST(CLUSTERS, count) { |
| 229 | ASSERT_EQ(2, cpuinfo_get_clusters_count()); |
| 230 | } |
| 231 | |
| 232 | TEST(CLUSTERS, non_null) { |
| 233 | ASSERT_TRUE(cpuinfo_get_clusters()); |
| 234 | } |
| 235 | |
| 236 | TEST(CLUSTERS, processor_start) { |
| 237 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 238 | switch (i) { |
| 239 | case 0: |
| 240 | ASSERT_EQ(0, cpuinfo_get_cluster(i)->processor_start); |
| 241 | break; |
| 242 | case 1: |
| 243 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->processor_start); |
| 244 | break; |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | TEST(CLUSTERS, processor_count) { |
| 250 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 251 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->processor_count); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | TEST(CLUSTERS, core_start) { |
| 256 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 257 | switch (i) { |
| 258 | case 0: |
| 259 | ASSERT_EQ(0, cpuinfo_get_cluster(i)->core_start); |
| 260 | break; |
| 261 | case 1: |
| 262 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->core_start); |
| 263 | break; |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | TEST(CLUSTERS, core_count) { |
| 269 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 270 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->core_count); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | TEST(CLUSTERS, cluster_id) { |
| 275 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 276 | ASSERT_EQ(i, cpuinfo_get_cluster(i)->cluster_id); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | TEST(CLUSTERS, package) { |
| 281 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 282 | ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_cluster(i)->package); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | TEST(CLUSTERS, vendor) { |
| 287 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 288 | ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_cluster(i)->vendor); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | TEST(CLUSTERS, uarch) { |
| 293 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 294 | switch (i) { |
| 295 | case 0: |
| 296 | ASSERT_EQ(cpuinfo_uarch_cortex_a73, cpuinfo_get_cluster(i)->uarch); |
| 297 | break; |
| 298 | case 1: |
| 299 | ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_cluster(i)->uarch); |
| 300 | break; |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | TEST(CLUSTERS, midr) { |
| 306 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 307 | switch (i) { |
| 308 | case 0: |
| 309 | ASSERT_EQ(UINT32_C(0x410FD091), cpuinfo_get_cluster(i)->midr); |
| 310 | break; |
| 311 | case 1: |
| 312 | ASSERT_EQ(UINT32_C(0x410FD034), cpuinfo_get_cluster(i)->midr); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | TEST(CLUSTERS, DISABLED_frequency) { |
| 319 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 320 | switch (i) { |
| 321 | case 0: |
| 322 | ASSERT_EQ(UINT64_C(2362000000), cpuinfo_get_cluster(i)->frequency); |
| 323 | break; |
| 324 | case 1: |
| 325 | ASSERT_EQ(UINT64_C(1844000000), cpuinfo_get_cluster(i)->frequency); |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 331 | TEST(PACKAGES, count) { |
| 332 | ASSERT_EQ(1, cpuinfo_get_packages_count()); |
| 333 | } |
| 334 | |
| 335 | TEST(PACKAGES, name) { |
| 336 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 337 | ASSERT_EQ("HiSilicon Kirin 960", |
| 338 | std::string(cpuinfo_get_package(i)->name, |
| 339 | strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); |
| 340 | } |
| 341 | } |
| 342 | |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 343 | TEST(PACKAGES, gpu_name) { |
| 344 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 345 | ASSERT_EQ("ARM Mali-G71", |
| 346 | std::string(cpuinfo_get_package(i)->gpu_name, |
| 347 | strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX))); |
| 348 | } |
| 349 | } |
| 350 | |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 351 | TEST(PACKAGES, processor_start) { |
| 352 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 353 | ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | TEST(PACKAGES, processor_count) { |
| 358 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 359 | ASSERT_EQ(8, cpuinfo_get_package(i)->processor_count); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | TEST(PACKAGES, core_start) { |
| 364 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 365 | ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | TEST(PACKAGES, core_count) { |
| 370 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 371 | ASSERT_EQ(8, cpuinfo_get_package(i)->core_count); |
| 372 | } |
| 373 | } |
| 374 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame] | 375 | TEST(PACKAGES, cluster_start) { |
| 376 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 377 | ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | TEST(PACKAGES, cluster_count) { |
| 382 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 383 | ASSERT_EQ(2, cpuinfo_get_package(i)->cluster_count); |
| 384 | } |
| 385 | } |
| 386 | |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 387 | TEST(ISA, thumb) { |
| 388 | #if CPUINFO_ARCH_ARM |
| 389 | ASSERT_TRUE(cpuinfo_has_arm_thumb()); |
| 390 | #elif CPUINFO_ARCH_ARM64 |
| 391 | ASSERT_FALSE(cpuinfo_has_arm_thumb()); |
| 392 | #endif |
| 393 | } |
| 394 | |
| 395 | TEST(ISA, thumb2) { |
| 396 | #if CPUINFO_ARCH_ARM |
| 397 | ASSERT_TRUE(cpuinfo_has_arm_thumb2()); |
| 398 | #elif CPUINFO_ARCH_ARM64 |
| 399 | ASSERT_FALSE(cpuinfo_has_arm_thumb2()); |
| 400 | #endif |
| 401 | } |
| 402 | |
| 403 | TEST(ISA, armv5e) { |
| 404 | #if CPUINFO_ARCH_ARM |
| 405 | ASSERT_TRUE(cpuinfo_has_arm_v5e()); |
| 406 | #elif CPUINFO_ARCH_ARM64 |
| 407 | ASSERT_FALSE(cpuinfo_has_arm_v5e()); |
| 408 | #endif |
| 409 | } |
| 410 | |
| 411 | TEST(ISA, armv6) { |
| 412 | #if CPUINFO_ARCH_ARM |
| 413 | ASSERT_TRUE(cpuinfo_has_arm_v6()); |
| 414 | #elif CPUINFO_ARCH_ARM64 |
| 415 | ASSERT_FALSE(cpuinfo_has_arm_v6()); |
| 416 | #endif |
| 417 | } |
| 418 | |
| 419 | TEST(ISA, armv6k) { |
| 420 | #if CPUINFO_ARCH_ARM |
| 421 | ASSERT_TRUE(cpuinfo_has_arm_v6k()); |
| 422 | #elif CPUINFO_ARCH_ARM64 |
| 423 | ASSERT_FALSE(cpuinfo_has_arm_v6k()); |
| 424 | #endif |
| 425 | } |
| 426 | |
| 427 | TEST(ISA, armv7) { |
| 428 | #if CPUINFO_ARCH_ARM |
| 429 | ASSERT_TRUE(cpuinfo_has_arm_v7()); |
| 430 | #elif CPUINFO_ARCH_ARM64 |
| 431 | ASSERT_FALSE(cpuinfo_has_arm_v7()); |
| 432 | #endif |
| 433 | } |
| 434 | |
| 435 | TEST(ISA, armv7mp) { |
| 436 | #if CPUINFO_ARCH_ARM |
| 437 | ASSERT_TRUE(cpuinfo_has_arm_v7mp()); |
| 438 | #elif CPUINFO_ARCH_ARM64 |
| 439 | ASSERT_FALSE(cpuinfo_has_arm_v7mp()); |
| 440 | #endif |
| 441 | } |
| 442 | |
| 443 | TEST(ISA, idiv) { |
| 444 | ASSERT_TRUE(cpuinfo_has_arm_idiv()); |
| 445 | } |
| 446 | |
| 447 | TEST(ISA, vfpv2) { |
| 448 | ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); |
| 449 | } |
| 450 | |
| 451 | TEST(ISA, vfpv3) { |
| 452 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); |
| 453 | } |
| 454 | |
| 455 | TEST(ISA, vfpv3_d32) { |
| 456 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); |
| 457 | } |
| 458 | |
| 459 | TEST(ISA, vfpv3_fp16) { |
| 460 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); |
| 461 | } |
| 462 | |
| 463 | TEST(ISA, vfpv3_fp16_d32) { |
| 464 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); |
| 465 | } |
| 466 | |
| 467 | TEST(ISA, vfpv4) { |
| 468 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); |
| 469 | } |
| 470 | |
| 471 | TEST(ISA, vfpv4_d32) { |
| 472 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); |
| 473 | } |
| 474 | |
| 475 | TEST(ISA, wmmx) { |
| 476 | ASSERT_FALSE(cpuinfo_has_arm_wmmx()); |
| 477 | } |
| 478 | |
| 479 | TEST(ISA, wmmx2) { |
| 480 | ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); |
| 481 | } |
| 482 | |
| 483 | TEST(ISA, neon) { |
| 484 | ASSERT_TRUE(cpuinfo_has_arm_neon()); |
| 485 | } |
| 486 | |
| 487 | TEST(ISA, neon_fp16) { |
| 488 | ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); |
| 489 | } |
| 490 | |
| 491 | TEST(ISA, neon_fma) { |
| 492 | ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); |
| 493 | } |
| 494 | |
| 495 | TEST(ISA, atomics) { |
| 496 | ASSERT_FALSE(cpuinfo_has_arm_atomics()); |
| 497 | } |
| 498 | |
| 499 | TEST(ISA, neon_rdm) { |
| 500 | ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); |
| 501 | } |
| 502 | |
| 503 | TEST(ISA, fp16_arith) { |
| 504 | ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); |
| 505 | } |
| 506 | |
| 507 | TEST(ISA, jscvt) { |
| 508 | ASSERT_FALSE(cpuinfo_has_arm_jscvt()); |
| 509 | } |
| 510 | |
| 511 | TEST(ISA, fcma) { |
| 512 | ASSERT_FALSE(cpuinfo_has_arm_fcma()); |
| 513 | } |
| 514 | |
| 515 | TEST(ISA, aes) { |
| 516 | ASSERT_TRUE(cpuinfo_has_arm_aes()); |
| 517 | } |
| 518 | |
| 519 | TEST(ISA, sha1) { |
| 520 | ASSERT_TRUE(cpuinfo_has_arm_sha1()); |
| 521 | } |
| 522 | |
| 523 | TEST(ISA, sha2) { |
| 524 | ASSERT_TRUE(cpuinfo_has_arm_sha2()); |
| 525 | } |
| 526 | |
| 527 | TEST(ISA, pmull) { |
| 528 | ASSERT_TRUE(cpuinfo_has_arm_pmull()); |
| 529 | } |
| 530 | |
| 531 | TEST(ISA, crc32) { |
| 532 | ASSERT_TRUE(cpuinfo_has_arm_crc32()); |
| 533 | } |
| 534 | |
| 535 | TEST(L1I, count) { |
| 536 | ASSERT_EQ(8, cpuinfo_get_l1i_caches_count()); |
| 537 | } |
| 538 | |
| 539 | TEST(L1I, non_null) { |
| 540 | ASSERT_TRUE(cpuinfo_get_l1i_caches()); |
| 541 | } |
| 542 | |
| 543 | TEST(L1I, size) { |
| 544 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 545 | switch (i) { |
| 546 | case 0: |
| 547 | case 1: |
| 548 | case 2: |
| 549 | case 3: |
| 550 | ASSERT_EQ(64 * 1024, cpuinfo_get_l1i_cache(i)->size); |
| 551 | break; |
| 552 | case 4: |
| 553 | case 5: |
| 554 | case 6: |
| 555 | case 7: |
| 556 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size); |
| 557 | break; |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | TEST(L1I, associativity) { |
| 563 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 564 | switch (i) { |
| 565 | case 0: |
| 566 | case 1: |
| 567 | case 2: |
| 568 | case 3: |
| 569 | ASSERT_EQ(4, cpuinfo_get_l1i_cache(i)->associativity); |
| 570 | break; |
| 571 | case 4: |
| 572 | case 5: |
| 573 | case 6: |
| 574 | case 7: |
| 575 | ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity); |
| 576 | break; |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | TEST(L1I, sets) { |
| 582 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 583 | ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, |
| 584 | 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); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | TEST(L1I, partitions) { |
| 589 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 590 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | TEST(L1I, line_size) { |
| 595 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 596 | ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | TEST(L1I, flags) { |
| 601 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 602 | ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | TEST(L1I, processors) { |
| 607 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 608 | ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); |
| 609 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | TEST(L1D, count) { |
| 614 | ASSERT_EQ(8, cpuinfo_get_l1d_caches_count()); |
| 615 | } |
| 616 | |
| 617 | TEST(L1D, non_null) { |
| 618 | ASSERT_TRUE(cpuinfo_get_l1d_caches()); |
| 619 | } |
| 620 | |
| 621 | TEST(L1D, size) { |
| 622 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 623 | switch (i) { |
| 624 | case 0: |
| 625 | case 1: |
| 626 | case 2: |
| 627 | case 3: |
| 628 | ASSERT_EQ(64 * 1024, cpuinfo_get_l1d_cache(i)->size); |
| 629 | break; |
| 630 | case 4: |
| 631 | case 5: |
| 632 | case 6: |
| 633 | case 7: |
| 634 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1d_cache(i)->size); |
| 635 | break; |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | TEST(L1D, associativity) { |
| 641 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 642 | switch (i) { |
| 643 | case 0: |
| 644 | case 1: |
| 645 | case 2: |
| 646 | case 3: |
| 647 | ASSERT_EQ(16, cpuinfo_get_l1d_cache(i)->associativity); |
| 648 | break; |
| 649 | case 4: |
| 650 | case 5: |
| 651 | case 6: |
| 652 | case 7: |
| 653 | ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); |
| 654 | break; |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | TEST(L1D, sets) { |
| 660 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 661 | ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, |
| 662 | 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); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | TEST(L1D, partitions) { |
| 667 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 668 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | TEST(L1D, line_size) { |
| 673 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 674 | ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | TEST(L1D, flags) { |
| 679 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 680 | ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | TEST(L1D, processors) { |
| 685 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 686 | ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); |
| 687 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | TEST(L2, count) { |
| 692 | ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); |
| 693 | } |
| 694 | |
| 695 | TEST(L2, non_null) { |
| 696 | ASSERT_TRUE(cpuinfo_get_l2_caches()); |
| 697 | } |
| 698 | |
| 699 | TEST(L2, size) { |
| 700 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 701 | switch (i) { |
| 702 | case 0: |
Marat Dukhan | 89d1e6c | 2017-11-20 14:43:44 +0300 | [diff] [blame] | 703 | ASSERT_EQ(2 * 1024 * 1024, cpuinfo_get_l2_cache(i)->size); |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 704 | break; |
| 705 | case 1: |
| 706 | ASSERT_EQ(512 * 1024, cpuinfo_get_l2_cache(i)->size); |
| 707 | break; |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | TEST(L2, associativity) { |
| 713 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 714 | ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | TEST(L2, sets) { |
| 719 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 720 | ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, |
| 721 | 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); |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | TEST(L2, partitions) { |
| 726 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 727 | ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | TEST(L2, line_size) { |
| 732 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 733 | ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | TEST(L2, flags) { |
| 738 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 739 | switch (i) { |
| 740 | case 0: |
| 741 | ASSERT_EQ(CPUINFO_CACHE_INCLUSIVE, cpuinfo_get_l2_cache(i)->flags); |
| 742 | break; |
| 743 | case 1: |
| 744 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); |
| 745 | break; |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | TEST(L2, processors) { |
| 751 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 752 | switch (i) { |
| 753 | case 0: |
| 754 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); |
| 755 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
| 756 | break; |
| 757 | case 1: |
| 758 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_start); |
| 759 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
| 760 | break; |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | TEST(L3, none) { |
| 766 | ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); |
| 767 | ASSERT_FALSE(cpuinfo_get_l3_caches()); |
| 768 | } |
| 769 | |
| 770 | TEST(L4, none) { |
| 771 | ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); |
| 772 | ASSERT_FALSE(cpuinfo_get_l4_caches()); |
| 773 | } |
| 774 | |
| 775 | #include <huawei-mate-9.h> |
| 776 | |
| 777 | int main(int argc, char* argv[]) { |
Marat Dukhan | 63a7a6b | 2017-11-29 15:11:56 -0800 | [diff] [blame] | 778 | #if CPUINFO_ARCH_ARM |
| 779 | cpuinfo_set_hwcap(UINT32_C(0x0037B0D6)); |
| 780 | cpuinfo_set_hwcap2(UINT32_C(0x0000001F)); |
| 781 | #elif CPUINFO_ARCH_ARM64 |
| 782 | cpuinfo_set_hwcap(UINT32_C(0x000000FF)); |
| 783 | #endif |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 784 | cpuinfo_mock_filesystem(filesystem); |
| 785 | #ifdef __ANDROID__ |
| 786 | cpuinfo_mock_android_properties(properties); |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 787 | cpuinfo_mock_gl_renderer("Mali-G71"); |
Marat Dukhan | b589f1f | 2017-10-19 12:02:00 -0700 | [diff] [blame] | 788 | #endif |
| 789 | cpuinfo_initialize(); |
| 790 | ::testing::InitGoogleTest(&argc, argv); |
| 791 | return RUN_ALL_TESTS(); |
| 792 | } |