Debian Codegraph @

rlimit/rlimit_linux_test.go

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 package rlimit
2
3 import (
4 "testing"
5
6 "github.com/cilium/ebpf/internal/linux"
7 "github.com/cilium/ebpf/internal/unix"
8
9 "github.com/go-quicktest/qt"
10 )
11
12 func TestRemoveMemlock(t *testing.T) {
13 var before unix.Rlimit
14 qt.Assert(t, qt.IsNil(unix.Prlimit(0, unix.RLIMIT_MEMLOCK, nil, &before)))
15
16 err := RemoveMemlock()
17 qt.Assert(t, qt.IsNil(err))
18
19 var after unix.Rlimit
20 qt.Assert(t, qt.IsNil(unix.Prlimit(0, unix.RLIMIT_MEMLOCK, nil, &after)))
21
22 // We can't use testutils here due to an import cycle.
23 version, err := linux.KernelVersion()
24 qt.Assert(t, qt.IsNil(err))
25
26 if version.Less(unsupportedMemcgAccounting.MinimumVersion) {
27 qt.Assert(t, qt.Equals(after.Cur, unix.RLIM_INFINITY), qt.Commentf("cur should be INFINITY"))
28 qt.Assert(t, qt.Equals(after.Max, unix.RLIM_INFINITY), qt.Commentf("max should be INFINITY"))
29 } else {
30 qt.Assert(t, qt.Equals(after.Cur, before.Cur), qt.Commentf("cur should be unchanged"))
31 qt.Assert(t, qt.Equals(after.Max, before.Max), qt.Commentf("max should be unchanged"))
32 }
33 }