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_mediatek_platform(
12 	const char platform[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 
parse_ro_mediatek_platform(std::string platform,uint32_t cores=1,uint32_t max_cpu_freq_max=0)17 inline std::string parse_ro_mediatek_platform(
18 	std::string platform, uint32_t cores=1, uint32_t max_cpu_freq_max=0)
19 {
20 	char platform_buffer[CPUINFO_BUILD_PROP_VALUE_MAX];
21 	strncpy(platform_buffer, platform.c_str(), CPUINFO_BUILD_PROP_VALUE_MAX);
22 	char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX];
23 	cpuinfo_arm_android_parse_ro_mediatek_platform(
24 		platform_buffer, cores, max_cpu_freq_max, chipset_name);
25 	return std::string(chipset_name, strnlen(chipset_name, CPUINFO_ARM_CHIPSET_NAME_MAX));
26 }
27 
TEST(RO_MEDIATEK_PLATFORM,qualcomm)28 TEST(RO_MEDIATEK_PLATFORM, qualcomm) {
29 	EXPECT_EQ("", parse_ro_mediatek_platform("MSM8225Q"));
30 	EXPECT_EQ("", parse_ro_mediatek_platform("Qualcomm Snapdragon 805"));
31 	EXPECT_EQ("", parse_ro_mediatek_platform("Qualcomm Snapdragon 820"));
32 }
33 
TEST(RO_MEDIATEK_PLATFORM,samsung)34 TEST(RO_MEDIATEK_PLATFORM, samsung) {
35 	EXPECT_EQ("", parse_ro_mediatek_platform("EXYNOS5420"));
36 	EXPECT_EQ("", parse_ro_mediatek_platform("Samsung  Exynos 5420"));
37 }
38 
TEST(RO_MEDIATEK_PLATFORM,apple)39 TEST(RO_MEDIATEK_PLATFORM, apple) {
40 	EXPECT_EQ("", parse_ro_mediatek_platform("Apple A9"));
41 	EXPECT_EQ("", parse_ro_mediatek_platform("Apple A10"));
42 }
43 
TEST(RO_MEDIATEK_PLATFORM,mediatek_mt)44 TEST(RO_MEDIATEK_PLATFORM, mediatek_mt) {
45 	EXPECT_EQ("MediaTek MT5861",
46 		parse_ro_mediatek_platform("mt5861"));
47 	EXPECT_EQ("MediaTek MT5882",
48 		parse_ro_mediatek_platform("mt5882"));
49 	EXPECT_EQ("MediaTek MT6570",
50 		parse_ro_mediatek_platform("mt6570"));
51 	EXPECT_EQ("MediaTek MT6572",
52 		parse_ro_mediatek_platform("mt6572"));
53 	EXPECT_EQ("MediaTek MT6572A",
54 		parse_ro_mediatek_platform("MT6572A"));
55 	EXPECT_EQ("MediaTek MT6575",
56 		parse_ro_mediatek_platform("mt6575"));
57 	EXPECT_EQ("MediaTek MT6577",
58 		parse_ro_mediatek_platform("MT6577"));
59 	EXPECT_EQ("MediaTek MT6577",
60 		parse_ro_mediatek_platform("mt6577"));
61 	EXPECT_EQ("MediaTek MT6580",
62 		parse_ro_mediatek_platform("mt6580"));
63 	EXPECT_EQ("MediaTek MT6582",
64 		parse_ro_mediatek_platform("MTK6582"));
65 	EXPECT_EQ("MediaTek MT6582",
66 		parse_ro_mediatek_platform("mt6582"));
67 	EXPECT_EQ("MediaTek MT6582M",
68 		parse_ro_mediatek_platform("MTK6582M"));
69 	EXPECT_EQ("MediaTek MT6589",
70 		parse_ro_mediatek_platform("MT6589"));
71 	EXPECT_EQ("MediaTek MT6589",
72 		parse_ro_mediatek_platform("MTK6589"));
73 	EXPECT_EQ("MediaTek MT6592",
74 		parse_ro_mediatek_platform("mt6592"));
75 	EXPECT_EQ("MediaTek MT6592T",
76 		parse_ro_mediatek_platform("MTK6592T"));
77 	EXPECT_EQ("MediaTek MT6595",
78 		parse_ro_mediatek_platform("mt6595"));
79 	EXPECT_EQ("MediaTek MT6732",
80 		parse_ro_mediatek_platform("mt6752", 4));
81 	EXPECT_EQ("MediaTek MT6735",
82 		parse_ro_mediatek_platform("mt6735"));
83 	EXPECT_EQ("MediaTek MT6735M",
84 		parse_ro_mediatek_platform("mt6735m"));
85 	EXPECT_EQ("MediaTek MT6737",
86 		parse_ro_mediatek_platform("mt6737"));
87 	EXPECT_EQ("MediaTek MT6737M",
88 		parse_ro_mediatek_platform("mt6737m"));
89 	EXPECT_EQ("MediaTek MT6737T",
90 		parse_ro_mediatek_platform("mt6737t"));
91 	EXPECT_EQ("MediaTek MT6750",
92 		parse_ro_mediatek_platform("mt6750"));
93 	EXPECT_EQ("MediaTek MT6752",
94 		parse_ro_mediatek_platform("mt6752", 8));
95 	EXPECT_EQ("MediaTek MT6753",
96 		parse_ro_mediatek_platform("mt6753"));
97 	EXPECT_EQ("MediaTek MT6755",
98 		parse_ro_mediatek_platform("mt6755"));
99 	EXPECT_EQ("MediaTek MT6757",
100 		parse_ro_mediatek_platform("mt6757"));
101 	EXPECT_EQ("MediaTek MT6795",
102 		parse_ro_mediatek_platform("mt6795"));
103 	EXPECT_EQ("MediaTek MT6797",
104 		parse_ro_mediatek_platform("mt6797"));
105 	EXPECT_EQ("MediaTek MT8111",
106 		parse_ro_mediatek_platform("MT8111"));
107 	EXPECT_EQ("MediaTek MT8127",
108 		parse_ro_mediatek_platform("MT8127"));
109 	EXPECT_EQ("MediaTek MT8127",
110 		parse_ro_mediatek_platform("mt8127"));
111 	EXPECT_EQ("MediaTek MT8135",
112 		parse_ro_mediatek_platform("mt8135"));
113 	EXPECT_EQ("MediaTek MT8151",
114 		parse_ro_mediatek_platform("mt8151"));
115 	EXPECT_EQ("MediaTek MT8163",
116 		parse_ro_mediatek_platform("mt8163"));
117 	EXPECT_EQ("MediaTek MT8167",
118 		parse_ro_mediatek_platform("mt8167"));
119 	EXPECT_EQ("MediaTek MT8173",
120 		parse_ro_mediatek_platform("mt8173"));
121 	EXPECT_EQ("MediaTek MT8312",
122 		parse_ro_mediatek_platform("MT8312"));
123 	EXPECT_EQ("MediaTek MT8382",
124 		parse_ro_mediatek_platform("MT8382"));
125 	EXPECT_EQ("MediaTek MT8382V",
126 		parse_ro_mediatek_platform("MT8382V"));
127 	EXPECT_EQ("MediaTek MT8392",
128 		parse_ro_mediatek_platform("MT8392"));
129 }
130