Skip to content

Commit 818b8cf

Browse files
RtoaxKernel Patches Daemon
authored andcommitted
selftests/bpf: Add tests for bpf_strnstr
Add two tests for bpf_strnstr(): bpf_strnstr("", "", 0) = 0 bpf_strnstr("hello world", "hello", 5) = 0 Signed-off-by: Rong Tao <[email protected]>
1 parent d84885c commit 818b8cf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/bpf/progs/string_kfuncs_success.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ __test(2) int test_strcspn(void *ctx) { return bpf_strcspn(str, "lo"); }
3030
__test(6) int test_strstr_found(void *ctx) { return bpf_strstr(str, "world"); }
3131
__test(-ENOENT) int test_strstr_notfound(void *ctx) { return bpf_strstr(str, "hi"); }
3232
__test(0) int test_strstr_empty(void *ctx) { return bpf_strstr(str, ""); }
33+
__test(0) int test_strnstr_found(void *ctx) { return bpf_strnstr("", "", 0); }
34+
__test(0) int test_strnstr_found(void *ctx) { return bpf_strnstr(str, "hello", 5); }
3335
__test(0) int test_strnstr_found(void *ctx) { return bpf_strnstr(str, "hello", 6); }
3436
__test(-ENOENT) int test_strnstr_notfound(void *ctx) { return bpf_strnstr(str, "hi", 10); }
3537
__test(0) int test_strnstr_empty(void *ctx) { return bpf_strnstr(str, "", 1); }

0 commit comments

Comments
 (0)