diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities')
10 files changed, 265 insertions, 58 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py index 2b63dbb1c83b..8d4132444fbd 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -23,8 +23,8 @@ class LibCxxAtomicTestCase(TestBase): var.SetPreferSyntheticValue(True) return var - @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIf(compiler=["gcc"]) + @add_test_categories(["libc++"]) def test(self): """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index dd97a9ab5977..bb20b0e7d98c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -30,8 +30,7 @@ class LibcxxListDataFormatterTestCase(TestBase): self.line4 = line_number('main.cpp', '// Set fourth break point at this line.') - @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @add_test_categories(["libc++"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py index be1547ea5d8f..ca8928129244 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -17,55 +17,112 @@ class LibcxxSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + def setUp(self): + TestBase.setUp(self) + ns = 'ndk' if lldbplatformutil.target_is_android() else '' + self.namespace = 'std::__' + ns + '1' + + def getVariableType(self, name): + var = self.frame().FindVariable(name) + self.assertTrue(var.IsValid()) + return var.GetType().GetCanonicalType().GetName() + + @add_test_categories(["libc++"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) -# bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) -# lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) -# -# # The stop reason of the thread should be breakpoint. -# self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -# substrs = ['stopped', -# 'stop reason = breakpoint']) -# -# # This is the function to remove the custom formats in order to have a -# # clean slate for the next test case. -# def cleanup(): -# self.runCmd('type format clear', check=False) -# self.runCmd('type summary clear', check=False) -# self.runCmd('type filter clear', check=False) -# self.runCmd('type synth clear', check=False) -# self.runCmd("settings set target.max-children-count 256", check=False) -# -# # Execute the cleanup function during test case tear down. -# self.addTearDownHook(cleanup) -# -# self.expect('image list', substrs = self.getLibcPlusPlusLibs()) -# -# self.expect("frame variable ii",substrs = ["size=0","{}"]) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"]) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) -# self.expect("frame variable ii[2]",substrs = [" = 2"]) -# self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ii",substrs = ["size=0","{}"]) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ii",substrs = ["size=0","{}"]) -# self.expect("frame variable ss",substrs = ["size=0","{}"]) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"']) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) -# self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) -# self.expect("frame variable ss[2]",substrs = [' = "b"']) -# lldbutil.continue_to_breakpoint(self.process(), bkpt) -# self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type filter clear', check=False) + self.runCmd('type synth clear', check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + ii_type = self.getVariableType("ii") + self.assertTrue(ii_type.startswith(self.namespace + "::set"), + "Type: " + ii_type) + + self.expect("frame variable ii", substrs=["size=0", "{}"]) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect( + "frame variable ii", + substrs=["size=6", + "[0] = 0", + "[1] = 1", + "[2] = 2", + "[3] = 3", + "[4] = 4", + "[5] = 5"]) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect( + "frame variable ii", + substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable ii[2]", substrs=[" = 2"]) + self.expect( + "p ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect("frame variable ii", substrs=["size=0", "{}"]) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect("frame variable ii", substrs=["size=0", "{}"]) + + ss_type = self.getVariableType("ss") + self.assertTrue(ii_type.startswith(self.namespace + "::set"), + "Type: " + ss_type) + + self.expect("frame variable ss", substrs=["size=0", "{}"]) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect( + "frame variable ss", + substrs=["size=2", + '[0] = "a"', + '[1] = "a very long string is right here"']) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect( + "frame variable ss", + substrs=["size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect( + "p ss", + substrs=["size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect("frame variable ss[2]", substrs=[' = "b"']) + lldbutil.continue_to_breakpoint(self.process(), bkpt) + self.expect( + "frame variable ss", + substrs=["size=3", + '[0] = "a"', + '[1] = "a very long string is right here"', + '[2] = "c"']) diff --git a/packages/Python/lldbsuite/test/functionalities/frame_var/Makefile b/packages/Python/lldbsuite/test/functionalities/frame_var/Makefile new file mode 100644 index 000000000000..50d4ab65a6ec --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/frame_var/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS += -std=c99 + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py b/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py new file mode 100644 index 000000000000..b29f94bdb059 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py @@ -0,0 +1,99 @@ +""" +Make sure the frame variable -g, -a, and -l flags work. +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class TestFrameVar(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # If your test case doesn't stress debug info, the + # set this to true. That way it won't be run once for + # each debug info format. + NO_DEBUG_INFO_TESTCASE = True + + def test_frame_var(self): + self.build() + self.do_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def do_test(self): + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint in main.c at the source matching + # "Set a breakpoint here" + breakpoint = target.BreakpointCreateBySourceRegex( + "Set a breakpoint here", lldb.SBFileSpec("main.c")) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() >= 1, + VALID_BREAKPOINT) + + error = lldb.SBError() + # This is the launch info. If you want to launch with arguments or + # environment variables, add them using SetArguments or + # SetEnvironmentEntries + + launch_info = lldb.SBLaunchInfo(None) + process = target.Launch(launch_info, error) + self.assertTrue(process, PROCESS_IS_VALID) + + # Did we hit our breakpoint? + from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint + threads = get_threads_stopped_at_breakpoint(process, breakpoint) + self.assertTrue( + len(threads) == 1, + "There should be a thread stopped at our breakpoint") + + # The hit count for the breakpoint should be 1. + self.assertTrue(breakpoint.GetHitCount() == 1) + + frame = threads[0].GetFrameAtIndex(0) + command_result = lldb.SBCommandReturnObject() + interp = self.dbg.GetCommandInterpreter() + + # Just get args: + result = interp.HandleCommand("frame var -l", command_result) + self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed") + output = command_result.GetOutput() + self.assertTrue("argc" in output, "Args didn't find argc") + self.assertTrue("argv" in output, "Args didn't find argv") + self.assertTrue("test_var" not in output, "Args found a local") + self.assertTrue("g_var" not in output, "Args found a global") + + # Just get locals: + result = interp.HandleCommand("frame var -a", command_result) + self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed") + output = command_result.GetOutput() + self.assertTrue("argc" not in output, "Locals found argc") + self.assertTrue("argv" not in output, "Locals found argv") + self.assertTrue("test_var" in output, "Locals didn't find test_var") + self.assertTrue("g_var" not in output, "Locals found a global") + + # Get the file statics: + result = interp.HandleCommand("frame var -l -a -g", command_result) + self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed") + output = command_result.GetOutput() + self.assertTrue("argc" not in output, "Globals found argc") + self.assertTrue("argv" not in output, "Globals found argv") + self.assertTrue("test_var" not in output, "Globals found test_var") + self.assertTrue("g_var" in output, "Globals didn't find g_var") + + + diff --git a/packages/Python/lldbsuite/test/functionalities/frame_var/main.c b/packages/Python/lldbsuite/test/functionalities/frame_var/main.c new file mode 100644 index 000000000000..da23af2ac550 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/frame_var/main.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +int g_var = 200; + +int +main(int argc, char **argv) +{ + int test_var = 10; + printf ("Set a breakpoint here: %d %d.\n", test_var, g_var); + return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py b/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py new file mode 100644 index 000000000000..90bd64901ee5 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py @@ -0,0 +1,45 @@ +""" +Make sure the !N and !-N commands work properly. +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class TestHistoryRecall(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # If your test case doesn't stress debug info, the + # set this to true. That way it won't be run once for + # each debug info format. + NO_DEBUG_INFO_TESTCASE = True + + def test_history_recall(self): + """Test the !N and !-N functionality of the command interpreter.""" + self.sample_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def sample_test(self): + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + interp.HandleCommand("command history", result, True) + interp.HandleCommand("platform list", result, True) + + interp.HandleCommand("!0", result, False) + self.assertTrue(result.Succeeded(), "!0 command did not work: %s"%(result.GetError())) + self.assertTrue("command history" in result.GetOutput(), "!0 didn't rerun command history") + + interp.HandleCommand("!-1", result, False) + self.assertTrue(result.Succeeded(), "!-1 command did not work: %s"%(result.GetError())) + self.assertTrue("host:" in result.GetOutput(), "!-1 didn't rerun platform list.") diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index 38b55ef40c6b..18c0da832606 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -39,7 +39,6 @@ class LinuxCoreTestCase(TestBase): super(LinuxCoreTestCase, self).tearDown() @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" @@ -58,21 +57,18 @@ class LinuxCoreTestCase(TestBase): self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running @@ -102,7 +98,6 @@ class LinuxCoreTestCase(TestBase): self.RemoveTempFile("linux-x86_64-pid.core") @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID @@ -132,7 +127,6 @@ class LinuxCoreTestCase(TestBase): self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_FPR_SSE(self): # check x86_64 core file diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py index 5b398c1ccf0c..5a11a52e93a6 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py @@ -23,14 +23,12 @@ class GCoreTestCase(TestBase): _x86_64_pid = 5669 @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py index 4895c051d63e..7cc3c0775ced 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py @@ -27,14 +27,12 @@ class LinuxCoreThreadsTestCase(TestBase): _x86_64_tid = 5250 @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid, self._i386_tid) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" |