summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-02-26 18:50:16 +0000
committerPavel Labath <labath@google.com>2018-02-26 18:50:16 +0000
commit7c94582f908abafd7ca18d032d9ea20dabb3a5a3 (patch)
tree5774b3d30f4cc71ee14cfd40ac30d2e65f6f94f8 /lldb/packages/Python/lldbsuite/test
parent473f3fbaf8069e53b1edea415e7254fad20ec4a2 (diff)
downloadbcm5719-llvm-7c94582f908abafd7ca18d032d9ea20dabb3a5a3.tar.gz
bcm5719-llvm-7c94582f908abafd7ca18d032d9ea20dabb3a5a3.zip
Add "lldb-test breakpoint" command and convert the case-sensitivity test to use it
Summary: The command takes two input arguments: a module to use as a debug target and a file containing a list of commands. The command will execute each of the breakpoint commands in the file and dump the breakpoint state after each one. The commands are expected to be breakpoint set/remove/etc. commands, but I explicitly allow any lldb command here, so you can do things like change setting which impact breakpoint resolution, etc. There is also a "-persistent" flag, which causes lldb-test to *not* automatically clear the breakpoint list after each command. Right now I don't use it, but the idea behind it was that it could be used to test more complex combinations of breakpoint commands (set+modify, set+disable, etc.). Right now the command prints out only the basic breakpoint state, but more information can be easily added there. To enable easy matching of the "at least one breakpoint location found" state, the command explicitly prints out the string "At least one breakpoint location.". To enable testing of breakpoints set with an absolute paths, I add the ability to perform rudimentary substitutions on the commands: right now the string %p is replaced by the directory which contains the command file (so, under normal circumstances, this will perform the same substitution as lit would do for %p). I use this command to rewrite the TestBreakpointCaseSensitivity test -- the test was checking about a dozen breakpoint commands, but it was launching a new process for each one, so it took about 90 seconds to run. The new test takes about 0.3 seconds for me, which is approximately a 300x speedup. Reviewers: davide, zturner, jingham Subscribers: luporl, lldb-commits Differential Revision: https://reviews.llvm.org/D43686 llvm-svn: 326112
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile6
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py129
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c8
3 files changed, 0 insertions, 143 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile
deleted file mode 100644
index 6067ee45e98..00000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-LEVEL = ../../../make
-
-C_SOURCES := main.c
-CFLAGS_EXTRAS += -std=c99
-
-include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
deleted file mode 100644
index 8d174580f29..00000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
+++ /dev/null
@@ -1,129 +0,0 @@
-"""
-Test case sensitivity of paths on Windows / POSIX
-llvm.org/pr22667
-"""
-
-import os
-import lldb
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from lldbsuite.test import lldbplatform, lldbplatformutil
-
-
-class BreakpointCaseSensitivityTestCase(TestBase):
- mydir = TestBase.compute_mydir(__file__)
- BREAKPOINT_TEXT = 'Set a breakpoint here'
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- self.line = line_number('main.c', self.BREAKPOINT_TEXT)
-
- @skipIf(hostoslist=no_match(['windows'])) # Skip for non-windows platforms
- def test_breakpoint_matches_file_with_different_case(self):
- """Set breakpoint on file, should match files with different case on Windows"""
- self.build()
- self.case_sensitivity_breakpoint(True)
-
- @skipIf(hostoslist=['windows']) # Skip for windows platforms
- def test_breakpoint_doesnt_match_file_with_different_case(self):
- """Set breakpoint on file, shouldn't match files with different case on POSIX systems"""
- self.build()
- self.case_sensitivity_breakpoint(False)
-
- def case_sensitivity_breakpoint(self, case_insensitive):
- """Set breakpoint on file, should match files with different case if case_insensitive is True"""
-
- # use different case to check CreateTarget
- exe = 'a.out'
- if case_insensitive:
- exe = exe.upper()
-
- exe = self.getBuildArtifact(exe)
-
- # Create a target by the debugger.
- self.target = self.dbg.CreateTarget(exe)
- self.assertTrue(self.target, VALID_TARGET)
- srcdir = self.getSourceDir()
-
- # try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex
- for regex in [False, True]:
- # should always hit
- self.check_breakpoint('main.c', regex, True)
- # should always hit
- self.check_breakpoint(os.path.join(srcdir, 'main.c'), regex, True)
- # different case for directory
- self.check_breakpoint(os.path.join(srcdir.upper(), 'main.c'),
- regex,
- case_insensitive)
- # different case for file
- self.check_breakpoint('Main.c',
- regex,
- case_insensitive)
- # different case for both
- self.check_breakpoint(os.path.join(srcdir.upper(), 'Main.c'),
- regex,
- case_insensitive)
-
- def check_breakpoint(self, file, source_regex, should_hit):
- """
- Check breakpoint hit at given file set by given method
-
- file:
- File where insert the breakpoint
-
- source_regex:
- True for testing using BreakpointCreateBySourceRegex,
- False for BreakpointCreateByLocation
-
- should_hit:
- True if the breakpoint should hit, False otherwise
- """
-
- desc = ' file %s set by %s' % (
- file, 'regex' if source_regex else 'location')
- if source_regex:
- breakpoint = self.target.BreakpointCreateBySourceRegex(
- self.BREAKPOINT_TEXT, lldb.SBFileSpec(file))
- else:
- breakpoint = self.target.BreakpointCreateByLocation(
- file, self.line)
-
- self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1,
- should_hit,
- VALID_BREAKPOINT + desc)
-
- # Get the breakpoint location from breakpoint after we verified that,
- # indeed, it has one location.
- location = breakpoint.GetLocationAtIndex(0)
-
- self.assertEqual(location.IsValid(),
- should_hit,
- VALID_BREAKPOINT_LOCATION + desc)
-
- process = self.target.LaunchSimple(
- None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID + desc)
-
- if should_hit:
- # Did we hit our breakpoint?
- from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
- threads = get_threads_stopped_at_breakpoint(process, breakpoint)
- self.assertEqual(
- len(threads),
- 1,
- "There should be a thread stopped at breakpoint" +
- desc)
- # The hit count for the breakpoint should be 1.
- self.assertEqual(breakpoint.GetHitCount(), 1)
-
- else:
- # check the breakpoint was not hit
- self.assertEqual(lldb.eStateExited, process.GetState())
- self.assertEqual(breakpoint.GetHitCount(), 0)
-
- # let process finish
- process.Continue()
-
- # cleanup
- self.target.BreakpointDelete(breakpoint.GetID())
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c
deleted file mode 100644
index 281ddfe7ef6..00000000000
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int
-main()
-{
- printf("Set a breakpoint here.\n");
- return 0;
-}
OpenPOWER on IntegriCloud