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