Re: [RFC PATCH bpf-next 2/4] selftests/bpf: Add re-attach test to fentry_test

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

 




> On Mar 28, 2021, at 4:26 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> 
> Adding the test to re-attach (detach/attach again) tracing
> fentry programs, plus check that already linked program can't
> be attached again.
> 
> Fixing the number of check-ed results, which should be 8.
> 
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> 
[...]
> +
> +void test_fentry_test(void)
> +{
> +	struct fentry_test *fentry_skel = NULL;
> +	struct bpf_link *link;
> +	int err;
> +
> +	fentry_skel = fentry_test__open_and_load();
> +	if (CHECK(!fentry_skel, "fentry_skel_load", "fentry skeleton failed\n"))
> +		goto cleanup;
> +
> +	err = fentry_test__attach(fentry_skel);
> +	if (CHECK(err, "fentry_attach", "fentry attach failed: %d\n", err))
> +		goto cleanup;
> +
> +	err = fentry_test(fentry_skel);
> +	if (CHECK(err, "fentry_test", "fentry test failed: %d\n", err))
> +		goto cleanup;
> +
> +	fentry_test__detach(fentry_skel);
> +
> +	/* Re-attach and test again */
> +	err = fentry_test__attach(fentry_skel);
> +	if (CHECK(err, "fentry_attach", "fentry re-attach failed: %d\n", err))
> +		goto cleanup;
> +
> +	link = bpf_program__attach(fentry_skel->progs.test1);
> +	if (CHECK(!IS_ERR(link), "attach_fentry re-attach without detach",
> +		  "err: %ld\n", PTR_ERR(link)))

nit: I guess we shouldn't print PTR_ERR(link) when link is not an error code?
This shouldn't break though. 

Thanks,
Song

> +		goto cleanup;
> +
> +	err = fentry_test(fentry_skel);
> +	CHECK(err, "fentry_test", "fentry test failed: %d\n", err);
> +
> cleanup:
> 	fentry_test__destroy(fentry_skel);
> }
> -- 
> 2.30.2
> 





[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