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 14, 2024
1 parent f40a009 commit 332247f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/cgrouprate/cgrouprate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,26 @@ func TestProcessCgroup(t *testing.T) {
}
}
}

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

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

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

// fail
empty := option.CgroupRate{Events: 0, Interval: 0}

opt = option.ParseCgroupRate("10")
assert.Equal(t, empty, opt)

opt = option.ParseCgroupRate("sure,1s")
assert.Equal(t, empty, opt)

opt = option.ParseCgroupRate("1,nope")
assert.Equal(t, empty, opt)
}

0 comments on commit 332247f

Please sign in to comment.