From: Zbigniew Jędrzejewski-Szmek Date: Sun, 6 Nov 2022 16:15:56 +0000 (+0100) Subject: tests: move tests for PROTECT_ERRNO to the right file X-Git-Tag: v253-rc1~572^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=737f274e1e97133222bbe7dc2112cff0edebc3ff;p=thirdparty%2Fsystemd.git tests: move tests for PROTECT_ERRNO to the right file Also, rename them to uppercase so that the test name matches what we're actually testing. --- diff --git a/src/test/test-errno-util.c b/src/test/test-errno-util.c index f858927c924..d3d022c33ff 100644 --- a/src/test/test-errno-util.c +++ b/src/test/test-errno-util.c @@ -47,4 +47,35 @@ TEST(STRERROR_OR_ELSE) { log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM)); } +TEST(PROTECT_ERRNO) { + errno = 12; + { + PROTECT_ERRNO; + errno = 11; + } + assert_se(errno == 12); +} + +static void test_unprotect_errno_inner_function(void) { + PROTECT_ERRNO; + + errno = 2222; +} + +TEST(UNPROTECT_ERRNO) { + errno = 4711; + + PROTECT_ERRNO; + + errno = 815; + + UNPROTECT_ERRNO; + + assert_se(errno == 4711); + + test_unprotect_errno_inner_function(); + + assert_se(errno == 4711); +} + DEFINE_TEST_MAIN(LOG_INFO); diff --git a/src/test/test-util.c b/src/test/test-util.c index ecbe08687a5..d2490228e7b 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -83,37 +83,6 @@ TEST(log2i) { assert_se(log2i(INT_MAX) == sizeof(int)*8-2); } -TEST(protect_errno) { - errno = 12; - { - PROTECT_ERRNO; - errno = 11; - } - assert_se(errno == 12); -} - -static void test_unprotect_errno_inner_function(void) { - PROTECT_ERRNO; - - errno = 2222; -} - -TEST(unprotect_errno) { - errno = 4711; - - PROTECT_ERRNO; - - errno = 815; - - UNPROTECT_ERRNO; - - assert_se(errno == 4711); - - test_unprotect_errno_inner_function(); - - assert_se(errno == 4711); -} - TEST(eqzero) { const uint32_t zeros[] = {0, 0, 0}; const uint32_t ones[] = {1, 1};