aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/expression_command/test/TestExprs.py')
-rw-r--r--packages/Python/lldbsuite/test/expression_command/test/TestExprs.py119
1 files changed, 65 insertions, 54 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py
index 8c9a9a5a27e7..1cd11a8c2759 100644
--- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py
+++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py
@@ -14,15 +14,16 @@ o test_expr_commands_can_handle_quotes:
from __future__ import print_function
-
import unittest2
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class BasicExprCommandsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -31,13 +32,14 @@ class BasicExprCommandsTestCase(TestBase):
# Call super's setUp().
TestBase.setUp(self)
# Find the line number to break for main.c.
- self.line = line_number('main.cpp',
- '// Please test many expressions while stopped at this line:')
+ self.line = line_number(
+ 'main.cpp',
+ '// Please test many expressions while stopped at this line:')
# Disable confirmation prompt to avoid infinite wait
self.runCmd("settings set auto-confirm true")
- self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
-
+ self.addTearDownHook(
+ lambda: self.runCmd("settings clear auto-confirm"))
def build_and_run(self):
"""These basic expression commands should work as expected."""
@@ -45,56 +47,58 @@ class BasicExprCommandsTestCase(TestBase):
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
self.runCmd("run", RUN_SUCCEEDED)
- @unittest2.expectedFailure("llvm.org/pr17135 <rdar://problem/14874559> APFloat::toString does not identify the correct (i.e. least) precision.")
+ @unittest2.expectedFailure(
+ "llvm.org/pr17135 <rdar://problem/14874559> APFloat::toString does not identify the correct (i.e. least) precision.")
def test_floating_point_expr_commands(self):
self.build_and_run()
self.expect("expression 2.234f",
- patterns = ["\(float\) \$.* = 2\.234"])
+ patterns=["\(float\) \$.* = 2\.234"])
# (float) $2 = 2.234
def test_many_expr_commands(self):
self.build_and_run()
self.expect("expression 2",
- patterns = ["\(int\) \$.* = 2"])
+ patterns=["\(int\) \$.* = 2"])
# (int) $0 = 1
self.expect("expression 2ull",
- patterns = ["\(unsigned long long\) \$.* = 2"])
+ patterns=["\(unsigned long long\) \$.* = 2"])
# (unsigned long long) $1 = 2
self.expect("expression 0.5f",
- patterns = ["\(float\) \$.* = 0\.5"])
+ patterns=["\(float\) \$.* = 0\.5"])
# (float) $2 = 0.5
self.expect("expression 2.234",
- patterns = ["\(double\) \$.* = 2\.234"])
+ patterns=["\(double\) \$.* = 2\.234"])
# (double) $3 = 2.234
self.expect("expression 2+3",
- patterns = ["\(int\) \$.* = 5"])
+ patterns=["\(int\) \$.* = 5"])
# (int) $4 = 5
self.expect("expression argc",
- patterns = ["\(int\) \$.* = 1"])
+ patterns=["\(int\) \$.* = 1"])
# (int) $5 = 1
self.expect("expression argc + 22",
- patterns = ["\(int\) \$.* = 23"])
+ patterns=["\(int\) \$.* = 23"])
# (int) $6 = 23
self.expect("expression argv",
- patterns = ["\(const char \*\*\) \$.* = 0x"])
+ patterns=["\(const char \*\*\) \$.* = 0x"])
# (const char *) $7 = ...
self.expect("expression argv[0]",
- substrs = ["(const char *)",
- "a.out"])
+ substrs=["(const char *)",
+ "a.out"])
# (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out"
@add_test_categories(['pyapi'])
@@ -115,12 +119,13 @@ class BasicExprCommandsTestCase(TestBase):
# Verify the breakpoint just created.
self.expect(str(breakpoint), BREAKPOINT_CREATED, exe=False,
- substrs = ['main.cpp',
- str(self.line)])
+ substrs=['main.cpp',
+ str(self.line)])
# Launch the process, and do not stop at the entry point.
# Pass 'X Y Z' as the args, which makes argc == 4.
- process = target.LaunchSimple (['X', 'Y', 'Z'], None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ ['X', 'Y', 'Z'], None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.LaunchProcess() failed")
@@ -130,16 +135,18 @@ class BasicExprCommandsTestCase(TestBase):
"instead the actual state is: '%s'" %
lldbutil.state_type_to_str(process.GetState()))
- thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint)
- self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint")
+ thread = lldbutil.get_one_thread_stopped_at_breakpoint(
+ process, breakpoint)
+ self.assertIsNotNone(
+ thread, "Expected one thread to be stopped at the breakpoint")
# The filename of frame #0 should be 'main.cpp' and function is main.
self.expect(lldbutil.get_filenames(thread)[0],
"Break correctly at main.cpp", exe=False,
- startstr = "main.cpp")
+ startstr="main.cpp")
self.expect(lldbutil.get_function_names(thread)[0],
"Break correctly at main()", exe=False,
- startstr = "main")
+ startstr="main")
# We should be stopped on the breakpoint with a hit count of 1.
self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
@@ -151,49 +158,51 @@ class BasicExprCommandsTestCase(TestBase):
val = frame.EvaluateExpression("2.234")
self.expect(val.GetValue(), "2.345 evaluated correctly", exe=False,
- startstr = "2.234")
+ startstr="2.234")
self.expect(val.GetTypeName(), "2.345 evaluated correctly", exe=False,
- startstr = "double")
+ startstr="double")
self.DebugSBValue(val)
val = frame.EvaluateExpression("argc")
self.expect(val.GetValue(), "Argc evaluated correctly", exe=False,
- startstr = "4")
+ startstr="4")
self.DebugSBValue(val)
val = frame.EvaluateExpression("*argv[1]")
self.expect(val.GetValue(), "Argv[1] evaluated correctly", exe=False,
- startstr = "'X'")
+ startstr="'X'")
self.DebugSBValue(val)
val = frame.EvaluateExpression("*argv[2]")
self.expect(val.GetValue(), "Argv[2] evaluated correctly", exe=False,
- startstr = "'Y'")
+ startstr="'Y'")
self.DebugSBValue(val)
val = frame.EvaluateExpression("*argv[3]")
self.expect(val.GetValue(), "Argv[3] evaluated correctly", exe=False,
- startstr = "'Z'")
+ startstr="'Z'")
self.DebugSBValue(val)
- callee_break = target.BreakpointCreateByName ("a_function_to_call", None)
+ callee_break = target.BreakpointCreateByName(
+ "a_function_to_call", None)
self.assertTrue(callee_break.GetNumLocations() > 0)
# Make sure ignoring breakpoints works from the command line:
self.expect("expression -i true -- a_function_to_call()",
- substrs = ['(int) $', ' 1'])
- self.assertTrue (callee_break.GetHitCount() == 1)
+ substrs=['(int) $', ' 1'])
+ self.assertTrue(callee_break.GetHitCount() == 1)
# Now try ignoring breakpoints using the SB API's:
options = lldb.SBExpressionOptions()
options.SetIgnoreBreakpoints(True)
value = frame.EvaluateExpression('a_function_to_call()', options)
- self.assertTrue (value.IsValid())
- self.assertTrue (value.GetValueAsSigned(0) == 2)
- self.assertTrue (callee_break.GetHitCount() == 2)
+ self.assertTrue(value.IsValid())
+ self.assertTrue(value.GetValueAsSigned(0) == 2)
+ self.assertTrue(callee_break.GetHitCount() == 2)
# rdar://problem/8686536
- # CommandInterpreter::HandleCommand is stripping \'s from input for WantsRawCommand commands
+ # CommandInterpreter::HandleCommand is stripping \'s from input for
+ # WantsRawCommand commands
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_expr_commands_can_handle_quotes(self):
"""Throw some expression commands with quotes at lldb."""
@@ -201,44 +210,46 @@ class BasicExprCommandsTestCase(TestBase):
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line, num_expected_locations=1,loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False)
self.runCmd("run", RUN_SUCCEEDED)
# runCmd: expression 'a'
# output: (char) $0 = 'a'
self.expect("expression 'a'",
- substrs = ['(char) $',
- "'a'"])
+ substrs=['(char) $',
+ "'a'"])
# runCmd: expression (int) printf ("\n\n\tHello there!\n")
# output: (int) $1 = 16
self.expect(r'''expression (int) printf ("\n\n\tHello there!\n")''',
- substrs = ['(int) $',
- '16'])
+ substrs=['(int) $',
+ '16'])
# runCmd: expression (int) printf("\t\x68\n")
# output: (int) $2 = 3
self.expect(r'''expression (int) printf("\t\x68\n")''',
- substrs = ['(int) $',
- '3'])
+ substrs=['(int) $',
+ '3'])
# runCmd: expression (int) printf("\"\n")
# output: (int) $3 = 2
self.expect(r'''expression (int) printf("\"\n")''',
- substrs = ['(int) $',
- '2'])
+ substrs=['(int) $',
+ '2'])
# runCmd: expression (int) printf("'\n")
# output: (int) $4 = 2
self.expect(r'''expression (int) printf("'\n")''',
- substrs = ['(int) $',
- '2'])
+ substrs=['(int) $',
+ '2'])
# runCmd: command alias print_hi expression (int) printf ("\n\tHi!\n")
- # output:
- self.runCmd(r'''command alias print_hi expression (int) printf ("\n\tHi!\n")''')
+ # output:
+ self.runCmd(
+ r'''command alias print_hi expression (int) printf ("\n\tHi!\n")''')
# This fails currently.
self.expect('print_hi',
- substrs = ['(int) $',
- '6'])
+ substrs=['(int) $',
+ '6'])