diff options
author | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
---|---|---|
committer | Felipe Sateler <fsateler@debian.org> | 2019-02-20 21:24:33 -0300 |
commit | 7c20daf69c4411979b7f8902f3601d1cdc56cc07 (patch) | |
tree | d59b9989ce55ed23693e80974d94c856f1c2c8b1 /src/test/test-util.c | |
parent | 6e866b331d7cd4a5e0759dd160dea6edabd3678e (diff) | |
download | systemd-7c20daf69c4411979b7f8902f3601d1cdc56cc07.tar.gz |
New upstream version 241upstream/241
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r-- | src/test/test-util.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 3c1b5f9b41..ffacd65669 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -139,11 +139,11 @@ static void test_container_of(void) { uint64_t v1; uint8_t pad2[2]; uint32_t v2; - } _packed_ myval = { }; + } myval = { }; log_info("/* %s */", __func__); - assert_cc(sizeof(myval) == 17); + assert_cc(sizeof(myval) >= 17); assert_se(container_of(&myval.v1, struct mytype, v1) == &myval); assert_se(container_of(&myval.v2, struct mytype, v2) == &myval); assert_se(container_of(&container_of(&myval.v2, @@ -213,6 +213,30 @@ static void test_protect_errno(void) { assert_se(errno == 12); } +static void test_unprotect_errno_inner_function(void) { + PROTECT_ERRNO; + + errno = 2222; +} + +static void test_unprotect_errno(void) { + log_info("/* %s */", __func__); + + errno = 4711; + + PROTECT_ERRNO; + + errno = 815; + + UNPROTECT_ERRNO; + + assert_se(errno == 4711); + + test_unprotect_errno_inner_function(); + + assert_se(errno == 4711); +} + static void test_in_set(void) { log_info("/* %s */", __func__); @@ -383,6 +407,7 @@ int main(int argc, char *argv[]) { test_div_round_up(); test_u64log2(); test_protect_errno(); + test_unprotect_errno(); test_in_set(); test_log2i(); test_eqzero(); |