info

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 8 Imported by: 12

Documentation

Index

Constants

View Source
const (
	PlatformAuto    = Platform("auto")
	PlatformNVML    = Platform("nvml")
	PlatformTegra   = Platform("tegra")
	PlatformWSL     = Platform("wsl")
	PlatformUnknown = Platform("unknown")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	PlatformResolver
	PropertyExtractor
}

Interface provides the API to the info package.

func New

func New(opts ...Option) Interface

New creates a new instance of the 'info' interface.

type Option

type Option func(*options)

Option defines a function for passing options to the New() call.

func WithDeviceLib added in v0.4.0

func WithDeviceLib(devicelib device.Interface) Option

WithDeviceLib sets the device library for the library.

func WithLogger added in v0.4.0

func WithLogger(logger basicLogger) Option

WithLogger sets the logger for the library.

func WithNvmlLib added in v0.4.0

func WithNvmlLib(nvmllib nvml.Interface) Option

WithNvmlLib sets the nvml library for the library.

func WithPlatform added in v0.4.0

func WithPlatform(platform Platform) Option

WithPlatform provides an option to set the platform explicitly.

func WithPropertyExtractor added in v0.4.0

func WithPropertyExtractor(propertyExtractor PropertyExtractor) Option

WithPropertyExtractor provides an Option to set the PropertyExtractor interface implementation. This is predominantly used for testing.

func WithRoot

func WithRoot(r string) Option

WithRoot provides a Option to set the root of the 'info' interface.

type Platform added in v0.4.0

type Platform string

Platform represents a supported plaform.

type PlatformResolver added in v0.4.0

type PlatformResolver interface {
	ResolvePlatform() Platform
}

PlatformResolver defines a function to resolve the current platform.

type PropertyExtractor added in v0.4.0

type PropertyExtractor interface {
	HasDXCore() (bool, string)
	HasNvml() (bool, string)
	HasTegraFiles() (bool, string)
	// Deprecated: Use HasTegraFiles instead.
	IsTegraSystem() (bool, string)
	// Deprecated: Use HasOnlyIntegratedGPUs
	UsesOnlyNVGPUModule() (bool, string)
	HasOnlyIntegratedGPUs() (bool, string)
}

PropertyExtractor provides a set of functions to query capabilities of the system.

type PropertyExtractorMock added in v0.4.0

type PropertyExtractorMock struct {
	// HasDXCoreFunc mocks the HasDXCore method.
	HasDXCoreFunc func() (bool, string)

	// HasNvmlFunc mocks the HasNvml method.
	HasNvmlFunc func() (bool, string)

	// HasOnlyIntegratedGPUsFunc mocks the HasOnlyIntegratedGPUs method.
	HasOnlyIntegratedGPUsFunc func() (bool, string)

	// HasTegraFilesFunc mocks the HasTegraFiles method.
	HasTegraFilesFunc func() (bool, string)

	// IsTegraSystemFunc mocks the IsTegraSystem method.
	IsTegraSystemFunc func() (bool, string)

	// UsesOnlyNVGPUModuleFunc mocks the UsesOnlyNVGPUModule method.
	UsesOnlyNVGPUModuleFunc func() (bool, string)
	// contains filtered or unexported fields
}

PropertyExtractorMock is a mock implementation of PropertyExtractor.

func TestSomethingThatUsesPropertyExtractor(t *testing.T) {

	// make and configure a mocked PropertyExtractor
	mockedPropertyExtractor := &PropertyExtractorMock{
		HasDXCoreFunc: func() (bool, string) {
			panic("mock out the HasDXCore method")
		},
		HasNvmlFunc: func() (bool, string) {
			panic("mock out the HasNvml method")
		},
		HasOnlyIntegratedGPUsFunc: func() (bool, string) {
			panic("mock out the HasOnlyIntegratedGPUs method")
		},
		HasTegraFilesFunc: func() (bool, string) {
			panic("mock out the HasTegraFiles method")
		},
		IsTegraSystemFunc: func() (bool, string) {
			panic("mock out the IsTegraSystem method")
		},
		UsesOnlyNVGPUModuleFunc: func() (bool, string) {
			panic("mock out the UsesOnlyNVGPUModule method")
		},
	}

	// use mockedPropertyExtractor in code that requires PropertyExtractor
	// and then make assertions.

}

func (*PropertyExtractorMock) HasDXCore added in v0.4.0

func (mock *PropertyExtractorMock) HasDXCore() (bool, string)

HasDXCore calls HasDXCoreFunc.

func (*PropertyExtractorMock) HasDXCoreCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasDXCoreCalls() []struct {
}

HasDXCoreCalls gets all the calls that were made to HasDXCore. Check the length with:

len(mockedPropertyExtractor.HasDXCoreCalls())

func (*PropertyExtractorMock) HasNvml added in v0.4.0

func (mock *PropertyExtractorMock) HasNvml() (bool, string)

HasNvml calls HasNvmlFunc.

func (*PropertyExtractorMock) HasNvmlCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasNvmlCalls() []struct {
}

HasNvmlCalls gets all the calls that were made to HasNvml. Check the length with:

len(mockedPropertyExtractor.HasNvmlCalls())

func (*PropertyExtractorMock) HasOnlyIntegratedGPUs added in v0.7.2

func (mock *PropertyExtractorMock) HasOnlyIntegratedGPUs() (bool, string)

HasOnlyIntegratedGPUs calls HasOnlyIntegratedGPUsFunc.

func (*PropertyExtractorMock) HasOnlyIntegratedGPUsCalls added in v0.7.2

func (mock *PropertyExtractorMock) HasOnlyIntegratedGPUsCalls() []struct {
}

HasOnlyIntegratedGPUsCalls gets all the calls that were made to HasOnlyIntegratedGPUs. Check the length with:

len(mockedPropertyExtractor.HasOnlyIntegratedGPUsCalls())

func (*PropertyExtractorMock) HasTegraFiles added in v0.4.0

func (mock *PropertyExtractorMock) HasTegraFiles() (bool, string)

HasTegraFiles calls HasTegraFilesFunc.

func (*PropertyExtractorMock) HasTegraFilesCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasTegraFilesCalls() []struct {
}

HasTegraFilesCalls gets all the calls that were made to HasTegraFiles. Check the length with:

len(mockedPropertyExtractor.HasTegraFilesCalls())

func (*PropertyExtractorMock) IsTegraSystem added in v0.4.0

func (mock *PropertyExtractorMock) IsTegraSystem() (bool, string)

IsTegraSystem calls IsTegraSystemFunc.

func (*PropertyExtractorMock) IsTegraSystemCalls added in v0.4.0

func (mock *PropertyExtractorMock) IsTegraSystemCalls() []struct {
}

IsTegraSystemCalls gets all the calls that were made to IsTegraSystem. Check the length with:

len(mockedPropertyExtractor.IsTegraSystemCalls())

func (*PropertyExtractorMock) UsesOnlyNVGPUModule added in v0.4.0

func (mock *PropertyExtractorMock) UsesOnlyNVGPUModule() (bool, string)

UsesOnlyNVGPUModule calls UsesOnlyNVGPUModuleFunc.

func (*PropertyExtractorMock) UsesOnlyNVGPUModuleCalls added in v0.4.0

func (mock *PropertyExtractorMock) UsesOnlyNVGPUModuleCalls() []struct {
}

UsesOnlyNVGPUModuleCalls gets all the calls that were made to UsesOnlyNVGPUModule. Check the length with:

len(mockedPropertyExtractor.UsesOnlyNVGPUModuleCalls())

Jump to

Keyboard shortcuts

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