blob: 16f87e641fbe50065159f5dc0f3bedccc8af9e6c [file] [log] [blame]
Paula Toth66d00fe2020-04-08 10:16:30 -07001//===-- Unittests for sigfillset ------------------------------------------===//
Alex Brachet123a5322020-04-01 15:07:49 -04002//
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 Reddyacca2982020-07-28 10:57:00 -070015#include "test/ErrnoSetterMatcher.h"
Alex Brachet123a5322020-04-01 15:07:49 -040016#include "utils/UnitTest/Test.h"
17
18TEST(Sigfillset, Invalid) {
19 using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
20 EXPECT_THAT(__llvm_libc::sigfillset(nullptr), Fails(EINVAL));
21}
22
23TEST(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}