@@ -27,15 +27,6 @@ func TestCustomizeImagePartitions(t *testing.T) {
2727 }
2828}
2929
30- func TestCustomizeImagePartitionsLegacyToEfi (t * testing.T ) {
31- for _ , version := range supportedAzureLinuxVersions {
32- t .Run (string (version ), func (t * testing.T ) {
33- testCustomizeImagePartitionsToEfi (t , "TestCustomizeImagePartitionsLegacyToEfi" + string (version ),
34- baseImageTypeCoreLegacy , version )
35- })
36- }
37- }
38-
3930func testCustomizeImagePartitionsToEfi (t * testing.T , testName string , imageType baseImageType ,
4031 imageVersion baseImageVersion ,
4132) {
@@ -53,6 +44,10 @@ func testCustomizeImagePartitionsToEfi(t *testing.T, testName string, imageType
5344 return
5445 }
5546
47+ verifyEfiPartitionsImage (t , outImageFilePath , imageVersion , buildDir )
48+ }
49+
50+ func verifyEfiPartitionsImage (t * testing.T , outImageFilePath string , imageVersion baseImageVersion , buildDir string ) {
5651 // Check output file type.
5752 checkFileType (t , outImageFilePath , "raw" )
5853
@@ -196,46 +191,60 @@ func TestCustomizeImagePartitionsSizeOnly(t *testing.T) {
196191 assert .Equal (t , uint64 (2 * diskutils .GiB ), partitions [3 ].SizeInBytes )
197192}
198193
199- func TestCustomizeImagePartitionsEfiToLegacy (t * testing.T ) {
194+ func TestCustomizeImagePartitionsLegacy (t * testing.T ) {
200195 // Skip this test on arm64 because the legacy bootloader is not supported.
201196 if runtime .GOARCH == "arm64" {
202197 t .Skip ("Skipping legacy test for arm64" )
203198 }
204199
205200 for _ , version := range supportedAzureLinuxVersions {
206201 t .Run (string (version ), func (t * testing.T ) {
207- testCustomizeImagePartitionsToLegacy (t , "TestCustomizeImagePartitionsEfiToLegacy " + string (version ),
202+ testCustomizeImagePartitionsLegacy (t , "TestCustomizeImagePartitionsLegacy " + string (version ),
208203 baseImageTypeCoreEfi , version )
209204 })
210205 }
211206}
212207
213- func TestCustomizeImagePartitionsLegacy (t * testing.T ) {
214- for _ , version := range supportedAzureLinuxVersions {
215- t .Run (string (version ), func (t * testing.T ) {
216- testCustomizeImagePartitionsToLegacy (t , "TestCustomizeImagePartitionsLegacy" + string (version ),
217- baseImageTypeCoreLegacy , version )
218- })
219- }
220- }
221-
222- func testCustomizeImagePartitionsToLegacy (t * testing.T , testName string , imageType baseImageType ,
208+ func testCustomizeImagePartitionsLegacy (t * testing.T , testName string , imageType baseImageType ,
223209 imageVersion baseImageVersion ,
224210) {
225211 baseImage := checkSkipForCustomizeImage (t , imageType , imageVersion )
226212
227213 testTmpDir := filepath .Join (tmpDir , testName )
228214 buildDir := filepath .Join (testTmpDir , "build" )
229- configFile := filepath .Join (testDir , "legacyboot-config.yaml" )
230- outImageFilePath := filepath .Join (buildDir , "image.raw" )
215+ legacybootConfigFile := filepath .Join (testDir , "legacyboot-config.yaml" )
216+ efiConfigFile := filepath .Join (testDir , "partitions-config.yaml" )
217+ outImageFilePath := filepath .Join (testTmpDir , "image.raw" )
231218
232- // Customize image.
233- err := CustomizeImageWithConfigFile (buildDir , configFile , baseImage , nil , outImageFilePath , "raw" ,
219+ // Convert to legacy image.
220+ err := CustomizeImageWithConfigFile (buildDir , legacybootConfigFile , baseImage , nil , outImageFilePath , "raw" ,
221+ "" /*outputPXEArtifactsDir*/ , false /*useBaseImageRpmRepos*/ , "" /*packageSnapshotTime*/ )
222+ if ! assert .NoError (t , err ) {
223+ return
224+ }
225+
226+ verifyLegacyBootImage (t , outImageFilePath , imageVersion , buildDir )
227+
228+ // Recustomize legacy image.
229+ err = CustomizeImageWithConfigFile (buildDir , legacybootConfigFile , outImageFilePath , nil , outImageFilePath , "raw" ,
234230 "" /*outputPXEArtifactsDir*/ , false /*useBaseImageRpmRepos*/ , "" /*packageSnapshotTime*/ )
235231 if ! assert .NoError (t , err ) {
236232 return
237233 }
238234
235+ verifyLegacyBootImage (t , outImageFilePath , imageVersion , buildDir )
236+
237+ // Convert back to EFI image.
238+ err = CustomizeImageWithConfigFile (buildDir , efiConfigFile , outImageFilePath , nil , outImageFilePath , "raw" ,
239+ "" /*outputPXEArtifactsDir*/ , false /*useBaseImageRpmRepos*/ , "" /*packageSnapshotTime*/ )
240+ if ! assert .NoError (t , err ) {
241+ return
242+ }
243+
244+ verifyEfiPartitionsImage (t , outImageFilePath , imageVersion , buildDir )
245+ }
246+
247+ func verifyLegacyBootImage (t * testing.T , outImageFilePath string , imageVersion baseImageVersion , buildDir string ) {
239248 // Check output file type.
240249 checkFileType (t , outImageFilePath , "raw" )
241250
0 commit comments