Compile the LLDB tests out-of-tree.

This patch is the result of a discussion on lldb-dev, see
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013111.html for
background.

For each test (should be eventually: each test configuration) a
separate build directory is created and we execute

  make VPATH=$srcdir/path/to/test -C $builddir/path/to/test -f $srcdir/path/to/test/Makefile -I $srcdir/path/to/test

In order to make this work all LLDB tests need to be updated to find
the executable in the test build directory, since CWD still points at
the test's source directory, which is a requirement for unittest2.

Although we have done extensive testing, I'm expecting that this first
attempt will break a few bots. Please DO NOT HESITATE TO REVERT this
patch in order to get the bots green again. We will likely have to
iterate on this some more.

Differential Revision: https://reviews.llvm.org/D42281

llvm-svn: 323803
This commit is contained in:
Adrian Prantl 2018-01-30 18:29:16 +00:00
parent 1d8e5ea250
commit 5ec76fe720
178 changed files with 744 additions and 631 deletions

View File

@ -135,15 +135,16 @@ see test/array_types/TestArrayTypes.py:
self.array_types()
This method is decorated with a skipUnless decorator so that it will only gets
included into the test suite if the platform it is running on is 'darwin', aka
Mac OS X.
included into the test suite if the platform it is running on is 'darwin', a.k.a.
macOS.
Type 'man dsymutil' for more details.
After the binary is built, it is time to specify the file to be used as the main
executable by lldb:
exe = os.path.join(os.getcwd(), "a.out")
# Construct the path to a file "a.out" inside the test's build folder.
exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
This is where the attribute assignment:
@ -174,10 +175,11 @@ execution. This can be accomplished by passing the keyword argument pair
After the current executable is set, we'll then execute two more commands:
# Set the output-path and verify it is set.
self.runCmd("settings set target.process.output-path 'stdout.txt'")
stdout = self.getBuildArtifact('stdout.txt')
self.runCmd("settings set target.process.output-path '%s'" %stdout)
self.expect("settings show target.process.output-path",
SETTING_MSG("target.process.output-path"),
startstr = "target.process.output-path (string) = 'stdout.txt'")
startstr = "target.process.output-path (string) = '.*stdout.txt'")
The first uses the 'settings set' command to set the static setting
target.process.output-path to be 'stdout.txt', instead of the default
@ -188,7 +190,7 @@ door and grabs the output from the command execution and expects to match the
start string of the output against what we pass in as the value of the keyword
argument pair:
startstr = "target.process.output-path (string) = 'stdout.txt'"
startstr = "target.process.output-path (string) = '%s'" %stdout
Take a look at TestBase.expect() within lldbtest.py for more details. Among
other things, it can also match against a list of regexp patterns as well as a
@ -204,15 +206,15 @@ And this asserts that the file 'stdout.txt' should be present after running the
program.
# The 'stdout.txt' file should now exist.
self.assertTrue(os.path.isfile("stdout.txt"),
"'stdout.txt' exists due to target.process.output-path.")
self.assertTrue(os.path.isfile(stdout),
"stdout.txt' exists due to target.process.output-path.")
Also take a look at main.cpp which emits some message to the stdout. Now, if we
pass this assertion, it's time to examine the contents of the file to make sure
it contains the same message as programmed in main.cpp:
# Read the output file produced by running the program.
with open('stdout.txt', 'r') as f:
with open(stdout, 'r') as f:
output = f.read()
self.expect(output, exe=False,
@ -235,8 +237,8 @@ file:
@classmethod
def classCleanup(cls):
system(["/bin/sh", "-c", "rm -f output.txt"])
system(["/bin/sh", "-c", "rm -f stdout.txt"])
system(["/bin/sh", "-c", "rm -f "+self.getBuildArtifact("output.txt")])
system(["/bin/sh", "-c", "rm -f "+self.getBuildArtifact("stdout.txt")])
This is a classmethod (as shown by the @classmethod decorator) which allows the
individual test class to perform cleanup actions after the test harness finishes

View File

@ -21,7 +21,6 @@ class SBDirCheckerCase(TestBase):
def setUp(self):
TestBase.setUp(self)
self.source = 'main.cpp'
self.exe_name = self.getBuildArtifact("a.out")
self.generateSource(self.source)
@skipIfNoSBHeaders
@ -35,16 +34,19 @@ class SBDirCheckerCase(TestBase):
self.skipTest(
"LLDB is 64-bit and cannot be linked to 32-bit test program.")
self.buildDriver(self.source, self.exe_name)
self.sanity_check_executable(self.exe_name)
exe_name = self.getBuildArtifact("a.out")
self.buildDriver(self.source, exe_name)
self.sanity_check_executable(exe_name)
def sanity_check_executable(self, exe_name):
"""Sanity check executable compiled from the auto-generated program."""
exe_name = self.getBuildArtifact("a.out")
exe = self.getBuildArtifact(exe_name)
self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET)
# This test uses a generated source file, so it's in the build directory.
self.line_to_break = line_number(
self.source, '// Set breakpoint here.')
self.getBuildArtifact(self.source), '// Set breakpoint here.')
env_cmd = "settings set target.env-vars %s=%s" % (
self.dylibPath, self.getLLDBLibraryEnvVal())

View File

@ -32,12 +32,12 @@ class TestMultipleSimultaneousDebuggers(TestBase):
def test_multiple_debuggers(self):
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver")
self.driver_exe = self.getBuildArtifact("multi-process-driver")
self.buildDriver('multi-process-driver.cpp', self.driver_exe)
self.addTearDownHook(lambda: os.remove(self.driver_exe))
self.signBinary(self.driver_exe)
self.inferior_exe = os.path.join(os.getcwd(), "testprog")
self.inferior_exe = self.getBuildArtifact("testprog")
self.buildDriver('testprog.cpp', self.inferior_exe)
self.addTearDownHook(lambda: os.remove(self.inferior_exe))

View File

@ -26,7 +26,7 @@ class TestMultipleTargets(TestBase):
def test_multiple_targets(self):
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
self.driver_exe = os.path.join(os.getcwd(), "multi-target")
self.driver_exe = self.getBuildArtifact("multi-target")
self.buildDriver('main.cpp', self.driver_exe)
self.addTearDownHook(lambda: os.remove(self.driver_exe))
self.signBinary(self.driver_exe)

View File

@ -89,14 +89,16 @@ class SBBreakpointCallbackCase(TestBase):
self.inferior = 'inferior_program'
self.buildProgram('inferior.cpp', self.inferior)
self.addTearDownHook(lambda: os.remove(self.inferior))
self.addTearDownHook(lambda:
os.remove(self.getBuildArtifact(self.inferior)))
self.buildDriver(sources, test_name)
self.addTearDownHook(lambda: os.remove(test_name))
self.addTearDownHook(lambda:
os.remove(self.getBuildArtifact(test_name)))
test_exe = os.path.join(os.getcwd(), test_name)
test_exe = self.getBuildArtifact(test_name)
self.signBinary(test_exe)
exe = [test_exe, self.inferior]
exe = [test_exe, self.getBuildArtifact(self.inferior)]
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
if self.TraceOn():

View File

@ -19,8 +19,7 @@ class ARMEmulationTestCase(TestBase):
@no_debug_info_test
def test_thumb_emulations(self):
current_dir = os.getcwd()
test_dir = os.path.join(current_dir, "new-test-files")
test_dir = os.path.join(self.getSourceDir(), "new-test-files")
files = os.listdir(test_dir)
thumb_files = list()
for f in files:
@ -33,8 +32,7 @@ class ARMEmulationTestCase(TestBase):
@no_debug_info_test
def test_arm_emulations(self):
current_dir = os.getcwd()
test_dir = os.path.join(current_dir, "new-test-files")
test_dir = os.path.join(self.getSourceDir(), "new-test-files")
files = os.listdir(test_dir)
arm_files = list()
for f in files:

View File

@ -94,7 +94,7 @@ class RepeatedExprsCase(BenchBase):
def run_gdb_repeated_exprs(self, exe_name, count):
import pexpect
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
# Set self.child_prompt, which is "(gdb) ".
self.child_prompt = '(gdb) '

View File

@ -107,6 +107,9 @@ lldb_platform_name = None
lldb_platform_url = None
lldb_platform_working_dir = None
# The base directory in which the tests are being built.
test_build_dir = None
# Parallel execution settings
is_inferior_test_runner = False
multiprocess_test_subdir = None

View File

@ -162,7 +162,7 @@ class DarwinLogTestBase(lldbtest.TestBase):
if enable_options is not None and len(enable_options) > 0:
enable_cmd += ' ' + ' '.join(enable_options)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.run_lldb_to_breakpoint(exe, self.source, self.line,
enable_command=enable_cmd,
settings_commands=settings_commands)
@ -382,7 +382,7 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase):
# self.runCmd("log enable lldb process")
# Launch the process - doesn't stop at entry.
process = target.LaunchSimple(None, None, os.getcwd())
process = target.LaunchSimple(None, None, self.getBuildDir())
self.assertIsNotNone(process, lldbtest.PROCESS_IS_VALID)
# Keep track of whether we're tracing output.

View File

@ -474,6 +474,8 @@ def parseOptionsAndInitTestdirs():
configuration.lldb_platform_url = args.lldb_platform_url
if args.lldb_platform_working_dir:
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
if args.test_build_dir:
configuration.test_build_dir = args.test_build_dir
if args.event_add_entries and len(args.event_add_entries) > 0:
entries = {}
@ -623,6 +625,12 @@ def setupSysPath():
os.environ["LLDB_TEST"] = scriptPath
# Set up the root build directory.
builddir = configuration.test_build_dir
if not configuration.test_build_dir:
raise Exception("test_build_dir is not set")
os.environ["LLDB_BUILD"] = os.path.abspath(configuration.test_build_dir)
# Set up the LLDB_SRC environment variable, so that the tests can locate
# the LLDB source code.
os.environ["LLDB_SRC"] = lldbsuite.lldb_root
@ -1186,6 +1194,11 @@ def run_suite():
configuration.lldb_platform_working_dir = None
configuration.lldb_platform_url = None
# Set up the working directory.
# Note that it's not dotest's job to clean this directory.
try: os.makedirs(configuration.test_build_dir)
except: pass
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
checkLibcxxSupport()

View File

@ -159,6 +159,12 @@ def create_parser():
metavar='Codesigning identity',
default='lldb_codesign',
help='The codesigning identity to use')
group.add_argument(
'--build-dir',
dest='test_build_dir',
metavar='Test build directory',
default='lldb-test-build',
help='The root build directory for the tests. It will be removed before running.')
# Configuration options
group = parser.add_argument_group('Remote platform options')

View File

@ -31,7 +31,8 @@ class ExprCommandCallOverriddenMethod(TestBase):
self.build()
# Set breakpoint in main and run exe
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
self.runCmd("file " + self.getBuildArtifact("a.out"),
CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)

View File

@ -11,23 +11,24 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
def enumerateJITFiles():
return [f for f in os.listdir(os.getcwd()) if f.startswith("jit")]
def countJITFiles():
return len(enumerateJITFiles())
def cleanJITFiles():
for j in enumerateJITFiles():
os.remove(j)
return
class SaveJITObjectsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def enumerateJITFiles(self):
return [f for f in os.listdir(self.getBuildDir()) if f.startswith("jit")]
def countJITFiles(self):
return len(self.enumerateJITFiles())
def cleanJITFiles(self):
for j in self.enumerateJITFiles():
os.remove(j)
return
@expectedFailureAll(oslist=["windows"])
def test_save_jit_objects(self):
self.build()
os.chdir(self.getBuildDir())
src_file = "main.c"
src_file_spec = lldb.SBFileSpec(src_file)
@ -36,16 +37,17 @@ class SaveJITObjectsTestCase(TestBase):
frame = thread.frames[0]
cleanJITFiles()
self.cleanJITFiles()
frame.EvaluateExpression("(void*)malloc(0x1)")
self.assertTrue(countJITFiles() == 0,
self.assertTrue(self.countJITFiles() == 0,
"No files emitted with save-jit-objects=false")
self.runCmd("settings set target.save-jit-objects true")
frame.EvaluateExpression("(void*)malloc(0x1)")
jit_files_count = countJITFiles()
cleanJITFiles()
jit_files_count = self.countJITFiles()
self.cleanJITFiles()
self.assertTrue(jit_files_count != 0,
"At least one file emitted with save-jit-objects=true")
process.Kill()
os.chdir(self.getSourceDir())

View File

@ -7,7 +7,7 @@ include $(LEVEL)/Makefile.rules
a.out: dummy
dummy:
$(MAKE) -f dummy.mk
$(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk
clean::
$(MAKE) -f dummy.mk clean
$(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean

View File

@ -45,7 +45,8 @@ class TopLevelExpressionsTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
def run_dummy(self):
self.runCmd("file dummy", CURRENT_EXECUTABLE_SET)
self.runCmd("file " + self.getBuildArtifact("dummy"),
CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self,

View File

@ -30,7 +30,7 @@ class AttachResumeTestCase(TestBase):
def process_attach_continue_interrupt_detach(self):
"""Test attach/continue/interrupt/detach"""
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)

View File

@ -30,9 +30,8 @@ class BadAddressBreakpointTestCase(TestBase):
def address_breakpoints(self):
"""Test that breakpoints set on a bad address say they are bad."""
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
"Set a breakpoint here", lldb.SBFileSpec("main.c"))
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "Set a breakpoint here", lldb.SBFileSpec("main.c"))
# Now see if we can read from 0. If I can't do that, I don't have a good way to know
# what an illegal address is...

View File

@ -44,16 +44,16 @@ class BreakpointCaseSensitivityTestCase(TestBase):
# Create a target by the debugger.
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
cwd = os.getcwd()
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(cwd, 'main.c'), regex, True)
self.check_breakpoint(os.path.join(srcdir, 'main.c'), regex, True)
# different case for directory
self.check_breakpoint(os.path.join(cwd.upper(), 'main.c'),
self.check_breakpoint(os.path.join(srcdir.upper(), 'main.c'),
regex,
case_insensitive)
# different case for file
@ -61,7 +61,7 @@ class BreakpointCaseSensitivityTestCase(TestBase):
regex,
case_insensitive)
# different case for both
self.check_breakpoint(os.path.join(cwd.upper(), 'Main.c'),
self.check_breakpoint(os.path.join(srcdir.upper(), 'Main.c'),
regex,
case_insensitive)

View File

@ -54,7 +54,7 @@ class RegexpBreakCommandTestCase(TestBase):
num_locations=1)
# Check breakpoint with full file path.
full_path = os.path.join(os.getcwd(), self.source)
full_path = os.path.join(self.getSourceDir(), self.source)
break_results = lldbutil.run_break_set_command(
self, "b %s:%d" % (full_path, self.line))
lldbutil.check_breakpoint_result(

View File

@ -63,7 +63,7 @@ class BreakpointNames(TestBase):
# Create a targets we are making breakpoint in and copying to:
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
self.main_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "main.c"))
self.main_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "main.c"))
def check_name_in_target(self, bkpt_name):
name_list = lldb.SBStringList()

View File

@ -15,7 +15,6 @@ class BreakpointSetRestart(TestBase):
def test_breakpoint_set_restart(self):
self.build()
cwd = os.getcwd()
exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
@ -33,9 +32,7 @@ class BreakpointSetRestart(TestBase):
break
bp = target.BreakpointCreateBySourceRegex(
self.BREAKPOINT_TEXT, lldb.SBFileSpec(
os.path.join(
cwd, 'main.cpp')))
self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp'))
self.assertTrue(
bp.IsValid() and bp.GetNumLocations() == 1,
VALID_BREAKPOINT)

View File

@ -1,7 +1,14 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
CXX_SOURCES := relative.cpp
EXE := CompDirSymLink
include $(LEVEL)/Makefile.rules
# Force relative filenames by copying it into the build directory.
relative.cpp: main.cpp
cp -f $< $@
clean::
rm -rf relative.cpp

View File

@ -13,7 +13,7 @@ from lldbsuite.test import lldbutil
_EXE_NAME = 'CompDirSymLink' # Must match Makefile
_SRC_FILE = 'main.cpp'
_SRC_FILE = 'relative.cpp'
_COMP_DIR_SYM_LINK_PROP = 'plugin.symbol-file.dwarf.comp-dir-symlink-paths'
@ -25,8 +25,11 @@ class CompDirSymLinkTestCase(TestBase):
# Call super's setUp().
TestBase.setUp(self)
# Find the line number to break inside main().
self.line = line_number(_SRC_FILE, '// Set break point at this line.')
self.src_path = os.path.join(os.getcwd(), _SRC_FILE)
self.line = line_number(
os.path.join(self.getSourceDir(), "main.cpp"),
'// Set break point at this line.')
self.src_path = self.getBuildArtifact(_SRC_FILE)
@skipIf(hostoslist=["windows"])
def test_symlink_paths_set(self):
@ -39,6 +42,7 @@ class CompDirSymLinkTestCase(TestBase):
@skipIf(hostoslist=no_match(["linux"]))
def test_symlink_paths_set_procselfcwd(self):
os.chdir(self.getBuildDir())
pwd_symlink = '/proc/self/cwd'
self.doBuild(pwd_symlink)
self.runCmd(
@ -59,15 +63,15 @@ class CompDirSymLinkTestCase(TestBase):
self.line)
def create_src_symlink(self):
pwd_symlink = os.path.join(os.getcwd(), 'pwd_symlink')
pwd_symlink = self.getBuildArtifact('pwd_symlink')
if os.path.exists(pwd_symlink):
os.unlink(pwd_symlink)
os.symlink(os.getcwd(), pwd_symlink)
os.symlink(self.getBuildDir(), pwd_symlink)
self.addTearDownHook(lambda: os.remove(pwd_symlink))
return pwd_symlink
def doBuild(self, pwd_symlink):
self.build(None, None, {'PWD': pwd_symlink}, True)
exe = os.path.join(os.getcwd(), _EXE_NAME)
exe = self.getBuildArtifact(_EXE_NAME)
self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)

View File

@ -73,7 +73,7 @@ class BreakpointSerialization(TestBase):
# Call super's setUp().
TestBase.setUp(self)
self.bkpts_file_path = os.path.join(os.getcwd(), "breakpoints.json")
self.bkpts_file_path = self.getBuildArtifact("breakpoints.json")
self.bkpts_file_spec = lldb.SBFileSpec(self.bkpts_file_path)
def check_equivalence(self, source_bps, do_write = True):
@ -119,7 +119,7 @@ class BreakpointSerialization(TestBase):
empty_module_list = lldb.SBFileSpecList()
empty_cu_list = lldb.SBFileSpecList()
blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c"))
blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c"))
# It isn't actually important for these purposes that these breakpoint
# actually have locations.
@ -147,7 +147,7 @@ class BreakpointSerialization(TestBase):
cu_list.Append(lldb.SBFileSpec("AnotherCU.c"))
cu_list.Append(lldb.SBFileSpec("ThirdCU.c"))
blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c"))
blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c"))
# It isn't actually important for these purposes that these breakpoint
# actually have locations.
@ -174,7 +174,7 @@ class BreakpointSerialization(TestBase):
empty_module_list = lldb.SBFileSpecList()
empty_cu_list = lldb.SBFileSpecList()
blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c"))
blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c"))
# It isn't actually important for these purposes that these breakpoint
# actually have locations.
@ -218,7 +218,7 @@ class BreakpointSerialization(TestBase):
empty_module_list = lldb.SBFileSpecList()
empty_cu_list = lldb.SBFileSpecList()
blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c"))
blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c"))
# It isn't actually important for these purposes that these breakpoint
# actually have locations.

View File

@ -30,9 +30,10 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
def test_command_script_immediate_output_console(self):
"""Test that LLDB correctly allows scripted commands to set immediate output to the console."""
self.makeBuildDir()
self.launch(timeout=10)
script = os.path.join(os.getcwd(), 'custom_command.py')
script = os.path.join(self.getSourceDir(), 'custom_command.py')
prompt = "\(lldb\) "
self.sendline('command script import %s' % script, patterns=[prompt])
@ -52,14 +53,15 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139")
def test_command_script_immediate_output_file(self):
"""Test that LLDB correctly allows scripted commands to set immediate output to a file."""
self.makeBuildDir()
self.launch(timeout=10)
test_files = {os.path.join(os.getcwd(), 'read.txt'): 'r',
os.path.join(os.getcwd(), 'write.txt'): 'w',
os.path.join(os.getcwd(), 'append.txt'): 'a',
os.path.join(os.getcwd(), 'write_plus.txt'): 'w+',
os.path.join(os.getcwd(), 'read_plus.txt'): 'r+',
os.path.join(os.getcwd(), 'append_plus.txt'): 'a+'}
test_files = {self.getBuildArtifact('read.txt'): 'r',
self.getBuildArtifact('write.txt'): 'w',
self.getBuildArtifact('append.txt'): 'a',
self.getBuildArtifact('write_plus.txt'): 'w+',
self.getBuildArtifact('read_plus.txt'): 'r+',
self.getBuildArtifact('append_plus.txt'): 'a+'}
starter_string = 'Starter Garbage\n'
write_string = 'writing to file with mode: '
@ -68,7 +70,7 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
with open(path, 'w+') as init:
init.write(starter_string)
script = os.path.join(os.getcwd(), 'custom_command.py')
script = os.path.join(self.getSourceDir(), 'custom_command.py')
prompt = "\(lldb\) "
self.sendline('command script import %s' % script, patterns=[prompt])

View File

@ -41,23 +41,23 @@ class ExecTestCase(TestBase):
self.do_test(True)
def do_test(self, skip_exec):
self.makeBuildDir()
exe = self.getBuildArtifact("a.out")
if self.getArchitecture() == 'x86_64':
source = os.path.join(os.getcwd(), "main.cpp")
o_file = os.path.join(os.getcwd(), "main.o")
source = self.getSourcePath("main.cpp")
o_file = self.getBuildArtifact("main.o")
execute_command(
"'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" %
(os.environ["CC"], source, o_file))
execute_command(
"'%s' -g -O0 -arch i386 -arch x86_64 '%s'" %
(os.environ["CC"], o_file))
"'%s' -g -O0 -arch i386 -arch x86_64 '%s' -o '%s'" %
(os.environ["CC"], o_file, exe))
if self.debug_info != "dsym":
dsym_path = self.getBuildArtifact("a.out.dSYM")
execute_command("rm -rf '%s'" % (dsym_path))
else:
self.build()
exe = self.getBuildArtifact("a.out")
# Create the target
target = self.dbg.CreateTarget(exe)

View File

@ -1,12 +1,14 @@
all: clean
$(CC) -arch i386 -g -c a.c
SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
all: a.c clean
$(CC) -arch i386 -g -c $(SRCDIR)/a.c
ar -q liba-i386.a a.o
ranlib liba-i386.a
$(CC) -arch x86_64 -g -c a.c
$(CC) -arch x86_64 -g -c $(SRCDIR)/a.c
ar -q liba-x86_64.a a.o
ranlib liba-x86_64.a
lipo -create -output liba.a liba-i386.a liba-x86_64.a
$(CC) -g -c main.c
$(CC) -g -c $(SRCDIR)/main.c
$(CC) -o a.out main.o -L. -la
clean:

View File

@ -6,7 +6,7 @@ C_SOURCES := somefunc.c
include $(LEVEL)/Makefile.rules
other-2.o: other-2.cpp
$(CXX) $(CFLAGS_NO_DEBUG) -c other-2.cpp
$(CXX) $(CFLAGS_NO_DEBUG) -c $(SRCDIR)/other-2.cpp
somefunc.o: somefunc.c
$(CC) $(CFLAGS) -std=c99 -c somefunc.c
$(CC) $(CFLAGS) -std=c99 -c $(SRCDIR)/somefunc.c

View File

@ -39,7 +39,7 @@ class LaunchWithShellExpandTestCase(TestBase):
self.runCmd(
"process launch -X true -w %s -- fi*.tx? () > <" %
(os.getcwd()))
(self.getSourceDir()))
process = self.process()
@ -77,7 +77,7 @@ class LaunchWithShellExpandTestCase(TestBase):
self.runCmd(
'process launch -X true -w %s -- "foo bar"' %
(os.getcwd()))
(self.getSourceDir()))
process = self.process()
@ -99,7 +99,8 @@ class LaunchWithShellExpandTestCase(TestBase):
self.runCmd("process kill")
self.runCmd('process launch -X true -w %s -- foo\ bar' % (os.getcwd()))
self.runCmd('process launch -X true -w %s -- foo\ bar'
% (self.getBuildDir()))
process = self.process()

View File

@ -7,11 +7,10 @@ CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules
.PHONY:
a.out: lib_a lib_b lib_c lib_d hidden_lib_d install_name_tool
lib_%:
$(MAKE) -f $*.mk
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/$*.mk
install_name_tool:
ifeq ($(OS),Darwin)
@ -20,11 +19,11 @@ endif
hidden_lib_d:
$(MAKE) -C hidden
$(MAKE) VPATH=$(SRCDIR)/hidden -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile
clean::
$(MAKE) -f a.mk clean
$(MAKE) -f b.mk clean
$(MAKE) -f c.mk clean
$(MAKE) -f d.mk clean
$(MAKE) -C hidden clean
$(MAKE) -f $(SRCDIR)/a.mk clean
$(MAKE) -f $(SRCDIR)/b.mk clean
$(MAKE) -f $(SRCDIR)/c.mk clean
$(MAKE) -f $(SRCDIR)/d.mk clean
$(MAKE) -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean

View File

@ -22,6 +22,7 @@ class LoadUnloadTestCase(TestBase):
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
lldbutil.mkdir_p(self.getBuildArtifact("hidden"))
# Find the line number to break for main.cpp.
self.line = line_number(
'main.cpp',
@ -36,12 +37,12 @@ class LoadUnloadTestCase(TestBase):
"=" +
os.environ["LD_LIBRARY_PATH"] +
":" +
os.getcwd())
self.getBuildDir())
else:
if lldb.remote_platform:
wd = lldb.remote_platform.GetWorkingDirectory()
else:
wd = os.getcwd()
wd = self.getBuildDir()
self.runCmd(
"settings set target.env-vars " +
self.dylibPath +
@ -63,7 +64,7 @@ class LoadUnloadTestCase(TestBase):
cwd = os.getcwd()
for f in shlibs:
err = lldb.remote_platform.Put(
lldb.SBFileSpec(os.path.join(cwd, f)),
lldb.SBFileSpec(self.getBuildArtifact(f)),
lldb.SBFileSpec(os.path.join(wd, f)))
if err.Fail():
raise RuntimeError(
@ -78,13 +79,16 @@ class LoadUnloadTestCase(TestBase):
raise RuntimeError(
"Unable to create a directory '%s'." % hidden_dir)
err = lldb.remote_platform.Put(
lldb.SBFileSpec(os.path.join(cwd, 'hidden', shlib)),
lldb.SBFileSpec(os.path.join('hidden', shlib)),
lldb.SBFileSpec(hidden_file))
if err.Fail():
raise RuntimeError(
"Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" %
(wd, err.GetCString()))
# libloadunload_d.so does not appear in the image list because executable
# dependencies are resolved relative to the debuggers PWD. Bug?
@expectedFailureAll(oslist=["linux"])
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
@not_remote_testsuite_ready
@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently
@ -100,11 +104,10 @@ class LoadUnloadTestCase(TestBase):
dylibName = 'libloadunload_d.so'
# The directory with the dynamic library we did not link to.
new_dir = os.path.join(os.getcwd(), "hidden")
new_dir = os.path.join(self.getBuildDir(), "hidden")
old_dylib = os.path.join(os.getcwd(), dylibName)
old_dylib = os.path.join(self.getBuildDir(), dylibName)
new_dylib = os.path.join(new_dir, dylibName)
exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@ -115,14 +118,14 @@ class LoadUnloadTestCase(TestBase):
# Add an image search path substitution pair.
self.runCmd(
"target modules search-paths add %s %s" %
(os.getcwd(), new_dir))
(self.getBuildDir(), new_dir))
self.expect("target modules search-paths list",
substrs=[os.getcwd(), new_dir])
substrs=[self.getBuildDir(), new_dir])
self.expect(
"target modules search-paths query %s" %
os.getcwd(),
self.getBuildDir(),
"Image search path successfully transformed",
substrs=[new_dir])
@ -146,6 +149,9 @@ class LoadUnloadTestCase(TestBase):
"LLDB successfully locates the relocated dynamic library",
substrs=[new_dylib])
# libloadunload_d.so does not appear in the image list because executable
# dependencies are resolved relative to the debuggers PWD. Bug?
@expectedFailureAll(oslist=["linux"])
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
@expectedFailureAndroid # wrong source file shows up for hidden library
@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently
@ -174,18 +180,19 @@ class LoadUnloadTestCase(TestBase):
if lldb.remote_platform:
wd = lldb.remote_platform.GetWorkingDirectory()
else:
wd = os.getcwd()
wd = self.getBuildDir()
old_dir = wd
new_dir = os.path.join(wd, special_dir)
old_dylib = os.path.join(old_dir, dylibName)
remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath
remove_dyld_path_cmd = "settings remove target.env-vars " \
+ self.dylibPath
self.addTearDownHook(
lambda: self.dbg.HandleCommand(remove_dyld_path_cmd))
# For now we don't track (DY)LD_LIBRARY_PATH, so the old library will be in
# the modules list.
# For now we don't track (DY)LD_LIBRARY_PATH, so the old
# library will be in the modules list.
self.expect("target modules list",
substrs=[os.path.basename(old_dylib)],
matching=True)
@ -203,7 +210,7 @@ class LoadUnloadTestCase(TestBase):
if not self.platformIsDarwin():
env_cmd_string += ":" + wd
self.runCmd(env_cmd_string)
# This time, the hidden library should be picked up.
self.expect("run", substrs=["return", "12345"])
@ -233,15 +240,14 @@ class LoadUnloadTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
ctx = self.platformContext
dylibName = ctx.shlib_prefix + 'loadunload_a.' + ctx.shlib_extension
localDylibPath = self.getBuildArtifact(dylibName)
if lldb.remote_platform:
shlib_dir = lldb.remote_platform.GetWorkingDirectory()
wd = lldb.remote_platform.GetWorkingDirectory()
remoteDylibPath = lldbutil.join_remote_paths(wd, dylibName)
else:
shlib_dir = self.mydir
if self.platformIsDarwin():
dylibName = 'libloadunload_a.dylib'
else:
dylibName = 'libloadunload_a.so'
remoteDylibPath = localDylibPath
# Make sure that a_function does not exist at this point.
self.expect(
@ -253,13 +259,10 @@ class LoadUnloadTestCase(TestBase):
# Use lldb 'process load' to load the dylib.
self.expect(
"process load %s --install" %
dylibName,
"%s loaded correctly" %
dylibName,
"process load %s --install=%s" % (localDylibPath, remoteDylibPath),
"%s loaded correctly" % dylibName,
patterns=[
'Loading "%s".*ok' %
dylibName,
'Loading "%s".*ok' % localDylibPath,
'Image [0-9]+ loaded'])
# Search for and match the "Image ([0-9]+) loaded" pattern.
@ -366,6 +369,9 @@ class LoadUnloadTestCase(TestBase):
substrs=['stopped',
'stop reason = step over'])
# We can't find a breakpoint location for d_init before launching because
# executable dependencies are resolved relative to the debuggers PWD. Bug?
@expectedFailureAll(oslist=["linux"])
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently
def test_static_init_during_load(self):

View File

@ -13,11 +13,10 @@ CXXFLAGS += -fPIC
include $(LEVEL)/Makefile.rules
.PHONY:
$(DYLIB_FILENAME): lib_b
lib_b:
"$(MAKE)" -f b.mk
.PHONY lib_b:
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/b.mk
clean::
"$(MAKE)" -f b.mk clean
$(MAKE) -I $(SRCDIR) -f $(SRCDIR)/b.mk clean

View File

@ -45,7 +45,7 @@ class PluginCommandTestCase(TestBase):
retobj = lldb.SBCommandReturnObject()
retval = debugger.GetCommandInterpreter().HandleCommand(
"plugin load %s" % plugin_lib_name, retobj)
"plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj)
retobj.Clear()

View File

@ -44,9 +44,9 @@ class PluginPythonOSPlugin(TestBase):
self.dbg.SetAsync(False)
# Create a target by the debugger.
cwd = os.getcwd()
exe = self.getBuildArtifact("a.out")
python_os_plugin_path = os.path.join(cwd, "operating_system.py")
python_os_plugin_path = os.path.join(self.getSourceDir(),
"operating_system.py")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@ -128,9 +128,9 @@ class PluginPythonOSPlugin(TestBase):
self.dbg.SetAsync(False)
# Create a target by the debugger.
cwd = os.getcwd()
exe = self.getBuildArtifact("a.out")
python_os_plugin_path = os.path.join(cwd, "operating_system2.py")
python_os_plugin_path = os.path.join(self.getSourceDir(),
"operating_system2.py")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)

View File

@ -64,7 +64,7 @@ class MiniDumpTestCase(TestBase):
"""Test that we can examine a more interesting stack in a mini dump."""
self.build()
exe = self.getBuildArtifact("a.out")
core = os.path.join(os.getcwd(), "core.dmp")
core = self.getBuildArtifact("core.dmp")
try:
# Set a breakpoint and capture a mini dump.
target = self.dbg.CreateTarget(exe)
@ -100,7 +100,7 @@ class MiniDumpTestCase(TestBase):
"""Test that we can examine local variables in a mini dump."""
self.build()
exe = self.getBuildArtifact("a.out")
core = os.path.join(os.getcwd(), "core.dmp")
core = self.getBuildArtifact("core.dmp")
try:
# Set a breakpoint and capture a mini dump.
target = self.dbg.CreateTarget(exe)

View File

@ -27,7 +27,7 @@ class ProcessAttachTestCase(TestBase):
def test_attach_to_process_by_id(self):
"""Test attach by process id"""
self.build()
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
# Spawn a new process
popen = self.spawnSubprocess(exe)
@ -43,13 +43,13 @@ class ProcessAttachTestCase(TestBase):
@expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails
def test_attach_to_process_from_different_dir_by_id(self):
"""Test attach by process id"""
newdir = self.getBuildArtifact("newdir")
try:
os.mkdir(os.path.join(os.getcwd(),'newdir'))
os.mkdir(newdir)
except OSError, e:
if e.errno != os.errno.EEXIST:
raise
testdir = os.getcwd()
newdir = os.path.join(testdir,'newdir')
testdir = self.getBuildDir()
exe = os.path.join(newdir, 'proc_attach')
self.buildProgram('main.cpp', exe)
self.addTearDownHook(lambda: shutil.rmtree(newdir))
@ -58,7 +58,7 @@ class ProcessAttachTestCase(TestBase):
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
os.chdir('newdir')
os.chdir(newdir)
self.addTearDownHook(lambda: os.chdir(testdir))
self.runCmd("process attach -p " + str(popen.pid))
@ -71,7 +71,7 @@ class ProcessAttachTestCase(TestBase):
def test_attach_to_process_by_name(self):
"""Test attach by process name"""
self.build()
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
# Spawn a new process
popen = self.spawnSubprocess(exe)

View File

@ -25,7 +25,7 @@ class AttachDeniedTestCase(TestBase):
def test_attach_to_process_by_id_denied(self):
"""Test attach by process id denied"""
self.build()
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
# Use a file as a synchronization point between test and inferior.
pid_file_path = lldbutil.append_to_process_working_directory(

View File

@ -132,7 +132,9 @@ class ProcessLaunchTestCase(TestBase):
out_file_name = "my_working_dir_test.out"
err_file_name = "my_working_dir_test.err"
my_working_dir_path = os.path.join(os.getcwd(), mywd)
my_working_dir_path = self.getBuildArtifact(mywd)
try: os.makedirs(my_working_dir_path)
except: pass
out_file_path = os.path.join(my_working_dir_path, out_file_name)
err_file_path = os.path.join(my_working_dir_path, err_file_name)

View File

@ -22,7 +22,7 @@ class ProcessSaveCoreTestCase(TestBase):
"""Test that SaveCore fails if the process isn't stopped."""
self.build()
exe = self.getBuildArtifact("a.out")
core = os.path.join(os.getcwd(), "core.dmp")
core = self.getBuildArtifact("core.dmp")
target = self.dbg.CreateTarget(exe)
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
@ -36,7 +36,7 @@ class ProcessSaveCoreTestCase(TestBase):
"""Test that we can save a Windows mini dump."""
self.build()
exe = self.getBuildArtifact("a.out")
core = os.path.join(os.getcwd(), "core.dmp")
core = self.getBuildArtifact("core.dmp")
try:
target = self.dbg.CreateTarget(exe)
breakpoint = target.BreakpointCreateByName("bar")

View File

@ -149,7 +149,7 @@ class RegisterCommandsTestCase(TestBase):
self.platform = "posix"
if self.platform != "":
self.log_file = os.path.join(os.getcwd(), 'TestRegisters.log')
self.log_file = self.getBuildArtifact('TestRegisters.log')
self.runCmd(
"log enable " +
self.platform +

View File

@ -35,6 +35,8 @@ class SingleQuoteInCommandLineTestCase(TestBase):
"""Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it."""
import pexpect
self.buildDefault()
try: os.makedirs(self.getBuildArtifact("path with '09"))
except: pass
system([["cp",
self.getBuildArtifact("a.out"),
"\"%s\"" % self.getBuildArtifact(self.myexe)]])

View File

@ -5,4 +5,4 @@ C_SOURCES := with-debug.c without-debug.c
include $(LEVEL)/Makefile.rules
without-debug.o: without-debug.c
$(CC) $(CFLAGS_NO_DEBUG) -c without-debug.c
$(CC) $(CFLAGS_NO_DEBUG) -c $<

View File

@ -46,7 +46,7 @@ class StopHookForMultipleThreadsTestCase(TestBase):
self.setTearDownCleanup(dictionary=self.d)
import pexpect
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
prompt = "(lldb) "
# So that the child gets torn down after the test.

View File

@ -62,8 +62,8 @@ class targetCommandTestCase(TestBase):
def do_target_command(self):
"""Exercise 'target create', 'target list', 'target select' commands."""
exe_a = self.getBuildArtifact("a.out")
exe_b = os.path.join(os.getcwd(), "b.out")
exe_c = os.path.join(os.getcwd(), "c.out")
exe_b = self.getBuildArtifact("b.out")
exe_c = self.getBuildArtifact("c.out")
self.runCmd("target list")
output = self.res.GetOutput()
@ -114,7 +114,8 @@ class targetCommandTestCase(TestBase):
def do_target_variable_command(self, exe_name):
"""Exercise 'target variable' command before and after starting the inferior."""
self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET)
self.runCmd("file " + self.getBuildArtifact(exe_name),
CURRENT_EXECUTABLE_SET)
self.expect(
"target variable my_global_char",
@ -206,7 +207,8 @@ class targetCommandTestCase(TestBase):
def do_target_variable_command_no_fail(self, exe_name):
"""Exercise 'target variable' command before and after starting the inferior."""
self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET)
self.runCmd("file " + self.getBuildArtifact(exe_name),
CURRENT_EXECUTABLE_SET)
self.expect(
"target variable my_global_char",

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -4,6 +4,7 @@ CXX_SOURCES := main.cpp
ENABLE_THREADS := YES
VPATH = ..
include $(LEVEL)/Makefile.rules
main.cpp: ../main.cpp
cp $< $@

View File

@ -46,7 +46,7 @@ class HelloWatchLocationTestCase(TestBase):
"""Test watching a location with '-s size' option."""
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

View File

@ -40,7 +40,7 @@ class HelloWatchpointTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

View File

@ -37,7 +37,7 @@ class WatchpointSlotsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Detect line number after which we are going to increment arrayName.

View File

@ -42,7 +42,7 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped in main.

View File

@ -46,7 +46,7 @@ class WatchpointCommandsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -117,7 +117,7 @@ class WatchpointCommandsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -174,7 +174,7 @@ class WatchpointCommandsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -234,7 +234,7 @@ class WatchpointCommandsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -304,7 +304,7 @@ class WatchpointCommandsTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

View File

@ -45,7 +45,7 @@ class WatchpointLLDBCommandTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -113,7 +113,7 @@ class WatchpointLLDBCommandTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

View File

@ -46,7 +46,7 @@ class WatchpointPythonCommandTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -116,7 +116,7 @@ class WatchpointPythonCommandTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
@ -144,7 +144,8 @@ class WatchpointPythonCommandTestCase(TestBase):
(self.source,
self.decl)])
cmd_script_file = os.path.join(os.getcwd(), "watchpoint_command.py")
cmd_script_file = os.path.join(self.getSourceDir(),
"watchpoint_command.py")
self.runCmd("command script import '%s'" % (cmd_script_file))
self.runCmd(

View File

@ -45,7 +45,7 @@ class WatchpointConditionCmdTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

View File

@ -41,8 +41,6 @@ class TestWatchpointSetEnable(TestBase):
# Create a target by the debugger.
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
cwd = os.getcwd()
bkpt_before = self.target.BreakpointCreateBySourceRegex("Set a breakpoint here", main_file_spec)
self.assertEqual(bkpt_before.GetNumLocations(), 1, "Failed setting the before breakpoint.")

View File

@ -62,7 +62,7 @@ class WatchpointSizeTestCase(TestBase):
self.build(dictionary=self.d)
self.setTearDownCleanup(dictionary=self.d)
exe = os.path.join(os.getcwd(), self.exe_name)
exe = self.getBuildArtifact(self.exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Detect line number after which we are going to increment arrayName.

View File

@ -1,18 +1,16 @@
LEVEL := ../../../make
LD_EXTRAS := -L. -l$(LIB_PREFIX)One -l$(LIB_PREFIX)Two
LD_EXTRAS := -L. -LOne -l$(LIB_PREFIX)One -LTwo -l$(LIB_PREFIX)Two
C_SOURCES := main.c
main.o : CFLAGS_EXTRAS += -g -O0
include $(LEVEL)/Makefile.rules
.PHONY:
a.out: lib_One lib_Two
lib_%:
$(MAKE) -f $*.mk
$(MAKE) VPATH=$(SRCDIR)/$* -I $(SRCDIR) -f $(SRCDIR)/$*.mk
clean::
$(MAKE) -f One.mk clean
$(MAKE) -f Two.mk clean
$(MAKE) -f $(SRCDIR)/One.mk clean
$(MAKE) -f $(SRCDIR)/Two.mk clean

View File

@ -1,12 +1,12 @@
LEVEL := ../../../make
DYLIB_NAME := One
DYLIB_C_SOURCES := One/One.c One/OneConstant.c
DYLIB_C_SOURCES := One.c OneConstant.c
DYLIB_ONLY := YES
include $(LEVEL)/Makefile.rules
CFLAGS_EXTRAS += -fPIC
One/OneConstant.o: One/OneConstant.c
OneConstant.o: OneConstant.c
$(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@

View File

@ -16,6 +16,11 @@ class TestConflictingSymbols(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
TestBase.setUp(self)
lldbutil.mkdir_p(self.getBuildArtifact("One"))
lldbutil.mkdir_p(self.getBuildArtifact("Two"))
def test_conflicting_symbols(self):
self.build()
exe = self.getBuildArtifact("a.out")

View File

@ -1,12 +1,12 @@
LEVEL := ../../../make
DYLIB_NAME := Two
DYLIB_C_SOURCES := Two/Two.c Two/TwoConstant.c
DYLIB_C_SOURCES := Two.c TwoConstant.c
DYLIB_ONLY := YES
include $(LEVEL)/Makefile.rules
CFLAGS_EXTRAS += -fPIC
Two/TwoConstant.o: Two/TwoConstant.c
TwoConstant.o: TwoConstant.c
$(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@

View File

@ -29,10 +29,10 @@ class TlsGlobalTestCase(TestBase):
"=" +
os.environ["LD_LIBRARY_PATH"] +
":" +
os.getcwd())
self.getBuildDir())
else:
self.runCmd("settings set target.env-vars " +
self.dylibPath + "=" + os.getcwd())
self.dylibPath + "=" + self.getBuildDir())
self.addTearDownHook(
lambda: self.runCmd(
"settings remove target.env-vars " +

View File

@ -40,9 +40,7 @@ class TestUnionMembers(TestBase):
def _load_exe(self):
self.build()
cwd = os.getcwd()
src_file = os.path.join(cwd, "main.c")
src_file = os.path.join(self.getSourceDir(), "main.c")
self.src_file_spec = lldb.SBFileSpec(src_file)
self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file")

View File

@ -18,9 +18,7 @@ class TestCppChainedCalls(TestBase):
self.assertTrue(src_file_spec.IsValid(), "Main source file")
# Get the path of the executable
cwd = os.getcwd()
exe_file = self.getBuildArtifact("a.out")
exe_path = os.path.join(cwd, exe_file)
exe_path = self.getBuildArtifact("a.out")
# Load the executable
target = self.dbg.CreateTarget(exe_path)

View File

@ -51,7 +51,7 @@ class CppValueCastTestCase(TestBase):
def do_sbvalue_cast(self, exe_name):
"""Test SBValue::Cast(SBType) API for C++ types."""
exe = os.path.join(os.getcwd(), exe_name)
exe = self.getBuildArtifact(exe_name)
# Create a target from the debugger.

View File

@ -20,7 +20,6 @@ class TestCppGlobalOperators(TestBase):
self.assertTrue(src_file_spec.IsValid(), "Main source file")
# Get the path of the executable
cwd = os.getcwd()
exe_path = self.getBuildArtifact("a.out")
# Load the executable

Some files were not shown because too many files have changed in this diff Show More