[Lldb-commits] [lldb] r325690 - Fix a couple of more tests to not create files in the source tree

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 21 07:33:53 PST 2018


Author: labath
Date: Wed Feb 21 07:33:53 2018
New Revision: 325690

URL: http://llvm.org/viewvc/llvm-project?rev=325690&view=rev
Log:
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

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py Wed Feb 21 07:33:53 2018
@@ -18,6 +18,7 @@ exe_name = 'AttachDenied'  # Must match
 class AttachDeniedTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
     @skipIfWindows
     @skipIfiOSSimulator
@@ -28,7 +29,7 @@ class AttachDeniedTestCase(TestBase):
         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(

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py Wed Feb 21 07:33:53 2018
@@ -13,6 +13,7 @@ from lldbsuite.test import lldbutil
 class ChangeProcessGroupTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
     def setUp(self):
         # Call super's setUp().
@@ -29,7 +30,7 @@ class ChangeProcessGroupTestCase(TestBas
         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(

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Wed Feb 21 07:33:53 2018
@@ -369,8 +369,8 @@ class _RemoteProcess(_BaseProcess):
     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 @@ class TestBase(Base):
             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))

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Wed Feb 21 07:33:53 2018
@@ -1249,11 +1249,11 @@ def join_remote_paths(*paths):
     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

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py Wed Feb 21 07:33:53 2018
@@ -61,12 +61,6 @@ class TargetAPITestCase(TestBase):
         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."""
         self.build()
@@ -268,8 +262,11 @@ class TargetAPITestCase(TestBase):
                     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 @@ class TargetAPITestCase(TestBase):
         # 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 @@ class TargetAPITestCase(TestBase):
 
         # 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)"])
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py Wed Feb 21 07:33:53 2018
@@ -20,7 +20,7 @@ class TestGdbRemoteModuleInfo(gdbremote_
 
         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}',

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=325690&r1=325689&r2=325690&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py Wed Feb 21 07:33:53 2018
@@ -549,7 +549,7 @@ class GdbRemoteTestCaseBase(TestBase):
                 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 @@ class GdbRemoteTestCaseBase(TestBase):
         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),




More information about the lldb-commits mailing list