@@ -387,6 +387,66 @@ func TestScan(t *testing.T) {
387
387
maxDevNum : 1 ,
388
388
expectedDevNum : 1 ,
389
389
},
390
+ {
391
+ name : "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), PF with dc capabilities" ,
392
+ dpdkDriver : "vfio-pci" ,
393
+ kernelVfDrivers : []string {"4xxxvf" },
394
+ dirs : []string {
395
+ "sys/bus/pci/drivers/4xxx" ,
396
+ "sys/bus/pci/drivers/vfio-pci" ,
397
+ "sys/bus/pci/devices/0000:02:00.0" ,
398
+ "sys/kernel/debug/qat_4xxx_0000:02:00.0" ,
399
+ "sys/bus/pci/devices/0000:02:01.0" ,
400
+ },
401
+ files : map [string ][]byte {
402
+ "sys/bus/pci/devices/0000:02:00.0/device" : []byte ("0x4940" ),
403
+ "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = dc" ),
404
+ "sys/bus/pci/devices/0000:02:01.0/device" : []byte ("0x4941" ),
405
+ },
406
+ symlinks : map [string ]string {
407
+ "sys/bus/pci/devices/0000:02:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile" ,
408
+ "sys/bus/pci/devices/0000:02:01.0/physfn" : "sys/bus/pci/devices/0000:02:00.0" ,
409
+ "sys/bus/pci/drivers/4xxx/0000:02:00.0" : "sys/bus/pci/devices/0000:02:00.0" ,
410
+ "sys/bus/pci/devices/0000:02:00.0/virtfn0" : "sys/bus/pci/devices/0000:02:01.0" ,
411
+ },
412
+ maxDevNum : 1 ,
413
+ expectedDevNum : 1 ,
414
+ },
415
+ {
416
+ name : "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), two PFs with dc and cy capabilities" ,
417
+ dpdkDriver : "vfio-pci" ,
418
+ kernelVfDrivers : []string {"4xxxvf" },
419
+ dirs : []string {
420
+ "sys/bus/pci/drivers/4xxx" ,
421
+ "sys/bus/pci/drivers/vfio-pci" ,
422
+ "sys/bus/pci/devices/0000:02:00.0" ,
423
+ "sys/bus/pci/devices/0000:03:00.0" ,
424
+ "sys/kernel/debug/qat_4xxx_0000:02:00.0" ,
425
+ "sys/kernel/debug/qat_4xxx_0000:03:00.0" ,
426
+ "sys/bus/pci/devices/0000:02:01.0" ,
427
+ "sys/bus/pci/devices/0000:03:01.0" ,
428
+ },
429
+ files : map [string ][]byte {
430
+ "sys/bus/pci/devices/0000:02:00.0/device" : []byte ("0x4940" ),
431
+ "sys/bus/pci/devices/0000:03:00.0/device" : []byte ("0x4940" ),
432
+ "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = dc" ),
433
+ "sys/kernel/debug/qat_4xxx_0000:03:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = sym;asym" ),
434
+ "sys/bus/pci/devices/0000:02:01.0/device" : []byte ("0x4941" ),
435
+ "sys/bus/pci/devices/0000:03:01.0/device" : []byte ("0x4941" ),
436
+ },
437
+ symlinks : map [string ]string {
438
+ "sys/bus/pci/devices/0000:02:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile" ,
439
+ "sys/bus/pci/devices/0000:03:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile2" ,
440
+ "sys/bus/pci/devices/0000:02:01.0/physfn" : "sys/bus/pci/devices/0000:02:00.0" ,
441
+ "sys/bus/pci/devices/0000:03:01.0/physfn" : "sys/bus/pci/devices/0000:03:00.0" ,
442
+ "sys/bus/pci/drivers/4xxx/0000:02:00.0" : "sys/bus/pci/devices/0000:02:00.0" ,
443
+ "sys/bus/pci/drivers/4xxx/0000:03:00.0" : "sys/bus/pci/devices/0000:03:00.0" ,
444
+ "sys/bus/pci/devices/0000:02:00.0/virtfn0" : "sys/bus/pci/devices/0000:02:01.0" ,
445
+ "sys/bus/pci/devices/0000:03:00.0/virtfn0" : "sys/bus/pci/devices/0000:03:01.0" ,
446
+ },
447
+ maxDevNum : 2 ,
448
+ expectedDevNum : 2 ,
449
+ },
390
450
}
391
451
for _ , tt := range tcases {
392
452
t .Run (tt .name , func (t * testing.T ) {
@@ -419,8 +479,12 @@ func TestScan(t *testing.T) {
419
479
if ! tt .expectedErr && err != nil {
420
480
t .Errorf ("got unexpected error: %+v" , err )
421
481
}
422
- if len (fN .tree ["generic" ]) != tt .expectedDevNum {
423
- t .Errorf ("expected %d, but got %d devices" , tt .expectedDevNum , len (fN .tree ["generic" ]))
482
+ devNum := 0
483
+ for _ , resource := range fN .tree {
484
+ devNum = devNum + len (resource )
485
+ }
486
+ if devNum != tt .expectedDevNum {
487
+ t .Errorf ("expected %d, but got %d devices" , tt .expectedDevNum , devNum )
424
488
}
425
489
426
490
if err = os .RemoveAll (tmpdir ); err != nil {
0 commit comments