-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package libbpfgo | ||
|
||
import "testing" | ||
|
||
func TestLogFilterOutput(t *testing.T) { | ||
tests := []struct { | ||
libbpfPrintLevel int | ||
output string | ||
expectedResult bool | ||
}{ | ||
{ | ||
output: "libbpf: prog 'trace_check_map_func_compatibility': failed to create kprobe 'check_map_func_compatibility+0x0' perf event: No such file or directory\n", | ||
expectedResult: true, | ||
}, | ||
{ | ||
output: "libbpf: Kernel error message: Exclusivity flag on\n", | ||
expectedResult: true, | ||
}, | ||
{ | ||
output: "libbpf: prog 'cgroup_skb_ingress': failed to attach to cgroup 'cgroup': Invalid argument\n", | ||
expectedResult: true, | ||
}, | ||
{ | ||
output: "libbpf: prog 'cgroup_skb_egress': failed to attach to cgroup 'cgroup': Invalid argument\n", | ||
expectedResult: true, | ||
}, | ||
{ | ||
output: "This is not a log message that should be filtered\n", | ||
expectedResult: false, | ||
}, | ||
{ | ||
output: "libbpf: This is not a log message that should be filtered\n", | ||
expectedResult: false, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
result := LogFilterOutput(test.libbpfPrintLevel, test.output) | ||
if result != test.expectedResult { | ||
t.Errorf("For input '%s', expected %v but got %v", test.output, test.expectedResult, result) | ||
} | ||
} | ||
} |