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