Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -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 | 8dd5ffc | 2017-08-11 00:05:50 -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 | 8dd5ffc | 2017-08-11 00:05:50 -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 | 8dd5ffc | 2017-08-11 00:05:50 -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 | ASSERT_EQ(cpuinfo_get_cluster(0), cpuinfo_get_processor(i)->cluster); |
| 30 | } |
| 31 | } |
| 32 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -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 | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
Marat Dukhan | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 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 | 846c178 | 2017-09-13 09:47:26 -0700 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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 | 2d37dc4 | 2017-09-25 01:32:37 -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 | 2d37dc4 | 2017-09-25 01:32:37 -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(0), cpuinfo_get_processor(i)->cache.l2); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -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 | 2d37dc4 | 2017-09-25 01:32:37 -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 | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 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 | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 77 | } |
| 78 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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 | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Marat Dukhan | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 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 | 7073e83 | 2017-09-24 22:23:55 -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 | 7073e83 | 2017-09-24 22:23:55 -0700 | [diff] [blame] | 92 | } |
| 93 | } |
| 94 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 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 | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -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(0), cpuinfo_get_core(i)->cluster); |
| 104 | } |
| 105 | } |
| 106 | |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -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 | 2d37dc4 | 2017-09-25 01:32:37 -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_qualcomm, cpuinfo_get_core(i)->vendor); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -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_krait, cpuinfo_get_core(i)->uarch); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | |
| 125 | TEST(CORES, midr) { |
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(0x513F06F1), cpuinfo_get_core(i)->midr); |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -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(2649600000), cpuinfo_get_core(i)->frequency); |
| 134 | } |
| 135 | } |
| 136 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 137 | TEST(PACKAGES, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 138 | ASSERT_EQ(1, cpuinfo_get_packages_count()); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | TEST(PACKAGES, name) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 142 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 143 | ASSERT_EQ("Qualcomm APQ8084", |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 144 | std::string(cpuinfo_get_package(i)->name, |
| 145 | strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 146 | } |
| 147 | } |
| 148 | |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 149 | TEST(PACKAGES, gpu_name) { |
| 150 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 151 | ASSERT_EQ("Qualcomm Adreno 420", |
| 152 | std::string(cpuinfo_get_package(i)->gpu_name, |
| 153 | strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX))); |
| 154 | } |
| 155 | } |
| 156 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 157 | TEST(PACKAGES, processor_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 158 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 159 | ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
| 163 | TEST(PACKAGES, processor_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 164 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 165 | ASSERT_EQ(4, cpuinfo_get_package(i)->processor_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | TEST(PACKAGES, core_start) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 170 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 171 | ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
| 175 | TEST(PACKAGES, core_count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 176 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 177 | ASSERT_EQ(4, cpuinfo_get_package(i)->core_count); |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
Marat Dukhan | 2b30793 | 2018-03-18 16:15:36 -0700 | [diff] [blame^] | 181 | TEST(PACKAGES, cluster_start) { |
| 182 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 183 | ASSERT_EQ(0, cpuinfo_get_package(i)->cluster_start); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | TEST(PACKAGES, cluster_count) { |
| 188 | for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { |
| 189 | ASSERT_EQ(1, cpuinfo_get_package(i)->cluster_count); |
| 190 | } |
| 191 | } |
| 192 | |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 193 | TEST(ISA, thumb) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 194 | ASSERT_TRUE(cpuinfo_has_arm_thumb()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | TEST(ISA, thumb2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 198 | ASSERT_TRUE(cpuinfo_has_arm_thumb2()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | TEST(ISA, armv5e) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 202 | ASSERT_TRUE(cpuinfo_has_arm_v5e()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | TEST(ISA, armv6) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 206 | ASSERT_TRUE(cpuinfo_has_arm_v6()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | TEST(ISA, armv6k) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 210 | ASSERT_TRUE(cpuinfo_has_arm_v6k()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | TEST(ISA, armv7) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 214 | ASSERT_TRUE(cpuinfo_has_arm_v7()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | TEST(ISA, armv7mp) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 218 | ASSERT_TRUE(cpuinfo_has_arm_v7mp()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | TEST(ISA, idiv) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 222 | ASSERT_TRUE(cpuinfo_has_arm_idiv()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | TEST(ISA, vfpv2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 226 | ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | TEST(ISA, vfpv3) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 230 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 233 | TEST(ISA, vfpv3_d32) { |
| 234 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 237 | TEST(ISA, vfpv3_fp16) { |
| 238 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 241 | TEST(ISA, vfpv3_fp16_d32) { |
| 242 | ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); |
| 243 | } |
| 244 | |
| 245 | TEST(ISA, vfpv4) { |
| 246 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); |
| 247 | } |
| 248 | |
| 249 | TEST(ISA, vfpv4_d32) { |
| 250 | ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | TEST(ISA, wmmx) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 254 | ASSERT_FALSE(cpuinfo_has_arm_wmmx()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | TEST(ISA, wmmx2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 258 | ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | TEST(ISA, neon) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 262 | ASSERT_TRUE(cpuinfo_has_arm_neon()); |
| 263 | } |
| 264 | |
| 265 | TEST(ISA, neon_fp16) { |
| 266 | ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); |
| 267 | } |
| 268 | |
| 269 | TEST(ISA, neon_fma) { |
| 270 | ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); |
| 271 | } |
| 272 | |
| 273 | TEST(ISA, atomics) { |
| 274 | ASSERT_FALSE(cpuinfo_has_arm_atomics()); |
| 275 | } |
| 276 | |
| 277 | TEST(ISA, neon_rdm) { |
| 278 | ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); |
| 279 | } |
| 280 | |
| 281 | TEST(ISA, fp16_arith) { |
| 282 | ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); |
| 283 | } |
| 284 | |
| 285 | TEST(ISA, jscvt) { |
| 286 | ASSERT_FALSE(cpuinfo_has_arm_jscvt()); |
| 287 | } |
| 288 | |
| 289 | TEST(ISA, fcma) { |
| 290 | ASSERT_FALSE(cpuinfo_has_arm_fcma()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | TEST(ISA, aes) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 294 | ASSERT_FALSE(cpuinfo_has_arm_aes()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | TEST(ISA, sha1) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 298 | ASSERT_FALSE(cpuinfo_has_arm_sha1()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | TEST(ISA, sha2) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 302 | ASSERT_FALSE(cpuinfo_has_arm_sha2()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | TEST(ISA, pmull) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 306 | ASSERT_FALSE(cpuinfo_has_arm_pmull()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | TEST(ISA, crc32) { |
Marat Dukhan | eb3025f | 2017-09-26 12:57:41 -0700 | [diff] [blame] | 310 | ASSERT_FALSE(cpuinfo_has_arm_crc32()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | TEST(L1I, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 314 | ASSERT_EQ(4, cpuinfo_get_l1i_caches_count()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | TEST(L1I, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 318 | ASSERT_TRUE(cpuinfo_get_l1i_caches()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | TEST(L1I, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 322 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 323 | ASSERT_EQ(16 * 1024, cpuinfo_get_l1i_cache(i)->size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 324 | } |
| 325 | } |
| 326 | |
| 327 | TEST(L1I, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 328 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 329 | ASSERT_EQ(4, cpuinfo_get_l1i_cache(i)->associativity); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
| 333 | TEST(L1I, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 334 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 335 | ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, |
| 336 | 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 | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | |
| 340 | TEST(L1I, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 341 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 342 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | |
| 346 | TEST(L1I, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 347 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 348 | ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | |
| 352 | TEST(L1I, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 353 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 354 | ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | |
| 358 | TEST(L1I, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 359 | for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { |
| 360 | ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); |
| 361 | ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
| 365 | TEST(L1D, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 366 | ASSERT_EQ(4, cpuinfo_get_l1d_caches_count()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | TEST(L1D, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 370 | ASSERT_TRUE(cpuinfo_get_l1d_caches()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | TEST(L1D, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 374 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 375 | ASSERT_EQ(16 * 1024, cpuinfo_get_l1d_cache(i)->size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | |
| 379 | TEST(L1D, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 380 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 381 | ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 382 | } |
| 383 | } |
| 384 | |
| 385 | TEST(L1D, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 386 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 387 | ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, |
| 388 | 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 | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | |
| 392 | TEST(L1D, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 393 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 394 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
| 398 | TEST(L1D, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 399 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 400 | ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
| 404 | TEST(L1D, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 405 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 406 | ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
| 410 | TEST(L1D, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 411 | for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { |
| 412 | ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); |
| 413 | ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | |
| 417 | TEST(L2, count) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 418 | ASSERT_EQ(1, cpuinfo_get_l2_caches_count()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | TEST(L2, non_null) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 422 | ASSERT_TRUE(cpuinfo_get_l2_caches()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | TEST(L2, size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 426 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 427 | ASSERT_EQ(2 * 1024 * 1024, cpuinfo_get_l2_cache(i)->size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | TEST(L2, associativity) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 432 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 433 | ASSERT_EQ(8, cpuinfo_get_l2_cache(i)->associativity); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
| 437 | TEST(L2, sets) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 438 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 439 | ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, |
| 440 | 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 | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | |
| 444 | TEST(L2, partitions) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 445 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 446 | ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 447 | } |
| 448 | } |
| 449 | |
| 450 | TEST(L2, line_size) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 451 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 452 | ASSERT_EQ(128, cpuinfo_get_l2_cache(i)->line_size); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | TEST(L2, flags) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 457 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 458 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | |
| 462 | TEST(L2, processors) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 463 | for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { |
| 464 | ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); |
| 465 | ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 466 | } |
| 467 | } |
| 468 | |
| 469 | TEST(L3, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 470 | ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); |
| 471 | ASSERT_FALSE(cpuinfo_get_l3_caches()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | TEST(L4, none) { |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 475 | ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); |
| 476 | ASSERT_FALSE(cpuinfo_get_l4_caches()); |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | #include <nexus6.h> |
| 480 | |
| 481 | int main(int argc, char* argv[]) { |
Marat Dukhan | 63a7a6b | 2017-11-29 15:11:56 -0800 | [diff] [blame] | 482 | #if CPUINFO_ARCH_ARM |
| 483 | cpuinfo_set_hwcap(UINT32_C(0x0007B0D7)); |
| 484 | #endif |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 485 | cpuinfo_mock_filesystem(filesystem); |
Marat Dukhan | 5659d29 | 2017-09-12 23:21:03 -0700 | [diff] [blame] | 486 | #ifdef __ANDROID__ |
| 487 | cpuinfo_mock_android_properties(properties); |
Marat Dukhan | fd0f3ef | 2017-12-18 17:45:18 -0800 | [diff] [blame] | 488 | cpuinfo_mock_gl_renderer("Adreno (TM) 420"); |
Marat Dukhan | 5659d29 | 2017-09-12 23:21:03 -0700 | [diff] [blame] | 489 | #endif |
Marat Dukhan | 8dd5ffc | 2017-08-11 00:05:50 -0700 | [diff] [blame] | 490 | cpuinfo_initialize(); |
| 491 | ::testing::InitGoogleTest(&argc, argv); |
| 492 | return RUN_ALL_TESTS(); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 493 | } |