-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
distro/fedora: add tests for boot mode
The same tests as added several commits ago for rhel8, 9 and 10.
- Loading branch information
1 parent
03febf5
commit b38df56
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package fedora | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/osbuild/images/pkg/blueprint" | ||
"github.com/osbuild/images/pkg/distro" | ||
"github.com/osbuild/images/pkg/platform" | ||
) | ||
|
||
// math/rand is good enough in this case | ||
/* #nosec G404 */ | ||
var rng = rand.New(rand.NewSource(0)) | ||
|
||
// TestESP checks whether all UEFI and hybrid images with a partition table have an ESP partition. | ||
// It also checks the opposite, i.e. that legacy images don't have an ESP. This test is only | ||
// performed on image types with a partition table, thus it doesn't run on e.g. installers and | ||
// ostree commits. | ||
func TestESP(t *testing.T) { | ||
distros := []string{"fedora-40", "fedora-41", "fedora-42"} | ||
for _, distroName := range distros { | ||
d := DistroFactory(distroName) | ||
|
||
for _, archName := range d.ListArches() { | ||
a, err := d.GetArch(archName) | ||
require.NoError(t, err) | ||
|
||
for _, itName := range a.ListImageTypes() { | ||
i, err := a.GetImageType(itName) | ||
require.NoError(t, err) | ||
|
||
it := i.(*imageType) | ||
// Nothing to test if the type doesn't have a base partition table. | ||
if it.basePartitionTables == nil { | ||
continue | ||
} | ||
|
||
t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, itName), func(t *testing.T) { | ||
pt, err := it.getPartitionTable(&blueprint.Customizations{}, distro.ImageOptions{}, rng) | ||
require.NoError(t, err) | ||
|
||
switch it.BootMode() { | ||
case platform.BOOT_HYBRID, platform.BOOT_UEFI: | ||
require.NotNil(t, pt.FindMountable("/boot/efi")) | ||
default: | ||
require.Nil(t, pt.FindMountable("/boot/efi")) | ||
} | ||
|
||
}) | ||
} | ||
} | ||
|
||
} | ||
} |