selftests/bpf: test_progs: remove unused ret

send_signal test returns static codes from the subtests which
nobody looks at, let's rely on the CHECK macros instead.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
Stanislav Fomichev 2019-08-21 16:44:27 -07:00 committed by Daniel Borkmann
parent 62d69f24fe
commit 86ccc384cf

View file

@ -8,7 +8,7 @@ static void sigusr1_handler(int signum)
sigusr1_received++;
}
static int test_send_signal_common(struct perf_event_attr *attr,
static void test_send_signal_common(struct perf_event_attr *attr,
int prog_type,
const char *test_name)
{
@ -23,13 +23,13 @@ static int test_send_signal_common(struct perf_event_attr *attr,
if (CHECK(pipe(pipe_c2p), test_name,
"pipe pipe_c2p error: %s\n", strerror(errno)))
goto no_fork_done;
return;
if (CHECK(pipe(pipe_p2c), test_name,
"pipe pipe_p2c error: %s\n", strerror(errno))) {
close(pipe_c2p[0]);
close(pipe_c2p[1]);
goto no_fork_done;
return;
}
pid = fork();
@ -38,7 +38,7 @@ static int test_send_signal_common(struct perf_event_attr *attr,
close(pipe_c2p[1]);
close(pipe_p2c[0]);
close(pipe_p2c[1]);
goto no_fork_done;
return;
}
if (pid == 0) {
@ -125,7 +125,7 @@ static int test_send_signal_common(struct perf_event_attr *attr,
goto disable_pmu;
}
err = CHECK(buf[0] != '2', test_name, "incorrect result\n");
CHECK(buf[0] != '2', test_name, "incorrect result\n");
/* notify child safe to exit */
write(pipe_p2c[1], buf, 1);
@ -138,11 +138,9 @@ static int test_send_signal_common(struct perf_event_attr *attr,
close(pipe_c2p[0]);
close(pipe_p2c[1]);
wait(NULL);
no_fork_done:
return err;
}
static int test_send_signal_tracepoint(void)
static void test_send_signal_tracepoint(void)
{
const char *id_path = "/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id";
struct perf_event_attr attr = {
@ -159,21 +157,21 @@ static int test_send_signal_tracepoint(void)
if (CHECK(efd < 0, "tracepoint",
"open syscalls/sys_enter_nanosleep/id failure: %s\n",
strerror(errno)))
return -1;
return;
bytes = read(efd, buf, sizeof(buf));
close(efd);
if (CHECK(bytes <= 0 || bytes >= sizeof(buf), "tracepoint",
"read syscalls/sys_enter_nanosleep/id failure: %s\n",
strerror(errno)))
return -1;
return;
attr.config = strtol(buf, NULL, 0);
return test_send_signal_common(&attr, BPF_PROG_TYPE_TRACEPOINT, "tracepoint");
test_send_signal_common(&attr, BPF_PROG_TYPE_TRACEPOINT, "tracepoint");
}
static int test_send_signal_perf(void)
static void test_send_signal_perf(void)
{
struct perf_event_attr attr = {
.sample_period = 1,
@ -181,11 +179,11 @@ static int test_send_signal_perf(void)
.config = PERF_COUNT_SW_CPU_CLOCK,
};
return test_send_signal_common(&attr, BPF_PROG_TYPE_PERF_EVENT,
"perf_sw_event");
test_send_signal_common(&attr, BPF_PROG_TYPE_PERF_EVENT,
"perf_sw_event");
}
static int test_send_signal_nmi(void)
static void test_send_signal_nmi(void)
{
struct perf_event_attr attr = {
.sample_freq = 50,
@ -205,25 +203,23 @@ static int test_send_signal_nmi(void)
printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n",
__func__);
test__skip();
return 0;
return;
}
/* Let the test fail with a more informative message */
} else {
close(pmu_fd);
}
return test_send_signal_common(&attr, BPF_PROG_TYPE_PERF_EVENT,
"perf_hw_event");
test_send_signal_common(&attr, BPF_PROG_TYPE_PERF_EVENT,
"perf_hw_event");
}
void test_send_signal(void)
{
int ret = 0;
if (test__start_subtest("send_signal_tracepoint"))
ret |= test_send_signal_tracepoint();
test_send_signal_tracepoint();
if (test__start_subtest("send_signal_perf"))
ret |= test_send_signal_perf();
test_send_signal_perf();
if (test__start_subtest("send_signal_nmi"))
ret |= test_send_signal_nmi();
test_send_signal_nmi();
}