github.com/linuxboot/fiano@v1.2.0/pkg/amd/manifest/psp_header_test.go (about)

     1  // Copyright 2019 the LinuxBoot Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package manifest
     6  
     7  import (
     8  	"bytes"
     9  	"testing"
    10  )
    11  
    12  func TestPSPHeaderParsing(t *testing.T) {
    13  	pspHeaderRaw := []byte{
    14  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    15  		0x24, 0x50, 0x53, 0x31, 0xc0, 0x50, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    16  		0x1e, 0x47, 0xa9, 0x18, 0xc0, 0x14, 0xd6, 0x5d, 0x3f, 0xcd, 0xe7, 0xbe, 0x98, 0x66, 0x2b, 0xf8,
    17  		0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x94, 0xc3, 0x8e, 0x41, 0x77, 0xd0, 0x47, 0x92,
    18  		0x92, 0xa7, 0xae, 0x67, 0x1d, 0x8, 0x3f, 0xb6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    19  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
    20  		0x57, 0x0, 0x13, 0x0, 0xff, 0xff, 0x1, 0x17, 0x0, 0x1, 0x0, 0x0, 0xc0, 0x53, 0x1, 0x0,
    21  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
    22  		0xe9, 0x92, 0x10, 0xa2, 0x7c, 0xc8, 0x35, 0xfa, 0xff, 0xf2, 0x77, 0x24, 0x21, 0xf6, 0x90, 0x6d,
    23  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    24  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    25  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    26  		0xee, 0x32, 0xb5, 0x3a, 0xe6, 0x2d, 0xf0, 0xe8, 0x99, 0x12, 0x15, 0x49, 0xdf, 0x9f, 0x0, 0x69,
    27  		0xc9, 0xcc, 0x88, 0x88, 0x41, 0x7b, 0xc, 0xe4, 0x83, 0x76, 0x3, 0xc2, 0x27, 0x4e, 0xd3, 0xc5,
    28  		0xee, 0x2d, 0x11, 0x84, 0x3c, 0x25, 0x47, 0xa4, 0x40, 0xe1, 0x25, 0xb1, 0xfa, 0x1a, 0x3a, 0x6a,
    29  		0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    30  	}
    31  	pspHeader, err := ParsePSPHeader(bytes.NewBuffer(pspHeaderRaw))
    32  	if err != nil {
    33  		t.Errorf("Expected no error when pasrsing PSPHeader, got: %v", err)
    34  		t.Fail()
    35  	}
    36  	if pspHeader.Cookie != PSPBootloaderCookie {
    37  		t.Errorf("Expected '%d' cookie in PSPHeader, got: '%d'", PSPBootloaderCookie, pspHeader.Cookie)
    38  	}
    39  	if pspHeader.Version.String() != "0.13.0.57" {
    40  		t.Errorf("Expected '0.13.0.57' version in PSPHeader, got: '%s'", pspHeader.Version.String())
    41  	}
    42  }