Skip to content

Commit

Permalink
fixup! enhancement: Use pointer fields for FibreChannel*
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
rexagod committed Mar 30, 2024
1 parent 7857a4f commit b8b34e5
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 46 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ require (
github.com/google/go-cmp v0.6.0
golang.org/x/sync v0.6.0
golang.org/x/sys v0.18.0
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
139 changes: 96 additions & 43 deletions sysfs/class_fibrechannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"k8s.io/utils/ptr"
)

func TestFibreChannelClass(t *testing.T) {
Expand All @@ -34,55 +33,109 @@ func TestFibreChannelClass(t *testing.T) {
t.Fatal(err)
}

// "host0" FibreChannelHost constants.
var (
name0 = "host0"
speed0 = "16 Gbit"
portState0 = "Online"
portType0 = "Point-To-Point (direct nport connection)"
portName0 = "1000e0071bce95f2"
symbolicName0 = "Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"
nodeName0 = "2000e0071bce95f2"
portID0 = "000002"
fabricName0 = "0"
devLossTMO0 = "30"
supportedClasses0 = "Class 3"
supportedSpeeds0 = "4 Gbit, 8 Gbit, 16 Gbit"

// "host0" FibreChannelHost.Counters constants.
dumpedFrames0 = ^uint64(0)
errorFrames0 = uint64(0)
invalidCRCCount0 = uint64(0x2)
rxFrames0 = uint64(0x3)
rxWords0 = uint64(0x4)
txFrames0 = uint64(0x5)
txWords0 = uint64(0x6)
secondsSinceLastReset0 = uint64(0x7)
invalidTXWordCount0 = uint64(0x8)
linkFailureCount0 = uint64(0x9)
lossOfSyncCount0 = uint64(0x10)
lossOfSignalCount0 = uint64(0x11)
nosCount0 = uint64(0x12)
fcpPacketAborts0 = uint64(0x13)
)

// "host1" FibreChannelHost constants.
var (
name1 = "host1"
portState1 = "Online"

// "host1" FibreChannelHost.Counters constants.
dumpedFrames1 = uint64(0)
errorFrames1 = ^uint64(0)
invalidCRCCount1 = uint64(0x20)
rxFrames1 = uint64(0x30)
rxWords1 = uint64(0x40)
txFrames1 = uint64(0x50)
txWords1 = uint64(0x60)
secondsSinceLastReset1 = uint64(0x70)
invalidTXWordCount1 = uint64(0x80)
linkFailureCount1 = uint64(0x90)
lossOfSyncCount1 = uint64(0x100)
lossOfSignalCount1 = uint64(0x110)
nosCount1 = uint64(0x120)
fcpPacketAborts1 = uint64(0x130)
)

want := FibreChannelClass{
"host0": FibreChannelHost{
Name: ptr.To("host0"),
Speed: ptr.To("16 Gbit"),
PortState: ptr.To("Online"),
PortType: ptr.To("Point-To-Point (direct nport connection)"),
PortName: ptr.To("1000e0071bce95f2"),
SymbolicName: ptr.To("Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"),
NodeName: ptr.To("2000e0071bce95f2"),
PortID: ptr.To("000002"),
FabricName: ptr.To("0"),
DevLossTMO: ptr.To("30"),
SupportedClasses: ptr.To("Class 3"),
SupportedSpeeds: ptr.To("4 Gbit, 8 Gbit, 16 Gbit"),
Name: &name0,
Speed: &speed0,
PortState: &portState0,
PortType: &portType0,
PortName: &portName0,
SymbolicName: &symbolicName0,
NodeName: &nodeName0,
PortID: &portID0,
FabricName: &fabricName0,
DevLossTMO: &devLossTMO0,
SupportedClasses: &supportedClasses0,
SupportedSpeeds: &supportedSpeeds0,
Counters: &FibreChannelCounters{
DumpedFrames: ptr.To(^uint64(0)),
ErrorFrames: ptr.To(uint64(0)),
InvalidCRCCount: ptr.To(uint64(0x2)),
RXFrames: ptr.To(uint64(0x3)),
RXWords: ptr.To(uint64(0x4)),
TXFrames: ptr.To(uint64(0x5)),
TXWords: ptr.To(uint64(0x6)),
SecondsSinceLastReset: ptr.To(uint64(0x7)),
InvalidTXWordCount: ptr.To(uint64(0x8)),
LinkFailureCount: ptr.To(uint64(0x9)),
LossOfSyncCount: ptr.To(uint64(0x10)),
LossOfSignalCount: ptr.To(uint64(0x11)),
NosCount: ptr.To(uint64(0x12)),
FCPPacketAborts: ptr.To(uint64(0x13)),
DumpedFrames: &dumpedFrames0,
ErrorFrames: &errorFrames0,
InvalidCRCCount: &invalidCRCCount0,
RXFrames: &rxFrames0,
RXWords: &rxWords0,
TXFrames: &txFrames0,
TXWords: &txWords0,
SecondsSinceLastReset: &secondsSinceLastReset0,
InvalidTXWordCount: &invalidTXWordCount0,
LinkFailureCount: &linkFailureCount0,
LossOfSyncCount: &lossOfSyncCount0,
LossOfSignalCount: &lossOfSignalCount0,
NosCount: &nosCount0,
FCPPacketAborts: &fcpPacketAborts0,
},
},
"host1": FibreChannelHost{
Name: ptr.To("host1"),
PortState: ptr.To("Online"),
Name: &name1,
PortState: &portState1,
Counters: &FibreChannelCounters{
DumpedFrames: ptr.To(uint64(0)),
ErrorFrames: ptr.To(^uint64(0)),
InvalidCRCCount: ptr.To(uint64(0x20)),
RXFrames: ptr.To(uint64(0x30)),
RXWords: ptr.To(uint64(0x40)),
TXFrames: ptr.To(uint64(0x50)),
TXWords: ptr.To(uint64(0x60)),
SecondsSinceLastReset: ptr.To(uint64(0x70)),
InvalidTXWordCount: ptr.To(uint64(0x80)),
LinkFailureCount: ptr.To(uint64(0x90)),
LossOfSyncCount: ptr.To(uint64(0x100)),
LossOfSignalCount: ptr.To(uint64(0x110)),
NosCount: ptr.To(uint64(0x120)),
FCPPacketAborts: ptr.To(uint64(0x130)),
DumpedFrames: &dumpedFrames1,
ErrorFrames: &errorFrames1,
InvalidCRCCount: &invalidCRCCount1,
RXFrames: &rxFrames1,
RXWords: &rxWords1,
TXFrames: &txFrames1,
TXWords: &txWords1,
SecondsSinceLastReset: &secondsSinceLastReset1,
InvalidTXWordCount: &invalidTXWordCount1,
LinkFailureCount: &linkFailureCount1,
LossOfSyncCount: &lossOfSyncCount1,
LossOfSignalCount: &lossOfSignalCount1,
NosCount: &nosCount1,
FCPPacketAborts: &fcpPacketAborts1,
},
},
}
Expand Down

0 comments on commit b8b34e5

Please sign in to comment.