summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-12 18:42:19 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-12 18:42:19 +0100
commit4b7c1d5d6a006088910bac42ab3b777be9cf3cc1 (patch)
tree4833224afa5e66b0025fcdda9aa2b31f092c9b1b /src/test
parent34a3e4ecad5fd2042eb83ffcbf30379a536cc3ee (diff)
test-cap-list: always check libcap comes to the same names as we do, for the names it knows
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-cap-list.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c
index a536522646..238f876f2a 100644
--- a/src/test/test-cap-list.c
+++ b/src/test/test-cap-list.c
@@ -45,5 +45,24 @@ int main(int argc, char *argv[]) {
assert_se(capability_from_name("15") == 15);
assert_se(capability_from_name("-1") == -EINVAL);
+ for (i = 0; i <= (int) cap_last_cap(); i++) {
+ _cleanup_cap_free_charp_ char *a = NULL;
+ const char *b;
+ unsigned u;
+
+ assert_se(a = cap_to_name(i));
+
+ /* quite the loop as soon as libcap only returns
+ * numeric ids, formatted as string */
+ if (safe_atou(a, &u) >= 0)
+ break;
+
+ assert_se(b = capability_to_name(i));
+
+ printf("%s vs. %s\n", a, b);
+
+ assert_se(streq(a, b));
+ }
+
return 0;
}