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 14, 2024
1 parent a6e8a30 commit 8d9bb9d
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.Fatalf("reading ME FPT: got %v, want nil", err)
}
entries := len(fpt.Entries)
if entries != expectedEntries {
t.Errorf("len(fpt.Entries): got %d, want %d", entries, expectedEntries)
}
if entries != int(fpt.PartitionCount) {
t.Errorf("fpt.PartitionCount: got %d, want %d (matching number of entries)", fpt.PartitionCount, entries)
}
})
}

0 comments on commit 8d9bb9d

Please sign in to comment.