From 09491e4cbb70b78ad1462d729d4fe816dcf9b9bd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Aug 2021 13:58:23 +0200 Subject: [PATCH] [partition] expect failures when kpm can't read the disk --- src/modules/partition/tests/DevicesTests.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/tests/DevicesTests.cpp b/src/modules/partition/tests/DevicesTests.cpp index 6d42e71e4..6513e955b 100644 --- a/src/modules/partition/tests/DevicesTests.cpp +++ b/src/modules/partition/tests/DevicesTests.cpp @@ -20,6 +20,8 @@ #include +#include + class DevicesTests : public QObject { Q_OBJECT @@ -33,9 +35,12 @@ private Q_SLOTS: private: std::unique_ptr< CalamaresUtils::Partition::KPMManager > m_d; + bool m_isRoot = false; }; -DevicesTests::DevicesTests() : m_d( std::make_unique< CalamaresUtils::Partition::KPMManager >() ) +DevicesTests::DevicesTests() + : m_d( std::make_unique< CalamaresUtils::Partition::KPMManager >() ) + , m_isRoot( geteuid() == 0 ) {} void @@ -54,6 +59,10 @@ DevicesTests::testKPMScanDevices() auto devices = backend->scanDevices( flags ); // These flags try to get "all" cDebug() << Logger::SubEntry << "Done getting devices."; + if ( !m_isRoot ) + { + QEXPECT_FAIL( "", "Test invalid when not root", Continue ); + } QVERIFY( devices.count() > 0 ); } @@ -66,6 +75,10 @@ DevicesTests::testPartUtilScanDevices() auto devices = PartUtils::getDevices(); cDebug() << Logger::SubEntry << "Done getting devices."; + if ( !m_isRoot ) + { + QEXPECT_FAIL( "", "Test invalid when not root", Continue ); + } QVERIFY( devices.count() > 0 ); }