From: Yu Watanabe Date: Tue, 28 Nov 2017 13:17:00 +0000 (+0900) Subject: test-cap-list: add more tests about capability_set_{from,to}_string() X-Git-Tag: v236~100^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7490%2Fhead;p=thirdparty%2Fsystemd.git test-cap-list: add more tests about capability_set_{from,to}_string() --- diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c index f6978cc5882..935567cc233 100644 --- a/src/test/test-cap-list.c +++ b/src/test/test-cap-list.c @@ -70,22 +70,72 @@ static void test_cap_list(void) { } } -static void test_capability_set_to_string_alloc(void) { - _cleanup_free_ char *t1 = NULL, *t2 = NULL, *t3 = NULL; +static void test_capability_set_one(uint64_t c, const char *t) { + _cleanup_free_ char *t1 = NULL; + uint64_t c1, c_masked = c & ((UINT64_C(1) << capability_list_length()) - 1); - assert_se(capability_set_to_string_alloc(0u, &t1) == 0); - assert_se(streq(t1, "")); + assert_se(capability_set_to_string_alloc(c, &t1) == 0); + assert_se(streq(t1, t)); - assert_se(capability_set_to_string_alloc(1u<