diff mbox series

[bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures

Message ID 20210322170720.2926715-1-kpsingh@kernel.org (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Better error messages for ima_setup.sh failures | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: linux-kselftest@vger.kernel.org netdev@vger.kernel.org yhs@fb.com kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com shuah@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

KP Singh March 22, 2021, 5:07 p.m. UTC
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(-)

Comments

Andrii Nakryiko March 26, 2021, 4:49 a.m. UTC | #1
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
>
diff mbox series

Patch

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);
 }