diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-11-16 15:51:48 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-12-08 04:18:23 +0300 |
commit | e9c08f722924c58041d2e0d90ea27140a4625776 (patch) | |
tree | b5cb0bf997fc3dade2f499defa376278b4d25654 /tools | |
parent | 5504f67944484495a5d8504d11fb998af05fe248 (diff) | |
download | linux-e9c08f722924c58041d2e0d90ea27140a4625776.tar.xz |
perf test sigtrap: Print errno string when failing
Helps a bit the user figuring out why it is failing:
Before:
$ perf test sigtrap
73: Sigtrap : FAILED!
$ perf test -v sigtrap
73: Sigtrap :
--- start ---
test child forked, pid 3816772
FAILED sys_perf_event_open()
test child finished with -1
---- end ----
Sigtrap: FAILED!
$
After:
$ perf test sigtrap
73: Sigtrap : FAILED!
$ perf test -v sigtrap
73: Sigtrap :
--- start ---
test child forked, pid 3816772
FAILED sys_perf_event_open(): Permission denied
test child finished with -1
---- end ----
Sigtrap: FAILED!
$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Fabian Hemmer <copy@copy.sh>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Marco Elver <elver@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kasan-dev@googlegroups.com
Link: http://lore.kernel.org/lkml/YZOpSVOCXe0zWeRs@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/tests/sigtrap.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/perf/tests/sigtrap.c b/tools/perf/tests/sigtrap.c index de409f21f952..1004bf0e7cc9 100644 --- a/tools/perf/tests/sigtrap.c +++ b/tools/perf/tests/sigtrap.c @@ -5,9 +5,11 @@ * Copyright (C) 2021, Google LLC. */ +#include <errno.h> #include <stdint.h> #include <stdlib.h> #include <linux/hw_breakpoint.h> +#include <linux/string.h> #include <pthread.h> #include <signal.h> #include <sys/ioctl.h> @@ -117,6 +119,7 @@ static int test__sigtrap(struct test_suite *test __maybe_unused, int subtest __m struct sigaction oldact; pthread_t threads[NUM_THREADS]; pthread_barrier_t barrier; + char sbuf[STRERR_BUFSIZE]; int i, fd, ret = TEST_FAIL; pthread_barrier_init(&barrier, NULL, NUM_THREADS + 1); @@ -125,19 +128,19 @@ static int test__sigtrap(struct test_suite *test __maybe_unused, int subtest __m action.sa_sigaction = sigtrap_handler; sigemptyset(&action.sa_mask); if (sigaction(SIGTRAP, &action, &oldact)) { - pr_debug("FAILED sigaction()\n"); + pr_debug("FAILED sigaction(): %s\n", str_error_r(errno, sbuf, sizeof(sbuf))); goto out; } fd = sys_perf_event_open(&attr, 0, -1, -1, perf_event_open_cloexec_flag()); if (fd < 0) { - pr_debug("FAILED sys_perf_event_open()\n"); + pr_debug("FAILED sys_perf_event_open(): %s\n", str_error_r(errno, sbuf, sizeof(sbuf))); goto out_restore_sigaction; } for (i = 0; i < NUM_THREADS; i++) { if (pthread_create(&threads[i], NULL, test_thread, &barrier)) { - pr_debug("FAILED pthread_create()"); + pr_debug("FAILED pthread_create(): %s\n", str_error_r(errno, sbuf, sizeof(sbuf))); goto out_close_perf_event; } } |