Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/src/signal/kill_test.cpp')
-rw-r--r--libc/test/src/signal/kill_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libc/test/src/signal/kill_test.cpp b/libc/test/src/signal/kill_test.cpp
new file mode 100644
index 000000000000..aaee7b951d8a
--- /dev/null
+++ b/libc/test/src/signal/kill_test.cpp
@@ -0,0 +1,31 @@
+//===-- Unittests for kill -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/signal/kill.h"
+
+#include "include/sys/syscall.h" // For syscall numbers.
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "test/ErrnoSetterMatcher.h"
+#include "utils/UnitTest/Test.h"
+
+#include <errno.h>
+#include <signal.h>
+
+using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
+
+TEST(LlvmLibcKillTest, TargetSelf) {
+ pid_t parent_pid = __llvm_libc::syscall_impl(SYS_getpid);
+ ASSERT_THAT(__llvm_libc::kill(parent_pid, 0), Succeeds(0));
+
+ EXPECT_DEATH(
+ [] {
+ pid_t child_pid = __llvm_libc::syscall_impl(SYS_getpid);
+ __llvm_libc::kill(child_pid, SIGKILL);
+ },
+ WITH_SIGNAL(SIGKILL));
+}