]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: move tests for PROTECT_ERRNO to the right file
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 6 Nov 2022 16:15:56 +0000 (17:15 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Nov 2022 12:41:13 +0000 (13:41 +0100)
Also, rename them to uppercase so that the test name matches what we're
actually testing.

src/test/test-errno-util.c
src/test/test-util.c

index f858927c924813024844d89c39197bb3221e5b44..d3d022c33fff7bb57d13f2bc9963582f8a62f7f3 100644 (file)
@@ -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);
index ecbe08687a5edeb2067db880ebcacc3ea875db1c..d2490228e7bcaf3e7b43ac45f98597d0ce61b631 100644 (file)
@@ -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};