aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/types/AbstractBase.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/types/AbstractBase.py')
-rw-r--r--packages/Python/lldbsuite/test/types/AbstractBase.py122
1 files changed, 81 insertions, 41 deletions
diff --git a/packages/Python/lldbsuite/test/types/AbstractBase.py b/packages/Python/lldbsuite/test/types/AbstractBase.py
index dd09c91f4d02..044a085e020e 100644
--- a/packages/Python/lldbsuite/test/types/AbstractBase.py
+++ b/packages/Python/lldbsuite/test/types/AbstractBase.py
@@ -4,15 +4,18 @@ Abstract base class of basic types provides a generic type tester method.
from __future__ import print_function
-import os, time
+import os
+import time
import re
import lldb
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil
+
def Msg(var, val, using_frame_variable):
return "'%s %s' matches the output (from compiled code): %s" % (
- 'frame variable --show-types' if using_frame_variable else 'expression' ,var, val)
+ 'frame variable --show-types' if using_frame_variable else 'expression', var, val)
+
class GenericTester(TestBase):
@@ -59,38 +62,56 @@ class GenericTester(TestBase):
#==========================================================================#
def build_and_run(self, source, atoms, bc=False, qd=False):
- self.build_and_run_with_source_atoms_expr(source, atoms, expr=False, bc=bc, qd=qd)
+ self.build_and_run_with_source_atoms_expr(
+ source, atoms, expr=False, bc=bc, qd=qd)
def build_and_run_expr(self, source, atoms, bc=False, qd=False):
- self.build_and_run_with_source_atoms_expr(source, atoms, expr=True, bc=bc, qd=qd)
+ self.build_and_run_with_source_atoms_expr(
+ source, atoms, expr=True, bc=bc, qd=qd)
- def build_and_run_with_source_atoms_expr(self, source, atoms, expr, bc=False, qd=False):
+ def build_and_run_with_source_atoms_expr(
+ self, source, atoms, expr, bc=False, qd=False):
# See also Makefile and basic_type.cpp:177.
if bc:
- d = {'CXX_SOURCES': source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DTEST_BLOCK_CAPTURED_VARS'}
+ d = {'CXX_SOURCES': source, 'EXE': self.exe_name,
+ 'CFLAGS_EXTRAS': '-DTEST_BLOCK_CAPTURED_VARS'}
else:
d = {'CXX_SOURCES': source, 'EXE': self.exe_name}
self.build(dictionary=d)
self.setTearDownCleanup(dictionary=d)
if expr:
- self.generic_type_expr_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd)
+ self.generic_type_expr_tester(
+ self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd)
else:
- self.generic_type_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd)
+ self.generic_type_tester(
+ self.exe_name,
+ atoms,
+ blockCaptured=bc,
+ quotedDisplay=qd)
def process_launch_o(self, localPath):
- # process launch command output redirect always goes to host the process is running on
+ # process launch command output redirect always goes to host the
+ # process is running on
if lldb.remote_platform:
# process launch -o requires a path that is valid on the target
self.assertIsNotNone(lldb.remote_platform.GetWorkingDirectory())
- remote_path = lldbutil.append_to_process_working_directory("lldb-stdout-redirect.txt")
- self.runCmd('process launch -o {remote}'.format(remote=remote_path))
+ remote_path = lldbutil.append_to_process_working_directory(
+ "lldb-stdout-redirect.txt")
+ self.runCmd(
+ 'process launch -o {remote}'.format(remote=remote_path))
# copy remote_path to local host
self.runCmd('platform get-file {remote} "{local}"'.format(
remote=remote_path, local=self.golden_filename))
else:
- self.runCmd('process launch -o "{local}"'.format(local=self.golden_filename))
-
- def generic_type_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False):
+ self.runCmd(
+ 'process launch -o "{local}"'.format(local=self.golden_filename))
+
+ def generic_type_tester(
+ self,
+ exe_name,
+ atoms,
+ quotedDisplay=False,
+ blockCaptured=False):
"""Test that variables with basic types are displayed correctly."""
self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET)
@@ -125,21 +146,30 @@ class GenericTester(TestBase):
# always setting inlined breakpoints.
self.runCmd('settings set target.inline-breakpoint-strategy always')
# And add hooks to restore the settings during tearDown().
- self.addTearDownHook(
- lambda: self.runCmd("settings set target.inline-breakpoint-strategy headers"))
+ self.addTearDownHook(lambda: self.runCmd(
+ "settings set target.inline-breakpoint-strategy headers"))
# Bring the program to the point where we can issue a series of
# 'frame variable --show-types' command.
if blockCaptured:
- break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.")
+ break_line = line_number(
+ "basic_type.cpp",
+ "// Break here to test block captured variables.")
else:
- break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.")
- lldbutil.run_break_set_by_file_and_line (self, "basic_type.cpp", break_line, num_expected_locations=1, loc_exact=True)
+ break_line = line_number(
+ "basic_type.cpp",
+ "// Here is the line we will break on to check variables.")
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "basic_type.cpp",
+ break_line,
+ num_expected_locations=1,
+ loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
- substrs = [" at basic_type.cpp:%d" % break_line,
- "stop reason = breakpoint"])
+ substrs=[" at basic_type.cpp:%d" % break_line,
+ "stop reason = breakpoint"])
#self.runCmd("frame variable --show-types")
@@ -162,19 +192,22 @@ class GenericTester(TestBase):
self.fail(self.DATA_TYPE_GROKKED)
# Expect the display type string to contain each and every atoms.
- self.expect(dt,
- "Display type: '%s' must contain the type atoms: '%s'" %
- (dt, atoms),
- exe=False,
- substrs = list(atoms))
+ self.expect(
+ dt, "Display type: '%s' must contain the type atoms: '%s'" %
+ (dt, atoms), exe=False, substrs=list(atoms))
# The (var, val) pair must match, too.
nv = ("%s = '%s'" if quotedDisplay else "%s = %s") % (var, val)
self.expect(output, Msg(var, val, True), exe=False,
- substrs = [nv])
+ substrs=[nv])
pass
- def generic_type_expr_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False):
+ def generic_type_expr_tester(
+ self,
+ exe_name,
+ atoms,
+ quotedDisplay=False,
+ blockCaptured=False):
"""Test that variable expressions with basic types are evaluated correctly."""
self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET)
@@ -209,21 +242,30 @@ class GenericTester(TestBase):
# always setting inlined breakpoints.
self.runCmd('settings set target.inline-breakpoint-strategy always')
# And add hooks to restore the settings during tearDown().
- self.addTearDownHook(
- lambda: self.runCmd("settings set target.inline-breakpoint-strategy headers"))
+ self.addTearDownHook(lambda: self.runCmd(
+ "settings set target.inline-breakpoint-strategy headers"))
# Bring the program to the point where we can issue a series of
# 'expr' command.
if blockCaptured:
- break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.")
+ break_line = line_number(
+ "basic_type.cpp",
+ "// Break here to test block captured variables.")
else:
- break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.")
- lldbutil.run_break_set_by_file_and_line (self, "basic_type.cpp", break_line, num_expected_locations=1, loc_exact=True)
+ break_line = line_number(
+ "basic_type.cpp",
+ "// Here is the line we will break on to check variables.")
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "basic_type.cpp",
+ break_line,
+ num_expected_locations=1,
+ loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("process status", STOPPED_DUE_TO_BREAKPOINT,
- substrs = [" at basic_type.cpp:%d" % break_line,
- "stop reason = breakpoint"])
+ substrs=[" at basic_type.cpp:%d" % break_line,
+ "stop reason = breakpoint"])
#self.runCmd("frame variable --show-types")
@@ -246,14 +288,12 @@ class GenericTester(TestBase):
self.fail(self.DATA_TYPE_GROKKED)
# Expect the display type string to contain each and every atoms.
- self.expect(dt,
- "Display type: '%s' must contain the type atoms: '%s'" %
- (dt, atoms),
- exe=False,
- substrs = list(atoms))
+ self.expect(
+ dt, "Display type: '%s' must contain the type atoms: '%s'" %
+ (dt, atoms), exe=False, substrs=list(atoms))
# The val part must match, too.
valPart = ("'%s'" if quotedDisplay else "%s") % val
self.expect(output, Msg(var, val, False), exe=False,
- substrs = [valPart])
+ substrs=[valPart])
pass