Commit d18decca authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

selftests/bpf: Use only stdout in un/load_bpf_testmod functions

We are about to use un/load_bpf_testmod functions in couple tests
and it's better  to print output to stdout,  so it's aligned with
tests ASSERT macros output, which use stdout as well.
Acked-by: default avatarDavid Vernet <void@manifault.com>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230515133756.1658301-5-jolsa@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 45db3109
...@@ -341,14 +341,14 @@ static int delete_module(const char *name, int flags) ...@@ -341,14 +341,14 @@ static int delete_module(const char *name, int flags)
void unload_bpf_testmod(bool verbose) void unload_bpf_testmod(bool verbose)
{ {
if (kern_sync_rcu()) if (kern_sync_rcu())
fprintf(stderr, "Failed to trigger kernel-side RCU sync!\n"); fprintf(stdout, "Failed to trigger kernel-side RCU sync!\n");
if (delete_module("bpf_testmod", 0)) { if (delete_module("bpf_testmod", 0)) {
if (errno == ENOENT) { if (errno == ENOENT) {
if (verbose) if (verbose)
fprintf(stdout, "bpf_testmod.ko is already unloaded.\n"); fprintf(stdout, "bpf_testmod.ko is already unloaded.\n");
return; return;
} }
fprintf(stderr, "Failed to unload bpf_testmod.ko from kernel: %d\n", -errno); fprintf(stdout, "Failed to unload bpf_testmod.ko from kernel: %d\n", -errno);
return; return;
} }
if (verbose) if (verbose)
...@@ -367,11 +367,11 @@ int load_bpf_testmod(bool verbose) ...@@ -367,11 +367,11 @@ int load_bpf_testmod(bool verbose)
fd = open("bpf_testmod.ko", O_RDONLY); fd = open("bpf_testmod.ko", O_RDONLY);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Can't find bpf_testmod.ko kernel module: %d\n", -errno); fprintf(stdout, "Can't find bpf_testmod.ko kernel module: %d\n", -errno);
return -ENOENT; return -ENOENT;
} }
if (finit_module(fd, "", 0)) { if (finit_module(fd, "", 0)) {
fprintf(stderr, "Failed to load bpf_testmod.ko into the kernel: %d\n", -errno); fprintf(stdout, "Failed to load bpf_testmod.ko into the kernel: %d\n", -errno);
close(fd); close(fd);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment