Skip to content

Commit ba6ee98

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 e5d7e36 commit ba6ee98

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ __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(str, "hello", 6); }
33+
__test(0) int test_strnstr_found1(void *ctx) { return bpf_strnstr("", "", 0); }
34+
__test(0) int test_strnstr_found2(void *ctx) { return bpf_strnstr(str, "hello", 5); }
35+
__test(0) int test_strnstr_found3(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); }
3638

0 commit comments

Comments
 (0)