Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Better error messages for ima_setup.sh failures

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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210322170720.2926715-1-kpsingh@kernel.org

authored by

KP Singh and committed by
Alexei Starovoitov
cff90846 b910eaaa

+4 -2
+4 -2
tools/testing/selftests/bpf/prog_tests/test_ima.c
··· 68 68 goto close_prog; 69 69 70 70 snprintf(cmd, sizeof(cmd), "./ima_setup.sh setup %s", measured_dir); 71 - if (CHECK_FAIL(system(cmd))) 71 + err = system(cmd); 72 + if (CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno)) 72 73 goto close_clean; 73 74 74 75 err = run_measured_process(measured_dir, &skel->bss->monitored_pid); ··· 82 81 83 82 close_clean: 84 83 snprintf(cmd, sizeof(cmd), "./ima_setup.sh cleanup %s", measured_dir); 85 - CHECK_FAIL(system(cmd)); 84 + err = system(cmd); 85 + CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno); 86 86 close_prog: 87 87 ima__destroy(skel); 88 88 }