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 <[email protected]>
  • Loading branch information
olsajiri committed May 6, 2024
1 parent 6e45bfc commit 0ff6169
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 @@ -257,3 +257,26 @@ func TestProcessCgroup(t *testing.T) {
assert.Equal(t, d.throttle, l.throttle)
}
}

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 0ff6169

Please sign in to comment.