1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2022 Google */ 3 4 #include <test_progs.h> 5 #include "test_autoattach.skel.h" 6 7 void test_autoattach(void) 8 { 9 struct test_autoattach *skel; 10 11 skel = test_autoattach__open_and_load(); 12 if (!ASSERT_OK_PTR(skel, "skel_open_and_load")) 13 goto cleanup; 14 15 /* disable auto-attach for prog2 */ 16 bpf_program__set_autoattach(skel->progs.prog2, false); 17 ASSERT_TRUE(bpf_program__autoattach(skel->progs.prog1), "autoattach_prog1"); 18 ASSERT_FALSE(bpf_program__autoattach(skel->progs.prog2), "autoattach_prog2"); 19 if (!ASSERT_OK(test_autoattach__attach(skel), "skel_attach")) 20 goto cleanup; 21 22 usleep(1); 23 24 ASSERT_TRUE(skel->bss->prog1_called, "attached_prog1"); 25 ASSERT_FALSE(skel->bss->prog2_called, "attached_prog2"); 26 27 cleanup: 28 test_autoattach__destroy(skel); 29 } 30 31