Skip to content

Commit

Permalink
tetragon: Add ParseCgroupRate test
Browse files Browse the repository at this point in the history
Adding test for ParseCgroupRate function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
  • Loading branch information
olsajiri committed Apr 4, 2024
1 parent 41f3b54 commit 17d458a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/cgrouprate/cgrouprate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,24 @@ func TestCheckThrottle(t *testing.T) {
}
}
}

func TestParseCgroupRate(t *testing.T) {
var opt option.CgroupRate

// ok
opt = option.ParseCgroupRate("1,1s")
assert.Equal(t, option.CgroupRate{1, 1000000000}, opt)

opt = option.ParseCgroupRate("1,1m")
assert.Equal(t, option.CgroupRate{1, 60000000000}, opt)

// fail
opt = option.ParseCgroupRate("10")
assert.Equal(t, option.CgroupRate{0, 0}, opt)

opt = option.ParseCgroupRate("sure,1s")
assert.Equal(t, option.CgroupRate{0, 0}, opt)

opt = option.ParseCgroupRate("1,nope")
assert.Equal(t, option.CgroupRate{0, 0}, opt)
}

0 comments on commit 17d458a

Please sign in to comment.