aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/capabilities/validate_cap.c
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-07-25 14:27:33 -0600
committerShuah Khan <shuahkh@osg.samsung.com>2017-08-02 15:30:29 -0600
commit7d005195e9eb6518017e02c1468e3de693cc7442 (patch)
treee5941c5694f296ebb2024aa2dfd7b458a7b4d9ff /tools/testing/selftests/capabilities/validate_cap.c
parentselftests: capabilities: fix to run Non-root +ia, sgidroot => i test (diff)
downloadlinux-dev-7d005195e9eb6518017e02c1468e3de693cc7442.tar.xz
linux-dev-7d005195e9eb6518017e02c1468e3de693cc7442.zip
selftests: capabilities: convert the test to use TAP13 ksft framework
Convert the test to use TAP13 ksft framework for test output. Converting error paths using err() and errx() will be done in another patch to make it easier for review and change management. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests/capabilities/validate_cap.c')
-rw-r--r--tools/testing/selftests/capabilities/validate_cap.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/testing/selftests/capabilities/validate_cap.c b/tools/testing/selftests/capabilities/validate_cap.c
index dd3c45f7b23c..9fd4345a8987 100644
--- a/tools/testing/selftests/capabilities/validate_cap.c
+++ b/tools/testing/selftests/capabilities/validate_cap.c
@@ -7,6 +7,8 @@
#include <sys/prctl.h>
#include <sys/auxv.h>
+#include "../kselftest.h"
+
#ifndef PR_CAP_AMBIENT
#define PR_CAP_AMBIENT 47
# define PR_CAP_AMBIENT_IS_SET 1
@@ -51,23 +53,26 @@ int main(int argc, char **argv)
capng_get_caps_process();
if (capng_have_capability(CAPNG_EFFECTIVE, CAP_NET_BIND_SERVICE) != bool_arg(argv, 1)) {
- printf("[FAIL]\tWrong effective state%s\n", atsec);
+ ksft_print_msg("Wrong effective state%s\n", atsec);
return 1;
}
+
if (capng_have_capability(CAPNG_PERMITTED, CAP_NET_BIND_SERVICE) != bool_arg(argv, 2)) {
- printf("[FAIL]\tWrong permitted state%s\n", atsec);
+ ksft_print_msg("Wrong permitted state%s\n", atsec);
return 1;
}
+
if (capng_have_capability(CAPNG_INHERITABLE, CAP_NET_BIND_SERVICE) != bool_arg(argv, 3)) {
- printf("[FAIL]\tWrong inheritable state%s\n", atsec);
+ ksft_print_msg("Wrong inheritable state%s\n", atsec);
return 1;
}
if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, CAP_NET_BIND_SERVICE, 0, 0, 0) != bool_arg(argv, 4)) {
- printf("[FAIL]\tWrong ambient state%s\n", atsec);
+ ksft_print_msg("Wrong ambient state%s\n", atsec);
return 1;
}
- printf("[OK]\tCapabilities after execve were correct\n");
+ ksft_print_msg("%s: Capabilities after execve were correct\n",
+ "validate_cap:");
return 0;
}