-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added logic to extract subsystem information from lspci command (#57)
* address review comments and include the lib-exports changes Signed-off-by: Nishant Parekh <nparekh@redhat.com>
- Loading branch information
1 parent
361da7d
commit 282b95f
Showing
6 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func Test_parseLspci(t *testing.T) { | ||
type args struct { | ||
output string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
exDesc string | ||
exSubsystem string | ||
parseErr bool | ||
}{ | ||
{ | ||
name: "ok", | ||
args: args{ | ||
output: "ca:00.0 Ethernet controller: Intel Corporation Ethernet Controller E810-C for SFP (rev 02)\nSubsystem: Intel Corporation Ethernet Network Adapter E810-XXV-4T\nControl: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+\n", | ||
}, | ||
exDesc: "Ethernet controller: Intel Corporation Ethernet Controller E810-C for SFP (rev 02)", | ||
exSubsystem: "Intel Corporation Ethernet Network Adapter E810-XXV-4T", | ||
parseErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
desc, subsystem, err := parseLspci(tt.args.output) | ||
if (err != nil) != tt.parseErr { | ||
t.Errorf("parseLspci() error = %v, wantErr %v", err, tt.parseErr) | ||
return | ||
} | ||
if desc != tt.exDesc { | ||
t.Errorf("parseLspci() description does not match got = %v, want %v", desc, tt.exDesc) | ||
} | ||
if subsystem != tt.exSubsystem { | ||
t.Errorf("parseLspci() subsystem does not match got = %v, want %v", subsystem, tt.exSubsystem) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters