summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-02-24 21:26:47 +0000
committerZachary Turner <zturner@google.com>2016-02-24 21:26:47 +0000
commit47c03462f52a13ba79ac257e7de88a74dd23f5d7 (patch)
tree33978281912ffc0642edc2732b252f5bb4698176 /lldb/packages/Python/lldbsuite/test
parent72c57f49c4b5638626f5a6ff91187f33976c321f (diff)
downloadbcm5719-llvm-47c03462f52a13ba79ac257e7de88a74dd23f5d7.tar.gz
bcm5719-llvm-47c03462f52a13ba79ac257e7de88a74dd23f5d7.zip
Some fixes for case insensitive paths on Windows.
Paths on Windows are not case-sensitive. Because of this, if a file is called main.cpp, you should be able to set a breakpoint on it by using the name Main.cpp. In an ideal world, you could just tell people to match the case, but in practice this can be a real problem as it requires you to know whether the person who compiled the program ran "clang++ main.cpp" or "clang++ Main.cpp", both of which would work, regardless of what the file was actually called. This fixes http://llvm.org/pr22667 Patch by Petr Hons Differential Revision: http://reviews.llvm.org/D17492 Reviewed by: zturner llvm-svn: 261771
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.py120
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c8
3 files changed, 134 insertions, 0 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
new file mode 100644
index 00000000000..6067ee45e98
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 00000000000..8db04915707
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
@@ -0,0 +1,120 @@
+"""
+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(oslist=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(oslist=['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 = os.path.join(os.getcwd(), exe)
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+ cwd = self.get_process_working_directory();
+
+ # 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(cwd, 'main.c'), regex, True)
+ # different case for directory
+ self.check_breakpoint(os.path.join(cwd.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(cwd.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 and location.IsEnabled(),
+ 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
new file mode 100644
index 00000000000..281ddfe7ef6
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main()
+{
+ printf("Set a breakpoint here.\n");
+ return 0;
+}
OpenPOWER on IntegriCloud