From 23cc81e7c221c6e78e54f8008cf089bbfbe15055 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Nov 2017 22:17:00 +0900 Subject: [PATCH] test-cap-list: add more tests about capability_set_{from,to}_string() --- src/test/test-cap-list.c | 68 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c index f6978cc..935567c 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<