Make test more lenient for custom clang version strings
[llvm-project.git] / libc / test / src / signal / sigdelset_test.cpp
blob622f1a32fbbe9a31168066d1015a45508d59d7f8
1 //===-- Unittests for sigdelset -------------------------------------------===//
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 //===----------------------------------------------------------------------===//
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"
17 #include <signal.h>
19 TEST(LlvmLibcSigdelset, Invalid) {
20 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
21 // Invalid set.
22 EXPECT_THAT(LIBC_NAMESPACE::sigdelset(nullptr, SIGUSR1), Fails(EINVAL));
24 sigset_t set;
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;
31 sigset_t set;
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),
35 Succeeds());
36 EXPECT_DEATH([] { LIBC_NAMESPACE::raise(SIGUSR1); }, WITH_SIGNAL(SIGUSR1));