brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 2033543 Raw
31 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/signal/kill.h"10 11#include "src/__support/OSUtil/syscall.h" // For internal syscall function.12#include "test/UnitTest/ErrnoSetterMatcher.h"13#include "test/UnitTest/Test.h"14 15#include <signal.h>16#include <sys/syscall.h> // For syscall numbers.17 18using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;19 20TEST(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));23 24  EXPECT_DEATH(25      [] {26        pid_t child_pid = LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_getpid);27        LIBC_NAMESPACE::kill(child_pid, SIGKILL);28      },29      WITH_SIGNAL(SIGKILL));30}31