Skip to content

Commit f3a9ab0

Browse files
committedFeb 21, 2018
Fix a couple of more tests to not create files in the source tree
Summary: These were not being flaky, but they're still making the tree dirty. These tests were using lldbutil.append_to_process_working_directory to derive the file path so I fix them by modifying the function to return the build directory for local tests. Technically, now the path returned by this function does not point to the process working directory for local tests, but I think it makes sense to keep the function name, as I think we should move towards launching the process in the build directory (and I intend to change this for the handful of inferiors that actually care about their PWD, for example because they need to create files there). Reviewers: davide, aprantl Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D43506 llvm-svn: 325690
1 parent cdd0675 commit f3a9ab0

File tree

7 files changed

+23
-28
lines changed

7 files changed

+23
-28
lines changed
 

‎lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
class AttachDeniedTestCase(TestBase):
1919

2020
mydir = TestBase.compute_mydir(__file__)
21+
NO_DEBUG_INFO_TESTCASE = True
2122

2223
@skipIfWindows
2324
@skipIfiOSSimulator
@@ -28,7 +29,7 @@ def test_attach_to_process_by_id_denied(self):
2829
exe = self.getBuildArtifact(exe_name)
2930

3031
# Use a file as a synchronization point between test and inferior.
31-
pid_file_path = lldbutil.append_to_process_working_directory(
32+
pid_file_path = lldbutil.append_to_process_working_directory(self,
3233
"pid_file_%d" % (int(time.time())))
3334
self.addTearDownHook(
3435
lambda: self.run_platform_command(

‎lldb/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class ChangeProcessGroupTestCase(TestBase):
1414

1515
mydir = TestBase.compute_mydir(__file__)
16+
NO_DEBUG_INFO_TESTCASE = True
1617

1718
def setUp(self):
1819
# Call super's setUp().
@@ -29,7 +30,7 @@ def test_setpgid(self):
2930
exe = self.getBuildArtifact("a.out")
3031

3132
# Use a file as a synchronization point between test and inferior.
32-
pid_file_path = lldbutil.append_to_process_working_directory(
33+
pid_file_path = lldbutil.append_to_process_working_directory(self,
3334
"pid_file_%d" % (int(time.time())))
3435
self.addTearDownHook(
3536
lambda: self.run_platform_command(

‎lldb/packages/Python/lldbsuite/test/lldbtest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ def pid(self):
369369
def launch(self, executable, args):
370370
if self._install_remote:
371371
src_path = executable
372-
dst_path = lldbutil.append_to_process_working_directory(
373-
os.path.basename(executable))
372+
dst_path = lldbutil.join_remote_paths(
373+
lldb.remote_platform.GetWorkingDirectory(), os.path.basename(executable))
374374

375375
dst_file_spec = lldb.SBFileSpec(dst_path, False)
376376
err = lldb.remote_platform.Install(
@@ -1987,7 +1987,7 @@ def registerSharedLibrariesWithTarget(self, target, shlibs):
19871987
if lldb.remote_platform:
19881988
# We must set the remote install location if we want the shared library
19891989
# to get uploaded to the remote target
1990-
remote_shlib_path = lldbutil.append_to_process_working_directory(
1990+
remote_shlib_path = lldbutil.append_to_process_working_directory(self,
19911991
os.path.basename(local_shlib_path))
19921992
shlib_module.SetRemoteInstallFileSpec(
19931993
lldb.SBFileSpec(remote_shlib_path, False))

‎lldb/packages/Python/lldbsuite/test/lldbutil.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1249,11 +1249,11 @@ def join_remote_paths(*paths):
12491249
return os.path.join(*paths).replace(os.path.sep, '/')
12501250

12511251

1252-
def append_to_process_working_directory(*paths):
1252+
def append_to_process_working_directory(test, *paths):
12531253
remote = lldb.remote_platform
12541254
if remote:
12551255
return join_remote_paths(remote.GetWorkingDirectory(), *paths)
1256-
return os.path.join(os.getcwd(), *paths)
1256+
return os.path.join(test.getBuildDir(), *paths)
12571257

12581258
# ==================================================
12591259
# Utility functions to get the correct signal number

‎lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py

+11-18
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ def test_get_description(self):
6060
self.build()
6161
self.get_description()
6262

63-
@add_test_categories(['pyapi'])
64-
def test_launch_new_process_and_redirect_stdout(self):
65-
"""Exercise SBTarget.Launch() API."""
66-
self.build()
67-
self.launch_new_process_and_redirect_stdout()
68-
6963
@add_test_categories(['pyapi'])
7064
def test_resolve_symbol_context_with_address(self):
7165
"""Exercise SBTarget.ResolveSymbolContextForAddress() API."""
@@ -268,8 +262,11 @@ def get_description(self):
268262
substrs=['a.out', 'Target', 'Module', 'Breakpoint'])
269263

270264
@not_remote_testsuite_ready
271-
def launch_new_process_and_redirect_stdout(self):
265+
@add_test_categories(['pyapi'])
266+
@no_debug_info_test
267+
def test_launch_new_process_and_redirect_stdout(self):
272268
"""Exercise SBTaget.Launch() API with redirected stdout."""
269+
self.build()
273270
exe = self.getBuildArtifact("a.out")
274271

275272
# Create a target by the debugger.
@@ -285,9 +282,12 @@ def launch_new_process_and_redirect_stdout(self):
285282
# Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file.
286283
# The inferior should run to completion after "process.Continue()"
287284
# call.
288-
local_path = "stdout.txt"
285+
local_path = self.getBuildArtifact("stdout.txt")
286+
if os.path.exists(local_path):
287+
os.remove(local_path)
288+
289289
if lldb.remote_platform:
290-
stdout_path = lldbutil.append_to_process_working_directory(
290+
stdout_path = lldbutil.append_to_process_working_directory(self,
291291
"lldb-stdout-redirect.txt")
292292
else:
293293
stdout_path = local_path
@@ -313,20 +313,13 @@ def launch_new_process_and_redirect_stdout(self):
313313

314314
# The 'stdout.txt' file should now exist.
315315
self.assertTrue(
316-
os.path.isfile("stdout.txt"),
316+
os.path.isfile(local_path),
317317
"'stdout.txt' exists due to redirected stdout via SBTarget.Launch() API.")
318318

319319
# Read the output file produced by running the program.
320-
with open('stdout.txt', 'r') as f:
320+
with open(local_path, 'r') as f:
321321
output = f.read()
322322

323-
# Let's delete the 'stdout.txt' file as a cleanup step.
324-
try:
325-
os.remove("stdout.txt")
326-
pass
327-
except OSError:
328-
pass
329-
330323
self.expect(output, exe=False,
331324
substrs=["a(1)", "b(2)", "a(3)"])
332325

‎lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def module_info(self):
2020

2121
self.test_sequence.add_log_lines([
2222
'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % (
23-
lldbutil.append_to_process_working_directory("a.out"),
23+
lldbutil.append_to_process_working_directory(self, "a.out"),
2424
info["triple"].decode('hex')),
2525
{"direction": "send",
2626
"regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}',

‎lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def prep_debug_monitor_and_inferior(
549549
inferior_exe_path = self.getBuildArtifact("a.out")
550550

551551
if lldb.remote_platform:
552-
remote_path = lldbutil.append_to_process_working_directory(
552+
remote_path = lldbutil.append_to_process_working_directory(self,
553553
os.path.basename(inferior_exe_path))
554554
remote_file_spec = lldb.SBFileSpec(remote_path, False)
555555
err = lldb.remote_platform.Install(lldb.SBFileSpec(
@@ -1610,7 +1610,7 @@ def install_and_create_launch_args(self):
16101610
exe_path = self.getBuildArtifact("a.out")
16111611
if not lldb.remote_platform:
16121612
return [exe_path]
1613-
remote_path = lldbutil.append_to_process_working_directory(
1613+
remote_path = lldbutil.append_to_process_working_directory(self,
16141614
os.path.basename(exe_path))
16151615
remote_file_spec = lldb.SBFileSpec(remote_path, False)
16161616
err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True),

0 commit comments

Comments
 (0)
Please sign in to comment.