Skip to content

Commit ba5117c

Browse files
Copilotharp-intel
andcommitted
Add test for NIC table with virtual function annotation
- Added TestNicTableValuesWithVirtualFunction to verify "(virtual)" annotation - Test ensures virtual functions are properly annotated in table output - Test ensures physical functions are not annotated Co-authored-by: harp-intel <78619061+harp-intel@users.noreply.github.com>
1 parent 453c84d commit ba5117c

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

internal/report/table_helpers_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,81 @@ tx-usecs: 50
780780
}
781781
}
782782

783+
func TestNicTableValuesWithVirtualFunction(t *testing.T) {
784+
nicinfoWithVF := `
785+
Interface: eth0
786+
Vendor: Intel Corporation
787+
Vendor ID: 8086
788+
Model: Ethernet Adaptive Virtual Function
789+
Model ID: 1889
790+
Speed: 10000Mb/s
791+
Link detected: yes
792+
driver: iavf
793+
version: 6.13.7-061307-generic
794+
firmware-version: N/A
795+
bus-info: 0000:c0:11.0
796+
MAC Address: 00:11:22:33:44:55
797+
NUMA Node: 1
798+
Virtual Function: yes
799+
CPU Affinity: 100:0-63;
800+
IRQ Balance: Enabled
801+
Adaptive RX: on TX: on
802+
rx-usecs: 100
803+
tx-usecs: 100
804+
----------------------------------------
805+
Interface: eth1
806+
Vendor: Intel Corporation
807+
Vendor ID: 8086
808+
Model: Ethernet Controller E810-C
809+
Model ID: 1592
810+
Speed: 25000Mb/s
811+
Link detected: yes
812+
driver: ice
813+
version: 6.13.7-061307-generic
814+
firmware-version: 4.20
815+
bus-info: 0000:c0:00.0
816+
MAC Address: aa:bb:cc:dd:ee:ff
817+
NUMA Node: 1
818+
Virtual Function: no
819+
CPU Affinity: 200:0-63;
820+
IRQ Balance: Enabled
821+
Adaptive RX: off TX: off
822+
rx-usecs: 50
823+
tx-usecs: 50
824+
----------------------------------------
825+
`
826+
827+
outputs := map[string]script.ScriptOutput{
828+
script.NicInfoScriptName: {Stdout: nicinfoWithVF},
829+
}
830+
831+
fields := nicTableValues(outputs)
832+
833+
if len(fields) == 0 {
834+
t.Fatal("Expected fields, got empty slice")
835+
}
836+
837+
// Find the Name field
838+
nameField := fields[0]
839+
if nameField.Name != "Name" {
840+
t.Fatalf("Expected first field to be 'Name', got '%s'", nameField.Name)
841+
}
842+
843+
if len(nameField.Values) != 2 {
844+
t.Fatalf("Expected 2 NIC names, got %d", len(nameField.Values))
845+
}
846+
847+
// Check that the virtual function has "(virtual)" annotation
848+
if nameField.Values[0] != "eth0 (virtual)" {
849+
t.Errorf("Expected 'eth0 (virtual)', got '%s'", nameField.Values[0])
850+
}
851+
852+
// Check that the physical function does not have "(virtual)" annotation
853+
if nameField.Values[1] != "eth1" {
854+
t.Errorf("Expected 'eth1', got '%s'", nameField.Values[1])
855+
}
856+
}
857+
783858
var nicinfo = `
784859
Interface: ens7f0np0
785860
Vendor: Broadcom Inc. and subsidiaries

0 commit comments

Comments
 (0)