1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ 3 #include <test_progs.h> 4 #include "kfunc_call_test.skel.h" 5 6 /* 7 * bpf_program__clone() loads a program from a prepared object with the 8 * fd_array of the object, where module BTF fds start at slot 1 and slot 0 is 9 * empty. It used to pass the fill index of that array as fd_array_cnt, which 10 * made the kernel resolve slot 0 and fail the load. 11 */ 12 void test_clone_module_kfunc(void) 13 { 14 struct kfunc_call_test *skel; 15 int err, fd; 16 17 skel = kfunc_call_test__open(); 18 if (!ASSERT_OK_PTR(skel, "skel_open")) 19 return; 20 21 err = bpf_object__prepare(skel->obj); 22 if (!ASSERT_OK(err, "prepare")) 23 goto out; 24 25 fd = bpf_program__clone(skel->progs.kfunc_call_test1, NULL); 26 if (ASSERT_GE(fd, 0, "clone")) 27 close(fd); 28 out: 29 kfunc_call_test__destroy(skel); 30 } 31