mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-25 03:15:44 -05:00
[hostinfo] Massage test to handle ARM
- there **is** another source of information about the CPU, so in the test use that to cross-check what hostCPU() says. NB: it's probably a good idea to fall back on the same file in hostCPU() for better accuracy.
This commit is contained in:
parent
272cf099be
commit
082770032f
1 changed files with 23 additions and 2 deletions
|
@ -63,8 +63,29 @@ HostInfoTests::testHostOS()
|
|||
// 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 cpunames{ QStringLiteral( "Intel" ), QStringLiteral( "AMD" ) };
|
||||
QVERIFY( cpunames.contains( hostCPU() ) );
|
||||
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…
Add table
Reference in a new issue