Re: [PATCH bpf 4/4] selftests/bpf: Add test for kfunc module order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 08, 2024 at 12:35:19PM +0200, Toke Høiland-Jørgensen wrote:

SNIP

> +static int test_run_prog(const struct bpf_program *prog,
> +			 struct bpf_test_run_opts *opts, int expect_val)
> +{
> +	int err;
> +
> +	err = bpf_prog_test_run_opts(bpf_program__fd(prog), opts);
> +	if (!ASSERT_OK(err, "bpf_prog_test_run_opts"))
> +		return err;
> +
> +	if (!ASSERT_EQ((int)opts->retval, expect_val, bpf_program__name(prog)))
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +void test_kfunc_module_order(void)
> +{
> +	struct kfunc_module_order *skel;
> +	char pkt_data[64] = {};
> +	int err = 0;
> +
> +	DECLARE_LIBBPF_OPTS(bpf_test_run_opts, test_opts, .data_in = pkt_data,
> +			    .data_size_in = sizeof(pkt_data));
> +
> +	err = load_module("bpf_test_modorder_x.ko",
> +			  env_verbosity > VERBOSE_NONE);
> +	if (!ASSERT_OK(err, "load bpf_test_modorder_x.ko"))
> +		return;
> +
> +	err = load_module("bpf_test_modorder_y.ko",
> +			  env_verbosity > VERBOSE_NONE);
> +	if (!ASSERT_OK(err, "load bpf_test_modorder_y.ko"))
> +		goto exit_modx;
> +
> +	skel = kfunc_module_order__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "kfunc_module_order__open_and_load()")) {
> +		err = -EINVAL;
> +		goto exit_mods;
> +	}
> +
> +	test_run_prog(skel->progs.call_kfunc_xy, &test_opts, 0);
> +	test_run_prog(skel->progs.call_kfunc_yx, &test_opts, 0);

nit, no need to pass expect_val, it's always 0

jirka




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux