-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tetragon: Allow to specify rb-* size options with size suffix
Adding support to set and display rb sizes with size suffixes. # ./tetragon --bpf-lib ./bpf/objs/ --rb-size-total 256M ... time="2023-10-13T20:18:51Z" level=info msg="Perf ring buffer size (bytes)" percpu=64M total=256M # ./tetragon --bpf-lib ./bpf/objs/ --rb-size 16M ... time="2023-10-13T20:18:27Z" level=info msg="Perf ring buffer size (bytes)" percpu=16M total=64M # ./tetragon --bpf-lib ./bpf/objs/ --rb-queue-size=100K ... time="2023-10-13T20:17:42Z" level=info msg="Perf ring buffer events queue size (events)" size=976K Signed-off-by: Jiri Olsa <jolsa@kernel.org>
- Loading branch information
Showing
5 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Tetragon | ||
|
||
package strutils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type parseSize struct { | ||
str string | ||
err bool | ||
val int | ||
} | ||
|
||
func TestParseSize(t *testing.T) { | ||
var tests = []parseSize{ | ||
parseSize{"1K", false, 1024}, | ||
parseSize{"256M", false, 256 * 1024 * 1024}, | ||
parseSize{"10G", false, 10 * 1024 * 1024 * 1024}, | ||
parseSize{"10k", true, 0}, | ||
parseSize{"abc", true, 0}, | ||
parseSize{"abcM", true, 0}, | ||
} | ||
|
||
for idx := range tests { | ||
test := tests[idx] | ||
val, err := ParseSize(test.str) | ||
assert.Equal(t, val, test.val) | ||
assert.Equal(t, err != nil, test.err) | ||
} | ||
} |