devices

package
v1.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NVIDIAUVMMinor      = 0
	NVIDIAUVMToolsMinor = 1
	NVIDIACTLMinor      = 255
	NVIDIAModesetMinor  = 254

	NVIDIAFrontend = Name("nvidia-frontend")
	NVIDIAGPU      = NVIDIAFrontend
	NVIDIACaps     = Name("nvidia-caps")
	NVIDIAUVM      = Name("nvidia-uvm")
)

Device major numbers and device names for NVIDIA devices

Variables

This section is empty.

Functions

This section is empty.

Types

type Devices

type Devices interface {
	Exists(Name) bool
	Get(Name) (Major, bool)
}

Devices represents the set of devices under /proc/devices

func GetNVIDIADevices

func GetNVIDIADevices() (Devices, error)

GetNVIDIADevices returns the set of NVIDIA Devices on the machine

type DevicesMock

type DevicesMock struct {
	// ExistsFunc mocks the Exists method.
	ExistsFunc func(name Name) bool

	// GetFunc mocks the Get method.
	GetFunc func(name Name) (Major, bool)
	// contains filtered or unexported fields
}

DevicesMock is a mock implementation of Devices.

func TestSomethingThatUsesDevices(t *testing.T) {

	// make and configure a mocked Devices
	mockedDevices := &DevicesMock{
		ExistsFunc: func(name Name) bool {
			panic("mock out the Exists method")
		},
		GetFunc: func(name Name) (Major, bool) {
			panic("mock out the Get method")
		},
	}

	// use mockedDevices in code that requires Devices
	// and then make assertions.

}

func (*DevicesMock) Exists

func (mock *DevicesMock) Exists(name Name) bool

Exists calls ExistsFunc.

func (*DevicesMock) ExistsCalls

func (mock *DevicesMock) ExistsCalls() []struct {
	Name Name
}

ExistsCalls gets all the calls that were made to Exists. Check the length with:

len(mockedDevices.ExistsCalls())

func (*DevicesMock) Get

func (mock *DevicesMock) Get(name Name) (Major, bool)

Get calls GetFunc.

func (*DevicesMock) GetCalls

func (mock *DevicesMock) GetCalls() []struct {
	Name Name
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedDevices.GetCalls())

type Major

type Major int

Major represents a device major as specified under /proc/devices

type Name

type Name string

Name represents the name of a device as specified under /proc/devices

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL