Skip to content

Commit

Permalink
pkg/uefi/meregion: add simple test to parse a valid FPT
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms committed Oct 9, 2024
1 parent a6e8a30 commit f373b45
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/uefi/meregion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package uefi

import (
"os"
"reflect"
"testing"
)
Expand Down Expand Up @@ -91,3 +92,26 @@ func TestFindFPTSignature(t *testing.T) {
})
}
}

func TestParseFPT(t *testing.T) {
t.Run("parse ME FPT", func(t *testing.T) {
fixtureFile := "../../data/PurleySiliconBinPkg/MeFirmware/IgnitionFirmware/MeRegion.bin"
meRegion, err := os.ReadFile(fixtureFile)
if err != nil {
t.Fatalf("could not read test fixture %q", fixtureFile)
}
expectedEntries := 10

fpt, err := NewMEFPT(meRegion)
if err != nil {
t.Errorf("expected no error reading a valid ME FPT, got %v", err)
}
entries := len(fpt.Entries)
if entries != expectedEntries {
t.Errorf("expected %d entries, got %d", expectedEntries, entries)
}
if entries != int(fpt.PartitionCount) {
t.Errorf("expected PartitionCount (%d) to match number of entries, got %d", fpt.PartitionCount, entries)
}
})
}

0 comments on commit f373b45

Please sign in to comment.