Paula Toth | 66d00fe | 2020-04-08 10:16:30 -0700 | [diff] [blame] | 1 | //===-- Unittests for sigfillset ------------------------------------------===// |
Alex Brachet | 123a532 | 2020-04-01 15:07:49 -0400 | [diff] [blame] | 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "include/errno.h" |
| 10 | #include "include/signal.h" |
| 11 | #include "src/signal/raise.h" |
| 12 | #include "src/signal/sigfillset.h" |
| 13 | #include "src/signal/sigprocmask.h" |
| 14 | |
Siva Chandra Reddy | acca298 | 2020-07-28 10:57:00 -0700 | [diff] [blame] | 15 | #include "test/ErrnoSetterMatcher.h" |
Alex Brachet | 123a532 | 2020-04-01 15:07:49 -0400 | [diff] [blame] | 16 | #include "utils/UnitTest/Test.h" |
| 17 | |
| 18 | TEST(Sigfillset, Invalid) { |
| 19 | using __llvm_libc::testing::ErrnoSetterMatcher::Fails; |
| 20 | EXPECT_THAT(__llvm_libc::sigfillset(nullptr), Fails(EINVAL)); |
| 21 | } |
| 22 | |
| 23 | TEST(Sigfillset, BlocksAll) { |
| 24 | using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; |
| 25 | sigset_t set; |
| 26 | EXPECT_THAT(__llvm_libc::sigfillset(&set), Succeeds()); |
| 27 | EXPECT_THAT(__llvm_libc::sigprocmask(SIG_SETMASK, &set, nullptr), Succeeds()); |
| 28 | EXPECT_EXITS([] { __llvm_libc::raise(SIGUSR1); }, 0); |
| 29 | } |