summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py56
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/main.cpp27
3 files changed, 86 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/Makefile
new file mode 100644
index 00000000000..99998b20bcb
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py
new file mode 100644
index 00000000000..602fee457c2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py
@@ -0,0 +1,56 @@
+"""
+Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str
+
+
+class SignalsAPITestCase(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @add_test_categories(['pyapi'])
+ @skipIfWindows # Windows doesn't have signals
+ def test_ignore_signal(self):
+ """Test Python SBUnixSignals.Suppress/Stop/Notify() API."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ line = line_number(
+ "main.cpp",
+ "// Set break point at this line and setup signal ignores.")
+ breakpoint = target.BreakpointCreateByLocation("main.cpp", line)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+ # Launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "There should be a thread stopped due to breakpoint")
+
+ unix_signals = process.GetUnixSignals()
+ sigint = unix_signals.GetSignalNumberFromName("SIGINT")
+ unix_signals.SetShouldSuppress(sigint, True)
+ unix_signals.SetShouldStop(sigint, False)
+ unix_signals.SetShouldNotify(sigint, False)
+
+ process.Continue()
+ self.assertTrue(
+ process.state == lldb.eStateExited,
+ "The process should have exited")
+ self.assertTrue(
+ process.GetExitStatus() == 0,
+ "The process should have returned 0")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/main.cpp
new file mode 100644
index 00000000000..c4c5a00dd09
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/python_api/signals/main.cpp
@@ -0,0 +1,27 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// 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 <stdio.h>
+#include <sys/types.h>
+#if defined(_WIN32)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <signal.h>
+#endif
+
+// This simple program is to test the lldb Python API related to process.
+
+int main (int argc, char const *argv[])
+{
+#if defined(_WIN32)
+ ::ExitProcess(1);
+#else
+ kill(getpid(), SIGINT); // Set break point at this line and setup signal ignores.
+#endif
+ return 0;
+}