1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #include <test_progs.h>
4 
5 #include "inner_array_lookup.skel.h"
6 
7 void test_inner_array_lookup(void)
8 {
9 	int map1_fd, err;
10 	int key = 3;
11 	int val = 1;
12 	struct inner_array_lookup *skel;
13 
14 	skel = inner_array_lookup__open_and_load();
15 	if (!ASSERT_OK_PTR(skel, "open_load_skeleton"))
16 		return;
17 
18 	err = inner_array_lookup__attach(skel);
19 	if (!ASSERT_OK(err, "skeleton_attach"))
20 		goto cleanup;
21 
22 	map1_fd = bpf_map__fd(skel->maps.inner_map1);
23 	bpf_map_update_elem(map1_fd, &key, &val, 0);
24 
25 	/* Probe should have set the element at index 3 to 2 */
26 	bpf_map_lookup_elem(map1_fd, &key, &val);
27 	ASSERT_EQ(val, 2, "value_is_2");
28 
29 cleanup:
30 	inner_array_lookup__destroy(skel);
31 }
32