Merge branch 'add-more-apis' into 'main'

Add new APIs in nvml and nvlib.device

See merge request nvidia/cloud-native/go-nvlib!29
This commit is contained in:
Kevin Klues 2023-01-19 11:47:11 +00:00
commit 6fe07bb333
9 changed files with 350 additions and 180 deletions

View File

@ -26,7 +26,9 @@ type Interface interface {
GetMigDevices() ([]MigDevice, error) GetMigDevices() ([]MigDevice, error)
GetMigProfiles() ([]MigProfile, error) GetMigProfiles() ([]MigProfile, error)
NewDevice(d nvml.Device) (Device, error) NewDevice(d nvml.Device) (Device, error)
NewDeviceByUUID(uuid string) (Device, error)
NewMigDevice(d nvml.Device) (MigDevice, error) NewMigDevice(d nvml.Device) (MigDevice, error)
NewMigDeviceByUUID(uuid string) (MigDevice, error)
NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, migMemorySizeMB, deviceMemorySizeBytes uint64) (MigProfile, error) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, migMemorySizeMB, deviceMemorySizeBytes uint64) (MigProfile, error)
ParseMigProfile(profile string) (MigProfile, error) ParseMigProfile(profile string) (MigProfile, error)
VisitDevices(func(i int, d Device) error) error VisitDevices(func(i int, d Device) error) error

View File

@ -46,6 +46,15 @@ func (d *devicelib) NewDevice(dev nvml.Device) (Device, error) {
return d.newDevice(dev) return d.newDevice(dev)
} }
// NewDeviceByUUID builds a new Device from a UUID
func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) {
dev, ret := d.nvml.DeviceGetHandleByUUID(uuid)
if ret != nvml.SUCCESS {
return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret)
}
return d.newDevice(dev)
}
// newDevice creates a device from an nvml.Device // newDevice creates a device from an nvml.Device
func (d *devicelib) newDevice(dev nvml.Device) (*device, error) { func (d *devicelib) newDevice(dev nvml.Device) (*device, error) {
return &device{dev, d}, nil return &device{dev, d}, nil

View File

@ -48,6 +48,15 @@ func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) {
return &migdevice{handle, d, nil}, nil return &migdevice{handle, d, nil}, nil
} }
// NewMigDeviceByUUID builds a new MigDevice from a UUID
func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) {
dev, ret := d.nvml.DeviceGetHandleByUUID(uuid)
if ret != nvml.SUCCESS {
return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret)
}
return d.NewMigDevice(dev)
}
// GetProfile returns the MIG profile associated with a MIG device // GetProfile returns the MIG profile associated with a MIG device
func (m *migdevice) GetProfile() (MigProfile, error) { func (m *migdevice) GetProfile() (MigProfile, error) {
if m.profile != nil { if m.profile != nil {

View File

@ -13,22 +13,22 @@ var _ ComputeInstance = &ComputeInstanceMock{}
// ComputeInstanceMock is a mock implementation of ComputeInstance. // ComputeInstanceMock is a mock implementation of ComputeInstance.
// //
// func TestSomethingThatUsesComputeInstance(t *testing.T) { // func TestSomethingThatUsesComputeInstance(t *testing.T) {
// //
// // make and configure a mocked ComputeInstance // // make and configure a mocked ComputeInstance
// mockedComputeInstance := &ComputeInstanceMock{ // mockedComputeInstance := &ComputeInstanceMock{
// DestroyFunc: func() Return { // DestroyFunc: func() Return {
// panic("mock out the Destroy method") // panic("mock out the Destroy method")
// }, // },
// GetInfoFunc: func() (ComputeInstanceInfo, Return) { // GetInfoFunc: func() (ComputeInstanceInfo, Return) {
// panic("mock out the GetInfo method") // panic("mock out the GetInfo method")
// }, // },
// } // }
// //
// // use mockedComputeInstance in code that requires ComputeInstance // // use mockedComputeInstance in code that requires ComputeInstance
// // and then make assertions. // // and then make assertions.
// //
// } // }
type ComputeInstanceMock struct { type ComputeInstanceMock struct {
// DestroyFunc mocks the Destroy method. // DestroyFunc mocks the Destroy method.
DestroyFunc func() Return DestroyFunc func() Return
@ -64,7 +64,8 @@ func (mock *ComputeInstanceMock) Destroy() Return {
// DestroyCalls gets all the calls that were made to Destroy. // DestroyCalls gets all the calls that were made to Destroy.
// Check the length with: // Check the length with:
// len(mockedComputeInstance.DestroyCalls()) //
// len(mockedComputeInstance.DestroyCalls())
func (mock *ComputeInstanceMock) DestroyCalls() []struct { func (mock *ComputeInstanceMock) DestroyCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -90,7 +91,8 @@ func (mock *ComputeInstanceMock) GetInfo() (ComputeInstanceInfo, Return) {
// GetInfoCalls gets all the calls that were made to GetInfo. // GetInfoCalls gets all the calls that were made to GetInfo.
// Check the length with: // Check the length with:
// len(mockedComputeInstance.GetInfoCalls()) //
// len(mockedComputeInstance.GetInfoCalls())
func (mock *ComputeInstanceMock) GetInfoCalls() []struct { func (mock *ComputeInstanceMock) GetInfoCalls() []struct {
} { } {
var calls []struct { var calls []struct {

View File

@ -88,6 +88,16 @@ func (d nvmlDevice) GetGpuInstanceProfileInfo(profile int) (GpuInstanceProfileIn
return GpuInstanceProfileInfo(p), Return(r) return GpuInstanceProfileInfo(p), Return(r)
} }
// GetGpuInstancePossiblePlacements returns the possible placements of a GPU Instance
func (d nvmlDevice) GetGpuInstancePossiblePlacements(info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) {
nvmlPlacements, r := nvml.Device(d).GetGpuInstancePossiblePlacements((*nvml.GpuInstanceProfileInfo)(info))
var placements []GpuInstancePlacement
for _, p := range nvmlPlacements {
placements = append(placements, GpuInstancePlacement(p))
}
return placements, Return(r)
}
// GetGpuInstances returns the set of GPU Instances associated with a Device // GetGpuInstances returns the set of GPU Instances associated with a Device
func (d nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { func (d nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance, Return) {
nvmlGis, r := nvml.Device(d).GetGpuInstances((*nvml.GpuInstanceProfileInfo)(info)) nvmlGis, r := nvml.Device(d).GetGpuInstances((*nvml.GpuInstanceProfileInfo)(info))
@ -98,6 +108,12 @@ func (d nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance
return gis, Return(r) return gis, Return(r)
} }
// CreateGpuInstanceWithPlacement creates a GPU Instance with a specific placement
func (d nvmlDevice) CreateGpuInstanceWithPlacement(info *GpuInstanceProfileInfo, placement *GpuInstancePlacement) (GpuInstance, Return) {
gi, r := nvml.Device(d).CreateGpuInstanceWithPlacement((*nvml.GpuInstanceProfileInfo)(info), (*nvml.GpuInstancePlacement)(placement))
return nvmlGpuInstance(gi), Return(r)
}
// GetMaxMigDeviceCount returns the maximum number of MIG devices that can be created on a Device // GetMaxMigDeviceCount returns the maximum number of MIG devices that can be created on a Device
func (d nvmlDevice) GetMaxMigDeviceCount() (int, Return) { func (d nvmlDevice) GetMaxMigDeviceCount() (int, Return) {
m, r := nvml.Device(d).GetMaxMigDeviceCount() m, r := nvml.Device(d).GetMaxMigDeviceCount()

View File

@ -13,80 +13,89 @@ var _ Device = &DeviceMock{}
// DeviceMock is a mock implementation of Device. // DeviceMock is a mock implementation of Device.
// //
// func TestSomethingThatUsesDevice(t *testing.T) { // func TestSomethingThatUsesDevice(t *testing.T) {
// //
// // make and configure a mocked Device // // make and configure a mocked Device
// mockedDevice := &DeviceMock{ // mockedDevice := &DeviceMock{
// GetAttributesFunc: func() (DeviceAttributes, Return) { // CreateGpuInstanceWithPlacementFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) {
// panic("mock out the GetAttributes method") // panic("mock out the CreateGpuInstanceWithPlacement method")
// }, // },
// GetComputeInstanceIdFunc: func() (int, Return) { // GetAttributesFunc: func() (DeviceAttributes, Return) {
// panic("mock out the GetComputeInstanceId method") // panic("mock out the GetAttributes method")
// }, // },
// GetCudaComputeCapabilityFunc: func() (int, int, Return) { // GetComputeInstanceIdFunc: func() (int, Return) {
// panic("mock out the GetCudaComputeCapability method") // panic("mock out the GetComputeInstanceId method")
// }, // },
// GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, Return) { // GetCudaComputeCapabilityFunc: func() (int, int, Return) {
// panic("mock out the GetDeviceHandleFromMigDeviceHandle method") // panic("mock out the GetCudaComputeCapability method")
// }, // },
// GetGpuInstanceByIdFunc: func(ID int) (GpuInstance, Return) { // GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, Return) {
// panic("mock out the GetGpuInstanceById method") // panic("mock out the GetDeviceHandleFromMigDeviceHandle method")
// }, // },
// GetGpuInstanceIdFunc: func() (int, Return) { // GetGpuInstanceByIdFunc: func(ID int) (GpuInstance, Return) {
// panic("mock out the GetGpuInstanceId method") // panic("mock out the GetGpuInstanceById method")
// }, // },
// GetGpuInstanceProfileInfoFunc: func(Profile int) (GpuInstanceProfileInfo, Return) { // GetGpuInstanceIdFunc: func() (int, Return) {
// panic("mock out the GetGpuInstanceProfileInfo method") // panic("mock out the GetGpuInstanceId method")
// }, // },
// GetGpuInstancesFunc: func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { // GetGpuInstancePossiblePlacementsFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) {
// panic("mock out the GetGpuInstances method") // panic("mock out the GetGpuInstancePossiblePlacements method")
// }, // },
// GetIndexFunc: func() (int, Return) { // GetGpuInstanceProfileInfoFunc: func(Profile int) (GpuInstanceProfileInfo, Return) {
// panic("mock out the GetIndex method") // panic("mock out the GetGpuInstanceProfileInfo method")
// }, // },
// GetMaxMigDeviceCountFunc: func() (int, Return) { // GetGpuInstancesFunc: func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) {
// panic("mock out the GetMaxMigDeviceCount method") // panic("mock out the GetGpuInstances method")
// }, // },
// GetMemoryInfoFunc: func() (Memory, Return) { // GetIndexFunc: func() (int, Return) {
// panic("mock out the GetMemoryInfo method") // panic("mock out the GetIndex method")
// }, // },
// GetMigDeviceHandleByIndexFunc: func(Index int) (Device, Return) { // GetMaxMigDeviceCountFunc: func() (int, Return) {
// panic("mock out the GetMigDeviceHandleByIndex method") // panic("mock out the GetMaxMigDeviceCount method")
// }, // },
// GetMigModeFunc: func() (int, int, Return) { // GetMemoryInfoFunc: func() (Memory, Return) {
// panic("mock out the GetMigMode method") // panic("mock out the GetMemoryInfo method")
// }, // },
// GetMinorNumberFunc: func() (int, Return) { // GetMigDeviceHandleByIndexFunc: func(Index int) (Device, Return) {
// panic("mock out the GetMinorNumber method") // panic("mock out the GetMigDeviceHandleByIndex method")
// }, // },
// GetNameFunc: func() (string, Return) { // GetMigModeFunc: func() (int, int, Return) {
// panic("mock out the GetName method") // panic("mock out the GetMigMode method")
// }, // },
// GetPciInfoFunc: func() (PciInfo, Return) { // GetMinorNumberFunc: func() (int, Return) {
// panic("mock out the GetPciInfo method") // panic("mock out the GetMinorNumber method")
// }, // },
// GetSupportedEventTypesFunc: func() (uint64, Return) { // GetNameFunc: func() (string, Return) {
// panic("mock out the GetSupportedEventTypes method") // panic("mock out the GetName method")
// }, // },
// GetUUIDFunc: func() (string, Return) { // GetPciInfoFunc: func() (PciInfo, Return) {
// panic("mock out the GetUUID method") // panic("mock out the GetPciInfo method")
// }, // },
// IsMigDeviceHandleFunc: func() (bool, Return) { // GetSupportedEventTypesFunc: func() (uint64, Return) {
// panic("mock out the IsMigDeviceHandle method") // panic("mock out the GetSupportedEventTypes method")
// }, // },
// RegisterEventsFunc: func(v uint64, eventSet EventSet) Return { // GetUUIDFunc: func() (string, Return) {
// panic("mock out the RegisterEvents method") // panic("mock out the GetUUID method")
// }, // },
// SetMigModeFunc: func(Mode int) (Return, Return) { // IsMigDeviceHandleFunc: func() (bool, Return) {
// panic("mock out the SetMigMode method") // panic("mock out the IsMigDeviceHandle method")
// }, // },
// } // RegisterEventsFunc: func(v uint64, eventSet EventSet) Return {
// panic("mock out the RegisterEvents method")
// },
// SetMigModeFunc: func(Mode int) (Return, Return) {
// panic("mock out the SetMigMode method")
// },
// }
// //
// // use mockedDevice in code that requires Device // // use mockedDevice in code that requires Device
// // and then make assertions. // // and then make assertions.
// //
// } // }
type DeviceMock struct { type DeviceMock struct {
// CreateGpuInstanceWithPlacementFunc mocks the CreateGpuInstanceWithPlacement method.
CreateGpuInstanceWithPlacementFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return)
// GetAttributesFunc mocks the GetAttributes method. // GetAttributesFunc mocks the GetAttributes method.
GetAttributesFunc func() (DeviceAttributes, Return) GetAttributesFunc func() (DeviceAttributes, Return)
@ -105,6 +114,9 @@ type DeviceMock struct {
// GetGpuInstanceIdFunc mocks the GetGpuInstanceId method. // GetGpuInstanceIdFunc mocks the GetGpuInstanceId method.
GetGpuInstanceIdFunc func() (int, Return) GetGpuInstanceIdFunc func() (int, Return)
// GetGpuInstancePossiblePlacementsFunc mocks the GetGpuInstancePossiblePlacements method.
GetGpuInstancePossiblePlacementsFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return)
// GetGpuInstanceProfileInfoFunc mocks the GetGpuInstanceProfileInfo method. // GetGpuInstanceProfileInfoFunc mocks the GetGpuInstanceProfileInfo method.
GetGpuInstanceProfileInfoFunc func(Profile int) (GpuInstanceProfileInfo, Return) GetGpuInstanceProfileInfoFunc func(Profile int) (GpuInstanceProfileInfo, Return)
@ -152,6 +164,13 @@ type DeviceMock struct {
// calls tracks calls to the methods. // calls tracks calls to the methods.
calls struct { 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 holds details about calls to the GetAttributes method.
GetAttributes []struct { GetAttributes []struct {
} }
@ -172,6 +191,11 @@ type DeviceMock struct {
// GetGpuInstanceId holds details about calls to the GetGpuInstanceId method. // GetGpuInstanceId holds details about calls to the GetGpuInstanceId method.
GetGpuInstanceId []struct { 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 holds details about calls to the GetGpuInstanceProfileInfo method.
GetGpuInstanceProfileInfo []struct { GetGpuInstanceProfileInfo []struct {
// Profile is the Profile argument value. // Profile is the Profile argument value.
@ -230,12 +254,14 @@ type DeviceMock struct {
Mode int Mode int
} }
} }
lockCreateGpuInstanceWithPlacement sync.RWMutex
lockGetAttributes sync.RWMutex lockGetAttributes sync.RWMutex
lockGetComputeInstanceId sync.RWMutex lockGetComputeInstanceId sync.RWMutex
lockGetCudaComputeCapability sync.RWMutex lockGetCudaComputeCapability sync.RWMutex
lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex
lockGetGpuInstanceById sync.RWMutex lockGetGpuInstanceById sync.RWMutex
lockGetGpuInstanceId sync.RWMutex lockGetGpuInstanceId sync.RWMutex
lockGetGpuInstancePossiblePlacements sync.RWMutex
lockGetGpuInstanceProfileInfo sync.RWMutex lockGetGpuInstanceProfileInfo sync.RWMutex
lockGetGpuInstances sync.RWMutex lockGetGpuInstances sync.RWMutex
lockGetIndex sync.RWMutex lockGetIndex sync.RWMutex
@ -253,6 +279,42 @@ type DeviceMock struct {
lockSetMigMode sync.RWMutex 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. // GetAttributes calls GetAttributesFunc.
func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) { func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) {
if mock.GetAttributesFunc == nil { if mock.GetAttributesFunc == nil {
@ -268,7 +330,8 @@ func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) {
// GetAttributesCalls gets all the calls that were made to GetAttributes. // GetAttributesCalls gets all the calls that were made to GetAttributes.
// Check the length with: // Check the length with:
// len(mockedDevice.GetAttributesCalls()) //
// len(mockedDevice.GetAttributesCalls())
func (mock *DeviceMock) GetAttributesCalls() []struct { func (mock *DeviceMock) GetAttributesCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -294,7 +357,8 @@ func (mock *DeviceMock) GetComputeInstanceId() (int, Return) {
// GetComputeInstanceIdCalls gets all the calls that were made to GetComputeInstanceId. // GetComputeInstanceIdCalls gets all the calls that were made to GetComputeInstanceId.
// Check the length with: // Check the length with:
// len(mockedDevice.GetComputeInstanceIdCalls()) //
// len(mockedDevice.GetComputeInstanceIdCalls())
func (mock *DeviceMock) GetComputeInstanceIdCalls() []struct { func (mock *DeviceMock) GetComputeInstanceIdCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -320,7 +384,8 @@ func (mock *DeviceMock) GetCudaComputeCapability() (int, int, Return) {
// GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability. // GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability.
// Check the length with: // Check the length with:
// len(mockedDevice.GetCudaComputeCapabilityCalls()) //
// len(mockedDevice.GetCudaComputeCapabilityCalls())
func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct { func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -346,7 +411,8 @@ func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, Return) {
// GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle. // GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle.
// Check the length with: // Check the length with:
// len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls()) //
// len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls())
func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct { func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -375,7 +441,8 @@ func (mock *DeviceMock) GetGpuInstanceById(ID int) (GpuInstance, Return) {
// GetGpuInstanceByIdCalls gets all the calls that were made to GetGpuInstanceById. // GetGpuInstanceByIdCalls gets all the calls that were made to GetGpuInstanceById.
// Check the length with: // Check the length with:
// len(mockedDevice.GetGpuInstanceByIdCalls()) //
// len(mockedDevice.GetGpuInstanceByIdCalls())
func (mock *DeviceMock) GetGpuInstanceByIdCalls() []struct { func (mock *DeviceMock) GetGpuInstanceByIdCalls() []struct {
ID int ID int
} { } {
@ -403,7 +470,8 @@ func (mock *DeviceMock) GetGpuInstanceId() (int, Return) {
// GetGpuInstanceIdCalls gets all the calls that were made to GetGpuInstanceId. // GetGpuInstanceIdCalls gets all the calls that were made to GetGpuInstanceId.
// Check the length with: // Check the length with:
// len(mockedDevice.GetGpuInstanceIdCalls()) //
// len(mockedDevice.GetGpuInstanceIdCalls())
func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct { func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -414,6 +482,38 @@ func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct {
return calls 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. // GetGpuInstanceProfileInfo calls GetGpuInstanceProfileInfoFunc.
func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) { func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) {
if mock.GetGpuInstanceProfileInfoFunc == nil { if mock.GetGpuInstanceProfileInfoFunc == nil {
@ -432,7 +532,8 @@ func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfi
// GetGpuInstanceProfileInfoCalls gets all the calls that were made to GetGpuInstanceProfileInfo. // GetGpuInstanceProfileInfoCalls gets all the calls that were made to GetGpuInstanceProfileInfo.
// Check the length with: // Check the length with:
// len(mockedDevice.GetGpuInstanceProfileInfoCalls()) //
// len(mockedDevice.GetGpuInstanceProfileInfoCalls())
func (mock *DeviceMock) GetGpuInstanceProfileInfoCalls() []struct { func (mock *DeviceMock) GetGpuInstanceProfileInfoCalls() []struct {
Profile int Profile int
} { } {
@ -463,7 +564,8 @@ func (mock *DeviceMock) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInst
// GetGpuInstancesCalls gets all the calls that were made to GetGpuInstances. // GetGpuInstancesCalls gets all the calls that were made to GetGpuInstances.
// Check the length with: // Check the length with:
// len(mockedDevice.GetGpuInstancesCalls()) //
// len(mockedDevice.GetGpuInstancesCalls())
func (mock *DeviceMock) GetGpuInstancesCalls() []struct { func (mock *DeviceMock) GetGpuInstancesCalls() []struct {
Info *GpuInstanceProfileInfo Info *GpuInstanceProfileInfo
} { } {
@ -491,7 +593,8 @@ func (mock *DeviceMock) GetIndex() (int, Return) {
// GetIndexCalls gets all the calls that were made to GetIndex. // GetIndexCalls gets all the calls that were made to GetIndex.
// Check the length with: // Check the length with:
// len(mockedDevice.GetIndexCalls()) //
// len(mockedDevice.GetIndexCalls())
func (mock *DeviceMock) GetIndexCalls() []struct { func (mock *DeviceMock) GetIndexCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -517,7 +620,8 @@ func (mock *DeviceMock) GetMaxMigDeviceCount() (int, Return) {
// GetMaxMigDeviceCountCalls gets all the calls that were made to GetMaxMigDeviceCount. // GetMaxMigDeviceCountCalls gets all the calls that were made to GetMaxMigDeviceCount.
// Check the length with: // Check the length with:
// len(mockedDevice.GetMaxMigDeviceCountCalls()) //
// len(mockedDevice.GetMaxMigDeviceCountCalls())
func (mock *DeviceMock) GetMaxMigDeviceCountCalls() []struct { func (mock *DeviceMock) GetMaxMigDeviceCountCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -543,7 +647,8 @@ func (mock *DeviceMock) GetMemoryInfo() (Memory, Return) {
// GetMemoryInfoCalls gets all the calls that were made to GetMemoryInfo. // GetMemoryInfoCalls gets all the calls that were made to GetMemoryInfo.
// Check the length with: // Check the length with:
// len(mockedDevice.GetMemoryInfoCalls()) //
// len(mockedDevice.GetMemoryInfoCalls())
func (mock *DeviceMock) GetMemoryInfoCalls() []struct { func (mock *DeviceMock) GetMemoryInfoCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -572,7 +677,8 @@ func (mock *DeviceMock) GetMigDeviceHandleByIndex(Index int) (Device, Return) {
// GetMigDeviceHandleByIndexCalls gets all the calls that were made to GetMigDeviceHandleByIndex. // GetMigDeviceHandleByIndexCalls gets all the calls that were made to GetMigDeviceHandleByIndex.
// Check the length with: // Check the length with:
// len(mockedDevice.GetMigDeviceHandleByIndexCalls()) //
// len(mockedDevice.GetMigDeviceHandleByIndexCalls())
func (mock *DeviceMock) GetMigDeviceHandleByIndexCalls() []struct { func (mock *DeviceMock) GetMigDeviceHandleByIndexCalls() []struct {
Index int Index int
} { } {
@ -600,7 +706,8 @@ func (mock *DeviceMock) GetMigMode() (int, int, Return) {
// GetMigModeCalls gets all the calls that were made to GetMigMode. // GetMigModeCalls gets all the calls that were made to GetMigMode.
// Check the length with: // Check the length with:
// len(mockedDevice.GetMigModeCalls()) //
// len(mockedDevice.GetMigModeCalls())
func (mock *DeviceMock) GetMigModeCalls() []struct { func (mock *DeviceMock) GetMigModeCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -626,7 +733,8 @@ func (mock *DeviceMock) GetMinorNumber() (int, Return) {
// GetMinorNumberCalls gets all the calls that were made to GetMinorNumber. // GetMinorNumberCalls gets all the calls that were made to GetMinorNumber.
// Check the length with: // Check the length with:
// len(mockedDevice.GetMinorNumberCalls()) //
// len(mockedDevice.GetMinorNumberCalls())
func (mock *DeviceMock) GetMinorNumberCalls() []struct { func (mock *DeviceMock) GetMinorNumberCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -652,7 +760,8 @@ func (mock *DeviceMock) GetName() (string, Return) {
// GetNameCalls gets all the calls that were made to GetName. // GetNameCalls gets all the calls that were made to GetName.
// Check the length with: // Check the length with:
// len(mockedDevice.GetNameCalls()) //
// len(mockedDevice.GetNameCalls())
func (mock *DeviceMock) GetNameCalls() []struct { func (mock *DeviceMock) GetNameCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -678,7 +787,8 @@ func (mock *DeviceMock) GetPciInfo() (PciInfo, Return) {
// GetPciInfoCalls gets all the calls that were made to GetPciInfo. // GetPciInfoCalls gets all the calls that were made to GetPciInfo.
// Check the length with: // Check the length with:
// len(mockedDevice.GetPciInfoCalls()) //
// len(mockedDevice.GetPciInfoCalls())
func (mock *DeviceMock) GetPciInfoCalls() []struct { func (mock *DeviceMock) GetPciInfoCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -704,7 +814,8 @@ func (mock *DeviceMock) GetSupportedEventTypes() (uint64, Return) {
// GetSupportedEventTypesCalls gets all the calls that were made to GetSupportedEventTypes. // GetSupportedEventTypesCalls gets all the calls that were made to GetSupportedEventTypes.
// Check the length with: // Check the length with:
// len(mockedDevice.GetSupportedEventTypesCalls()) //
// len(mockedDevice.GetSupportedEventTypesCalls())
func (mock *DeviceMock) GetSupportedEventTypesCalls() []struct { func (mock *DeviceMock) GetSupportedEventTypesCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -730,7 +841,8 @@ func (mock *DeviceMock) GetUUID() (string, Return) {
// GetUUIDCalls gets all the calls that were made to GetUUID. // GetUUIDCalls gets all the calls that were made to GetUUID.
// Check the length with: // Check the length with:
// len(mockedDevice.GetUUIDCalls()) //
// len(mockedDevice.GetUUIDCalls())
func (mock *DeviceMock) GetUUIDCalls() []struct { func (mock *DeviceMock) GetUUIDCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -756,7 +868,8 @@ func (mock *DeviceMock) IsMigDeviceHandle() (bool, Return) {
// IsMigDeviceHandleCalls gets all the calls that were made to IsMigDeviceHandle. // IsMigDeviceHandleCalls gets all the calls that were made to IsMigDeviceHandle.
// Check the length with: // Check the length with:
// len(mockedDevice.IsMigDeviceHandleCalls()) //
// len(mockedDevice.IsMigDeviceHandleCalls())
func (mock *DeviceMock) IsMigDeviceHandleCalls() []struct { func (mock *DeviceMock) IsMigDeviceHandleCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -787,7 +900,8 @@ func (mock *DeviceMock) RegisterEvents(v uint64, eventSet EventSet) Return {
// RegisterEventsCalls gets all the calls that were made to RegisterEvents. // RegisterEventsCalls gets all the calls that were made to RegisterEvents.
// Check the length with: // Check the length with:
// len(mockedDevice.RegisterEventsCalls()) //
// len(mockedDevice.RegisterEventsCalls())
func (mock *DeviceMock) RegisterEventsCalls() []struct { func (mock *DeviceMock) RegisterEventsCalls() []struct {
V uint64 V uint64
EventSet EventSet EventSet EventSet
@ -820,7 +934,8 @@ func (mock *DeviceMock) SetMigMode(Mode int) (Return, Return) {
// SetMigModeCalls gets all the calls that were made to SetMigMode. // SetMigModeCalls gets all the calls that were made to SetMigMode.
// Check the length with: // Check the length with:
// len(mockedDevice.SetMigModeCalls()) //
// len(mockedDevice.SetMigModeCalls())
func (mock *DeviceMock) SetMigModeCalls() []struct { func (mock *DeviceMock) SetMigModeCalls() []struct {
Mode int Mode int
} { } {

View File

@ -13,34 +13,34 @@ var _ GpuInstance = &GpuInstanceMock{}
// GpuInstanceMock is a mock implementation of GpuInstance. // GpuInstanceMock is a mock implementation of GpuInstance.
// //
// func TestSomethingThatUsesGpuInstance(t *testing.T) { // func TestSomethingThatUsesGpuInstance(t *testing.T) {
// //
// // make and configure a mocked GpuInstance // // make and configure a mocked GpuInstance
// mockedGpuInstance := &GpuInstanceMock{ // mockedGpuInstance := &GpuInstanceMock{
// CreateComputeInstanceFunc: func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { // CreateComputeInstanceFunc: func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) {
// panic("mock out the CreateComputeInstance method") // panic("mock out the CreateComputeInstance method")
// }, // },
// DestroyFunc: func() Return { // DestroyFunc: func() Return {
// panic("mock out the Destroy method") // panic("mock out the Destroy method")
// }, // },
// GetComputeInstanceByIdFunc: func(ID int) (ComputeInstance, Return) { // GetComputeInstanceByIdFunc: func(ID int) (ComputeInstance, Return) {
// panic("mock out the GetComputeInstanceById method") // panic("mock out the GetComputeInstanceById method")
// }, // },
// GetComputeInstanceProfileInfoFunc: func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { // GetComputeInstanceProfileInfoFunc: func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) {
// panic("mock out the GetComputeInstanceProfileInfo method") // panic("mock out the GetComputeInstanceProfileInfo method")
// }, // },
// GetComputeInstancesFunc: func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { // GetComputeInstancesFunc: func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) {
// panic("mock out the GetComputeInstances method") // panic("mock out the GetComputeInstances method")
// }, // },
// GetInfoFunc: func() (GpuInstanceInfo, Return) { // GetInfoFunc: func() (GpuInstanceInfo, Return) {
// panic("mock out the GetInfo method") // panic("mock out the GetInfo method")
// }, // },
// } // }
// //
// // use mockedGpuInstance in code that requires GpuInstance // // use mockedGpuInstance in code that requires GpuInstance
// // and then make assertions. // // and then make assertions.
// //
// } // }
type GpuInstanceMock struct { type GpuInstanceMock struct {
// CreateComputeInstanceFunc mocks the CreateComputeInstance method. // CreateComputeInstanceFunc mocks the CreateComputeInstance method.
CreateComputeInstanceFunc func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) CreateComputeInstanceFunc func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return)
@ -117,7 +117,8 @@ func (mock *GpuInstanceMock) CreateComputeInstance(Info *ComputeInstanceProfileI
// CreateComputeInstanceCalls gets all the calls that were made to CreateComputeInstance. // CreateComputeInstanceCalls gets all the calls that were made to CreateComputeInstance.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.CreateComputeInstanceCalls()) //
// len(mockedGpuInstance.CreateComputeInstanceCalls())
func (mock *GpuInstanceMock) CreateComputeInstanceCalls() []struct { func (mock *GpuInstanceMock) CreateComputeInstanceCalls() []struct {
Info *ComputeInstanceProfileInfo Info *ComputeInstanceProfileInfo
} { } {
@ -145,7 +146,8 @@ func (mock *GpuInstanceMock) Destroy() Return {
// DestroyCalls gets all the calls that were made to Destroy. // DestroyCalls gets all the calls that were made to Destroy.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.DestroyCalls()) //
// len(mockedGpuInstance.DestroyCalls())
func (mock *GpuInstanceMock) DestroyCalls() []struct { func (mock *GpuInstanceMock) DestroyCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -174,7 +176,8 @@ func (mock *GpuInstanceMock) GetComputeInstanceById(ID int) (ComputeInstance, Re
// GetComputeInstanceByIdCalls gets all the calls that were made to GetComputeInstanceById. // GetComputeInstanceByIdCalls gets all the calls that were made to GetComputeInstanceById.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.GetComputeInstanceByIdCalls()) //
// len(mockedGpuInstance.GetComputeInstanceByIdCalls())
func (mock *GpuInstanceMock) GetComputeInstanceByIdCalls() []struct { func (mock *GpuInstanceMock) GetComputeInstanceByIdCalls() []struct {
ID int ID int
} { } {
@ -207,7 +210,8 @@ func (mock *GpuInstanceMock) GetComputeInstanceProfileInfo(Profile int, EngProfi
// GetComputeInstanceProfileInfoCalls gets all the calls that were made to GetComputeInstanceProfileInfo. // GetComputeInstanceProfileInfoCalls gets all the calls that were made to GetComputeInstanceProfileInfo.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.GetComputeInstanceProfileInfoCalls()) //
// len(mockedGpuInstance.GetComputeInstanceProfileInfoCalls())
func (mock *GpuInstanceMock) GetComputeInstanceProfileInfoCalls() []struct { func (mock *GpuInstanceMock) GetComputeInstanceProfileInfoCalls() []struct {
Profile int Profile int
EngProfile int EngProfile int
@ -240,7 +244,8 @@ func (mock *GpuInstanceMock) GetComputeInstances(Info *ComputeInstanceProfileInf
// GetComputeInstancesCalls gets all the calls that were made to GetComputeInstances. // GetComputeInstancesCalls gets all the calls that were made to GetComputeInstances.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.GetComputeInstancesCalls()) //
// len(mockedGpuInstance.GetComputeInstancesCalls())
func (mock *GpuInstanceMock) GetComputeInstancesCalls() []struct { func (mock *GpuInstanceMock) GetComputeInstancesCalls() []struct {
Info *ComputeInstanceProfileInfo Info *ComputeInstanceProfileInfo
} { } {
@ -268,7 +273,8 @@ func (mock *GpuInstanceMock) GetInfo() (GpuInstanceInfo, Return) {
// GetInfoCalls gets all the calls that were made to GetInfo. // GetInfoCalls gets all the calls that were made to GetInfo.
// Check the length with: // Check the length with:
// len(mockedGpuInstance.GetInfoCalls()) //
// len(mockedGpuInstance.GetInfoCalls())
func (mock *GpuInstanceMock) GetInfoCalls() []struct { func (mock *GpuInstanceMock) GetInfoCalls() []struct {
} { } {
var calls []struct { var calls []struct {

View File

@ -13,43 +13,43 @@ var _ Interface = &InterfaceMock{}
// InterfaceMock is a mock implementation of Interface. // InterfaceMock is a mock implementation of Interface.
// //
// func TestSomethingThatUsesInterface(t *testing.T) { // func TestSomethingThatUsesInterface(t *testing.T) {
// //
// // make and configure a mocked Interface // // make and configure a mocked Interface
// mockedInterface := &InterfaceMock{ // mockedInterface := &InterfaceMock{
// DeviceGetCountFunc: func() (int, Return) { // DeviceGetCountFunc: func() (int, Return) {
// panic("mock out the DeviceGetCount method") // panic("mock out the DeviceGetCount method")
// }, // },
// DeviceGetHandleByIndexFunc: func(Index int) (Device, Return) { // DeviceGetHandleByIndexFunc: func(Index int) (Device, Return) {
// panic("mock out the DeviceGetHandleByIndex method") // panic("mock out the DeviceGetHandleByIndex method")
// }, // },
// DeviceGetHandleByUUIDFunc: func(UUID string) (Device, Return) { // DeviceGetHandleByUUIDFunc: func(UUID string) (Device, Return) {
// panic("mock out the DeviceGetHandleByUUID method") // panic("mock out the DeviceGetHandleByUUID method")
// }, // },
// ErrorStringFunc: func(r Return) string { // ErrorStringFunc: func(r Return) string {
// panic("mock out the ErrorString method") // panic("mock out the ErrorString method")
// }, // },
// EventSetCreateFunc: func() (EventSet, Return) { // EventSetCreateFunc: func() (EventSet, Return) {
// panic("mock out the EventSetCreate method") // panic("mock out the EventSetCreate method")
// }, // },
// InitFunc: func() Return { // InitFunc: func() Return {
// panic("mock out the Init method") // panic("mock out the Init method")
// }, // },
// ShutdownFunc: func() Return { // ShutdownFunc: func() Return {
// panic("mock out the Shutdown method") // panic("mock out the Shutdown method")
// }, // },
// SystemGetCudaDriverVersionFunc: func() (int, Return) { // SystemGetCudaDriverVersionFunc: func() (int, Return) {
// panic("mock out the SystemGetCudaDriverVersion method") // panic("mock out the SystemGetCudaDriverVersion method")
// }, // },
// SystemGetDriverVersionFunc: func() (string, Return) { // SystemGetDriverVersionFunc: func() (string, Return) {
// panic("mock out the SystemGetDriverVersion method") // panic("mock out the SystemGetDriverVersion method")
// }, // },
// } // }
// //
// // use mockedInterface in code that requires Interface // // use mockedInterface in code that requires Interface
// // and then make assertions. // // and then make assertions.
// //
// } // }
type InterfaceMock struct { type InterfaceMock struct {
// DeviceGetCountFunc mocks the DeviceGetCount method. // DeviceGetCountFunc mocks the DeviceGetCount method.
DeviceGetCountFunc func() (int, Return) DeviceGetCountFunc func() (int, Return)
@ -140,7 +140,8 @@ func (mock *InterfaceMock) DeviceGetCount() (int, Return) {
// DeviceGetCountCalls gets all the calls that were made to DeviceGetCount. // DeviceGetCountCalls gets all the calls that were made to DeviceGetCount.
// Check the length with: // Check the length with:
// len(mockedInterface.DeviceGetCountCalls()) //
// len(mockedInterface.DeviceGetCountCalls())
func (mock *InterfaceMock) DeviceGetCountCalls() []struct { func (mock *InterfaceMock) DeviceGetCountCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -169,7 +170,8 @@ func (mock *InterfaceMock) DeviceGetHandleByIndex(Index int) (Device, Return) {
// DeviceGetHandleByIndexCalls gets all the calls that were made to DeviceGetHandleByIndex. // DeviceGetHandleByIndexCalls gets all the calls that were made to DeviceGetHandleByIndex.
// Check the length with: // Check the length with:
// len(mockedInterface.DeviceGetHandleByIndexCalls()) //
// len(mockedInterface.DeviceGetHandleByIndexCalls())
func (mock *InterfaceMock) DeviceGetHandleByIndexCalls() []struct { func (mock *InterfaceMock) DeviceGetHandleByIndexCalls() []struct {
Index int Index int
} { } {
@ -200,7 +202,8 @@ func (mock *InterfaceMock) DeviceGetHandleByUUID(UUID string) (Device, Return) {
// DeviceGetHandleByUUIDCalls gets all the calls that were made to DeviceGetHandleByUUID. // DeviceGetHandleByUUIDCalls gets all the calls that were made to DeviceGetHandleByUUID.
// Check the length with: // Check the length with:
// len(mockedInterface.DeviceGetHandleByUUIDCalls()) //
// len(mockedInterface.DeviceGetHandleByUUIDCalls())
func (mock *InterfaceMock) DeviceGetHandleByUUIDCalls() []struct { func (mock *InterfaceMock) DeviceGetHandleByUUIDCalls() []struct {
UUID string UUID string
} { } {
@ -231,7 +234,8 @@ func (mock *InterfaceMock) ErrorString(r Return) string {
// ErrorStringCalls gets all the calls that were made to ErrorString. // ErrorStringCalls gets all the calls that were made to ErrorString.
// Check the length with: // Check the length with:
// len(mockedInterface.ErrorStringCalls()) //
// len(mockedInterface.ErrorStringCalls())
func (mock *InterfaceMock) ErrorStringCalls() []struct { func (mock *InterfaceMock) ErrorStringCalls() []struct {
R Return R Return
} { } {
@ -259,7 +263,8 @@ func (mock *InterfaceMock) EventSetCreate() (EventSet, Return) {
// EventSetCreateCalls gets all the calls that were made to EventSetCreate. // EventSetCreateCalls gets all the calls that were made to EventSetCreate.
// Check the length with: // Check the length with:
// len(mockedInterface.EventSetCreateCalls()) //
// len(mockedInterface.EventSetCreateCalls())
func (mock *InterfaceMock) EventSetCreateCalls() []struct { func (mock *InterfaceMock) EventSetCreateCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -285,7 +290,8 @@ func (mock *InterfaceMock) Init() Return {
// InitCalls gets all the calls that were made to Init. // InitCalls gets all the calls that were made to Init.
// Check the length with: // Check the length with:
// len(mockedInterface.InitCalls()) //
// len(mockedInterface.InitCalls())
func (mock *InterfaceMock) InitCalls() []struct { func (mock *InterfaceMock) InitCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -311,7 +317,8 @@ func (mock *InterfaceMock) Shutdown() Return {
// ShutdownCalls gets all the calls that were made to Shutdown. // ShutdownCalls gets all the calls that were made to Shutdown.
// Check the length with: // Check the length with:
// len(mockedInterface.ShutdownCalls()) //
// len(mockedInterface.ShutdownCalls())
func (mock *InterfaceMock) ShutdownCalls() []struct { func (mock *InterfaceMock) ShutdownCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -337,7 +344,8 @@ func (mock *InterfaceMock) SystemGetCudaDriverVersion() (int, Return) {
// SystemGetCudaDriverVersionCalls gets all the calls that were made to SystemGetCudaDriverVersion. // SystemGetCudaDriverVersionCalls gets all the calls that were made to SystemGetCudaDriverVersion.
// Check the length with: // Check the length with:
// len(mockedInterface.SystemGetCudaDriverVersionCalls()) //
// len(mockedInterface.SystemGetCudaDriverVersionCalls())
func (mock *InterfaceMock) SystemGetCudaDriverVersionCalls() []struct { func (mock *InterfaceMock) SystemGetCudaDriverVersionCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -363,7 +371,8 @@ func (mock *InterfaceMock) SystemGetDriverVersion() (string, Return) {
// SystemGetDriverVersionCalls gets all the calls that were made to SystemGetDriverVersion. // SystemGetDriverVersionCalls gets all the calls that were made to SystemGetDriverVersion.
// Check the length with: // Check the length with:
// len(mockedInterface.SystemGetDriverVersionCalls()) //
// len(mockedInterface.SystemGetDriverVersionCalls())
func (mock *InterfaceMock) SystemGetDriverVersionCalls() []struct { func (mock *InterfaceMock) SystemGetDriverVersionCalls() []struct {
} { } {
var calls []struct { var calls []struct {

View File

@ -39,12 +39,14 @@ type Interface interface {
// //
//go:generate moq -out device_mock.go . Device //go:generate moq -out device_mock.go . Device
type Device interface { type Device interface {
CreateGpuInstanceWithPlacement(*GpuInstanceProfileInfo, *GpuInstancePlacement) (GpuInstance, Return)
GetAttributes() (DeviceAttributes, Return) GetAttributes() (DeviceAttributes, Return)
GetComputeInstanceId() (int, Return) GetComputeInstanceId() (int, Return)
GetCudaComputeCapability() (int, int, Return) GetCudaComputeCapability() (int, int, Return)
GetDeviceHandleFromMigDeviceHandle() (Device, Return) GetDeviceHandleFromMigDeviceHandle() (Device, Return)
GetGpuInstanceById(ID int) (GpuInstance, Return) GetGpuInstanceById(ID int) (GpuInstance, Return)
GetGpuInstanceId() (int, Return) GetGpuInstanceId() (int, Return)
GetGpuInstancePossiblePlacements(*GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return)
GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return)
GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return)
GetIndex() (int, Return) GetIndex() (int, Return)