gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/uefivars/boot/efiDppMessage_test.go (about) 1 // Copyright 2020 the u-root 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 // SPDX-License-Identifier: BSD-3-Clause 6 // 7 8 package boot 9 10 import ( 11 "testing" 12 ) 13 14 //func ParseDppMsgATAPI(h EfiDevicePathProtocolHdr, b []byte) (*DppMsgATAPI, error) 15 func TestParseDppMsgATAPI(t *testing.T) { 16 in := []byte{0, 1, 2, 3} 17 hdr := EfiDevicePathProtocolHdr{ 18 ProtoType: 3, 19 ProtoSubType: 1, 20 Length: uint16(len(in) + 4), 21 } 22 p, err := ParseDppMsgATAPI(hdr, in) 23 if err != nil { 24 t.Fatal(err) 25 } 26 want := "ATAPI(pri=true,master=false,lun=770)" 27 got := p.String() 28 if want != got { 29 t.Errorf("\nwant %s\n got %s", want, got) 30 } 31 wantp := "ATAPI" 32 gotp := p.ProtoSubTypeStr() 33 if wantp != gotp { 34 t.Errorf("want %s got %s", wantp, gotp) 35 } 36 } 37 38 //func ParseDppMsgMAC(h EfiDevicePathProtocolHdr, b []byte) (*DppMsgMAC, error) 39 func TestParseDppMsgMAC(t *testing.T) { 40 in := []byte{ 41 0x00, 0x26, 0xfd, 0x00, 0x26, 0xfd, 0x00, 0x00, 42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 0x06, 46 } 47 hdr := EfiDevicePathProtocolHdr{ 48 ProtoType: 3, 49 ProtoSubType: 11, 50 Length: uint16(len(in) + 4), 51 } 52 p, err := ParseDppMsgMAC(hdr, in) 53 if err != nil { 54 t.Fatal(err) 55 } 56 want := "MAC(mac=0026fd0026fd0000000000000000000000000000000000000000000000000000,iftype=0x6)" 57 got := p.String() 58 if want != got { 59 t.Errorf("\nwant %s\n got %s", want, got) 60 } 61 wantp := "MAC" 62 gotp := p.ProtoSubTypeStr() 63 if wantp != gotp { 64 t.Errorf("want %s got %s", wantp, gotp) 65 } 66 }