diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index c8c6f7fd4..6c7abc183 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -52,9 +52,6 @@ calamares_add_test( CreateLayoutsTests.cpp LIBRARIES kpmcore - calamares - calamaresui - Qt5::Gui DEFINITIONS ${_partition_defs} ) @@ -63,6 +60,10 @@ calamares_add_test( SOURCES ${PartitionModule_SOURCE_DIR}/jobs/AutoMountManagementJob.cpp AutoMountTests.cpp - LIBRARIES - calamares +) + +calamares_add_test( + partitiondevicestest + SOURCES + DevicesTests.cpp ) diff --git a/src/modules/partition/tests/DevicesTests.cpp b/src/modules/partition/tests/DevicesTests.cpp new file mode 100644 index 000000000..82311b288 --- /dev/null +++ b/src/modules/partition/tests/DevicesTests.cpp @@ -0,0 +1,56 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "core/DeviceList.h" + +#include "utils/Logger.h" + +#include +#include + +class DevicesTests : public QObject +{ + Q_OBJECT + +public: + DevicesTests(); + +private Q_SLOTS: + void testKPMScanDevices(); + void testPartUtilScanDevices(); +}; + +DevicesTests::DevicesTests() {} + +void +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 ) ); + cDebug() << Logger::SubEntry << "Done getting devices."; +#else + cWarning() << "Test skipped; use KPMCore4"; +#endif +} + +void +DevicesTests::testPartUtilScanDevices() +{ + Logger::setupLogLevel( Logger::LOGVERBOSE ); + + cDebug() << "Getting devices via PartUtils"; + auto l = PartUtils::getDevices(); + cDebug() << Logger::SubEntry << "Done getting devices."; + + QVERIFY( l.count() > 0 ); +}