diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-01-18 20:04:13 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-02-08 10:34:47 +0100 |
commit | 840f606d88fef2f5d240b2d759ce7b951354d5bb (patch) | |
tree | fb9ab4e029e24b520ae33910f26fa5bb4e60f4e4 /src/test/test-util.c | |
parent | 1cae151d8e38d4017ccd65ed12c459774e537bb2 (diff) | |
download | systemd-840f606d88fef2f5d240b2d759ce7b951354d5bb.tar.gz |
util.h: add new UNPROTECT_ERRNO macro
THis is inspired by #11395, but much simpler.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r-- | src/test/test-util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 40c1f4a3aa..ffacd65669 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -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(); |