1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2021 Facebook */ 3 #include <test_progs.h> 4 #include "recursion.skel.h" 5 6 void test_recursion(void) 7 { 8 struct recursion *skel; 9 int key = 0; 10 int err; 11 12 skel = recursion__open_and_load(); 13 if (!ASSERT_OK_PTR(skel, "skel_open_and_load")) 14 return; 15 16 err = recursion__attach(skel); 17 if (!ASSERT_OK(err, "skel_attach")) 18 goto out; 19 20 ASSERT_EQ(skel->bss->pass1, 0, "pass1 == 0"); 21 bpf_map_lookup_elem(bpf_map__fd(skel->maps.hash1), &key, 0); 22 ASSERT_EQ(skel->bss->pass1, 1, "pass1 == 1"); 23 bpf_map_lookup_elem(bpf_map__fd(skel->maps.hash1), &key, 0); 24 ASSERT_EQ(skel->bss->pass1, 2, "pass1 == 2"); 25 26 ASSERT_EQ(skel->bss->pass2, 0, "pass2 == 0"); 27 bpf_map_lookup_elem(bpf_map__fd(skel->maps.hash2), &key, 0); 28 ASSERT_EQ(skel->bss->pass2, 1, "pass2 == 1"); 29 bpf_map_lookup_elem(bpf_map__fd(skel->maps.hash2), &key, 0); 30 ASSERT_EQ(skel->bss->pass2, 2, "pass2 == 2"); 31 out: 32 recursion__destroy(skel); 33 } 34