]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-signal-util: add test for signal_is_blocked()
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Feb 2021 11:04:49 +0000 (12:04 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Mar 2021 03:41:39 +0000 (12:41 +0900)
src/test/test-signal-util.c

index 51e604f72367ec450eac8dc3aa0b441f8ca8c49c..76ab9b8ad289d5c83536924e633b4055e8fa5357 100644 (file)
@@ -105,28 +105,21 @@ static void test_signal_from_string(void) {
 }
 
 static void test_block_signals(void) {
-        sigset_t ss;
-
-        assert_se(sigprocmask(0, NULL, &ss) >= 0);
-
-        assert_se(sigismember(&ss, SIGUSR1) == 0);
-        assert_se(sigismember(&ss, SIGALRM) == 0);
-        assert_se(sigismember(&ss, SIGVTALRM) == 0);
+        assert_se(signal_is_blocked(SIGUSR1) == 0);
+        assert_se(signal_is_blocked(SIGALRM) == 0);
+        assert_se(signal_is_blocked(SIGVTALRM) == 0);
 
         {
                 BLOCK_SIGNALS(SIGUSR1, SIGVTALRM);
 
-                assert_se(sigprocmask(0, NULL, &ss) >= 0);
-                assert_se(sigismember(&ss, SIGUSR1) == 1);
-                assert_se(sigismember(&ss, SIGALRM) == 0);
-                assert_se(sigismember(&ss, SIGVTALRM) == 1);
-
+                assert_se(signal_is_blocked(SIGUSR1) > 0);
+                assert_se(signal_is_blocked(SIGALRM) == 0);
+                assert_se(signal_is_blocked(SIGVTALRM) > 0);
         }
 
-        assert_se(sigprocmask(0, NULL, &ss) >= 0);
-        assert_se(sigismember(&ss, SIGUSR1) == 0);
-        assert_se(sigismember(&ss, SIGALRM) == 0);
-        assert_se(sigismember(&ss, SIGVTALRM) == 0);
+        assert_se(signal_is_blocked(SIGUSR1) == 0);
+        assert_se(signal_is_blocked(SIGALRM) == 0);
+        assert_se(signal_is_blocked(SIGVTALRM) == 0);
 }
 
 static void test_ignore_signals(void) {