mirror of
https://github.com/google/go-attestation.git
synced 2024-12-21 05:53:25 +00:00
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package internal
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestParseUEFIVariableData(t *testing.T) {
|
|
data := []byte{0x61, 0xdf, 0xe4, 0x8b, 0xca, 0x93, 0xd2, 0x11, 0xaa, 0xd, 0x0, 0xe0, 0x98,
|
|
0x3, 0x2b, 0x8c, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
|
|
0x0, 0x0, 0x0, 0x0, 0x53, 0x0, 0x65, 0x0, 0x63, 0x0, 0x75, 0x0, 0x72, 0x0,
|
|
0x65, 0x0, 0x42, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x74, 0x0, 0x1}
|
|
want := UEFIVariableData{
|
|
Header: UEFIVariableDataHeader{
|
|
VariableName: efiGUID{Data1: 0x8be4df61, Data2: 0x93ca, Data3: 0x11d2, Data4: [8]uint8{0xaa, 0xd, 0x0, 0xe0, 0x98, 0x3, 0x2b, 0x8c}},
|
|
UnicodeNameLength: 0xa,
|
|
VariableDataLength: 0x1,
|
|
},
|
|
UnicodeName: []uint16{0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x42, 0x6f, 0x6f, 0x74},
|
|
VariableData: []uint8{0x1},
|
|
}
|
|
|
|
got, err := ParseUEFIVariableData(bytes.NewReader(data))
|
|
if err != nil {
|
|
t.Fatalf("ParseEFIVariableData() failed: %v", err)
|
|
}
|
|
if diff := cmp.Diff(want, got); diff != "" {
|
|
t.Errorf("ParseUEFIVariableData() mismatch (-want +got):\n%s", diff)
|
|
}
|
|
}
|