@ -24,53 +24,7 @@ TEST(ARMLinuxTest, CPUInfo) {
const char * cpuinfo ;
unsigned long hwcap ;
unsigned long hwcap2 ;
bool broken_neon ;
} kTests [ ] = {
// https://crbug.com/341598#c33
{
" Processor: ARMv7 Processory rev 0 (v71) \n "
" processor: 0 \n "
" BogoMIPS: 13.50 \n "
" \n "
" Processor: 1 \n "
" BogoMIPS: 13.50 \n "
" \n "
" Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 "
" idiva idivt \n "
" CPU implementer : 0x51 \n "
" CPU architecture: 7 \n "
" CPU variant: 0x1 \n "
" CPU part: 0x04d \n "
" CPU revision: 0 \n "
" \n "
" Hardware: SAMSUNG M2 \n "
" Revision: 0010 \n "
" Serial: 00001e030000354e \n " ,
HWCAP_NEON ,
0 ,
true ,
} ,
// https://crbug.com/341598#c39
{
" Processor : ARMv7 Processor rev 0 (v7l) \n "
" processor : 0 \n "
" BogoMIPS : 13.53 \n "
" \n "
" Features : swp half thumb fastmult vfp edsp neon vfpv3 tls "
" vfpv4 \n "
" CPU implementer : 0x51 \n "
" CPU architecture: 7 \n "
" CPU variant : 0x1 \n "
" CPU part : 0x04d \n "
" CPU revision : 0 \n "
" \n "
" Hardware : SAMSUNG M2_ATT \n "
" Revision : 0010 \n "
" Serial : 0000df0c00004d4c \n " ,
HWCAP_NEON ,
0 ,
true ,
} ,
// Nexus 4 from https://crbug.com/341598#c43
{
" Processor : ARMv7 Processor rev 2 (v7l) \n "
@ -99,28 +53,6 @@ TEST(ARMLinuxTest, CPUInfo) {
" Serial : 0000000000000000 \n " ,
HWCAP_NEON ,
0 ,
false ,
} ,
// Razr M from https://crbug.com/341598#c43
{
" Processor : ARMv7 Processor rev 4 (v7l) \n "
" processor : 0 \n "
" BogoMIPS : 13.53 \n "
" \n "
" Features : swp half thumb fastmult vfp edsp neon vfpv3 tls "
" vfpv4 \n "
" CPU implementer : 0x51 \n "
" CPU architecture: 7 \n "
" CPU variant : 0x1 \n "
" CPU part : 0x04d \n "
" CPU revision : 4 \n "
" \n "
" Hardware : msm8960dt \n "
" Revision : 82a0 \n "
" Serial : 0001000201fe37a5 \n " ,
HWCAP_NEON ,
0 ,
false ,
} ,
// Pixel 2 (truncated slightly)
{
@ -165,15 +97,12 @@ TEST(ARMLinuxTest, CPUInfo) {
" Hardware : Qualcomm Technologies, Inc MSM8998 \n " ,
HWCAP_NEON , // CPU architecture 8 implies NEON.
HWCAP2_AES | HWCAP2_PMULL | HWCAP2_SHA1 | HWCAP2_SHA2 ,
false ,
} ,
// Nexus 4 from
// Garbage should be tolerated.
{
" Blah blah blah this is definitely an ARM CPU " ,
0 ,
0 ,
false ,
} ,
// A hypothetical ARMv8 CPU without crc32 (and thus no trailing space
// after the last crypto entry).
@ -182,7 +111,6 @@ TEST(ARMLinuxTest, CPUInfo) {
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
HWCAP2_AES | HWCAP2_PMULL | HWCAP2_SHA1 | HWCAP2_SHA2 ,
false ,
} ,
// Various combinations of ARMv8 flags.
{
@ -190,42 +118,36 @@ TEST(ARMLinuxTest, CPUInfo) {
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
HWCAP2_AES | HWCAP2_SHA1 | HWCAP2_SHA2 ,
false ,
} ,
{
" Features : pmull sha2 \n "
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
HWCAP2_PMULL | HWCAP2_SHA2 ,
false ,
} ,
{
" Features : aes aes aes not_aes aes aes \n "
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
HWCAP2_AES ,
false ,
} ,
{
" Features : \n "
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
0 ,
false ,
} ,
{
" Features : nothing \n "
" CPU architecture: 8 \n " ,
HWCAP_NEON ,
0 ,
false ,
} ,
// If opening /proc/cpuinfo fails, we process the empty string.
{
" " ,
0 ,
0 ,
false ,
} ,
} ;
@ -234,6 +156,5 @@ TEST(ARMLinuxTest, CPUInfo) {
STRING_PIECE sp = { t . cpuinfo , strlen ( t . cpuinfo ) } ;
EXPECT_EQ ( t . hwcap , crypto_get_arm_hwcap_from_cpuinfo ( & sp ) ) ;
EXPECT_EQ ( t . hwcap2 , crypto_get_arm_hwcap2_from_cpuinfo ( & sp ) ) ;
EXPECT_EQ ( t . broken_neon ? 1 : 0 , crypto_cpuinfo_has_broken_neon ( & sp ) ) ;
}
}