mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-06 16:04:26 +01:00
Some tests are now failing due to the changes how PCIe is handled. Update the test accordingly. Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
// Copyright (c) 2017-2018 Intel Corporation
|
|
// Copyright (c) 2018 Huawei Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package drivers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetVFIODetails(t *testing.T) {
|
|
type testData struct {
|
|
deviceStr string
|
|
expectedStr string
|
|
}
|
|
|
|
data := []testData{
|
|
{"0000:02:10.0", "0000:02:10.0"},
|
|
{"0000:0210.0", ""},
|
|
{"f79944e4-5a3d-11e8-99ce-", ""},
|
|
{"f79944e4-5a3d-11e8-99ce", ""},
|
|
{"test", ""},
|
|
{"", ""},
|
|
}
|
|
|
|
for _, d := range data {
|
|
deviceBDF, deviceSysfsDev, vfioDeviceType, err := GetVFIODetails(d.deviceStr, "")
|
|
|
|
switch vfioDeviceType {
|
|
case config.VFIOPCIDeviceNormalType:
|
|
assert.Equal(t, d.expectedStr, deviceBDF)
|
|
case config.VFIOPCIDeviceMediatedType, config.VFIOAPDeviceMediatedType:
|
|
assert.Equal(t, d.expectedStr, deviceSysfsDev)
|
|
default:
|
|
assert.NotNil(t, err)
|
|
}
|
|
|
|
if d.expectedStr == "" {
|
|
assert.NotNil(t, err)
|
|
} else {
|
|
assert.Nil(t, err)
|
|
}
|
|
}
|
|
|
|
}
|