Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -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 | 2f3950c | 2017-09-08 18:25:26 -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 | 2f3950c | 2017-09-08 18:25:26 -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 | 2f3950c | 2017-09-08 18:25:26 -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 | 2f3950c | 2017-09-08 18:25:26 -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++) { |
| 173 | ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_core(i)->uarch); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | |
| 177 | TEST(CORES, midr) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 178 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 179 | ASSERT_EQ(UINT32_C(0x410FD033), cpuinfo_get_core(i)->midr); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
Marat Dukhan | 575a630 | 2018-03-10 14:38:49 -0800 | [diff] [blame] | 183 | TEST(CORES, DISABLED_frequency) { |
| 184 | for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { |
| 185 | ASSERT_EQ(UINT32_C(1500000000), cpuinfo_get_core(i)->frequency); |
| 186 | } |
| 187 | } |
| 188 | |
Marat Dukhan | dbc7840 | 2018-03-18 22:49:35 -0700 | [diff] [blame^] | 189 | TEST(CLUSTERS, count) { |
| 190 | ASSERT_EQ(2, cpuinfo_get_clusters_count()); |
| 191 | } |
| 192 | |
| 193 | TEST(CLUSTERS, non_null) { |
| 194 | ASSERT_TRUE(cpuinfo_get_clusters()); |
| 195 | } |
| 196 | |
| 197 | TEST(CLUSTERS, processor_start) { |
| 198 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 199 | switch (i) { |
| 200 | case 0: |
| 201 | ASSERT_EQ(0, cpuinfo_get_cluster(i)->processor_start); |
| 202 | break; |
| 203 | case 1: |
| 204 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->processor_start); |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | TEST(CLUSTERS, processor_count) { |
| 211 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 212 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->processor_count); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | TEST(CLUSTERS, core_start) { |
| 217 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 218 | switch (i) { |
| 219 | case 0: |
| 220 | ASSERT_EQ(0, cpuinfo_get_cluster(i)->core_start); |
| 221 | break; |
| 222 | case 1: |
| 223 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->core_start); |
| 224 | break; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | TEST(CLUSTERS, core_count) { |
| 230 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 231 | ASSERT_EQ(4, cpuinfo_get_cluster(i)->core_count); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | TEST(CLUSTERS, cluster_id) { |
| 236 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 237 | ASSERT_EQ(i, cpuinfo_get_cluster(i)->cluster_id); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | TEST(CLUSTERS, package) { |
| 242 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 243 | ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_cluster(i)->package); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | TEST(CLUSTERS, vendor) { |
| 248 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 249 | ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_cluster(i)->vendor); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | TEST(CLUSTERS, uarch) { |
| 254 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 255 | ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_cluster(i)->uarch); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | TEST(CLUSTERS, midr) { |
| 260 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 261 | ASSERT_EQ(UINT32_C(0x410FD033), cpuinfo_get_cluster(i)->midr); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | TEST(CLUSTERS, DISABLED_frequency) { |
| 266 | for (uint32_t i = 0; i < cpuinfo_get_clusters_count(); i++) { |
| 267 | ASSERT_EQ(UINT64_C(1500000000), cpuinfo_get_cluster(i)->frequency); |
| 268 | } |
| 269 | } |
| 270 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 271 | TEST(PACKAGES, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 272 | ASSERT_EQ(1, cpuinfo_get_packages_count()); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | TEST(PACKAGES, name) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 276 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 277 | ASSERT_EQ("Samsung Exynos 7580", |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 278 | std::string(cpuinfo_get_package(i)->name, |
| 279 | strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 283 | TEST(PACKAGES, gpu_name) { |
| 284 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 285 | ASSERT_EQ("ARM Mali-T720", |
| 286 | std::string(cpuinfo_get_package(i)->gpu_name, |
| 287 | strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX))); |
| 288 | } |
| 289 | } |
| 290 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 291 | TEST(PACKAGES, processor_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 292 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 293 | ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | TEST(PACKAGES, processor_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 298 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 299 | ASSERT_EQ(8, cpuinfo_get_package(i)->processor_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
| 303 | TEST(PACKAGES, core_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 304 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 305 | ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | |
| 309 | TEST(PACKAGES, core_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 310 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 311 | ASSERT_EQ(8, cpuinfo_get_package(i)->core_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame] | 315 | TEST(PACKAGES, cluster_start) { |
| 316 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 317 | ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | TEST(PACKAGES, cluster_count) { |
| 322 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 323 | ASSERT_EQ(2, cpuinfo_get_package(i)->cluster_count); |
| 324 | } |
| 325 | } |
| 326 | |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 327 | TEST(ISA, thumb) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 328 | #if CPUINFO_ARCH_ARM |
| 329 | ASSERT_TRUE(cpuinfo_has_arm_thumb()); |
| 330 | #elif CPUINFO_ARCH_ARM64 |
| 331 | ASSERT_FALSE(cpuinfo_has_arm_thumb()); |
| 332 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | TEST(ISA, thumb2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 336 | #if CPUINFO_ARCH_ARM |
| 337 | ASSERT_TRUE(cpuinfo_has_arm_thumb2()); |
| 338 | #elif CPUINFO_ARCH_ARM64 |
| 339 | ASSERT_FALSE(cpuinfo_has_arm_thumb2()); |
| 340 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | TEST(ISA, armv5e) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 344 | #if CPUINFO_ARCH_ARM |
| 345 | ASSERT_TRUE(cpuinfo_has_arm_v5e()); |
| 346 | #elif CPUINFO_ARCH_ARM64 |
| 347 | ASSERT_FALSE(cpuinfo_has_arm_v5e()); |
| 348 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | TEST(ISA, armv6) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 352 | #if CPUINFO_ARCH_ARM |
| 353 | ASSERT_TRUE(cpuinfo_has_arm_v6()); |
| 354 | #elif CPUINFO_ARCH_ARM64 |
| 355 | ASSERT_FALSE(cpuinfo_has_arm_v6()); |
| 356 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | TEST(ISA, armv6k) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 360 | #if CPUINFO_ARCH_ARM |
| 361 | ASSERT_TRUE(cpuinfo_has_arm_v6k()); |
| 362 | #elif CPUINFO_ARCH_ARM64 |
| 363 | ASSERT_FALSE(cpuinfo_has_arm_v6k()); |
| 364 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | TEST(ISA, armv7) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 368 | #if CPUINFO_ARCH_ARM |
| 369 | ASSERT_TRUE(cpuinfo_has_arm_v7()); |
| 370 | #elif CPUINFO_ARCH_ARM64 |
| 371 | ASSERT_FALSE(cpuinfo_has_arm_v7()); |
| 372 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | TEST(ISA, armv7mp) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 376 | #if CPUINFO_ARCH_ARM |
| 377 | ASSERT_TRUE(cpuinfo_has_arm_v7mp()); |
| 378 | #elif CPUINFO_ARCH_ARM64 |
| 379 | ASSERT_FALSE(cpuinfo_has_arm_v7mp()); |
| 380 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | TEST(ISA, idiv) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 384 | ASSERT_TRUE(cpuinfo_has_arm_idiv()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | TEST(ISA, vfpv2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 388 | ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | TEST(ISA, vfpv3) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 392 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 393 | } |
| 394 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 395 | TEST(ISA, vfpv3_d32) { |
| 396 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 399 | TEST(ISA, vfpv3_fp16) { |
| 400 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 403 | TEST(ISA, vfpv3_fp16_d32) { |
| 404 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); |
| 405 | } |
| 406 | |
| 407 | TEST(ISA, vfpv4) { |
| 408 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); |
| 409 | } |
| 410 | |
| 411 | TEST(ISA, vfpv4_d32) { |
| 412 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | TEST(ISA, wmmx) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 416 | ASSERT_FALSE(cpuinfo_has_arm_wmmx()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | TEST(ISA, wmmx2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 420 | ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | TEST(ISA, neon) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 424 | ASSERT_TRUE(cpuinfo_has_arm_neon()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 427 | TEST(ISA, neon_fp16) { |
| 428 | ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 431 | TEST(ISA, neon_fma) { |
| 432 | ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 435 | TEST(ISA, atomics) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 436 | ASSERT_FALSE(cpuinfo_has_arm_atomics()); |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 437 | } |
| 438 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 439 | TEST(ISA, neon_rdm) { |
| 440 | ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 443 | TEST(ISA, fp16_arith) { |
| 444 | ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | TEST(ISA, jscvt) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 448 | ASSERT_FALSE(cpuinfo_has_arm_jscvt()); |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | TEST(ISA, fcma) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 452 | ASSERT_FALSE(cpuinfo_has_arm_fcma()); |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 453 | } |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 454 | |
| 455 | TEST(ISA, aes) { |
| 456 | ASSERT_TRUE(cpuinfo_has_arm_aes()); |
| 457 | } |
| 458 | |
| 459 | TEST(ISA, sha1) { |
| 460 | ASSERT_TRUE(cpuinfo_has_arm_sha1()); |
| 461 | } |
| 462 | |
| 463 | TEST(ISA, sha2) { |
| 464 | ASSERT_TRUE(cpuinfo_has_arm_sha2()); |
| 465 | } |
| 466 | |
| 467 | TEST(ISA, pmull) { |
| 468 | ASSERT_TRUE(cpuinfo_has_arm_pmull()); |
| 469 | } |
| 470 | |
| 471 | TEST(ISA, crc32) { |
| 472 | ASSERT_TRUE(cpuinfo_has_arm_crc32()); |
| 473 | } |
Marat Dukhan | 3e8e1c7 | 2017-09-13 12:15:35 -0700 | [diff] [blame] | 474 | |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 475 | TEST(L1I, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 476 | ASSERT_EQ(8, cpuinfo_get_l1i_caches_count()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | TEST(L1I, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 480 | ASSERT_TRUE(cpuinfo_get_l1i_caches()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | TEST(L1I, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 484 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 485 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1i_cache(i)->size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
| 489 | TEST(L1I, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 490 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 491 | ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | |
| 495 | TEST(L1I, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 496 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 497 | ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, |
| 498 | 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 | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
| 502 | TEST(L1I, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 503 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 504 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 505 | } |
| 506 | } |
| 507 | |
| 508 | TEST(L1I, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 509 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 510 | ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | |
| 514 | TEST(L1I, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 515 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 516 | ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | |
| 520 | TEST(L1I, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 521 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 522 | ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); |
| 523 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
| 527 | TEST(L1D, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 528 | ASSERT_EQ(8, cpuinfo_get_l1d_caches_count()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | TEST(L1D, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 532 | ASSERT_TRUE(cpuinfo_get_l1d_caches()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | TEST(L1D, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 536 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 537 | ASSERT_EQ(32 * 1024, cpuinfo_get_l1d_cache(i)->size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | |
| 541 | TEST(L1D, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 542 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 543 | ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | |
| 547 | TEST(L1D, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 548 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 549 | ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, |
| 550 | 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 | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | |
| 554 | TEST(L1D, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 555 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 556 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | |
| 560 | TEST(L1D, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 561 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 562 | ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 563 | } |
| 564 | } |
| 565 | |
| 566 | TEST(L1D, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 567 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 568 | ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | |
| 572 | TEST(L1D, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 573 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 574 | ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); |
| 575 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 576 | } |
| 577 | } |
| 578 | |
| 579 | TEST(L2, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 580 | ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | TEST(L2, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 584 | ASSERT_TRUE(cpuinfo_get_l2_caches()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | TEST(L2, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 588 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 589 | ASSERT_EQ(256 * 1024, cpuinfo_get_l2_cache(i)->size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 590 | } |
| 591 | } |
| 592 | |
| 593 | TEST(L2, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 594 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 595 | ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 596 | } |
| 597 | } |
| 598 | |
| 599 | TEST(L2, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 600 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 601 | ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, |
| 602 | 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 | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 603 | } |
| 604 | } |
| 605 | |
| 606 | TEST(L2, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 607 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 608 | ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 609 | } |
| 610 | } |
| 611 | |
| 612 | TEST(L2, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 613 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 614 | ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | |
| 618 | TEST(L2, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 619 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 620 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
| 624 | TEST(L2, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 625 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 626 | switch (i) { |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 627 | case 0: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 628 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); |
| 629 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 630 | break; |
| 631 | case 1: |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 632 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_start); |
| 633 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 634 | break; |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | TEST(L3, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 640 | ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); |
| 641 | ASSERT_FALSE(cpuinfo_get_l3_caches()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | TEST(L4, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 645 | ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); |
| 646 | ASSERT_FALSE(cpuinfo_get_l4_caches()); |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | #include <galaxy-j7-uae.h> |
| 650 | |
| 651 | int main(int argc, char* argv[]) { |
Marat Dukhan | 63a7a6b | 2017-11-29 15:11:56 -0800 | [diff] [blame] | 652 | #if CPUINFO_ARCH_ARM |
| 653 | cpuinfo_set_hwcap(UINT32_C(0x0007B0D6)); |
| 654 | cpuinfo_set_hwcap2(UINT32_C(0x0000001F)); |
Marat Dukhan | 63a7a6b | 2017-11-29 15:11:56 -0800 | [diff] [blame] | 655 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 656 | cpuinfo_mock_filesystem(filesystem); |
Marat Dukhan | d156525 | 2017-09-12 00:29:01 -0700 | [diff] [blame] | 657 | #ifdef __ANDROID__ |
| 658 | cpuinfo_mock_android_properties(properties); |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 659 | cpuinfo_mock_gl_renderer("Mali-T720"); |
Marat Dukhan | d156525 | 2017-09-12 00:29:01 -0700 | [diff] [blame] | 660 | #endif |
Marat Dukhan | 2f3950c | 2017-09-08 18:25:26 -0700 | [diff] [blame] | 661 | cpuinfo_initialize(); |
| 662 | ::testing::InitGoogleTest(&argc, argv); |
| 663 | return RUN_ALL_TESTS(); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 664 | } |