summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-09-10 12:04:04 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-09-10 12:04:04 +0000
commitd9442afba1bd65fd0b5c93b67922eaed923445e2 (patch)
tree4cf657a31d92a6a17d07dd8a81e85bd00fe22d39 /lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest
parent3729b17cff53b536d2019b2d4c90e2a6f17754d1 (diff)
downloadbcm5719-llvm-d9442afba1bd65fd0b5c93b67922eaed923445e2.tar.gz
bcm5719-llvm-d9442afba1bd65fd0b5c93b67922eaed923445e2.zip
[lldb] Readd missing functionalities/breakpoint tests
It seems when I restructured the test folders the functionalities/breakpoint was deleted. This just reverts this change and re-adds the tests. llvm-svn: 371512
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile7
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py69
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp3
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp9
5 files changed, 93 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
new file mode 100644
index 00000000000..06ef85cf908
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+DYLIB_NAME := foo
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
new file mode 100644
index 00000000000..b8281e9c85b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
@@ -0,0 +1,69 @@
+from __future__ import print_function
+
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestMoveNearest(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line1 = line_number('foo.h', '// !BR1')
+ self.line2 = line_number('foo.h', '// !BR2')
+ self.line_between = line_number('main.cpp', "// BR_Between")
+ print("BR_Between found at", self.line_between)
+ self.line_main = line_number('main.cpp', '// !BR_main')
+
+ def test(self):
+ """Test target.move-to-nearest logic"""
+
+ self.build()
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ lldbutil.run_break_set_by_symbol(self, 'main', sym_exact=True)
+ environment = self.registerSharedLibrariesWithTarget(target, ["foo"])
+ process = target.LaunchSimple(None, environment, self.get_process_working_directory())
+ self.assertEquals(process.GetState(), lldb.eStateStopped)
+
+ # Regardless of the -m value the breakpoint should have exactly one
+ # location on the foo functions
+ self.runCmd("settings set target.move-to-nearest-code true")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 1")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 1")
+
+ self.runCmd("settings set target.move-to-nearest-code false")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 0")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 0")
+
+
+ # Make sure we set a breakpoint in main with -m 1 for various lines in
+ # the function declaration
+ # "int"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main-1, extra_options="-m 1")
+ # "main()"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main, extra_options="-m 1")
+ # "{"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+1, extra_options="-m 1")
+ # "return .."
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+2, extra_options="-m 1")
+
+ # Make sure we don't put move the breakpoint if it is set between two functions:
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_between, extra_options="-m 1", num_expected_locations=0)
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
new file mode 100644
index 00000000000..8dad0a23f36
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.h"
+
+int call_foo1() { return foo1(); }
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
new file mode 100644
index 00000000000..9f0e56dd22e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
@@ -0,0 +1,5 @@
+inline int foo1() { return 1; } // !BR1
+
+inline int foo2() { return 2; } // !BR2
+
+LLDB_TEST_API extern int call_foo1();
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
new file mode 100644
index 00000000000..76a22a5420f
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+
+int call_foo2() { return foo2(); }
+// BR_Between
+int
+main() // !BR_main
+{
+ return call_foo1() + call_foo2();
+}
OpenPOWER on IntegriCloud