1 //===-- Unittests for sigdelset -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/signal/raise.h"
10 #include "src/signal/sigdelset.h"
11 #include "src/signal/sigfillset.h"
12 #include "src/signal/sigprocmask.h"
14 #include "test/UnitTest/ErrnoSetterMatcher.h"
15 #include "test/UnitTest/Test.h"
19 TEST(LlvmLibcSigdelset
, Invalid
) {
20 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails
;
22 EXPECT_THAT(LIBC_NAMESPACE::sigdelset(nullptr, SIGUSR1
), Fails(EINVAL
));
25 // Valid set, invalid signum.
26 EXPECT_THAT(LIBC_NAMESPACE::sigdelset(&set
, -1), Fails(EINVAL
));
29 TEST(LlvmLibcSigdelset
, UnblockOne
) {
30 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds
;
32 EXPECT_THAT(LIBC_NAMESPACE::sigfillset(&set
), Succeeds());
33 EXPECT_THAT(LIBC_NAMESPACE::sigdelset(&set
, SIGUSR1
), Succeeds());
34 EXPECT_THAT(LIBC_NAMESPACE::sigprocmask(SIG_SETMASK
, &set
, nullptr),
36 EXPECT_DEATH([] { LIBC_NAMESPACE::raise(SIGUSR1
); }, WITH_SIGNAL(SIGUSR1
));