aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2019-08-30 13:07:31 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2019-09-03 21:01:52 +0200
commit416c572821841bef2cbb6346fb559901efff4ff3 (patch)
tree569b593d80ac5a6b2f8d9eeed6643c37da53ba5c /tools/testing
parentselftests/bpf: fix "ctx:write sysctl:write read ok" on s390 (diff)
downloadlinux-dev-416c572821841bef2cbb6346fb559901efff4ff3.tar.xz
linux-dev-416c572821841bef2cbb6346fb559901efff4ff3.zip
selftests/bpf: improve unexpected success reporting in test_syctl
When tests fail because sysctl() unexpectedly succeeds, they print an inappropriate "Unexpected failure" message and a random errno. Zero out errno before calling sysctl() and replace the message with "Unexpected success". Fixes: 1f5fa9ab6e2e ("selftests/bpf: Test BPF_CGROUP_SYSCTL") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/bpf/test_sysctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_sysctl.c b/tools/testing/selftests/bpf/test_sysctl.c
index 908f327839d5..106644f7e73e 100644
--- a/tools/testing/selftests/bpf/test_sysctl.c
+++ b/tools/testing/selftests/bpf/test_sysctl.c
@@ -1499,6 +1499,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test)
goto err;
}
+ errno = 0;
if (access_sysctl(sysctl_path, test) == -1) {
if (test->result == OP_EPERM && errno == EPERM)
goto out;
@@ -1507,7 +1508,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test)
}
if (test->result != SUCCESS) {
- log_err("Unexpected failure");
+ log_err("Unexpected success");
goto err;
}