@@ -17,6 +17,7 @@ import (
1717 "github.com/jaypipes/ghw/pkg/marshal"
1818 "github.com/jaypipes/ghw/pkg/option"
1919 "github.com/jaypipes/ghw/pkg/pci"
20+ "github.com/jaypipes/ghw/pkg/util"
2021
2122 "github.com/jaypipes/ghw/testdata"
2223)
@@ -133,7 +134,10 @@ func TestPCIMarshalJSON(t *testing.T) {
133134 t .Fatalf ("Expected no error creating PciInfo, but got %v" , err )
134135 }
135136
136- dev := info .ParseDevice ("0000:3c:00.0" , "pci:v0000144Dd0000A804sv0000144Dsd0000A801bc01sc08i02" )
137+ dev := info .ParseDevice ("0000:3c:00.0" , "pci:v0000144Dd0000A804sv0000144Dsd0000A801bc01sc08i02\n " )
138+ if dev == nil {
139+ t .Fatalf ("Failed to parse valid modalias" )
140+ }
137141 s := marshal .SafeJSON (context .FromEnv (), dev , true )
138142 if s == "" {
139143 t .Fatalf ("Error marshalling device: %v" , dev )
@@ -211,3 +215,21 @@ func TestPCIMarshalUnmarshal(t *testing.T) {
211215 t .Fatalf ("Expected no error unmarshaling pci.Info, but got %v" , err )
212216 }
213217}
218+
219+ func TestPCIModaliasWithUpperCaseClassID (t * testing.T ) {
220+ if _ , ok := os .LookupEnv ("GHW_TESTING_SKIP_PCI" ); ok {
221+ t .Skip ("Skipping PCI tests." )
222+ }
223+ info , err := pci .New ()
224+ if err != nil {
225+ t .Fatalf ("Expected no error creating PciInfo, but got %v" , err )
226+ }
227+
228+ dev := info .ParseDevice ("0000:00:1f.4" , "pci:v00008086d00009D23sv00001028sd000007EAbc0Csc05i00\n " )
229+ if dev == nil {
230+ t .Fatalf ("Failed to parse valid modalias" )
231+ }
232+ if dev .Class .Name == util .UNKNOWN {
233+ t .Fatalf ("Failed to lookup class name" )
234+ }
235+ }
0 commit comments