...
1 package fscommon
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7
8 "github.com/opencontainers/runc/libcontainer/configs"
9 )
10
11
12
13
14
15
16
17 func TestRdmaSet(t *testing.T) {
18 testCgroupPath := filepath.Join(t.TempDir(), "rdma")
19
20
21 err := os.Mkdir(testCgroupPath, 0o755)
22 if err != nil {
23 t.Fatal(err)
24 }
25
26 rdmaDevice := "mlx5_1"
27 maxHandles := uint32(100)
28 maxObjects := uint32(300)
29
30 rdmaStubResource := &configs.Resources{
31 Rdma: map[string]configs.LinuxRdma{
32 rdmaDevice: {
33 HcaHandles: &maxHandles,
34 HcaObjects: &maxObjects,
35 },
36 },
37 }
38
39 if err := RdmaSet(testCgroupPath, rdmaStubResource); err != nil {
40 t.Fatal(err)
41 }
42
43
44 rdmaEntries, err := readRdmaEntries(testCgroupPath, "rdma.max")
45 if err != nil {
46 t.Fatal(err)
47 }
48 if len(rdmaEntries) != 1 {
49 t.Fatal("rdma_test: Got the wrong values while parsing entries from rdma.max")
50 }
51 if rdmaEntries[0].HcaHandles != maxHandles {
52 t.Fatalf("rdma_test: Got the wrong value for hca_handles")
53 }
54 if rdmaEntries[0].HcaObjects != maxObjects {
55 t.Fatalf("rdma_test: Got the wrong value for hca_Objects")
56 }
57 }
58
View as plain text