<div dir="ltr">I'm having some trouble running lldb's test suite. I'm getting the error "AssertionError: False is not True : Current executable set successfully".<div><br></div><div>I've attached a partially complete test, but since I can't get the test suite working right now, it's not been run.<div class="gmail_extra">
<br></div><div class="gmail_extra"><div>--<br>Russell Harmon</div>
<br></div><div class="gmail_extra"><div class="gmail_extra">From 0f30f6f866cf54cc4f49d47f5814543e2ef0eb60 Mon Sep 17 00:00:00 2001</div><div class="gmail_extra">From: Russell Harmon <<a href="mailto:russ@eatnumber1.com">russ@eatnumber1.com</a>></div>
<div class="gmail_extra">Date: Mon, 1 Jul 2013 10:15:14 -0700</div><div class="gmail_extra">Subject: [PATCH] Add a unit test of SBUnixSignals</div><div class="gmail_extra"><br></div><div class="gmail_extra">---</div><div class="gmail_extra">
test/python_api/signals/Makefile | 5 +++</div><div class="gmail_extra"> test/python_api/signals/TestSignalsAPI.py | 51 +++++++++++++++++++++++++++++++</div><div class="gmail_extra"> test/python_api/signals/main.cpp | 21 +++++++++++++</div>
<div class="gmail_extra"> 3 files changed, 77 insertions(+)</div><div class="gmail_extra"> create mode 100644 test/python_api/signals/Makefile</div><div class="gmail_extra"> create mode 100644 test/python_api/signals/TestSignalsAPI.py</div>
<div class="gmail_extra"> create mode 100644 test/python_api/signals/main.cpp</div><div class="gmail_extra"><br></div><div class="gmail_extra">diff --git a/test/python_api/signals/Makefile b/test/python_api/signals/Makefile</div>
<div class="gmail_extra">new file mode 100644</div><div class="gmail_extra">index 0000000..8a7102e</div><div class="gmail_extra">--- /dev/null</div><div class="gmail_extra">+++ b/test/python_api/signals/Makefile</div><div class="gmail_extra">
@@ -0,0 +1,5 @@</div><div class="gmail_extra">+LEVEL = ../../make</div><div class="gmail_extra">+</div><div class="gmail_extra">+CXX_SOURCES := main.cpp</div><div class="gmail_extra">+</div><div class="gmail_extra">+include $(LEVEL)/Makefile.rules</div>
<div class="gmail_extra">diff --git a/test/python_api/signals/TestSignalsAPI.py b/test/python_api/signals/TestSignalsAPI.py</div><div class="gmail_extra">new file mode 100644</div><div class="gmail_extra">index 0000000..fd064d3</div>
<div class="gmail_extra">--- /dev/null</div><div class="gmail_extra">+++ b/test/python_api/signals/TestSignalsAPI.py</div><div class="gmail_extra">@@ -0,0 +1,51 @@</div><div class="gmail_extra">+"""</div><div class="gmail_extra">
+Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.</div><div class="gmail_extra">+"""</div><div class="gmail_extra">+</div><div class="gmail_extra">+import os, time</div><div class="gmail_extra">
+import unittest2</div><div class="gmail_extra">+import lldb</div><div class="gmail_extra">+from lldbutil import get_stopped_thread, state_type_to_str</div><div class="gmail_extra">+from lldbtest import *</div><div class="gmail_extra">
+</div><div class="gmail_extra">+class ProcessAPITestCase(TestBase):</div><div class="gmail_extra">+ mydir = os.path.join("python_api", "signals")</div><div class="gmail_extra">+</div><div class="gmail_extra">
+ def setUp(self):</div><div class="gmail_extra">+ # Call super's setUp().</div><div class="gmail_extra">+ TestBase.setUp(self)</div><div class="gmail_extra">+ # Find the line number to break inside main().</div>
<div class="gmail_extra">+ self.line = line_number("main.cpp", "// Set break point at this line.")</div><div class="gmail_extra">+</div><div class="gmail_extra">+ @python_api_test</div><div class="gmail_extra">
+ def test_ignore_signal(self):</div><div class="gmail_extra">+ """Test Python SBUnixSignals.Suppress/Stop/Notify() API."""</div><div class="gmail_extra">+ exe = os.path.join(os.getcwd(), "a.out")</div>
<div class="gmail_extra">+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)</div><div class="gmail_extra">+</div><div class="gmail_extra">+ target = self.dbg.CreateTarget(exe)</div><div class="gmail_extra">
+ self.assertTrue(target, VALID_TARGET)</div><div class="gmail_extra">+</div><div class="gmail_extra">+ breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)</div><div class="gmail_extra">
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)</div><div class="gmail_extra">+</div><div class="gmail_extra">+ # Launch the process, and do not stop at the entry point.</div><div class="gmail_extra">+ process = target.LaunchSimple(None, None, os.getcwd())</div>
<div class="gmail_extra">+</div><div class="gmail_extra">+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)</div><div class="gmail_extra">+ self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint")</div>
<div class="gmail_extra">+</div><div class="gmail_extra">+ unix_signals = process.unix_signals</div><div class="gmail_extra">+ sigint = unix_signals.GetSignalNumberFromName("SIGINT")</div><div class="gmail_extra">
+ unix_signals.SetShouldSuppress(sigint, True)</div><div class="gmail_extra">+ unix_signals.SetShouldStop(sigint, False)</div><div class="gmail_extra">+ unix_signals.SetShouldNotify(sigint, False)</div>
<div class="gmail_extra">+</div><div class="gmail_extra">+ process.Continue()</div><div class="gmail_extra">+</div><div class="gmail_extra">+</div><div class="gmail_extra">+if __name__ == '__main__':</div>
<div class="gmail_extra">
+ import atexit</div><div class="gmail_extra">+ lldb.SBDebugger.Initialize()</div><div class="gmail_extra">+ atexit.register(lambda: lldb.SBDebugger.Terminate())</div><div class="gmail_extra">+ unittest2.main()</div>
<div class="gmail_extra">diff --git a/test/python_api/signals/main.cpp b/test/python_api/signals/main.cpp</div><div class="gmail_extra">new file mode 100644</div><div class="gmail_extra">index 0000000..8658a9c</div><div class="gmail_extra">
--- /dev/null</div><div class="gmail_extra">+++ b/test/python_api/signals/main.cpp</div><div class="gmail_extra">@@ -0,0 +1,21 @@</div><div class="gmail_extra">+//===-- main.c --------------------------------------------------*- C++ -*-===//</div>
<div class="gmail_extra">+//</div><div class="gmail_extra">+// The LLVM Compiler Infrastructure</div><div class="gmail_extra">+//</div><div class="gmail_extra">+// This file is distributed under the University of Illinois Open Source</div>
<div class="gmail_extra">+// License. See LICENSE.TXT for details.</div><div class="gmail_extra">+//</div><div class="gmail_extra">+//===----------------------------------------------------------------------===//</div><div class="gmail_extra">
+#include <stdio.h></div><div class="gmail_extra">+#include <unistd.h></div><div class="gmail_extra">+#include <signal.h></div><div class="gmail_extra">+</div><div class="gmail_extra">+// This simple program is to test the lldb Python API related to process.</div>
<div class="gmail_extra">+</div><div class="gmail_extra">+int main (int argc, char const *argv[])</div><div class="gmail_extra">+{</div><div class="gmail_extra">+ int i = 0; // Set break point at this line.</div><div class="gmail_extra">
+</div><div class="gmail_extra">+ kill(getpid(), SIGINT);</div><div class="gmail_extra">+ return 0;</div><div class="gmail_extra">+}</div><div class="gmail_extra">-- </div><div class="gmail_extra">1.8.1.3</div><div class="gmail_extra">
<br></div></div></div></div>