1 // SPDX-License-Identifier: GPL-2.0 2 #include <test_progs.h> 3 4 #include "map_kptr.skel.h" 5 6 void test_map_kptr(void) 7 { 8 struct map_kptr *skel; 9 int key = 0, ret; 10 char buf[24]; 11 12 skel = map_kptr__open_and_load(); 13 if (!ASSERT_OK_PTR(skel, "map_kptr__open_and_load")) 14 return; 15 16 ret = bpf_map_update_elem(bpf_map__fd(skel->maps.array_map), &key, buf, 0); 17 ASSERT_OK(ret, "array_map update"); 18 ret = bpf_map_update_elem(bpf_map__fd(skel->maps.array_map), &key, buf, 0); 19 ASSERT_OK(ret, "array_map update2"); 20 21 ret = bpf_map_update_elem(bpf_map__fd(skel->maps.hash_map), &key, buf, 0); 22 ASSERT_OK(ret, "hash_map update"); 23 ret = bpf_map_delete_elem(bpf_map__fd(skel->maps.hash_map), &key); 24 ASSERT_OK(ret, "hash_map delete"); 25 26 ret = bpf_map_update_elem(bpf_map__fd(skel->maps.hash_malloc_map), &key, buf, 0); 27 ASSERT_OK(ret, "hash_malloc_map update"); 28 ret = bpf_map_delete_elem(bpf_map__fd(skel->maps.hash_malloc_map), &key); 29 ASSERT_OK(ret, "hash_malloc_map delete"); 30 31 ret = bpf_map_update_elem(bpf_map__fd(skel->maps.lru_hash_map), &key, buf, 0); 32 ASSERT_OK(ret, "lru_hash_map update"); 33 ret = bpf_map_delete_elem(bpf_map__fd(skel->maps.lru_hash_map), &key); 34 ASSERT_OK(ret, "lru_hash_map delete"); 35 36 map_kptr__destroy(skel); 37 } 38