commit
5066624a8e
@ -91,6 +91,17 @@ hostCPUmatch( const QString& s )
|
||||
return QString();
|
||||
}
|
||||
|
||||
static QString
|
||||
hostCPUmatchARM( const QString& s )
|
||||
{
|
||||
// Both Rock64 and Raspberry pi mention 0x41
|
||||
if ( s.contains( ": 0x41" ) )
|
||||
{
|
||||
return QStringLiteral( "ARM" );
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
#if defined( Q_OS_FREEBSD )
|
||||
QString
|
||||
hostCPU_FreeBSD()
|
||||
@ -127,6 +138,10 @@ hostCPU_Linux()
|
||||
{
|
||||
return hostCPUmatch( line );
|
||||
}
|
||||
if ( line.startsWith( "CPU implementer" ) )
|
||||
{
|
||||
return hostCPUmatchARM( line );
|
||||
}
|
||||
}
|
||||
}
|
||||
return QString(); // Not open, or not found
|
||||
|
@ -59,7 +59,33 @@ HostInfoTests::testHostOS()
|
||||
|
||||
QCOMPARE( expect, hostOS() );
|
||||
QCOMPARE( expect, hostOSName() ); // Might be the same
|
||||
QCOMPARE( QStringLiteral( "Intel" ), hostCPU() ); // On all my developer machines
|
||||
|
||||
// This is a lousy test, too: the implementation reads /proc/cpuinfo
|
||||
// and that's the only way we could use, too, to find what the "right"
|
||||
// answer is.
|
||||
QStringList x86cpunames{ QStringLiteral( "Intel" ), QStringLiteral( "AMD" ) };
|
||||
QStringList armcpunames{ QStringLiteral( "ARM" ) };
|
||||
const QString cpu = hostCPU();
|
||||
QVERIFY( x86cpunames.contains( cpu ) || armcpunames.contains( cpu ) );
|
||||
|
||||
// Try to detect family in a different way
|
||||
QFile modalias( "/sys/devices/system/cpu/modalias" );
|
||||
if ( modalias.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
QString cpumodalias = modalias.readLine();
|
||||
if ( cpumodalias.contains( "type:x86" ) )
|
||||
{
|
||||
QVERIFY( x86cpunames.contains( cpu ) );
|
||||
}
|
||||
else if ( cpumodalias.contains( "type:aarch64" ) )
|
||||
{
|
||||
QVERIFY( armcpunames.contains( cpu ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QCOMPARE( cpu, QString( "Unknown CPU modalias '%1'" ).arg(cpumodalias) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user