LRU hash map updates may legitimately return -ENOMEM. Relax the percpu
stats selftest to accept that error for LRU map types so it matches the
map's expected behavior.

Signed-off-by: Leon Hwang <[email protected]>
---
 tools/testing/selftests/bpf/map_tests/map_percpu_stats.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/map_tests/map_percpu_stats.c 
b/tools/testing/selftests/bpf/map_tests/map_percpu_stats.c
index 1c7c04288eff..d510a9c54978 100644
--- a/tools/testing/selftests/bpf/map_tests/map_percpu_stats.c
+++ b/tools/testing/selftests/bpf/map_tests/map_percpu_stats.c
@@ -188,7 +188,8 @@ static void *patch_map_thread(void *arg)
                                                   40, retry_for_nomem_fn);
                else
                        ret = bpf_map_update_elem(opts->map_fd, &i, val_ptr, 0);
-               CHECK(ret < 0, "bpf_map_update_elem", "key=%d error: %s\n", i, 
strerror(errno));
+               CHECK(ret < 0 && (!is_lru(opts->map_type) || ret != -ENOMEM),
+                     "bpf_map_update_elem", "key=%d error: %s\n", i, 
strerror(errno));
 
                if (opts->map_type == BPF_MAP_TYPE_HASH_OF_MAPS)
                        close(val);
-- 
2.52.0


Reply via email to