devices

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 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      = Name("nvidia")
	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)
	Count() int
}

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

func New added in v1.14.6

func New(opts ...Option) Devices

New creates a new devices struct with the specified options.

type DevicesMock

type DevicesMock struct {
	// CountFunc mocks the Count method.
	CountFunc func() int

	// 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{
		CountFunc: func() int {
			panic("mock out the Count method")
		},
		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) Count added in v1.14.6

func (mock *DevicesMock) Count() int

Count calls CountFunc.

func (*DevicesMock) CountCalls added in v1.14.6

func (mock *DevicesMock) CountCalls() []struct {
}

CountCalls gets all the calls that were made to Count. Check the length with:

len(mockedDevices.CountCalls())

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

type Option added in v1.14.6

type Option func(*builder)

func WithDeviceToMajor added in v1.14.6

func WithDeviceToMajor(deviceToMajor map[string]int) Option

WithDeviceToMajor specifies an explicit device name to major number map.

func WithFilter added in v1.14.6

func WithFilter(filter func(string) bool) Option

WithFilter specifies a filter to exclude devices.

Jump to

Keyboard shortcuts

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