Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package devmanager
import (
"time"
"ascend-common/devmanager/common"
"ascend-common/devmanager/dcmi"
)
var _ DeviceInterface = &DeviceManagerMock{}
type DeviceManagerMock struct {
DevType string
}
func (d *DeviceManagerMock) WaitDeviceOnline(resetTimeout int) {
}
func (d *DeviceManagerMock) GetValidBoardInfo() (common.BoardInfo, error) {
return common.BoardInfo{}, nil
}
func (d *DeviceManagerMock) GetValidMainBoardInfo() (uint32, error) {
return 0, nil
}
func (d *DeviceManagerMock) StartHccsPingMesh(logicID int32, portID int, operate common.HccspingMeshOperate) error {
return nil
}
func (d *DeviceManagerMock) StopHccsPingMesh(logicID int32, portID int, taskID uint) error {
return nil
}
func (d *DeviceManagerMock) GetHccsPingMeshInfo(logicID int32, portID int, taskID uint) (*common.HccspingMeshInfo, error) {
return &common.HccspingMeshInfo{}, nil
}
func (d *DeviceManagerMock) GetHccsPingMeshState(logicID int32, portID int, taskID uint) (int, error) {
return 0, nil
}
func (d *DeviceManagerMock) Init() error {
return nil
}
func (d *DeviceManagerMock) ShutDown() error {
return nil
}
func (d *DeviceManagerMock) GetDevType() string {
return d.DevType
}
func (d *DeviceManagerMock) GetAllDeviceCount() (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetCardList() (int32, []int32, error) {
return 1, []int32{0}, nil
}
func (d *DeviceManagerMock) GetDeviceNumInCard(cardID int32) (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceList() (int32, []int32, error) {
return 1, []int32{0}, nil
}
func (d *DeviceManagerMock) GetDeviceHealth(logicID int32) (uint32, error) {
return 0, nil
}
func (d *DeviceManagerMock) GetDeviceNetWorkHealth(logicID int32) (uint32, error) {
return 0, nil
}
func (d *DeviceManagerMock) GetDeviceUtilizationRate(logicID int32, deviceType common.DeviceType) (uint32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceUtilizationRateV2(logicID int32) (common.DcmiMultiUtilizationInfo, error) {
return common.DcmiMultiUtilizationInfo{
AicUtil: 1,
AicoreUtil: 1,
AivUtil: 1,
NpuUtil: 1,
}, nil
}
func (d *DeviceManagerMock) GetDeviceUtilizationRateV2Period(logicID int32) (common.DcmiMultiUtilizationInfo, error) {
return common.DcmiMultiUtilizationInfo{
AicUtil: 1,
AicoreUtil: 1,
AivUtil: 1,
NpuUtil: 1,
}, nil
}
func (d *DeviceManagerMock) GetDeviceUtilizationRateCommon(logicID int32) (common.DcmiMultiUtilizationInfo, error) {
return common.DcmiMultiUtilizationInfo{
AicUtil: 1,
AicoreUtil: 1,
AivUtil: 1,
NpuUtil: 1,
}, nil
}
func (d *DeviceManagerMock) GetDeviceTemperature(logicID int32) (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceVoltage(logicID int32) (float32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDevicePowerInfo(logicID int32) (float32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceFrequency(logicID int32, deviceType common.DeviceType) (uint32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceMemoryInfo(logicID int32) (*common.MemoryInfo, error) {
return &common.MemoryInfo{
MemorySize: 1,
MemoryAvailable: 1,
Frequency: 1,
Utilization: 1,
}, nil
}
func (d *DeviceManagerMock) GetDeviceHbmInfo(logicID int32) (*common.HbmInfo, error) {
return &common.HbmInfo{
MemorySize: 1,
Frequency: 1,
Usage: 1,
Temp: 1,
BandWidthUtilRate: 1,
}, nil
}
func (d *DeviceManagerMock) GetDeviceErrorCode(logicID int32) (int32, int64, error) {
return int32(0), int64(0), nil
}
func (d *DeviceManagerMock) GetChipInfo(logicID int32) (*common.ChipInfo, error) {
chip := &common.ChipInfo{
Type: "ascend",
Name: common.Chip910,
Version: "v1",
}
return chip, nil
}
func (d *DeviceManagerMock) GetPhysicIDFromLogicID(logicID int32) (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetLogicIDFromPhysicID(physicID int32) (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceLogicID(cardID, deviceID int32) (int32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetDeviceIPAddress(logicID, ipType int32) (string, error) {
if ipType == 0 {
return "127.0.0.1", nil
}
return "::1", nil
}
func (d *DeviceManagerMock) CreateVirtualDevice(logicID int32, vDevInfo common.CgoCreateVDevRes) (common.
CgoCreateVDevOut, error) {
return common.CgoCreateVDevOut{}, nil
}
func (d *DeviceManagerMock) GetVirtualDeviceInfo(logicID int32) (common.VirtualDevInfo, error) {
return common.VirtualDevInfo{}, nil
}
func (d *DeviceManagerMock) DestroyVirtualDevice(logicID int32, vDevID uint32) error {
return nil
}
func (d *DeviceManagerMock) GetMcuPowerInfo(cardID int32) (float32, error) {
return 1, nil
}
func (d *DeviceManagerMock) GetCardIDDeviceID(logicID int32) (int32, int32, error) {
return 0, 0, nil
}
func (d *DeviceManagerMock) GetProductType(logicID int32) (string, error) {
return "", nil
}
func (d *DeviceManagerMock) GetAllProductType() ([]string, error) {
return []string{}, nil
}
func (d *DeviceManagerMock) GetNpuWorkMode() string {
return common.SMPMode
}
func (d *DeviceManagerMock) SetDeviceReset(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) GetDeviceBootStatus(logicID int32) (int, error) {
return common.BootStartFinish, nil
}
func (d *DeviceManagerMock) GetDeviceAllErrorCode(logicID int32) (int32, []int64, error) {
return 0, []int64{}, nil
}
func (d *DeviceManagerMock) GetDeviceAllErrorCodeWithTimeOut(
logicID int32, timeout time.Duration) (int32, []int64, error) {
return 0, []int64{}, nil
}
func (d *DeviceManagerMock) SubscribeDeviceFaultEvent(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) SetFaultEventCallFunc(businessFunc func(common.DevFaultInfo)) error {
return nil
}
func (d *DeviceManagerMock) GetDieID(logicID int32, dcmiDieType dcmi.DieType) (string, error) {
return "ABCDEFGHIGKLMNOPQRSTUVWXYZ01234567890123", nil
}
func (d *DeviceManagerMock) GetDevProcessInfo(logicID int32) (*common.DevProcessInfo, error) {
return &common.DevProcessInfo{}, nil
}
func (d *DeviceManagerMock) GetPCIeBusInfo(logicID int32) (string, error) {
return "0000:61:00.0", nil
}
func (d *DeviceManagerMock) GetBoardInfo(logicID int32) (common.BoardInfo, error) {
return common.BoardInfo{}, nil
}
func (d *DeviceManagerMock) GetCardElabelV2(cardID int32) (common.ElabelInfo, error) {
return common.ElabelInfo{}, nil
}
func (d *DeviceManagerMock) GetProductTypeArray() []string {
return []string{common.Atlas200ISoc}
}
func (d *DeviceManagerMock) GetPCIEBandwidth(logicID int32, _ int) (common.PCIEBwStat, error) {
return common.PCIEBwStat{}, nil
}
func (d *DeviceManagerMock) SetIsTrainingCard() error {
return nil
}
func (d *DeviceManagerMock) IsTrainingCard() bool {
return true
}
func (d *DeviceManagerMock) GetDcmiVersion() string {
return "v1"
}
func (d *DeviceManagerMock) GetValidChipInfo() (common.ChipInfo, error) {
return common.ChipInfo{}, nil
}
func (d *DeviceManagerMock) GetDeviceEccInfo(logicID int32,
dcmiDeviceType common.DcmiDeviceType) (*common.ECCInfo, error) {
return &common.ECCInfo{EnableFlag: 1}, nil
}
func (d *DeviceManagerMock) GetSuperPodInfo(logicID int32) (common.CgoSuperPodInfo, error) {
return common.CgoSuperPodInfo{}, nil
}
func (d *DeviceManagerMock) GetSioInfo(logicID int32) (*common.SioCrcErrStatisticInfo, error) {
return &common.SioCrcErrStatisticInfo{
TxErrCnt: 0,
RxErrCnt: 0,
}, nil
}
func (d *DeviceManagerMock) GetHccsStatisticInfo(logicID int32) (*common.HccsStatisticInfo, error) {
return &common.HccsStatisticInfo{}, nil
}
func (d *DeviceManagerMock) GetHccsStatisticInfoInU64(logicID int32) (*common.HccsStatisticInfo, error) {
return &common.HccsStatisticInfo{}, nil
}
func (d *DeviceManagerMock) GetMainBoardId() uint32 {
return 0
}
func (d *DeviceManagerMock) GetHccsBandwidthInfo(logicID int32) (*common.HccsBandwidthInfo, error) {
return &common.HccsBandwidthInfo{}, nil
}
func (d *DeviceManagerMock) GetBrotherCardID(logicID int32) (int32, error) {
const noneBroCard = -1
return noneBroCard, nil
}
func (d *DeviceManagerMock) GetOutBandChannelState(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) PreResetSoc(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) SetDeviceResetOutBand(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) RescanSoc(logicID int32) error {
return nil
}
func (d *DeviceManagerMock) GetChipBaseInfos() ([]*common.ChipBaseInfo, error) {
return nil, nil
}
func (d *DeviceManagerMock) GetSuperPodStatus(int32, uint32) (int, error) { return 0, nil }
func (d *DeviceManagerMock) SetSuperPodStatus(int32, uint32, uint32) error { return nil }
func (d *DeviceManagerMock) GetMultiDiePolicy() (dcmi.DiePolicyType, error) {
return 0, nil
}
func (d *DeviceManagerMock) SetMultiDiePolicy(policy dcmi.DiePolicyType) error {
return nil
}