[libcalamares] Expand KPMCore tests

- check on FS names as well
main
Adriaan de Groot 5 years ago
parent 30335f27f0
commit fe3495ff97

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org> * SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -15,14 +16,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
* *
* SPDX-License-Identifier: GPL-3.0-or-later
* License-Filename: LICENSE
*
*/ */
#include "utils/Logger.h" #include "utils/Logger.h"
#include <kpmcore/core/partitiontable.h> #include <kpmcore/core/partitiontable.h>
#include <kpmcore/fs/filesystem.h>
#include <QtTest/QtTest> #include <QtTest/QtTest>
@ -36,6 +35,7 @@ private Q_SLOTS:
void initTestCase(); void initTestCase();
void testFlagNames(); void testFlagNames();
void testFSNames();
}; };
KPMTests::KPMTests() {} KPMTests::KPMTests() {}
@ -51,12 +51,13 @@ KPMTests::initTestCase()
void void
KPMTests::testFlagNames() KPMTests::testFlagNames()
{ {
cDebug() << "Partition flags according to KPMCore:";
int f = 1; int f = 1;
QStringList names; QStringList names;
QString s; QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() ) while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{ {
cDebug() << f << s; cDebug() << Logger::SubEntry << f << s;
names.append( s ); names.append( s );
f <<= 1; f <<= 1;
@ -78,6 +79,29 @@ KPMTests::testFlagNames()
#endif #endif
} }
void
KPMTests::testFSNames()
{
cDebug() << "FileSystem names according to KPMCore:";
// This uses KPMCore directly, rather than Calamares partition/FileSystem.h
// which doesn't wrap nameForType() -- it just provides more meaningful
// names for FS naming on FileSystem objects.
QStringList fsNames;
const auto fstypes = FileSystem::types();
fsNames.reserve( fstypes.count() );
for ( const auto t : fstypes )
{
QString s = FileSystem::nameForType( t, { "C" } ); // Untranslated
cDebug() << Logger::SubEntry << s;
fsNames.append( s );
}
QVERIFY( fsNames.contains( "ext2" ) );
QVERIFY( fsNames.contains( "ext4" ) );
QVERIFY( fsNames.contains( "reiser" ) );
}
QTEST_GUILESS_MAIN( KPMTests ) QTEST_GUILESS_MAIN( KPMTests )

Loading…
Cancel
Save