Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
| 2 | |
| 3 | #include <cpuinfo.h> |
| 4 | #include <cpuinfo-mock.h> |
| 5 | |
| 6 | |
| 7 | TEST(PROCESSORS, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 8 | ASSERT_EQ(8, cpuinfo_get_processors_count()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | TEST(PROCESSORS, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 12 | ASSERT_TRUE(cpuinfo_get_processors()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 13 | } |
| 14 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 15 | TEST(PROCESSORS, smt_id) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 16 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
| 17 | ASSERT_EQ(0, cpuinfo_get_processor(i)->smt_id); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 18 | } |
| 19 | } |
| 20 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 21 | TEST(PROCESSORS, core) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 22 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
| 23 | ASSERT_EQ(cpuinfo_get_core(i), cpuinfo_get_processor(i)->core); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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 | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 46 | TEST(PROCESSORS, package) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 47 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
| 48 | ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_processor(i)->package); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Marat Dukhan | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 52 | TEST(PROCESSORS, linux_id) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 53 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
Marat Dukhan | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 54 | switch (i) { |
| 55 | case 0: |
| 56 | case 1: |
| 57 | case 2: |
| 58 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 59 | ASSERT_EQ(i + 4, cpuinfo_get_processor(i)->linux_id); |
Marat Dukhan | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 60 | break; |
| 61 | case 4: |
| 62 | case 5: |
| 63 | case 6: |
| 64 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 65 | ASSERT_EQ(i - 4, cpuinfo_get_processor(i)->linux_id); |
Marat Dukhan | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 66 | break; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 71 | TEST(PROCESSORS, l1i) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 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); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 74 | } |
| 75 | } |
| 76 | |
| 77 | TEST(PROCESSORS, l1d) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 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); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | TEST(PROCESSORS, l2) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 84 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 85 | switch (i) { |
| 86 | case 0: |
| 87 | case 1: |
| 88 | case 2: |
| 89 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 90 | ASSERT_EQ(cpuinfo_get_l2_cache(0), cpuinfo_get_processor(i)->cache.l2); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 91 | break; |
| 92 | case 4: |
| 93 | case 5: |
| 94 | case 6: |
| 95 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 96 | ASSERT_EQ(cpuinfo_get_l2_cache(1), cpuinfo_get_processor(i)->cache.l2); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 97 | break; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | TEST(PROCESSORS, l3) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 103 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
| 104 | ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l3); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 105 | } |
| 106 | } |
| 107 | |
| 108 | TEST(PROCESSORS, l4) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 109 | for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { |
| 110 | ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l4); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 111 | } |
| 112 | } |
| 113 | |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 114 | TEST(CORES, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 115 | ASSERT_EQ(8, cpuinfo_get_cores_count()); |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 118 | TEST(CORES, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 119 | ASSERT_TRUE(cpuinfo_get_cores()); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 122 | TEST(CORES, processor_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 123 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 124 | ASSERT_EQ(i, cpuinfo_get_core(i)->processor_start); |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
| 128 | TEST(CORES, processor_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 129 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 130 | ASSERT_EQ(1, cpuinfo_get_core(i)->processor_count); |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 134 | TEST(CORES, core_id) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 135 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 136 | ASSERT_EQ(i, cpuinfo_get_core(i)->core_id); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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 | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 159 | TEST(CORES, package) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 160 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 161 | ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_core(i)->package); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
| 165 | TEST(CORES, vendor) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 166 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 167 | ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_core(i)->vendor); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | TEST(CORES, uarch) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 172 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 173 | switch (i) { |
| 174 | case 0: |
| 175 | case 1: |
| 176 | case 2: |
| 177 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 178 | ASSERT_EQ(cpuinfo_uarch_cortex_a15, cpuinfo_get_core(i)->uarch); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 179 | break; |
| 180 | case 4: |
| 181 | case 5: |
| 182 | case 6: |
| 183 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 184 | ASSERT_EQ(cpuinfo_uarch_cortex_a7, cpuinfo_get_core(i)->uarch); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 185 | break; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | TEST(CORES, midr) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 191 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 192 | switch (i) { |
| 193 | case 0: |
| 194 | case 1: |
| 195 | case 2: |
| 196 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 197 | ASSERT_EQ(UINT32_C(0x412FC0F3), cpuinfo_get_core(i)->midr); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 198 | break; |
| 199 | case 4: |
| 200 | case 5: |
| 201 | case 6: |
| 202 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 203 | ASSERT_EQ(UINT32_C(0x410FC073), cpuinfo_get_core(i)->midr); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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(1900000000), cpuinfo_get_core(i)->frequency); |
| 217 | break; |
| 218 | case 4: |
| 219 | case 5: |
| 220 | case 6: |
| 221 | case 7: |
| 222 | ASSERT_EQ(UINT64_C(1300000000), 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_a15, cpuinfo_get_cluster(i)->uarch); |
| 297 | break; |
| 298 | case 1: |
| 299 | ASSERT_EQ(cpuinfo_uarch_cortex_a7, 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(0x412FC0F3), cpuinfo_get_cluster(i)->midr); |
| 310 | break; |
| 311 | case 1: |
| 312 | ASSERT_EQ(UINT32_C(0x410FC073), 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(1900000000), cpuinfo_get_cluster(i)->frequency); |
| 323 | break; |
| 324 | case 1: |
| 325 | ASSERT_EQ(UINT64_C(1300000000), cpuinfo_get_cluster(i)->frequency); |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 331 | TEST(PACKAGES, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 332 | ASSERT_EQ(1, cpuinfo_get_packages_count()); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | TEST(PACKAGES, name) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 336 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 337 | ASSERT_EQ("Samsung Exynos 5422", |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 338 | std::string(cpuinfo_get_package(i)->name, |
| 339 | strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 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-T628", |
| 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 | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 351 | TEST(PACKAGES, processor_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 352 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 353 | ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | TEST(PACKAGES, processor_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 358 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 359 | ASSERT_EQ(8, cpuinfo_get_package(i)->processor_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
| 363 | TEST(PACKAGES, core_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 364 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 365 | ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 366 | } |
| 367 | } |
| 368 | |
| 369 | TEST(PACKAGES, core_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 370 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 371 | ASSERT_EQ(8, cpuinfo_get_package(i)->core_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 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 | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 387 | TEST(ISA, thumb) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 388 | ASSERT_TRUE(cpuinfo_has_arm_thumb()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | TEST(ISA, thumb2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 392 | ASSERT_TRUE(cpuinfo_has_arm_thumb2()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | TEST(ISA, armv5e) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 396 | ASSERT_TRUE(cpuinfo_has_arm_v5e()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | TEST(ISA, armv6) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 400 | ASSERT_TRUE(cpuinfo_has_arm_v6()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | TEST(ISA, armv6k) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 404 | ASSERT_TRUE(cpuinfo_has_arm_v6k()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | TEST(ISA, armv7) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 408 | ASSERT_TRUE(cpuinfo_has_arm_v7()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | TEST(ISA, armv7mp) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 412 | ASSERT_TRUE(cpuinfo_has_arm_v7mp()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | TEST(ISA, idiv) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 416 | ASSERT_TRUE(cpuinfo_has_arm_idiv()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | TEST(ISA, vfpv2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 420 | ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | TEST(ISA, vfpv3) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 424 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 427 | TEST(ISA, vfpv3_d32) { |
| 428 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 431 | TEST(ISA, vfpv3_fp16) { |
| 432 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 435 | TEST(ISA, vfpv3_fp16_d32) { |
| 436 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); |
| 437 | } |
| 438 | |
| 439 | TEST(ISA, vfpv4) { |
| 440 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); |
| 441 | } |
| 442 | |
| 443 | TEST(ISA, vfpv4_d32) { |
| 444 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | TEST(ISA, wmmx) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 448 | ASSERT_FALSE(cpuinfo_has_arm_wmmx()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | TEST(ISA, wmmx2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 452 | ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | TEST(ISA, neon) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 456 | ASSERT_TRUE(cpuinfo_has_arm_neon()); |
| 457 | } |
| 458 | |
| 459 | TEST(ISA, neon_fp16) { |
| 460 | ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); |
| 461 | } |
| 462 | |
| 463 | TEST(ISA, neon_fma) { |
| 464 | ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); |
| 465 | } |
| 466 | |
| 467 | TEST(ISA, atomics) { |
| 468 | ASSERT_FALSE(cpuinfo_has_arm_atomics()); |
| 469 | } |
| 470 | |
| 471 | TEST(ISA, neon_rdm) { |
| 472 | ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); |
| 473 | } |
| 474 | |
| 475 | TEST(ISA, fp16_arith) { |
| 476 | ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); |
| 477 | } |
| 478 | |
| 479 | TEST(ISA, jscvt) { |
| 480 | ASSERT_FALSE(cpuinfo_has_arm_jscvt()); |
| 481 | } |
| 482 | |
| 483 | TEST(ISA, fcma) { |
| 484 | ASSERT_FALSE(cpuinfo_has_arm_fcma()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | TEST(ISA, aes) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 488 | ASSERT_FALSE(cpuinfo_has_arm_aes()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | TEST(ISA, sha1) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 492 | ASSERT_FALSE(cpuinfo_has_arm_sha1()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | TEST(ISA, sha2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 496 | ASSERT_FALSE(cpuinfo_has_arm_sha2()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | TEST(ISA, pmull) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 500 | ASSERT_FALSE(cpuinfo_has_arm_pmull()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | TEST(ISA, crc32) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 504 | ASSERT_FALSE(cpuinfo_has_arm_crc32()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | TEST(L1I, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 508 | ASSERT_EQ(8, cpuinfo_get_l1i_caches_count()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | TEST(L1I, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 512 | ASSERT_TRUE(cpuinfo_get_l1i_caches()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | TEST(L1I, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 516 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 517 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | |
| 521 | TEST(L1I, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 522 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 523 | ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
| 527 | TEST(L1I, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 528 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 529 | ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, |
| 530 | 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 Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
| 534 | TEST(L1I, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 535 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 536 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 537 | } |
| 538 | } |
| 539 | |
| 540 | TEST(L1I, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 541 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 542 | switch (i) { |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 543 | case 0: |
| 544 | case 1: |
| 545 | case 2: |
| 546 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 547 | ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 548 | break; |
| 549 | case 4: |
| 550 | case 5: |
| 551 | case 6: |
| 552 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 553 | ASSERT_EQ(32, cpuinfo_get_l1i_cache(i)->line_size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 554 | break; |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | TEST(L1I, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 560 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 561 | ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 562 | } |
| 563 | } |
| 564 | |
| 565 | TEST(L1I, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 566 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 567 | ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); |
| 568 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | |
| 572 | TEST(L1D, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 573 | ASSERT_EQ(8, cpuinfo_get_l1d_caches_count()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | TEST(L1D, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 577 | ASSERT_TRUE(cpuinfo_get_l1d_caches()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | TEST(L1D, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 581 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 582 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1d_cache(i)->size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 583 | } |
| 584 | } |
| 585 | |
| 586 | TEST(L1D, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 587 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 588 | switch (i) { |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 589 | case 0: |
| 590 | case 1: |
| 591 | case 2: |
| 592 | case 3: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 593 | ASSERT_EQ(2, cpuinfo_get_l1d_cache(i)->associativity); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 594 | break; |
| 595 | case 4: |
| 596 | case 5: |
| 597 | case 6: |
| 598 | case 7: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 599 | ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 600 | break; |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | TEST(L1D, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 606 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 607 | ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, |
| 608 | 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 Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 609 | } |
| 610 | } |
| 611 | |
| 612 | TEST(L1D, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 613 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 614 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | |
| 618 | TEST(L1D, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 619 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 620 | ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
| 624 | TEST(L1D, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 625 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 626 | ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
| 630 | TEST(L1D, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 631 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 632 | ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); |
| 633 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 634 | } |
| 635 | } |
| 636 | |
| 637 | TEST(L2, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 638 | ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | TEST(L2, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 642 | ASSERT_TRUE(cpuinfo_get_l2_caches()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | TEST(L2, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 646 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 647 | switch (i) { |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 648 | case 0: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 649 | ASSERT_EQ(2 * 1024 * 1024, cpuinfo_get_l2_cache(i)->size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 650 | break; |
| 651 | case 1: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 652 | ASSERT_EQ(512 * 1024, cpuinfo_get_l2_cache(i)->size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 653 | break; |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | TEST(L2, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 659 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 660 | switch (i) { |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 661 | case 0: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 662 | ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 663 | break; |
| 664 | case 1: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 665 | ASSERT_EQ(8, cpuinfo_get_l2_cache(i)->associativity); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 666 | break; |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | TEST(L2, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 672 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 673 | ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, |
| 674 | 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 Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | |
| 678 | TEST(L2, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 679 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 680 | ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 681 | } |
| 682 | } |
| 683 | |
| 684 | TEST(L2, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 685 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 686 | ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 687 | } |
| 688 | } |
| 689 | |
| 690 | TEST(L2, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 691 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 692 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | |
| 696 | TEST(L2, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 697 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 698 | switch (i) { |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 699 | case 0: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 700 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); |
| 701 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 702 | break; |
| 703 | case 1: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 704 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_start); |
| 705 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 706 | break; |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | TEST(L3, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 712 | ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); |
| 713 | ASSERT_FALSE(cpuinfo_get_l3_caches()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | TEST(L4, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 717 | ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); |
| 718 | ASSERT_FALSE(cpuinfo_get_l4_caches()); |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | #include <galaxy-s5-global.h> |
| 722 | |
| 723 | int main(int argc, char* argv[]) { |
Marat Dukhan | 63a7a6b | 2017-11-29 15:11:56 -0800 | [diff] [blame] | 724 | #if CPUINFO_ARCH_ARM |
| 725 | cpuinfo_set_hwcap(UINT32_C(0x0007B0D7)); |
| 726 | #endif |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 727 | cpuinfo_mock_filesystem(filesystem); |
Marat Dukhan | d156525 | 2017-09-12 00:29:01 -0700 | [diff] [blame] | 728 | #ifdef __ANDROID__ |
| 729 | cpuinfo_mock_android_properties(properties); |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 730 | cpuinfo_mock_gl_renderer("Mali-T628"); |
Marat Dukhan | d156525 | 2017-09-12 00:29:01 -0700 | [diff] [blame] | 731 | #endif |
Marat Dukhan | e1f62e5 | 2017-09-08 17:11:08 -0700 | [diff] [blame] | 732 | cpuinfo_initialize(); |
| 733 | ::testing::InitGoogleTest(&argc, argv); |
| 734 | return RUN_ALL_TESTS(); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 735 | } |