~pali/llvm/lldb-trunk

« back to all changes in this revision

Viewing changes to packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py

  • Committer: labath
  • Date: 2018-02-21 15:33:53 UTC
  • Revision ID: svn-v4:91177308-0d34-0410-b5e6-96231b3b80d8:lldb/trunk:325690
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

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
        self.get_description()
62
62
 
63
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
 
 
69
 
    @add_test_categories(['pyapi'])
70
64
    def test_resolve_symbol_context_with_address(self):
71
65
        """Exercise SBTarget.ResolveSymbolContextForAddress() API."""
72
66
        self.build()
268
262
                    substrs=['a.out', 'Target', 'Module', 'Breakpoint'])
269
263
 
270
264
    @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):
272
268
        """Exercise SBTaget.Launch() API with redirected stdout."""
 
269
        self.build()
273
270
        exe = self.getBuildArtifact("a.out")
274
271
 
275
272
        # Create a target by the debugger.
285
282
        # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file.
286
283
        # The inferior should run to completion after "process.Continue()"
287
284
        # 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
 
289
289
        if lldb.remote_platform:
290
 
            stdout_path = lldbutil.append_to_process_working_directory(
 
290
            stdout_path = lldbutil.append_to_process_working_directory(self,
291
291
                "lldb-stdout-redirect.txt")
292
292
        else:
293
293
            stdout_path = local_path
313
313
 
314
314
        # The 'stdout.txt' file should now exist.
315
315
        self.assertTrue(
316
 
            os.path.isfile("stdout.txt"),
 
316
            os.path.isfile(local_path),
317
317
            "'stdout.txt' exists due to redirected stdout via SBTarget.Launch() API.")
318
318
 
319
319
        # 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:
321
321
            output = f.read()
322
322
 
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
 
 
330
323
        self.expect(output, exe=False,
331
324
                    substrs=["a(1)", "b(2)", "a(3)"])
332
325