bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures
@ 2021-03-22 17:07 KP Singh
  2021-03-26  4:49 ` Andrii Nakryiko
  0 siblings, 1 reply; 2+ messages in thread
From: KP Singh @ 2021-03-22 17:07 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Florent Revest, Brendan Jackman

The current implementation uses the CHECK_FAIL macro which does not
provide useful error messages when the script fails. Use the CHECK macro
instead and provide more descriptive messages to aid debugging.

Signed-off-by: KP Singh <kpsingh@kernel.org>
---
 tools/testing/selftests/bpf/prog_tests/test_ima.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_ima.c b/tools/testing/selftests/bpf/prog_tests/test_ima.c
index b54bc0c351b7..0252f61d611a 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_ima.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_ima.c
@@ -68,7 +68,8 @@ void test_test_ima(void)
 		goto close_prog;
 
 	snprintf(cmd, sizeof(cmd), "./ima_setup.sh setup %s", measured_dir);
-	if (CHECK_FAIL(system(cmd)))
+	err = system(cmd);
+	if (CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno))
 		goto close_clean;
 
 	err = run_measured_process(measured_dir, &skel->bss->monitored_pid);
@@ -81,7 +82,8 @@ void test_test_ima(void)
 
 close_clean:
 	snprintf(cmd, sizeof(cmd), "./ima_setup.sh cleanup %s", measured_dir);
-	CHECK_FAIL(system(cmd));
+	err = system(cmd);
+	CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno);
 close_prog:
 	ima__destroy(skel);
 }
-- 
2.31.0.rc2.261.g7f71774620-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures
  2021-03-22 17:07 [PATCH bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures KP Singh
@ 2021-03-26  4:49 ` Andrii Nakryiko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2021-03-26  4:49 UTC (permalink / raw)
  To: KP Singh
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Florent Revest, Brendan Jackman

On Mon, Mar 22, 2021 at 10:07 AM KP Singh <kpsingh@kernel.org> wrote:
>
> The current implementation uses the CHECK_FAIL macro which does not
> provide useful error messages when the script fails. Use the CHECK macro
> instead and provide more descriptive messages to aid debugging.
>
> Signed-off-by: KP Singh <kpsingh@kernel.org>
> ---

This was applied to bpf-next, but commit bot doesn't seem very
attentive at the moment :) Thanks for improvements!

>  tools/testing/selftests/bpf/prog_tests/test_ima.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_ima.c b/tools/testing/selftests/bpf/prog_tests/test_ima.c
> index b54bc0c351b7..0252f61d611a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_ima.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_ima.c
> @@ -68,7 +68,8 @@ void test_test_ima(void)
>                 goto close_prog;
>
>         snprintf(cmd, sizeof(cmd), "./ima_setup.sh setup %s", measured_dir);
> -       if (CHECK_FAIL(system(cmd)))
> +       err = system(cmd);
> +       if (CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno))
>                 goto close_clean;
>
>         err = run_measured_process(measured_dir, &skel->bss->monitored_pid);
> @@ -81,7 +82,8 @@ void test_test_ima(void)
>
>  close_clean:
>         snprintf(cmd, sizeof(cmd), "./ima_setup.sh cleanup %s", measured_dir);
> -       CHECK_FAIL(system(cmd));
> +       err = system(cmd);
> +       CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno);
>  close_prog:
>         ima__destroy(skel);
>  }
> --
> 2.31.0.rc2.261.g7f71774620-goog
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-26  4:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 17:07 [PATCH bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures KP Singh
2021-03-26  4:49 ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).