From ee46e4d9820f1ab631fb1dda780a2ac43f02ce1c Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 18 Apr 2023 12:10:36 +0200 Subject: test: cover missed stuff from securebits-util.h --- src/test/test-secure-bits.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/test/test-secure-bits.c') diff --git a/src/test/test-secure-bits.c b/src/test/test-secure-bits.c index d44bef6a09..27e6a20e09 100644 --- a/src/test/test-secure-bits.c +++ b/src/test/test-secure-bits.c @@ -28,6 +28,7 @@ TEST(secure_bits_basic) { r = secure_bits_from_string(*bit); assert_se(r > 0); + assert_se(secure_bits_is_valid(r)); assert_se(secure_bits_to_string_alloc(r, &s) >= 0); printf("%s = 0x%x = %s\n", *bit, (unsigned)r, s); assert_se(streq(*bit, s)); @@ -38,6 +39,7 @@ TEST(secure_bits_basic) { assert_se(joined); r = secure_bits_from_string(joined); assert_se(r > 0); + assert_se(secure_bits_is_valid(r)); assert_se(secure_bits_to_string_alloc(r, &str) >= 0); printf("%s = 0x%x = %s\n", joined, (unsigned)r, str); assert_se(streq(joined, str)); @@ -54,6 +56,16 @@ TEST(secure_bits_basic) { /* Empty secure bits */ assert_se(secure_bits_to_string_alloc(0, &str) >= 0); assert_se(isempty(str)); + + str = mfree(str); + + /* Bits to string with check */ + assert_se(secure_bits_to_string_alloc_with_check(INT_MAX, &str) == -EINVAL); + assert_se(str == NULL); + assert_se(secure_bits_to_string_alloc_with_check( + (1 << SECURE_KEEP_CAPS) | (1 << SECURE_KEEP_CAPS_LOCKED), + &str) >= 0); + assert_se(streq(str, "keep-caps keep-caps-locked")); } TEST(secure_bits_mix) { @@ -75,6 +87,7 @@ TEST(secure_bits_mix) { r = secure_bits_from_string(s->input); assert_se(r > 0); + assert_se(secure_bits_is_valid(r)); assert_se(secure_bits_to_string_alloc(r, &str) >= 0); printf("%s = 0x%x = %s\n", s->input, (unsigned)r, str); assert_se(streq(s->expected, str)); -- cgit v1.2.1