devicepath/parser_test.go

26 lines
942 B
Go
Raw Normal View History

2023-08-27 09:31:03 +00:00
package devicepath_test
2023-08-27 13:09:30 +00:00
import (
"testing"
2023-08-27 09:31:03 +00:00
2023-09-16 14:20:09 +00:00
"git.faercol.me/faercol/devicepath"
2023-08-27 13:09:30 +00:00
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2023-08-27 09:31:03 +00:00
2023-08-27 13:09:30 +00:00
func TestOK(t *testing.T) {
input := "Sata(1,65535,0)"
res, err := devicepath.Parsenode(input)
require.NoError(t, err)
assert.Equal(t, devicepath.MessagingDevicePath, res.Type())
assert.Equal(t, devicepath.SATAMessaging, res.SubType())
assert.Equal(t, "Sata(1,65535,0)", res.String())
}
func TestParseDevicePathOK(t *testing.T) {
2023-09-16 15:21:48 +00:00
input := "PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x1)/Sata(0,65535,0)/HD(1,GPT,16f06d01-50da-6544-86bd-f3457f980086,0x1000,0x96000)/File(\\EFI\\HTTPBOOT\\HTTP_BOOT_CLIENT.EFI)"
2023-08-27 13:09:30 +00:00
res, err := devicepath.ParseDevicePath(input)
require.NoError(t, err)
2023-09-16 15:21:48 +00:00
assert.Equal(t, "PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x1)/Sata(0,65535,0)/HD(1,GPT,16f06d01-50da-6544-86bd-f3457f980086,0x1000,0x96000)/File(\\EFI\\HTTPBOOT\\HTTP_BOOT_CLIENT.EFI)", res.String())
2023-08-27 09:31:03 +00:00
}