Marat Dukhan | 006461a | 2017-08-24 16:10:46 -0700 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <string.h> |
| 5 | |
| 6 | #include <string> |
| 7 | |
| 8 | #define CPUINFO_BUILD_PROP_VALUE_MAX 92 |
| 9 | #define CPUINFO_ARM_CHIPSET_NAME_MAX 48 |
| 10 | |
| 11 | extern "C" void cpuinfo_arm_android_parse_ro_chipname( |
| 12 | const char chipname[CPUINFO_BUILD_PROP_VALUE_MAX], |
| 13 | uint32_t cores, |
| 14 | uint32_t max_cpu_freq_max, |
| 15 | char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX]); |
| 16 | |
| 17 | inline std::string parse_ro_chipname( |
| 18 | std::string chipname, uint32_t cores=1, uint32_t max_cpu_freq_max=0) |
| 19 | { |
| 20 | char chipname_buffer[CPUINFO_BUILD_PROP_VALUE_MAX]; |
| 21 | strncpy(chipname_buffer, chipname.c_str(), CPUINFO_BUILD_PROP_VALUE_MAX); |
| 22 | char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX]; |
| 23 | cpuinfo_arm_android_parse_ro_chipname( |
| 24 | chipname_buffer, cores, max_cpu_freq_max, chipset_name); |
| 25 | return std::string(chipset_name, strnlen(chipset_name, CPUINFO_ARM_CHIPSET_NAME_MAX)); |
| 26 | } |
| 27 | |
| 28 | TEST(RO_CHIPNAME, qualcomm_msm) { |
| 29 | EXPECT_EQ("Qualcomm MSM7630", |
| 30 | parse_ro_chipname("MSM7630_SURF")); |
| 31 | EXPECT_EQ("Qualcomm MSM8210", |
| 32 | parse_ro_chipname("MSM8210")); |
| 33 | EXPECT_EQ("Qualcomm MSM8226", |
| 34 | parse_ro_chipname("MSM8226")); |
| 35 | EXPECT_EQ("Qualcomm MSM8228", |
| 36 | parse_ro_chipname("MSM8228")); |
| 37 | EXPECT_EQ("Qualcomm MSM8230AB", |
| 38 | parse_ro_chipname("MSM8230AB")); |
| 39 | EXPECT_EQ("Qualcomm MSM8230VV", |
| 40 | parse_ro_chipname("MSM8230VV")); |
| 41 | EXPECT_EQ("Qualcomm MSM8239", |
| 42 | parse_ro_chipname("MSM8239")); |
| 43 | EXPECT_EQ("Qualcomm MSM8260A", |
| 44 | parse_ro_chipname("MSM8260A")); |
| 45 | EXPECT_EQ("Qualcomm MSM8274", |
| 46 | parse_ro_chipname("MSM8274")); |
| 47 | EXPECT_EQ("Qualcomm MSM8610", |
| 48 | parse_ro_chipname("MSM8610", 2)); |
| 49 | EXPECT_EQ("Qualcomm MSM8626", |
| 50 | parse_ro_chipname("MSM8626")); |
| 51 | EXPECT_EQ("Qualcomm MSM8660", |
| 52 | parse_ro_chipname("MSM8660_SURF")); |
| 53 | EXPECT_EQ("Qualcomm MSM8674", |
| 54 | parse_ro_chipname("MSM8674")); |
| 55 | EXPECT_EQ("Qualcomm MSM8674PRO", |
| 56 | parse_ro_chipname("MSM8674PRO")); |
| 57 | EXPECT_EQ("Qualcomm MSM8916", |
| 58 | parse_ro_chipname("MSM8216")); |
| 59 | EXPECT_EQ("Qualcomm MSM8916", |
| 60 | parse_ro_chipname("MSM8916", 4)); |
| 61 | EXPECT_EQ("Qualcomm MSM8916", |
| 62 | parse_ro_chipname("msm8916", 4)); |
| 63 | EXPECT_EQ("Qualcomm MSM8917", |
| 64 | parse_ro_chipname("MSM8937", 4)); |
| 65 | EXPECT_EQ("Qualcomm MSM8926", |
| 66 | parse_ro_chipname("MSM8926")); |
| 67 | EXPECT_EQ("Qualcomm MSM8928", |
| 68 | parse_ro_chipname("MSM8928")); |
| 69 | EXPECT_EQ("Qualcomm MSM8929", |
| 70 | parse_ro_chipname("MSM8929")); |
| 71 | EXPECT_EQ("Qualcomm MSM8930", |
| 72 | parse_ro_chipname("MSM8930")); |
| 73 | EXPECT_EQ("Qualcomm MSM8930AB", |
| 74 | parse_ro_chipname("MSM8930AB")); |
| 75 | EXPECT_EQ("Qualcomm MSM8930VV", |
| 76 | parse_ro_chipname("MSM8930VV")); |
| 77 | EXPECT_EQ("Qualcomm MSM8939", |
| 78 | parse_ro_chipname("MSM8939")); |
| 79 | EXPECT_EQ("Qualcomm MSM8952", |
| 80 | parse_ro_chipname("MSM8952")); |
| 81 | EXPECT_EQ("Qualcomm MSM8953", |
| 82 | parse_ro_chipname("MSM8953")); |
| 83 | EXPECT_EQ("Qualcomm MSM8960", |
| 84 | parse_ro_chipname("MSM8960", 2)); |
| 85 | EXPECT_EQ("Qualcomm MSM8974", |
| 86 | parse_ro_chipname("MSM8974")); |
| 87 | EXPECT_EQ("Qualcomm MSM8974PRO", |
| 88 | parse_ro_chipname("MSM8974PRO")); |
| 89 | EXPECT_EQ("Qualcomm MSM8976", |
| 90 | parse_ro_chipname("MSM8976")); |
| 91 | EXPECT_EQ("Qualcomm MSM8996", |
| 92 | parse_ro_chipname("MSM8996", 4)); |
| 93 | EXPECT_EQ("Qualcomm MSM8998", |
| 94 | parse_ro_chipname("MSM8998")); |
| 95 | } |
| 96 | |
| 97 | TEST(RO_CHIPNAME, qualcomm_apq) { |
| 98 | EXPECT_EQ("Qualcomm APQ8016", |
| 99 | parse_ro_chipname("APQ8016")); |
| 100 | EXPECT_EQ("Qualcomm APQ8026", |
| 101 | parse_ro_chipname("APQ8026")); |
| 102 | EXPECT_EQ("Qualcomm APQ8064", |
| 103 | parse_ro_chipname("apq8064")); |
| 104 | EXPECT_EQ("Qualcomm APQ8074", |
| 105 | parse_ro_chipname("APQ8074")); |
| 106 | EXPECT_EQ("Qualcomm APQ8076", |
| 107 | parse_ro_chipname("APQ8076")); |
| 108 | EXPECT_EQ("Qualcomm APQ8084", |
| 109 | parse_ro_chipname("APQ8084")); |
| 110 | } |
| 111 | |
| 112 | TEST(RO_CHIPNAME, mediatek_mt) { |
| 113 | EXPECT_EQ("MediaTek MT6737T", |
| 114 | parse_ro_chipname("MT6737T")); |
| 115 | EXPECT_EQ("MediaTek MT6757", |
| 116 | parse_ro_chipname("MT6757")); |
| 117 | } |
| 118 | |
| 119 | TEST(RO_CHIPNAME, samsung_exynos) { |
| 120 | EXPECT_EQ("Samsung Exynos 3470", |
| 121 | parse_ro_chipname("exynos3470")); |
| 122 | EXPECT_EQ("Samsung Exynos 3475", |
| 123 | parse_ro_chipname("exynos3475")); |
| 124 | EXPECT_EQ("Samsung Exynos 4415", |
| 125 | parse_ro_chipname("exynos4415")); |
| 126 | EXPECT_EQ("Samsung Exynos 5260", |
| 127 | parse_ro_chipname("exynos5260")); |
| 128 | EXPECT_EQ("Samsung Exynos 5410", |
| 129 | parse_ro_chipname("exynos5410")); |
| 130 | EXPECT_EQ("Samsung Exynos 5420", |
Marat Dukhan | ab7f949 | 2018-03-08 13:06:40 -0800 | [diff] [blame^] | 131 | parse_ro_chipname("exynos5420", 4)); |
Marat Dukhan | 006461a | 2017-08-24 16:10:46 -0700 | [diff] [blame] | 132 | EXPECT_EQ("Samsung Exynos 5422", |
| 133 | parse_ro_chipname("exynos5422")); |
| 134 | EXPECT_EQ("Samsung Exynos 5430", |
| 135 | parse_ro_chipname("exynos5430")); |
| 136 | EXPECT_EQ("Samsung Exynos 5433", |
| 137 | parse_ro_chipname("exynos5433")); |
| 138 | EXPECT_EQ("Samsung Exynos 7420", |
| 139 | parse_ro_chipname("exynos7420")); |
| 140 | EXPECT_EQ("Samsung Exynos 7570", |
| 141 | parse_ro_chipname("exynos7570")); |
| 142 | EXPECT_EQ("Samsung Exynos 7578", |
| 143 | parse_ro_chipname("exynos7580", 4)); |
| 144 | EXPECT_EQ("Samsung Exynos 7580", |
| 145 | parse_ro_chipname("exynos7580", 8)); |
| 146 | EXPECT_EQ("Samsung Exynos 7870", |
| 147 | parse_ro_chipname("exynos7870")); |
| 148 | EXPECT_EQ("Samsung Exynos 7880", |
| 149 | parse_ro_chipname("exynos7880")); |
| 150 | EXPECT_EQ("Samsung Exynos 8890", |
| 151 | parse_ro_chipname("exynos8890")); |
| 152 | EXPECT_EQ("Samsung Exynos 8895", |
| 153 | parse_ro_chipname("exynos8895")); |
| 154 | } |
| 155 | |
| 156 | TEST(RO_CHIPNAME, marvell_pxa) { |
| 157 | EXPECT_EQ("Marvell PXA1088", |
| 158 | parse_ro_chipname("PXA1088")); |
| 159 | EXPECT_EQ("Marvell PXA986", |
| 160 | parse_ro_chipname("PXA986")); |
| 161 | } |
| 162 | |
| 163 | TEST(RO_CHIPNAME, renesas) { |
| 164 | EXPECT_EQ("Renesas MP5232", |
| 165 | parse_ro_chipname("mp523x")); |
| 166 | } |
| 167 | |
| 168 | TEST(RO_CHIPNAME, spreadtrum) { |
| 169 | EXPECT_EQ("Spreadtrum SC6815AS", |
| 170 | parse_ro_chipname("SC6815AS")); |
| 171 | EXPECT_EQ("Spreadtrum SC7715A", |
| 172 | parse_ro_chipname("SC7715A")); |
| 173 | EXPECT_EQ("Spreadtrum SC7715T", |
| 174 | parse_ro_chipname("SC7715T")); |
| 175 | EXPECT_EQ("Spreadtrum SC7727S", |
| 176 | parse_ro_chipname("SC7727S")); |
| 177 | EXPECT_EQ("Spreadtrum SC7727S", |
| 178 | parse_ro_chipname("sc7727s")); |
| 179 | EXPECT_EQ("Spreadtrum SC7727SE", |
| 180 | parse_ro_chipname("SC7727SE")); |
| 181 | EXPECT_EQ("Spreadtrum SC7730S", |
| 182 | parse_ro_chipname("sc7730s")); |
| 183 | EXPECT_EQ("Spreadtrum SC7730SE", |
| 184 | parse_ro_chipname("SC7730SE")); |
| 185 | EXPECT_EQ("Spreadtrum SC7730SW", |
| 186 | parse_ro_chipname("SC7730SW")); |
| 187 | EXPECT_EQ("Spreadtrum SC7735S", |
| 188 | parse_ro_chipname("sc7735s")); |
| 189 | EXPECT_EQ("Spreadtrum SC9830I", |
| 190 | parse_ro_chipname("SC9830I")); |
| 191 | } |