Regenerate mocks for NVML

Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
Kevin Klues 2022-12-08 14:47:41 +00:00
parent 6a4886e49e
commit 5d4be6ac55
4 changed files with 312 additions and 180 deletions

View File

@ -64,6 +64,7 @@ func (mock *ComputeInstanceMock) Destroy() Return {
// DestroyCalls gets all the calls that were made to Destroy.
// Check the length with:
//
// len(mockedComputeInstance.DestroyCalls())
func (mock *ComputeInstanceMock) DestroyCalls() []struct {
} {
@ -90,6 +91,7 @@ func (mock *ComputeInstanceMock) GetInfo() (ComputeInstanceInfo, Return) {
// GetInfoCalls gets all the calls that were made to GetInfo.
// Check the length with:
//
// len(mockedComputeInstance.GetInfoCalls())
func (mock *ComputeInstanceMock) GetInfoCalls() []struct {
} {

View File

@ -17,6 +17,9 @@ var _ Device = &DeviceMock{}
//
// // make and configure a mocked Device
// mockedDevice := &DeviceMock{
// CreateGpuInstanceWithPlacementFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) {
// panic("mock out the CreateGpuInstanceWithPlacement method")
// },
// GetAttributesFunc: func() (DeviceAttributes, Return) {
// panic("mock out the GetAttributes method")
// },
@ -35,6 +38,9 @@ var _ Device = &DeviceMock{}
// GetGpuInstanceIdFunc: func() (int, Return) {
// panic("mock out the GetGpuInstanceId method")
// },
// GetGpuInstancePossiblePlacementsFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) {
// panic("mock out the GetGpuInstancePossiblePlacements method")
// },
// GetGpuInstanceProfileInfoFunc: func(Profile int) (GpuInstanceProfileInfo, Return) {
// panic("mock out the GetGpuInstanceProfileInfo method")
// },
@ -87,6 +93,9 @@ var _ Device = &DeviceMock{}
//
// }
type DeviceMock struct {
// CreateGpuInstanceWithPlacementFunc mocks the CreateGpuInstanceWithPlacement method.
CreateGpuInstanceWithPlacementFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return)
// GetAttributesFunc mocks the GetAttributes method.
GetAttributesFunc func() (DeviceAttributes, Return)
@ -105,6 +114,9 @@ type DeviceMock struct {
// GetGpuInstanceIdFunc mocks the GetGpuInstanceId method.
GetGpuInstanceIdFunc func() (int, Return)
// GetGpuInstancePossiblePlacementsFunc mocks the GetGpuInstancePossiblePlacements method.
GetGpuInstancePossiblePlacementsFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return)
// GetGpuInstanceProfileInfoFunc mocks the GetGpuInstanceProfileInfo method.
GetGpuInstanceProfileInfoFunc func(Profile int) (GpuInstanceProfileInfo, Return)
@ -152,6 +164,13 @@ type DeviceMock struct {
// calls tracks calls to the methods.
calls struct {
// CreateGpuInstanceWithPlacement holds details about calls to the CreateGpuInstanceWithPlacement method.
CreateGpuInstanceWithPlacement []struct {
// GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value.
GpuInstanceProfileInfo *GpuInstanceProfileInfo
// GpuInstancePlacement is the gpuInstancePlacement argument value.
GpuInstancePlacement *GpuInstancePlacement
}
// GetAttributes holds details about calls to the GetAttributes method.
GetAttributes []struct {
}
@ -172,6 +191,11 @@ type DeviceMock struct {
// GetGpuInstanceId holds details about calls to the GetGpuInstanceId method.
GetGpuInstanceId []struct {
}
// GetGpuInstancePossiblePlacements holds details about calls to the GetGpuInstancePossiblePlacements method.
GetGpuInstancePossiblePlacements []struct {
// GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value.
GpuInstanceProfileInfo *GpuInstanceProfileInfo
}
// GetGpuInstanceProfileInfo holds details about calls to the GetGpuInstanceProfileInfo method.
GetGpuInstanceProfileInfo []struct {
// Profile is the Profile argument value.
@ -230,12 +254,14 @@ type DeviceMock struct {
Mode int
}
}
lockCreateGpuInstanceWithPlacement sync.RWMutex
lockGetAttributes sync.RWMutex
lockGetComputeInstanceId sync.RWMutex
lockGetCudaComputeCapability sync.RWMutex
lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex
lockGetGpuInstanceById sync.RWMutex
lockGetGpuInstanceId sync.RWMutex
lockGetGpuInstancePossiblePlacements sync.RWMutex
lockGetGpuInstanceProfileInfo sync.RWMutex
lockGetGpuInstances sync.RWMutex
lockGetIndex sync.RWMutex
@ -253,6 +279,42 @@ type DeviceMock struct {
lockSetMigMode sync.RWMutex
}
// CreateGpuInstanceWithPlacement calls CreateGpuInstanceWithPlacementFunc.
func (mock *DeviceMock) CreateGpuInstanceWithPlacement(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) {
if mock.CreateGpuInstanceWithPlacementFunc == nil {
panic("DeviceMock.CreateGpuInstanceWithPlacementFunc: method is nil but Device.CreateGpuInstanceWithPlacement was just called")
}
callInfo := struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
GpuInstancePlacement *GpuInstancePlacement
}{
GpuInstanceProfileInfo: gpuInstanceProfileInfo,
GpuInstancePlacement: gpuInstancePlacement,
}
mock.lockCreateGpuInstanceWithPlacement.Lock()
mock.calls.CreateGpuInstanceWithPlacement = append(mock.calls.CreateGpuInstanceWithPlacement, callInfo)
mock.lockCreateGpuInstanceWithPlacement.Unlock()
return mock.CreateGpuInstanceWithPlacementFunc(gpuInstanceProfileInfo, gpuInstancePlacement)
}
// CreateGpuInstanceWithPlacementCalls gets all the calls that were made to CreateGpuInstanceWithPlacement.
// Check the length with:
//
// len(mockedDevice.CreateGpuInstanceWithPlacementCalls())
func (mock *DeviceMock) CreateGpuInstanceWithPlacementCalls() []struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
GpuInstancePlacement *GpuInstancePlacement
} {
var calls []struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
GpuInstancePlacement *GpuInstancePlacement
}
mock.lockCreateGpuInstanceWithPlacement.RLock()
calls = mock.calls.CreateGpuInstanceWithPlacement
mock.lockCreateGpuInstanceWithPlacement.RUnlock()
return calls
}
// GetAttributes calls GetAttributesFunc.
func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) {
if mock.GetAttributesFunc == nil {
@ -268,6 +330,7 @@ func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) {
// GetAttributesCalls gets all the calls that were made to GetAttributes.
// Check the length with:
//
// len(mockedDevice.GetAttributesCalls())
func (mock *DeviceMock) GetAttributesCalls() []struct {
} {
@ -294,6 +357,7 @@ func (mock *DeviceMock) GetComputeInstanceId() (int, Return) {
// GetComputeInstanceIdCalls gets all the calls that were made to GetComputeInstanceId.
// Check the length with:
//
// len(mockedDevice.GetComputeInstanceIdCalls())
func (mock *DeviceMock) GetComputeInstanceIdCalls() []struct {
} {
@ -320,6 +384,7 @@ func (mock *DeviceMock) GetCudaComputeCapability() (int, int, Return) {
// GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability.
// Check the length with:
//
// len(mockedDevice.GetCudaComputeCapabilityCalls())
func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct {
} {
@ -346,6 +411,7 @@ func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, Return) {
// GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle.
// Check the length with:
//
// len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls())
func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct {
} {
@ -375,6 +441,7 @@ func (mock *DeviceMock) GetGpuInstanceById(ID int) (GpuInstance, Return) {
// GetGpuInstanceByIdCalls gets all the calls that were made to GetGpuInstanceById.
// Check the length with:
//
// len(mockedDevice.GetGpuInstanceByIdCalls())
func (mock *DeviceMock) GetGpuInstanceByIdCalls() []struct {
ID int
@ -403,6 +470,7 @@ func (mock *DeviceMock) GetGpuInstanceId() (int, Return) {
// GetGpuInstanceIdCalls gets all the calls that were made to GetGpuInstanceId.
// Check the length with:
//
// len(mockedDevice.GetGpuInstanceIdCalls())
func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct {
} {
@ -414,6 +482,38 @@ func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct {
return calls
}
// GetGpuInstancePossiblePlacements calls GetGpuInstancePossiblePlacementsFunc.
func (mock *DeviceMock) GetGpuInstancePossiblePlacements(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) {
if mock.GetGpuInstancePossiblePlacementsFunc == nil {
panic("DeviceMock.GetGpuInstancePossiblePlacementsFunc: method is nil but Device.GetGpuInstancePossiblePlacements was just called")
}
callInfo := struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
}{
GpuInstanceProfileInfo: gpuInstanceProfileInfo,
}
mock.lockGetGpuInstancePossiblePlacements.Lock()
mock.calls.GetGpuInstancePossiblePlacements = append(mock.calls.GetGpuInstancePossiblePlacements, callInfo)
mock.lockGetGpuInstancePossiblePlacements.Unlock()
return mock.GetGpuInstancePossiblePlacementsFunc(gpuInstanceProfileInfo)
}
// GetGpuInstancePossiblePlacementsCalls gets all the calls that were made to GetGpuInstancePossiblePlacements.
// Check the length with:
//
// len(mockedDevice.GetGpuInstancePossiblePlacementsCalls())
func (mock *DeviceMock) GetGpuInstancePossiblePlacementsCalls() []struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
} {
var calls []struct {
GpuInstanceProfileInfo *GpuInstanceProfileInfo
}
mock.lockGetGpuInstancePossiblePlacements.RLock()
calls = mock.calls.GetGpuInstancePossiblePlacements
mock.lockGetGpuInstancePossiblePlacements.RUnlock()
return calls
}
// GetGpuInstanceProfileInfo calls GetGpuInstanceProfileInfoFunc.
func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) {
if mock.GetGpuInstanceProfileInfoFunc == nil {
@ -432,6 +532,7 @@ func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfi
// GetGpuInstanceProfileInfoCalls gets all the calls that were made to GetGpuInstanceProfileInfo.
// Check the length with:
//
// len(mockedDevice.GetGpuInstanceProfileInfoCalls())
func (mock *DeviceMock) GetGpuInstanceProfileInfoCalls() []struct {
Profile int
@ -463,6 +564,7 @@ func (mock *DeviceMock) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInst
// GetGpuInstancesCalls gets all the calls that were made to GetGpuInstances.
// Check the length with:
//
// len(mockedDevice.GetGpuInstancesCalls())
func (mock *DeviceMock) GetGpuInstancesCalls() []struct {
Info *GpuInstanceProfileInfo
@ -491,6 +593,7 @@ func (mock *DeviceMock) GetIndex() (int, Return) {
// GetIndexCalls gets all the calls that were made to GetIndex.
// Check the length with:
//
// len(mockedDevice.GetIndexCalls())
func (mock *DeviceMock) GetIndexCalls() []struct {
} {
@ -517,6 +620,7 @@ func (mock *DeviceMock) GetMaxMigDeviceCount() (int, Return) {
// GetMaxMigDeviceCountCalls gets all the calls that were made to GetMaxMigDeviceCount.
// Check the length with:
//
// len(mockedDevice.GetMaxMigDeviceCountCalls())
func (mock *DeviceMock) GetMaxMigDeviceCountCalls() []struct {
} {
@ -543,6 +647,7 @@ func (mock *DeviceMock) GetMemoryInfo() (Memory, Return) {
// GetMemoryInfoCalls gets all the calls that were made to GetMemoryInfo.
// Check the length with:
//
// len(mockedDevice.GetMemoryInfoCalls())
func (mock *DeviceMock) GetMemoryInfoCalls() []struct {
} {
@ -572,6 +677,7 @@ func (mock *DeviceMock) GetMigDeviceHandleByIndex(Index int) (Device, Return) {
// GetMigDeviceHandleByIndexCalls gets all the calls that were made to GetMigDeviceHandleByIndex.
// Check the length with:
//
// len(mockedDevice.GetMigDeviceHandleByIndexCalls())
func (mock *DeviceMock) GetMigDeviceHandleByIndexCalls() []struct {
Index int
@ -600,6 +706,7 @@ func (mock *DeviceMock) GetMigMode() (int, int, Return) {
// GetMigModeCalls gets all the calls that were made to GetMigMode.
// Check the length with:
//
// len(mockedDevice.GetMigModeCalls())
func (mock *DeviceMock) GetMigModeCalls() []struct {
} {
@ -626,6 +733,7 @@ func (mock *DeviceMock) GetMinorNumber() (int, Return) {
// GetMinorNumberCalls gets all the calls that were made to GetMinorNumber.
// Check the length with:
//
// len(mockedDevice.GetMinorNumberCalls())
func (mock *DeviceMock) GetMinorNumberCalls() []struct {
} {
@ -652,6 +760,7 @@ func (mock *DeviceMock) GetName() (string, Return) {
// GetNameCalls gets all the calls that were made to GetName.
// Check the length with:
//
// len(mockedDevice.GetNameCalls())
func (mock *DeviceMock) GetNameCalls() []struct {
} {
@ -678,6 +787,7 @@ func (mock *DeviceMock) GetPciInfo() (PciInfo, Return) {
// GetPciInfoCalls gets all the calls that were made to GetPciInfo.
// Check the length with:
//
// len(mockedDevice.GetPciInfoCalls())
func (mock *DeviceMock) GetPciInfoCalls() []struct {
} {
@ -704,6 +814,7 @@ func (mock *DeviceMock) GetSupportedEventTypes() (uint64, Return) {
// GetSupportedEventTypesCalls gets all the calls that were made to GetSupportedEventTypes.
// Check the length with:
//
// len(mockedDevice.GetSupportedEventTypesCalls())
func (mock *DeviceMock) GetSupportedEventTypesCalls() []struct {
} {
@ -730,6 +841,7 @@ func (mock *DeviceMock) GetUUID() (string, Return) {
// GetUUIDCalls gets all the calls that were made to GetUUID.
// Check the length with:
//
// len(mockedDevice.GetUUIDCalls())
func (mock *DeviceMock) GetUUIDCalls() []struct {
} {
@ -756,6 +868,7 @@ func (mock *DeviceMock) IsMigDeviceHandle() (bool, Return) {
// IsMigDeviceHandleCalls gets all the calls that were made to IsMigDeviceHandle.
// Check the length with:
//
// len(mockedDevice.IsMigDeviceHandleCalls())
func (mock *DeviceMock) IsMigDeviceHandleCalls() []struct {
} {
@ -787,6 +900,7 @@ func (mock *DeviceMock) RegisterEvents(v uint64, eventSet EventSet) Return {
// RegisterEventsCalls gets all the calls that were made to RegisterEvents.
// Check the length with:
//
// len(mockedDevice.RegisterEventsCalls())
func (mock *DeviceMock) RegisterEventsCalls() []struct {
V uint64
@ -820,6 +934,7 @@ func (mock *DeviceMock) SetMigMode(Mode int) (Return, Return) {
// SetMigModeCalls gets all the calls that were made to SetMigMode.
// Check the length with:
//
// len(mockedDevice.SetMigModeCalls())
func (mock *DeviceMock) SetMigModeCalls() []struct {
Mode int

View File

@ -117,6 +117,7 @@ func (mock *GpuInstanceMock) CreateComputeInstance(Info *ComputeInstanceProfileI
// CreateComputeInstanceCalls gets all the calls that were made to CreateComputeInstance.
// Check the length with:
//
// len(mockedGpuInstance.CreateComputeInstanceCalls())
func (mock *GpuInstanceMock) CreateComputeInstanceCalls() []struct {
Info *ComputeInstanceProfileInfo
@ -145,6 +146,7 @@ func (mock *GpuInstanceMock) Destroy() Return {
// DestroyCalls gets all the calls that were made to Destroy.
// Check the length with:
//
// len(mockedGpuInstance.DestroyCalls())
func (mock *GpuInstanceMock) DestroyCalls() []struct {
} {
@ -174,6 +176,7 @@ func (mock *GpuInstanceMock) GetComputeInstanceById(ID int) (ComputeInstance, Re
// GetComputeInstanceByIdCalls gets all the calls that were made to GetComputeInstanceById.
// Check the length with:
//
// len(mockedGpuInstance.GetComputeInstanceByIdCalls())
func (mock *GpuInstanceMock) GetComputeInstanceByIdCalls() []struct {
ID int
@ -207,6 +210,7 @@ func (mock *GpuInstanceMock) GetComputeInstanceProfileInfo(Profile int, EngProfi
// GetComputeInstanceProfileInfoCalls gets all the calls that were made to GetComputeInstanceProfileInfo.
// Check the length with:
//
// len(mockedGpuInstance.GetComputeInstanceProfileInfoCalls())
func (mock *GpuInstanceMock) GetComputeInstanceProfileInfoCalls() []struct {
Profile int
@ -240,6 +244,7 @@ func (mock *GpuInstanceMock) GetComputeInstances(Info *ComputeInstanceProfileInf
// GetComputeInstancesCalls gets all the calls that were made to GetComputeInstances.
// Check the length with:
//
// len(mockedGpuInstance.GetComputeInstancesCalls())
func (mock *GpuInstanceMock) GetComputeInstancesCalls() []struct {
Info *ComputeInstanceProfileInfo
@ -268,6 +273,7 @@ func (mock *GpuInstanceMock) GetInfo() (GpuInstanceInfo, Return) {
// GetInfoCalls gets all the calls that were made to GetInfo.
// Check the length with:
//
// len(mockedGpuInstance.GetInfoCalls())
func (mock *GpuInstanceMock) GetInfoCalls() []struct {
} {

View File

@ -140,6 +140,7 @@ func (mock *InterfaceMock) DeviceGetCount() (int, Return) {
// DeviceGetCountCalls gets all the calls that were made to DeviceGetCount.
// Check the length with:
//
// len(mockedInterface.DeviceGetCountCalls())
func (mock *InterfaceMock) DeviceGetCountCalls() []struct {
} {
@ -169,6 +170,7 @@ func (mock *InterfaceMock) DeviceGetHandleByIndex(Index int) (Device, Return) {
// DeviceGetHandleByIndexCalls gets all the calls that were made to DeviceGetHandleByIndex.
// Check the length with:
//
// len(mockedInterface.DeviceGetHandleByIndexCalls())
func (mock *InterfaceMock) DeviceGetHandleByIndexCalls() []struct {
Index int
@ -200,6 +202,7 @@ func (mock *InterfaceMock) DeviceGetHandleByUUID(UUID string) (Device, Return) {
// DeviceGetHandleByUUIDCalls gets all the calls that were made to DeviceGetHandleByUUID.
// Check the length with:
//
// len(mockedInterface.DeviceGetHandleByUUIDCalls())
func (mock *InterfaceMock) DeviceGetHandleByUUIDCalls() []struct {
UUID string
@ -231,6 +234,7 @@ func (mock *InterfaceMock) ErrorString(r Return) string {
// ErrorStringCalls gets all the calls that were made to ErrorString.
// Check the length with:
//
// len(mockedInterface.ErrorStringCalls())
func (mock *InterfaceMock) ErrorStringCalls() []struct {
R Return
@ -259,6 +263,7 @@ func (mock *InterfaceMock) EventSetCreate() (EventSet, Return) {
// EventSetCreateCalls gets all the calls that were made to EventSetCreate.
// Check the length with:
//
// len(mockedInterface.EventSetCreateCalls())
func (mock *InterfaceMock) EventSetCreateCalls() []struct {
} {
@ -285,6 +290,7 @@ func (mock *InterfaceMock) Init() Return {
// InitCalls gets all the calls that were made to Init.
// Check the length with:
//
// len(mockedInterface.InitCalls())
func (mock *InterfaceMock) InitCalls() []struct {
} {
@ -311,6 +317,7 @@ func (mock *InterfaceMock) Shutdown() Return {
// ShutdownCalls gets all the calls that were made to Shutdown.
// Check the length with:
//
// len(mockedInterface.ShutdownCalls())
func (mock *InterfaceMock) ShutdownCalls() []struct {
} {
@ -337,6 +344,7 @@ func (mock *InterfaceMock) SystemGetCudaDriverVersion() (int, Return) {
// SystemGetCudaDriverVersionCalls gets all the calls that were made to SystemGetCudaDriverVersion.
// Check the length with:
//
// len(mockedInterface.SystemGetCudaDriverVersionCalls())
func (mock *InterfaceMock) SystemGetCudaDriverVersionCalls() []struct {
} {
@ -363,6 +371,7 @@ func (mock *InterfaceMock) SystemGetDriverVersion() (string, Return) {
// SystemGetDriverVersionCalls gets all the calls that were made to SystemGetDriverVersion.
// Check the length with:
//
// len(mockedInterface.SystemGetDriverVersionCalls())
func (mock *InterfaceMock) SystemGetDriverVersionCalls() []struct {
} {