File: dp_vmbus_root_test.go

package info (click to toggle)
golang-github-canonical-go-efilib 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,836 kB
  • sloc: makefile: 3
file content (39 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2022 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.

package linux

import (
	"path/filepath"

	efi "github.com/canonical/go-efilib"
	. "gopkg.in/check.v1"
)

type vmbusRootSuite struct {
	TarFileMixin
}

var _ = Suite(&vmbusRootSuite{})

func (s *vmbusRootSuite) TestHandleVMBusRootDevicePathNodeSkip(c *C) {
	state := &devicePathBuilderState{remaining: []string{"ACPI0004:00"}}
	c.Check(handleVMBusRootDevicePathNode(state), Equals, errSkipDevicePathNodeHandler)
}

func (s *vmbusRootSuite) TestHandleVMBusRootDevicePathNode(c *C) {
	restore := MockSysfsPath(filepath.Join(s.UnpackTar(c, "testdata/sys.tar"), "sys"))
	defer restore()

	state := &devicePathBuilderState{
		Interface: interfaceTypeUnknown,
		processed: []string{"LNXSYSTM:00", "LNXSYBUS:00", "ACPI0004:00"},
		remaining: []string{"VMBUS:00", "f8b3781b-1e82-4818-a1c3-63d806ec15bb", "host6", "target6:0:0", "6:0:0:0", "block", "sdf"}}
	c.Check(handleVMBusRootDevicePathNode(state), IsNil)
	c.Check(state.processed, DeepEquals, []string{"LNXSYSTM:00", "LNXSYBUS:00", "ACPI0004:00", "VMBUS:00"})
	c.Check(state.remaining, DeepEquals, []string{"f8b3781b-1e82-4818-a1c3-63d806ec15bb", "host6", "target6:0:0", "6:0:0:0", "block", "sdf"})
	c.Check(state.Interface, Equals, interfaceTypeVMBus)
	c.Check(state.Path, DeepEquals, efi.DevicePath{
		&efi.ACPIExtendedDevicePathNode{HIDStr: "VMBus"}})
}