[lldb-dev] Ignoring Signals via the API

Malea, Daniel daniel.malea at intel.com
Wed Jul 3 16:30:20 PDT 2013


If you run dotest.py with the "-t" flag you'll see a bit more of what's going on during the test execution...

Off hand I can't see anything clearly wrong with the test..But I haven't run it.



On 2013-07-03, at 6:56 PM, "Russell Harmon" <russ at eatnumber1.com<mailto:russ at eatnumber1.com>> wrote:

I'm having some trouble running lldb's test suite. I'm getting the error "AssertionError: False is not True : Current executable set successfully".

I've attached a partially complete test, but since I can't get the test suite working right now, it's not been run.

--
Russell Harmon

>From 0f30f6f866cf54cc4f49d47f5814543e2ef0eb60 Mon Sep 17 00:00:00 2001
From: Russell Harmon <russ at eatnumber1.com<mailto:russ at eatnumber1.com>>
Date: Mon, 1 Jul 2013 10:15:14 -0700
Subject: [PATCH] Add a unit test of SBUnixSignals

---
 test/python_api/signals/Makefile          |  5 +++
 test/python_api/signals/TestSignalsAPI.py | 51 +++++++++++++++++++++++++++++++
 test/python_api/signals/main.cpp          | 21 +++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 test/python_api/signals/Makefile
 create mode 100644 test/python_api/signals/TestSignalsAPI.py
 create mode 100644 test/python_api/signals/main.cpp

diff --git a/test/python_api/signals/Makefile b/test/python_api/signals/Makefile
new file mode 100644
index 0000000..8a7102e
--- /dev/null
+++ b/test/python_api/signals/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/test/python_api/signals/TestSignalsAPI.py b/test/python_api/signals/TestSignalsAPI.py
new file mode 100644
index 0000000..fd064d3
--- /dev/null
+++ b/test/python_api/signals/TestSignalsAPI.py
@@ -0,0 +1,51 @@
+"""
+Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbutil import get_stopped_thread, state_type_to_str
+from lldbtest import *
+
+class ProcessAPITestCase(TestBase):
+    mydir = os.path.join("python_api", "signals")
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break inside main().
+        self.line = line_number("main.cpp", "// Set break point at this line.")
+
+    @python_api_test
+    def test_ignore_signal(self):
+        """Test Python SBUnixSignals.Suppress/Stop/Notify() API."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+        self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+        # Launch the process, and do not stop at the entry point.
+        process = target.LaunchSimple(None, None, os.getcwd())
+
+        thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+        self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint")
+
+        unix_signals = process.unix_signals
+        sigint = unix_signals.GetSignalNumberFromName("SIGINT")
+        unix_signals.SetShouldSuppress(sigint, True)
+        unix_signals.SetShouldStop(sigint, False)
+        unix_signals.SetShouldNotify(sigint, False)
+
+        process.Continue()
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()
diff --git a/test/python_api/signals/main.cpp b/test/python_api/signals/main.cpp
new file mode 100644
index 0000000..8658a9c
--- /dev/null
+++ b/test/python_api/signals/main.cpp
@@ -0,0 +1,21 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+
+// This simple program is to test the lldb Python API related to process.
+
+int main (int argc, char const *argv[])
+{
+    int i = 0; // Set break point at this line.
+
+    kill(getpid(), SIGINT);
+    return 0;
+}
--
1.8.1.3

<0001-Add-a-unit-test-of-SBUnixSignals.patch>
_______________________________________________
lldb-dev mailing list
lldb-dev at cs.uiuc.edu<mailto:lldb-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list