m/p/gpt: add GPT package
This introduces our own GPT package. It will be used for provisioning
and Metropolis images.
Change-Id: I905cd5d540673fd4b69c01d8975f98b88e24edd4
Reviewed-on: https://review.monogon.dev/c/monogon/+/956
Tested-by: Jenkins CI
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/gpt/structs_test.go b/metropolis/pkg/gpt/structs_test.go
new file mode 100644
index 0000000..dc53635
--- /dev/null
+++ b/metropolis/pkg/gpt/structs_test.go
@@ -0,0 +1,27 @@
+package gpt
+
+import (
+ "encoding/binary"
+ "reflect"
+ "testing"
+)
+
+func TestStructureSizes(t *testing.T) {
+ cases := []struct {
+ StructInstance interface{}
+ ExpectedSize int
+ }{
+ {mbr{}, 512},
+ {mbrPartitionRecord{}, 16},
+ {header{}, 92},
+ {partition{}, 128},
+ }
+ for _, c := range cases {
+ t.Run(reflect.TypeOf(c.StructInstance).String(), func(t *testing.T) {
+ actualSize := binary.Size(c.StructInstance)
+ if actualSize != c.ExpectedSize {
+ t.Errorf("Expected %d bytes, got %d", c.ExpectedSize, actualSize)
+ }
+ })
+ }
+}