From 0eafcf39040f8537f1b53882a82eede57b9bc0f0 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 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/uefi/meregion_test.go b/pkg/uefi/meregion_test.go index 3b989814..158c4a8e 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,25 @@ func TestFindFPTSignature(t *testing.T) { }) } } + +func TestParseFPT(t *testing.T) { + t.Run("parse ME FPT", func(t *testing.T) { + meRegion, err := os.ReadFile("../../data/PurleySiliconBinPkg/MeFirmware/IgnitionFirmware/MeRegion.bin") + if err != nil { + t.Errorf("%q", err) + } + expectedEntries := 10 + + fpt, err := NewMEFPT(meRegion) + if err != nil { + t.Errorf("expected no error reading a valid ME FPT") + } + 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) + } + }) +}