diff --git a/src/modules/partition/tests/2a-legacy.conf b/src/modules/partition/tests/2a-legacy.conf new file mode 100644 index 000000000..47111a66f --- /dev/null +++ b/src/modules/partition/tests/2a-legacy.conf @@ -0,0 +1,9 @@ +--- +# Deprecated alias of efi.mountPoint +efiSystemPartition: "/boot/thisisatest" + +# Deprecated alias of efi.recommendedSize +efiSystemPartitionSize: 75MiB + +# Deprecated alias of efi.label +efiSystemPartitionName: testLabel diff --git a/src/modules/partition/tests/2b-modern.conf b/src/modules/partition/tests/2b-modern.conf new file mode 100644 index 000000000..5b6a6ddf6 --- /dev/null +++ b/src/modules/partition/tests/2b-modern.conf @@ -0,0 +1,6 @@ +--- +efi: + mountPoint: "/boot/thisismodern" + recommendedSize: 80MiB + minimumSize: 65MiB + label: "UEFI" diff --git a/src/modules/partition/tests/2c-mixed.conf b/src/modules/partition/tests/2c-mixed.conf new file mode 100644 index 000000000..f472ebef6 --- /dev/null +++ b/src/modules/partition/tests/2c-mixed.conf @@ -0,0 +1,7 @@ +--- +efi: + mountPoint: "/boot/thisismixed" + minimumSize: 80MiB + +efiSystemPartitionSize: 175MiB +efiSystemPartitionName: legacy diff --git a/src/modules/partition/tests/ConfigTests.cpp b/src/modules/partition/tests/ConfigTests.cpp index 4353d5f8f..2500f157e 100644 --- a/src/modules/partition/tests/ConfigTests.cpp +++ b/src/modules/partition/tests/ConfigTests.cpp @@ -33,6 +33,7 @@ private Q_SLOTS: void initTestCase(); void testEmptyConfig(); void testLegacySize(); + void testAll(); }; ConfigTests::ConfigTests() = default; @@ -84,7 +85,7 @@ ConfigTests::testLegacySize() { Config c( nullptr ); - const auto* gs = Calamares::JobQueue::instanceGlobalStorage(); + auto* gs = Calamares::JobQueue::instanceGlobalStorage(); QVERIFY( gs ); @@ -115,6 +116,65 @@ ConfigTests::testLegacySize() } } +void +ConfigTests::testAll() +{ + Config c( nullptr ); + + auto* gs = Calamares::JobQueue::instanceGlobalStorage(); + QVERIFY( gs ); + + + // Legacy only + { + gs->clear(); + const auto file = QStringLiteral( BUILD_AS_TEST "/2a-legacy.conf" ); + bool ok = false; + c.setConfigurationMap( Calamares::YAML::load( file, &ok ) ); + + cDebug() << "Tried to load" << file << "success?" << ok; + + QVERIFY( ok ); + + QVERIFY( gs->value( PartUtils::efiFilesystemRecommendedSizeGSKey() ).isValid() ); // Something was filled in + QCOMPARE( PartUtils::efiFilesystemRecommendedSize(), 75_MiB ); // From config + QCOMPARE( PartUtils::efiFilesystemMinimumSize(), 75_MiB ); // No separate setting + + QCOMPARE( gs->value( "efiSystemPartition" ).toString(), QStringLiteral( "/boot/thisisatest" ) ); + QCOMPARE( gs->value( "efiSystemPartitionName" ).toString(), QStringLiteral( "testLabel" ) ); + } + + // Modern only + { + gs->clear(); + bool ok = false; + c.setConfigurationMap( Calamares::YAML::load( QStringLiteral( BUILD_AS_TEST "/2b-modern.conf" ), &ok ) ); + + QVERIFY( ok ); + + QCOMPARE( PartUtils::efiFilesystemRecommendedSize(), 80_MiB ); // From config + QCOMPARE( PartUtils::efiFilesystemMinimumSize(), 65_MiB ); // Taken from config + + QCOMPARE( gs->value( "efiSystemPartition" ).toString(), QStringLiteral( "/boot/thisismodern" ) ); + QCOMPARE( gs->value( "efiSystemPartitionName" ).toString(), QStringLiteral( "UEFI" ) ); + } + + // Mixed settings + { + gs->clear(); + bool ok = false; + c.setConfigurationMap( Calamares::YAML::load( QStringLiteral( BUILD_AS_TEST "/2c-mixed.conf" ), &ok ) ); + + QVERIFY( ok ); + + QCOMPARE( PartUtils::efiFilesystemRecommendedSize(), 175_MiB ); // From config + QCOMPARE( PartUtils::efiFilesystemMinimumSize(), 80_MiB ); // Taken from config + + QCOMPARE( gs->value( "efiSystemPartition" ).toString(), QStringLiteral( "/boot/thisismixed" ) ); + QCOMPARE( gs->value( "efiSystemPartitionName" ).toString(), QStringLiteral( "legacy" ) ); + } +} + QTEST_GUILESS_MAIN( ConfigTests )