From 8d9bb9dfebe4f660439951148db53f676b79eecb Mon Sep 17 00:00:00 2001 From: Daniel Maslowski Date: Sun, 29 Sep 2024 19:09:58 +0200 Subject: [PATCH] pkg/uefi/meregion: add simple test to parse a valid FPT Signed-off-by: Daniel Maslowski --- pkg/uefi/meregion_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/uefi/meregion_test.go b/pkg/uefi/meregion_test.go index 3b989814..10784213 100644 --- a/pkg/uefi/meregion_test.go +++ b/pkg/uefi/meregion_test.go @@ -5,6 +5,7 @@ package uefi import ( + "os" "reflect" "testing" ) @@ -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) + } + }) +}