labath created this revision. labath added reviewers: davide, aprantl. 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). https://reviews.llvm.org/D43506 Files: packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py packages/Python/lldbsuite/test/lldbtest.py packages/Python/lldbsuite/test/lldbutil.py packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Index: packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py =================================================================== --- packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -549,7 +549,7 @@ inferior_exe_path = self.getBuildArtifact("a.out") if lldb.remote_platform: - remote_path = lldbutil.append_to_process_working_directory( + remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(inferior_exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec( @@ -1610,7 +1610,7 @@ exe_path = self.getBuildArtifact("a.out") if not lldb.remote_platform: return [exe_path] - remote_path = lldbutil.append_to_process_working_directory( + remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), Index: packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py =================================================================== --- packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py +++ packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py @@ -20,7 +20,7 @@ self.test_sequence.add_log_lines([ 'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % ( - lldbutil.append_to_process_working_directory("a.out"), + lldbutil.append_to_process_working_directory(self, "a.out"), info["triple"].decode('hex')), {"direction": "send", "regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}', Index: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py =================================================================== --- packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -60,12 +60,6 @@ self.build() self.get_description() - @add_test_categories(['pyapi']) - def test_launch_new_process_and_redirect_stdout(self): - """Exercise SBTarget.Launch() API.""" - self.build() - self.launch_new_process_and_redirect_stdout() - @add_test_categories(['pyapi']) def test_resolve_symbol_context_with_address(self): """Exercise SBTarget.ResolveSymbolContextForAddress() API.""" @@ -268,8 +262,11 @@ substrs=['a.out', 'Target', 'Module', 'Breakpoint']) @not_remote_testsuite_ready - def launch_new_process_and_redirect_stdout(self): + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_launch_new_process_and_redirect_stdout(self): """Exercise SBTaget.Launch() API with redirected stdout.""" + self.build() exe = self.getBuildArtifact("a.out") # Create a target by the debugger. @@ -285,9 +282,12 @@ # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. # The inferior should run to completion after "process.Continue()" # call. - local_path = "stdout.txt" + local_path = self.getBuildArtifact("stdout.txt") + if os.path.exists(local_path): + os.remove(local_path) + if lldb.remote_platform: - stdout_path = lldbutil.append_to_process_working_directory( + stdout_path = lldbutil.append_to_process_working_directory(self, "lldb-stdout-redirect.txt") else: stdout_path = local_path @@ -313,20 +313,13 @@ # The 'stdout.txt' file should now exist. self.assertTrue( - os.path.isfile("stdout.txt"), + os.path.isfile(local_path), "'stdout.txt' exists due to redirected stdout via SBTarget.Launch() API.") # Read the output file produced by running the program. - with open('stdout.txt', 'r') as f: + with open(local_path, 'r') as f: output = f.read() - # Let's delete the 'stdout.txt' file as a cleanup step. - try: - os.remove("stdout.txt") - pass - except OSError: - pass - self.expect(output, exe=False, substrs=["a(1)", "b(2)", "a(3)"]) Index: packages/Python/lldbsuite/test/lldbutil.py =================================================================== --- packages/Python/lldbsuite/test/lldbutil.py +++ packages/Python/lldbsuite/test/lldbutil.py @@ -1249,11 +1249,11 @@ return os.path.join(*paths).replace(os.path.sep, '/') -def append_to_process_working_directory(*paths): +def append_to_process_working_directory(test, *paths): remote = lldb.remote_platform if remote: return join_remote_paths(remote.GetWorkingDirectory(), *paths) - return os.path.join(os.getcwd(), *paths) + return os.path.join(test.getBuildDir(), *paths) # ================================================== # Utility functions to get the correct signal number Index: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -369,8 +369,8 @@ def launch(self, executable, args): if self._install_remote: src_path = executable - dst_path = lldbutil.append_to_process_working_directory( - os.path.basename(executable)) + dst_path = lldbutil.join_remote_paths( + lldb.remote_platform.GetWorkingDirectory(), os.path.basename(executable)) dst_file_spec = lldb.SBFileSpec(dst_path, False) err = lldb.remote_platform.Install( @@ -1987,7 +1987,7 @@ if lldb.remote_platform: # We must set the remote install location if we want the shared library # to get uploaded to the remote target - remote_shlib_path = lldbutil.append_to_process_working_directory( + remote_shlib_path = lldbutil.append_to_process_working_directory(self, os.path.basename(local_shlib_path)) shlib_module.SetRemoteInstallFileSpec( lldb.SBFileSpec(remote_shlib_path, False)) Index: packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py +++ packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py @@ -13,6 +13,7 @@ class ChangeProcessGroupTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -29,7 +30,7 @@ exe = self.getBuildArtifact("a.out") # Use a file as a synchronization point between test and inferior. - pid_file_path = lldbutil.append_to_process_working_directory( + pid_file_path = lldbutil.append_to_process_working_directory(self, "pid_file_%d" % (int(time.time()))) self.addTearDownHook( lambda: self.run_platform_command( Index: packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py =================================================================== --- packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py +++ packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py @@ -18,6 +18,7 @@ class AttachDeniedTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @skipIfWindows @skipIfiOSSimulator @@ -28,7 +29,7 @@ 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( + pid_file_path = lldbutil.append_to_process_working_directory(self, "pid_file_%d" % (int(time.time()))) self.addTearDownHook( lambda: self.run_platform_command(
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits