Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / libc / test / src / signal / kill_test.cpp
blob2033543c97a2b496729d03a6e6e5e4ed1a3ece39
1 //===-- Unittests for kill -----------------------------------------------===//
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/kill.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "test/UnitTest/ErrnoSetterMatcher.h"
13 #include "test/UnitTest/Test.h"
15 #include <signal.h>
16 #include <sys/syscall.h> // For syscall numbers.
18 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
20 TEST(LlvmLibcKillTest, TargetSelf) {
21 pid_t parent_pid = LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_getpid);
22 ASSERT_THAT(LIBC_NAMESPACE::kill(parent_pid, 0), Succeeds(0));
24 EXPECT_DEATH(
25 [] {
26 pid_t child_pid = LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_getpid);
27 LIBC_NAMESPACE::kill(child_pid, SIGKILL);
29 WITH_SIGNAL(SIGKILL));