mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-27 04:05:59 +08:00
Add support to get devlink resources
- Update nl package with new netlink attribute types and consts - Define structs to model devlink device resources - Add DevlinkGetDeviceResources method to return device resources - Add basic test Signed-off-by: adrianc <adrianc@nvidia.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package netlink
|
||||
@@ -262,3 +263,26 @@ func areInfoStructsEqual(first *DevlinkDeviceInfo, second *DevlinkDeviceInfo) bo
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func TestDevlinkGetDeviceResources(t *testing.T) {
|
||||
minKernelRequired(t, 5, 11)
|
||||
tearDown := setUpNetlinkTestWithKModule(t, "devlink")
|
||||
defer tearDown()
|
||||
|
||||
if bus == "" || device == "" {
|
||||
//TODO: setup netdevsim device instead of getting device from flags
|
||||
t.Log("devlink bus and device are empty, skipping test")
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
res, err := DevlinkGetDeviceResources(bus, device)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get device(%s/%s) resources. %s", bus, device, err)
|
||||
}
|
||||
|
||||
if res.Bus != bus || res.Device != device {
|
||||
t.Fatalf("missmatching bus/device")
|
||||
}
|
||||
|
||||
t.Logf("Resources: %+v", res)
|
||||
}
|
||||
|
Reference in New Issue
Block a user