mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-23 00:38:26 +00:00
1dc028cdf2
This change adds a UsesNVGPUModule function that checks whether the nvgpu kernel module is used by NVML. This allows for more robust detection of Tegra-based platforms where libnvidia-ml.so is supported to enumerate the iGPU. Signed-off-by: Evan Lezar <elezar@nvidia.com>
195 lines
4.8 KiB
Go
195 lines
4.8 KiB
Go
// Code generated by moq; DO NOT EDIT.
|
|
// github.com/matryer/moq
|
|
|
|
package info
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// Ensure, that infoInterfaceMock does implement infoInterface.
|
|
// If this is not the case, regenerate this file with moq.
|
|
var _ infoInterface = &infoInterfaceMock{}
|
|
|
|
// infoInterfaceMock is a mock implementation of infoInterface.
|
|
//
|
|
// func TestSomethingThatUsesinfoInterface(t *testing.T) {
|
|
//
|
|
// // make and configure a mocked infoInterface
|
|
// mockedinfoInterface := &infoInterfaceMock{
|
|
// HasDXCoreFunc: func() (bool, string) {
|
|
// panic("mock out the HasDXCore method")
|
|
// },
|
|
// HasNvmlFunc: func() (bool, string) {
|
|
// panic("mock out the HasNvml method")
|
|
// },
|
|
// IsTegraSystemFunc: func() (bool, string) {
|
|
// panic("mock out the IsTegraSystem method")
|
|
// },
|
|
// UsesNVGPUModuleFunc: func() (bool, string) {
|
|
// panic("mock out the UsesNVGPUModule method")
|
|
// },
|
|
// }
|
|
//
|
|
// // use mockedinfoInterface in code that requires infoInterface
|
|
// // and then make assertions.
|
|
//
|
|
// }
|
|
type infoInterfaceMock struct {
|
|
// HasDXCoreFunc mocks the HasDXCore method.
|
|
HasDXCoreFunc func() (bool, string)
|
|
|
|
// HasNvmlFunc mocks the HasNvml method.
|
|
HasNvmlFunc func() (bool, string)
|
|
|
|
// IsTegraSystemFunc mocks the IsTegraSystem method.
|
|
IsTegraSystemFunc func() (bool, string)
|
|
|
|
// UsesNVGPUModuleFunc mocks the UsesNVGPUModule method.
|
|
UsesNVGPUModuleFunc func() (bool, string)
|
|
|
|
// calls tracks calls to the methods.
|
|
calls struct {
|
|
// HasDXCore holds details about calls to the HasDXCore method.
|
|
HasDXCore []struct {
|
|
}
|
|
// HasNvml holds details about calls to the HasNvml method.
|
|
HasNvml []struct {
|
|
}
|
|
// IsTegraSystem holds details about calls to the IsTegraSystem method.
|
|
IsTegraSystem []struct {
|
|
}
|
|
// UsesNVGPUModule holds details about calls to the UsesNVGPUModule method.
|
|
UsesNVGPUModule []struct {
|
|
}
|
|
}
|
|
lockHasDXCore sync.RWMutex
|
|
lockHasNvml sync.RWMutex
|
|
lockIsTegraSystem sync.RWMutex
|
|
lockUsesNVGPUModule sync.RWMutex
|
|
}
|
|
|
|
// HasDXCore calls HasDXCoreFunc.
|
|
func (mock *infoInterfaceMock) HasDXCore() (bool, string) {
|
|
callInfo := struct {
|
|
}{}
|
|
mock.lockHasDXCore.Lock()
|
|
mock.calls.HasDXCore = append(mock.calls.HasDXCore, callInfo)
|
|
mock.lockHasDXCore.Unlock()
|
|
if mock.HasDXCoreFunc == nil {
|
|
var (
|
|
bOut bool
|
|
sOut string
|
|
)
|
|
return bOut, sOut
|
|
}
|
|
return mock.HasDXCoreFunc()
|
|
}
|
|
|
|
// HasDXCoreCalls gets all the calls that were made to HasDXCore.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedinfoInterface.HasDXCoreCalls())
|
|
func (mock *infoInterfaceMock) HasDXCoreCalls() []struct {
|
|
} {
|
|
var calls []struct {
|
|
}
|
|
mock.lockHasDXCore.RLock()
|
|
calls = mock.calls.HasDXCore
|
|
mock.lockHasDXCore.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// HasNvml calls HasNvmlFunc.
|
|
func (mock *infoInterfaceMock) HasNvml() (bool, string) {
|
|
callInfo := struct {
|
|
}{}
|
|
mock.lockHasNvml.Lock()
|
|
mock.calls.HasNvml = append(mock.calls.HasNvml, callInfo)
|
|
mock.lockHasNvml.Unlock()
|
|
if mock.HasNvmlFunc == nil {
|
|
var (
|
|
bOut bool
|
|
sOut string
|
|
)
|
|
return bOut, sOut
|
|
}
|
|
return mock.HasNvmlFunc()
|
|
}
|
|
|
|
// HasNvmlCalls gets all the calls that were made to HasNvml.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedinfoInterface.HasNvmlCalls())
|
|
func (mock *infoInterfaceMock) HasNvmlCalls() []struct {
|
|
} {
|
|
var calls []struct {
|
|
}
|
|
mock.lockHasNvml.RLock()
|
|
calls = mock.calls.HasNvml
|
|
mock.lockHasNvml.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// IsTegraSystem calls IsTegraSystemFunc.
|
|
func (mock *infoInterfaceMock) IsTegraSystem() (bool, string) {
|
|
callInfo := struct {
|
|
}{}
|
|
mock.lockIsTegraSystem.Lock()
|
|
mock.calls.IsTegraSystem = append(mock.calls.IsTegraSystem, callInfo)
|
|
mock.lockIsTegraSystem.Unlock()
|
|
if mock.IsTegraSystemFunc == nil {
|
|
var (
|
|
bOut bool
|
|
sOut string
|
|
)
|
|
return bOut, sOut
|
|
}
|
|
return mock.IsTegraSystemFunc()
|
|
}
|
|
|
|
// IsTegraSystemCalls gets all the calls that were made to IsTegraSystem.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedinfoInterface.IsTegraSystemCalls())
|
|
func (mock *infoInterfaceMock) IsTegraSystemCalls() []struct {
|
|
} {
|
|
var calls []struct {
|
|
}
|
|
mock.lockIsTegraSystem.RLock()
|
|
calls = mock.calls.IsTegraSystem
|
|
mock.lockIsTegraSystem.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// UsesNVGPUModule calls UsesNVGPUModuleFunc.
|
|
func (mock *infoInterfaceMock) UsesNVGPUModule() (bool, string) {
|
|
callInfo := struct {
|
|
}{}
|
|
mock.lockUsesNVGPUModule.Lock()
|
|
mock.calls.UsesNVGPUModule = append(mock.calls.UsesNVGPUModule, callInfo)
|
|
mock.lockUsesNVGPUModule.Unlock()
|
|
if mock.UsesNVGPUModuleFunc == nil {
|
|
var (
|
|
bOut bool
|
|
sOut string
|
|
)
|
|
return bOut, sOut
|
|
}
|
|
return mock.UsesNVGPUModuleFunc()
|
|
}
|
|
|
|
// UsesNVGPUModuleCalls gets all the calls that were made to UsesNVGPUModule.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedinfoInterface.UsesNVGPUModuleCalls())
|
|
func (mock *infoInterfaceMock) UsesNVGPUModuleCalls() []struct {
|
|
} {
|
|
var calls []struct {
|
|
}
|
|
mock.lockUsesNVGPUModule.RLock()
|
|
calls = mock.calls.UsesNVGPUModule
|
|
mock.lockUsesNVGPUModule.RUnlock()
|
|
return calls
|
|
}
|