Commit 3e23c997 authored by Cupertino Miranda's avatar Cupertino Miranda Committed by Andrii Nakryiko

selftests/bpf: Match tests against regular expression

This patch changes a few tests to make use of regular expressions.
Fixed tests otherwise fail when compiled with GCC.
Signed-off-by: default avatarCupertino Miranda <cupertino.miranda@oracle.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20240617141458.471620-3-cupertino.miranda@oracle.com
parent f06ae619
...@@ -964,7 +964,7 @@ int dynptr_invalidate_slice_reinit(void *ctx) ...@@ -964,7 +964,7 @@ int dynptr_invalidate_slice_reinit(void *ctx)
* mem_or_null pointers. * mem_or_null pointers.
*/ */
SEC("?raw_tp") SEC("?raw_tp")
__failure __msg("R1 type=scalar expected=percpu_ptr_") __failure __regex("R[0-9]+ type=scalar expected=percpu_ptr_")
int dynptr_invalidate_slice_or_null(void *ctx) int dynptr_invalidate_slice_or_null(void *ctx)
{ {
struct bpf_dynptr ptr; struct bpf_dynptr ptr;
...@@ -982,7 +982,7 @@ int dynptr_invalidate_slice_or_null(void *ctx) ...@@ -982,7 +982,7 @@ int dynptr_invalidate_slice_or_null(void *ctx)
/* Destruction of dynptr should also any slices obtained from it */ /* Destruction of dynptr should also any slices obtained from it */
SEC("?raw_tp") SEC("?raw_tp")
__failure __msg("R7 invalid mem access 'scalar'") __failure __regex("R[0-9]+ invalid mem access 'scalar'")
int dynptr_invalidate_slice_failure(void *ctx) int dynptr_invalidate_slice_failure(void *ctx)
{ {
struct bpf_dynptr ptr1; struct bpf_dynptr ptr1;
...@@ -1069,7 +1069,7 @@ int dynptr_read_into_slot(void *ctx) ...@@ -1069,7 +1069,7 @@ int dynptr_read_into_slot(void *ctx)
/* bpf_dynptr_slice()s are read-only and cannot be written to */ /* bpf_dynptr_slice()s are read-only and cannot be written to */
SEC("?tc") SEC("?tc")
__failure __msg("R0 cannot write into rdonly_mem") __failure __regex("R[0-9]+ cannot write into rdonly_mem")
int skb_invalid_slice_write(struct __sk_buff *skb) int skb_invalid_slice_write(struct __sk_buff *skb)
{ {
struct bpf_dynptr ptr; struct bpf_dynptr ptr;
......
...@@ -105,7 +105,7 @@ long rbtree_api_remove_unadded_node(void *ctx) ...@@ -105,7 +105,7 @@ long rbtree_api_remove_unadded_node(void *ctx)
} }
SEC("?tc") SEC("?tc")
__failure __msg("Unreleased reference id=3 alloc_insn=10") __failure __regex("Unreleased reference id=3 alloc_insn=[0-9]+")
long rbtree_api_remove_no_drop(void *ctx) long rbtree_api_remove_no_drop(void *ctx)
{ {
struct bpf_rb_node *res; struct bpf_rb_node *res;
......
...@@ -32,7 +32,7 @@ static bool less(struct bpf_rb_node *a, const struct bpf_rb_node *b) ...@@ -32,7 +32,7 @@ static bool less(struct bpf_rb_node *a, const struct bpf_rb_node *b)
} }
SEC("?tc") SEC("?tc")
__failure __msg("Unreleased reference id=4 alloc_insn=21") __failure __regex("Unreleased reference id=4 alloc_insn=[0-9]+")
long rbtree_refcounted_node_ref_escapes(void *ctx) long rbtree_refcounted_node_ref_escapes(void *ctx)
{ {
struct node_acquire *n, *m; struct node_acquire *n, *m;
...@@ -73,7 +73,7 @@ long refcount_acquire_maybe_null(void *ctx) ...@@ -73,7 +73,7 @@ long refcount_acquire_maybe_null(void *ctx)
} }
SEC("?tc") SEC("?tc")
__failure __msg("Unreleased reference id=3 alloc_insn=9") __failure __regex("Unreleased reference id=3 alloc_insn=[0-9]+")
long rbtree_refcounted_node_ref_escapes_owning_input(void *ctx) long rbtree_refcounted_node_ref_escapes_owning_input(void *ctx)
{ {
struct node_acquire *n, *m; struct node_acquire *n, *m;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment