1*eca53ba6SRoland Levillain // Copyright 2017 Google LLC
2*eca53ba6SRoland Levillain //
3*eca53ba6SRoland Levillain // Licensed under the Apache License, Version 2.0 (the "License");
4*eca53ba6SRoland Levillain // you may not use this file except in compliance with the License.
5*eca53ba6SRoland Levillain // You may obtain a copy of the License at
6*eca53ba6SRoland Levillain //
7*eca53ba6SRoland Levillain // http://www.apache.org/licenses/LICENSE-2.0
8*eca53ba6SRoland Levillain //
9*eca53ba6SRoland Levillain // Unless required by applicable law or agreed to in writing, software
10*eca53ba6SRoland Levillain // distributed under the License is distributed on an "AS IS" BASIS,
11*eca53ba6SRoland Levillain // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*eca53ba6SRoland Levillain // See the License for the specific language governing permissions and
13*eca53ba6SRoland Levillain // limitations under the License.
14*eca53ba6SRoland Levillain
15*eca53ba6SRoland Levillain #include "cpuinfo_arm.h"
16*eca53ba6SRoland Levillain
17*eca53ba6SRoland Levillain #include "filesystem_for_testing.h"
18*eca53ba6SRoland Levillain #include "gtest/gtest.h"
19*eca53ba6SRoland Levillain #include "hwcaps_for_testing.h"
20*eca53ba6SRoland Levillain
21*eca53ba6SRoland Levillain namespace cpu_features {
22*eca53ba6SRoland Levillain namespace {
23*eca53ba6SRoland Levillain
TEST(CpuinfoArmTest,ArmFeaturesEnum)24*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, ArmFeaturesEnum) {
25*eca53ba6SRoland Levillain const char *last_name = GetArmFeaturesEnumName(ARM_LAST_);
26*eca53ba6SRoland Levillain EXPECT_STREQ(last_name, "unknown_feature");
27*eca53ba6SRoland Levillain for (int i = static_cast<int>(ARM_SWP); i != static_cast<int>(ARM_LAST_); ++i) {
28*eca53ba6SRoland Levillain const auto feature = static_cast<ArmFeaturesEnum>(i);
29*eca53ba6SRoland Levillain const char *name = GetArmFeaturesEnumName(feature);
30*eca53ba6SRoland Levillain ASSERT_FALSE(name == nullptr);
31*eca53ba6SRoland Levillain EXPECT_STRNE(name, "");
32*eca53ba6SRoland Levillain EXPECT_STRNE(name, last_name);
33*eca53ba6SRoland Levillain }
34*eca53ba6SRoland Levillain }
35*eca53ba6SRoland Levillain
TEST(CpuinfoArmTest,FromHardwareCap)36*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, FromHardwareCap) {
37*eca53ba6SRoland Levillain ResetHwcaps();
38*eca53ba6SRoland Levillain SetHardwareCapabilities(ARM_HWCAP_NEON, ARM_HWCAP2_AES | ARM_HWCAP2_CRC32);
39*eca53ba6SRoland Levillain GetEmptyFilesystem(); // disabling /proc/cpuinfo
40*eca53ba6SRoland Levillain const auto info = GetArmInfo();
41*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfp); // triggered by vfpv3
42*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpv3); // triggered by neon
43*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.neon);
44*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.aes);
45*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.crc32);
46*eca53ba6SRoland Levillain
47*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv4);
48*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.iwmmxt);
49*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crunch);
50*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.thumbee);
51*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3d16);
52*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idiva);
53*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idivt);
54*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.pmull);
55*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha1);
56*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha2);
57*eca53ba6SRoland Levillain
58*eca53ba6SRoland Levillain // check some random features with EnumValue():
59*eca53ba6SRoland Levillain EXPECT_TRUE(GetArmFeaturesEnumValue(&info.features, ARM_VFP));
60*eca53ba6SRoland Levillain EXPECT_FALSE(GetArmFeaturesEnumValue(&info.features, ARM_VFPV4));
61*eca53ba6SRoland Levillain // out of bound EnumValue() check
62*eca53ba6SRoland Levillain EXPECT_FALSE(GetArmFeaturesEnumValue(&info.features, (ArmFeaturesEnum)~0x0));
63*eca53ba6SRoland Levillain }
64*eca53ba6SRoland Levillain
TEST(CpuinfoArmTest,ODroidFromCpuInfo)65*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, ODroidFromCpuInfo) {
66*eca53ba6SRoland Levillain ResetHwcaps();
67*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
68*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo", R"(processor : 0
69*eca53ba6SRoland Levillain model name : ARMv7 Processor rev 3 (v71)
70*eca53ba6SRoland Levillain BogoMIPS : 120.00
71*eca53ba6SRoland Levillain Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae
72*eca53ba6SRoland Levillain CPU implementer : 0x41
73*eca53ba6SRoland Levillain CPU architecture: 7
74*eca53ba6SRoland Levillain CPU variant : 0x2
75*eca53ba6SRoland Levillain CPU part : 0xc0f
76*eca53ba6SRoland Levillain CPU revision : 3)");
77*eca53ba6SRoland Levillain const auto info = GetArmInfo();
78*eca53ba6SRoland Levillain EXPECT_EQ(info.implementer, 0x41);
79*eca53ba6SRoland Levillain EXPECT_EQ(info.variant, 0x2);
80*eca53ba6SRoland Levillain EXPECT_EQ(info.part, 0xc0f);
81*eca53ba6SRoland Levillain EXPECT_EQ(info.revision, 3);
82*eca53ba6SRoland Levillain EXPECT_EQ(info.architecture, 7);
83*eca53ba6SRoland Levillain
84*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.swp);
85*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.half);
86*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.thumb);
87*eca53ba6SRoland Levillain EXPECT_FALSE(info.features._26bit);
88*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.fastmult);
89*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.fpa);
90*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfp);
91*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.edsp);
92*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.java);
93*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.iwmmxt);
94*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crunch);
95*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.thumbee);
96*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.neon);
97*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpv3);
98*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3d16);
99*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.tls);
100*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpv4);
101*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idiva);
102*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idivt);
103*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpd32);
104*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.lpae);
105*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.evtstrm);
106*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.aes);
107*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.pmull);
108*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha1);
109*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha2);
110*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crc32);
111*eca53ba6SRoland Levillain }
112*eca53ba6SRoland Levillain
113*eca53ba6SRoland Levillain // Linux test-case
TEST(CpuinfoArmTest,RaspberryPiZeroFromCpuInfo)114*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, RaspberryPiZeroFromCpuInfo) {
115*eca53ba6SRoland Levillain ResetHwcaps();
116*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
117*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo", R"(processor : 0
118*eca53ba6SRoland Levillain model name : ARMv6-compatible processor rev 7 (v6l)
119*eca53ba6SRoland Levillain BogoMIPS : 697.95
120*eca53ba6SRoland Levillain Features : half thumb fastmult vfp edsp java tls
121*eca53ba6SRoland Levillain CPU implementer : 0x41
122*eca53ba6SRoland Levillain CPU architecture: 7
123*eca53ba6SRoland Levillain CPU variant : 0x0
124*eca53ba6SRoland Levillain CPU part : 0xb76
125*eca53ba6SRoland Levillain CPU revision : 7
126*eca53ba6SRoland Levillain
127*eca53ba6SRoland Levillain Hardware : BCM2835
128*eca53ba6SRoland Levillain Revision : 9000c1
129*eca53ba6SRoland Levillain Serial : 000000006cd946f3)");
130*eca53ba6SRoland Levillain const auto info = GetArmInfo();
131*eca53ba6SRoland Levillain EXPECT_EQ(info.implementer, 0x41);
132*eca53ba6SRoland Levillain EXPECT_EQ(info.variant, 0x0);
133*eca53ba6SRoland Levillain EXPECT_EQ(info.part, 0xb76);
134*eca53ba6SRoland Levillain EXPECT_EQ(info.revision, 7);
135*eca53ba6SRoland Levillain EXPECT_EQ(info.architecture, 6);
136*eca53ba6SRoland Levillain
137*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.swp);
138*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.half);
139*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.thumb);
140*eca53ba6SRoland Levillain EXPECT_FALSE(info.features._26bit);
141*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.fastmult);
142*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.fpa);
143*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfp);
144*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.edsp);
145*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.java);
146*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.iwmmxt);
147*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crunch);
148*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.thumbee);
149*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.neon);
150*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3);
151*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3d16);
152*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.tls);
153*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv4);
154*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idiva);
155*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idivt);
156*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpd32);
157*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.lpae);
158*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.evtstrm);
159*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.aes);
160*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.pmull);
161*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha1);
162*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha2);
163*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crc32);
164*eca53ba6SRoland Levillain }
165*eca53ba6SRoland Levillain
TEST(CpuinfoArmTest,MarvellArmadaFromCpuInfo)166*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, MarvellArmadaFromCpuInfo) {
167*eca53ba6SRoland Levillain ResetHwcaps();
168*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
169*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo", R"(processor : 0
170*eca53ba6SRoland Levillain model name : ARMv7 Processor rev 1 (v7l)
171*eca53ba6SRoland Levillain BogoMIPS : 50.00
172*eca53ba6SRoland Levillain Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
173*eca53ba6SRoland Levillain CPU implementer : 0x41
174*eca53ba6SRoland Levillain CPU architecture: 7
175*eca53ba6SRoland Levillain CPU variant : 0x4
176*eca53ba6SRoland Levillain CPU part : 0xc09
177*eca53ba6SRoland Levillain CPU revision : 1
178*eca53ba6SRoland Levillain
179*eca53ba6SRoland Levillain processor : 1
180*eca53ba6SRoland Levillain model name : ARMv7 Processor rev 1 (v7l)
181*eca53ba6SRoland Levillain BogoMIPS : 50.00
182*eca53ba6SRoland Levillain Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
183*eca53ba6SRoland Levillain CPU implementer : 0x41
184*eca53ba6SRoland Levillain CPU architecture: 7
185*eca53ba6SRoland Levillain CPU variant : 0x4
186*eca53ba6SRoland Levillain CPU part : 0xc09
187*eca53ba6SRoland Levillain CPU revision : 1
188*eca53ba6SRoland Levillain
189*eca53ba6SRoland Levillain Hardware : Marvell Armada 380/385 (Device Tree)
190*eca53ba6SRoland Levillain Revision : 0000
191*eca53ba6SRoland Levillain Serial : 0000000000000000)");
192*eca53ba6SRoland Levillain const auto info = GetArmInfo();
193*eca53ba6SRoland Levillain EXPECT_EQ(info.implementer, 0x41);
194*eca53ba6SRoland Levillain EXPECT_EQ(info.variant, 0x4);
195*eca53ba6SRoland Levillain EXPECT_EQ(info.part, 0xc09);
196*eca53ba6SRoland Levillain EXPECT_EQ(info.revision, 1);
197*eca53ba6SRoland Levillain EXPECT_EQ(info.architecture, 7);
198*eca53ba6SRoland Levillain
199*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.swp);
200*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.half);
201*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.thumb);
202*eca53ba6SRoland Levillain EXPECT_FALSE(info.features._26bit);
203*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.fastmult);
204*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.fpa);
205*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfp);
206*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.edsp);
207*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.java);
208*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.iwmmxt);
209*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crunch);
210*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.thumbee);
211*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.neon);
212*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpv3);
213*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3d16);
214*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.tls);
215*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv4);
216*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idiva);
217*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idivt);
218*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfpd32);
219*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.lpae);
220*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.evtstrm);
221*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.aes);
222*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.pmull);
223*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha1);
224*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha2);
225*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crc32);
226*eca53ba6SRoland Levillain }
227*eca53ba6SRoland Levillain
228*eca53ba6SRoland Levillain // Android test-case
229*eca53ba6SRoland Levillain // http://code.google.com/p/android/issues/detail?id=10812
TEST(CpuinfoArmTest,InvalidArmv7)230*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, InvalidArmv7) {
231*eca53ba6SRoland Levillain ResetHwcaps();
232*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
233*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
234*eca53ba6SRoland Levillain R"(Processor : ARMv6-compatible processor rev 6 (v6l)
235*eca53ba6SRoland Levillain BogoMIPS : 199.47
236*eca53ba6SRoland Levillain Features : swp half thumb fastmult vfp edsp java
237*eca53ba6SRoland Levillain CPU implementer : 0x41
238*eca53ba6SRoland Levillain CPU architecture: 7
239*eca53ba6SRoland Levillain CPU variant : 0x0
240*eca53ba6SRoland Levillain CPU part : 0xb76
241*eca53ba6SRoland Levillain CPU revision : 6
242*eca53ba6SRoland Levillain
243*eca53ba6SRoland Levillain Hardware : SPICA
244*eca53ba6SRoland Levillain Revision : 0020
245*eca53ba6SRoland Levillain Serial : 33323613546d00ec )");
246*eca53ba6SRoland Levillain const auto info = GetArmInfo();
247*eca53ba6SRoland Levillain EXPECT_EQ(info.architecture, 6);
248*eca53ba6SRoland Levillain
249*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.swp);
250*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.half);
251*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.thumb);
252*eca53ba6SRoland Levillain EXPECT_FALSE(info.features._26bit);
253*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.fastmult);
254*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.fpa);
255*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.vfp);
256*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.edsp);
257*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.java);
258*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.iwmmxt);
259*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crunch);
260*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.thumbee);
261*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.neon);
262*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3);
263*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv3d16);
264*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.tls);
265*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpv4);
266*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idiva);
267*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.idivt);
268*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.vfpd32);
269*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.lpae);
270*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.evtstrm);
271*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.aes);
272*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.pmull);
273*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha1);
274*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.sha2);
275*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.crc32);
276*eca53ba6SRoland Levillain }
277*eca53ba6SRoland Levillain
278*eca53ba6SRoland Levillain // Android test-case
279*eca53ba6SRoland Levillain // https://crbug.com/341598.
TEST(CpuinfoArmTest,InvalidNeon)280*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, InvalidNeon) {
281*eca53ba6SRoland Levillain ResetHwcaps();
282*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
283*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
284*eca53ba6SRoland Levillain R"(Processor: ARMv7 Processory rev 0 (v71)
285*eca53ba6SRoland Levillain processor: 0
286*eca53ba6SRoland Levillain BogoMIPS: 13.50
287*eca53ba6SRoland Levillain
288*eca53ba6SRoland Levillain Processor: 1
289*eca53ba6SRoland Levillain BogoMIPS: 13.50
290*eca53ba6SRoland Levillain
291*eca53ba6SRoland Levillain Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
292*eca53ba6SRoland Levillain CPU implementer : 0x51
293*eca53ba6SRoland Levillain CPU architecture: 7
294*eca53ba6SRoland Levillain CPU variant: 0x1
295*eca53ba6SRoland Levillain CPU part: 0x04d
296*eca53ba6SRoland Levillain CPU revision: 0
297*eca53ba6SRoland Levillain
298*eca53ba6SRoland Levillain Hardware: SAMSUNG M2
299*eca53ba6SRoland Levillain Revision: 0010
300*eca53ba6SRoland Levillain Serial: 00001e030000354e)");
301*eca53ba6SRoland Levillain const auto info = GetArmInfo();
302*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.swp);
303*eca53ba6SRoland Levillain EXPECT_FALSE(info.features.neon);
304*eca53ba6SRoland Levillain }
305*eca53ba6SRoland Levillain
306*eca53ba6SRoland Levillain // The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report IDIV
307*eca53ba6SRoland Levillain // support.
TEST(CpuinfoArmTest,Nexus4_0x510006f2)308*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, Nexus4_0x510006f2) {
309*eca53ba6SRoland Levillain ResetHwcaps();
310*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
311*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
312*eca53ba6SRoland Levillain R"(CPU implementer : 0x51
313*eca53ba6SRoland Levillain CPU architecture: 7
314*eca53ba6SRoland Levillain CPU variant : 0x0
315*eca53ba6SRoland Levillain CPU part : 0x6f
316*eca53ba6SRoland Levillain CPU revision : 2)");
317*eca53ba6SRoland Levillain const auto info = GetArmInfo();
318*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idiva);
319*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idivt);
320*eca53ba6SRoland Levillain
321*eca53ba6SRoland Levillain EXPECT_EQ(GetArmCpuId(&info), 0x510006f2);
322*eca53ba6SRoland Levillain }
323*eca53ba6SRoland Levillain
324*eca53ba6SRoland Levillain // The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report IDIV
325*eca53ba6SRoland Levillain // support.
TEST(CpuinfoArmTest,Nexus4_0x510006f3)326*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, Nexus4_0x510006f3) {
327*eca53ba6SRoland Levillain ResetHwcaps();
328*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
329*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
330*eca53ba6SRoland Levillain R"(CPU implementer : 0x51
331*eca53ba6SRoland Levillain CPU architecture: 7
332*eca53ba6SRoland Levillain CPU variant : 0x0
333*eca53ba6SRoland Levillain CPU part : 0x6f
334*eca53ba6SRoland Levillain CPU revision : 3)");
335*eca53ba6SRoland Levillain const auto info = GetArmInfo();
336*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idiva);
337*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idivt);
338*eca53ba6SRoland Levillain
339*eca53ba6SRoland Levillain EXPECT_EQ(GetArmCpuId(&info), 0x510006f3);
340*eca53ba6SRoland Levillain }
341*eca53ba6SRoland Levillain
342*eca53ba6SRoland Levillain // The 2013 Nexus 7 (Qualcomm Krait) kernel configuration forgets to report IDIV
343*eca53ba6SRoland Levillain // support.
TEST(CpuinfoArmTest,Nexus7_2013_0x511006f0)344*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, Nexus7_2013_0x511006f0) {
345*eca53ba6SRoland Levillain ResetHwcaps();
346*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
347*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
348*eca53ba6SRoland Levillain R"(CPU implementer : 0x51
349*eca53ba6SRoland Levillain CPU architecture: 7
350*eca53ba6SRoland Levillain CPU variant : 0x1
351*eca53ba6SRoland Levillain CPU part : 0x06f
352*eca53ba6SRoland Levillain CPU revision : 0)");
353*eca53ba6SRoland Levillain const auto info = GetArmInfo();
354*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idiva);
355*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idivt);
356*eca53ba6SRoland Levillain
357*eca53ba6SRoland Levillain EXPECT_EQ(GetArmCpuId(&info), 0x511006f0);
358*eca53ba6SRoland Levillain }
359*eca53ba6SRoland Levillain
360*eca53ba6SRoland Levillain // The emulator-specific Android 4.2 kernel fails to report support for the
361*eca53ba6SRoland Levillain // 32-bit ARM IDIV instruction. Technically, this is a feature of the virtual
362*eca53ba6SRoland Levillain // CPU implemented by the emulator.
TEST(CpuinfoArmTest,EmulatorSpecificIdiv)363*eca53ba6SRoland Levillain TEST(CpuinfoArmTest, EmulatorSpecificIdiv) {
364*eca53ba6SRoland Levillain ResetHwcaps();
365*eca53ba6SRoland Levillain auto& fs = GetEmptyFilesystem();
366*eca53ba6SRoland Levillain fs.CreateFile("/proc/cpuinfo",
367*eca53ba6SRoland Levillain R"(Processor : ARMv7 Processor rev 0 (v7l)
368*eca53ba6SRoland Levillain BogoMIPS : 629.14
369*eca53ba6SRoland Levillain Features : swp half thumb fastmult vfp edsp neon vfpv3
370*eca53ba6SRoland Levillain CPU implementer : 0x41
371*eca53ba6SRoland Levillain CPU architecture: 7
372*eca53ba6SRoland Levillain CPU variant : 0x0
373*eca53ba6SRoland Levillain CPU part : 0xc08
374*eca53ba6SRoland Levillain CPU revision : 0
375*eca53ba6SRoland Levillain
376*eca53ba6SRoland Levillain Hardware : Goldfish
377*eca53ba6SRoland Levillain Revision : 0000
378*eca53ba6SRoland Levillain Serial : 0000000000000000)");
379*eca53ba6SRoland Levillain const auto info = GetArmInfo();
380*eca53ba6SRoland Levillain EXPECT_TRUE(info.features.idiva);
381*eca53ba6SRoland Levillain }
382*eca53ba6SRoland Levillain
383*eca53ba6SRoland Levillain } // namespace
384*eca53ba6SRoland Levillain } // namespace cpu_features
385