[partition] Fix build of devices test

This commit is contained in:
Adriaan de Groot 2021-08-31 13:45:15 +02:00
parent 854eb845d2
commit ede19c8a61
2 changed files with 19 additions and 8 deletions

View File

@ -44,12 +44,12 @@ calamares_add_test(
calamares_add_test(
partitioncreatelayoutstest
SOURCES
CreateLayoutsTests.cpp
${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionLayout.cpp
${PartitionModule_SOURCE_DIR}/core/PartUtils.cpp
${PartitionModule_SOURCE_DIR}/core/DeviceModel.cpp
CreateLayoutsTests.cpp
LIBRARIES
kpmcore
Calamares::calamaresui
@ -67,4 +67,7 @@ calamares_add_test(
partitiondevicestest
SOURCES
DevicesTests.cpp
${PartitionModule_SOURCE_DIR}/core/DeviceList.cpp
LIBRARIES
kpmcore
)

View File

@ -11,6 +11,9 @@
#include "utils/Logger.h"
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <QObject>
#include <QtTest/QtTest>
@ -33,14 +36,13 @@ DevicesTests::testKPMScanDevices()
{
Logger::setupLogLevel( Logger::LOGVERBOSE );
#if defined( WITH_KPMCORE4API )
cDebug() << "Getting devices via KPMCore";
CoreBackend* backend = CoreBackendManager::self()->backend();
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
QVERIFY( backend );
auto devices = backend->scanDevices(); // Whatever the default is /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
cDebug() << Logger::SubEntry << "Done getting devices.";
#else
cWarning() << "Test skipped; use KPMCore4";
#endif
QVERIFY( devices.count() > 0 );
}
void
@ -49,8 +51,14 @@ DevicesTests::testPartUtilScanDevices()
Logger::setupLogLevel( Logger::LOGVERBOSE );
cDebug() << "Getting devices via PartUtils";
auto l = PartUtils::getDevices();
auto devices = PartUtils::getDevices();
cDebug() << Logger::SubEntry << "Done getting devices.";
QVERIFY( l.count() > 0 );
QVERIFY( devices.count() > 0 );
}
QTEST_GUILESS_MAIN( DevicesTests )
#include "utils/moc-warnings.h"
#include "DevicesTests.moc"