Skip to content

Commit

Permalink
make mockdevice function public
Browse files Browse the repository at this point in the history
  • Loading branch information
jongchanpark-furiosa committed Aug 21, 2024
1 parent 0693bef commit 442373d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/smi/device_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func testDeviceErrorInfo(arch Arch, t *testing.T, expected DeviceErrorInfo) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

device_error_info, err := mockdevice.DeviceErrorInfo()

Expand Down
2 changes: 1 addition & 1 deletion pkg/smi/device_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func testDeviceFiles(arch Arch, t *testing.T, expected []DeviceFile) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

device_files, err := mockdevice.DeviceFiles()

Expand Down
2 changes: 1 addition & 1 deletion pkg/smi/device_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func testDeviceInfo(arch Arch, t *testing.T, expected DeviceInfo) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

device_info, err := mockdevice.DeviceInfo()

Expand Down
8 changes: 4 additions & 4 deletions pkg/smi/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func testCoreStatus(arch Arch, t *testing.T, expected map[uint32]CoreStatus) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

core_status, err := mockdevice.CoreStatus()

Expand Down Expand Up @@ -40,7 +40,7 @@ func TestRngdCoreStatus(t *testing.T) {
}

func testLiveness(arch Arch, t *testing.T, expected bool) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

liveness, err := mockdevice.Liveness()

Expand Down Expand Up @@ -84,13 +84,13 @@ func testGetDeviceToDeviceLinkType(devices []Device, t *testing.T) {
}

func TestWarboyGetDeviceToDeviceLinkType(t *testing.T) {
devices := getStaticMockDevices(ArchRngd)
devices := GetStaticMockDevices(ArchRngd)

testGetDeviceToDeviceLinkType(devices, t)
}

func TestRngdGetDeviceToDeviceLinkType(t *testing.T) {
devices := getStaticMockDevices(ArchRngd)
devices := GetStaticMockDevices(ArchRngd)

testGetDeviceToDeviceLinkType(devices, t)
}
6 changes: 3 additions & 3 deletions pkg/smi/mock_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ var linkTypeHintMap = map[int]map[int]LinkType{
7: {0: LinkTypeInterconnect, 1: LinkTypeInterconnect, 2: LinkTypeInterconnect, 3: LinkTypeInterconnect, 4: LinkTypeCpu, 5: LinkTypeCpu, 6: LinkTypeHostBridge, 7: LinkTypeNoc},
}

func getStaticMockDevices(arch Arch) (mockDevices []Device) {
func GetStaticMockDevices(arch Arch) (mockDevices []Device) {
for i := range iter.N(8) {
mockDevices = append(mockDevices, getStaticMockDevice(arch, i))
mockDevices = append(mockDevices, GetStaticMockDevice(arch, i))
}

return
}

func getStaticMockDevice(arch Arch, nodeIdx int) Device {
func GetStaticMockDevice(arch Arch, nodeIdx int) Device {
switch arch {
case ArchWarboy:
return &staticWarboyMockDevice{
Expand Down
6 changes: 3 additions & 3 deletions pkg/smi/performance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func testDeviceTemperature(arch Arch, t *testing.T, expected deviceTemperature) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

temperature, err := mockdevice.DeviceTemperature()
if err != nil {
Expand Down Expand Up @@ -36,7 +36,7 @@ func TestRngdDeviceTemperature(t *testing.T) {
}

func testPowerConsumption(arch Arch, t *testing.T, expected float64) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

power, err := mockdevice.PowerConsumption()
if err != nil {
Expand All @@ -61,7 +61,7 @@ func TestRngdPowerConsumption(t *testing.T) {
}

func testDeviceUtilization(arch Arch, t *testing.T) {
mockdevice := getStaticMockDevice(arch, 0)
mockdevice := GetStaticMockDevice(arch, 0)

_, err := mockdevice.DeviceUtilization() // Currenlty, not to check the value.

Expand Down

0 comments on commit 442373d

Please sign in to comment.