Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei committed Mar 27, 2023
1 parent 749d301 commit a7f7924
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/util/cgroup/cgroups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,29 @@
package cgroup

import (
"flag"
"log"
"os"
"testing"

"github.com/containerd/cgroups/v3"
)

var (
cgVersion cgroups.CGMode
expected uint64
)

func TestMain(m *testing.M) {
flag.Uint64Var(&expected, "expected", 0, "Expected cgroup's memory limit")
flag.Parse()

cgVersion = cgroups.Mode()
log.Println("Cgroups version:", cgVersion)

os.Exit(m.Run())
}

func TestFromCgroup(t *testing.T) {
limit, err := FromCgroup()
if cgVersion == cgroups.Unavailable && err != ErrNoCgroup {
Expand Down

0 comments on commit a7f7924

Please sign in to comment.