[lldb/Test] Remove support for forking a subprocess from the test suite.
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 15 Jul 2020 15:51:24 +0000 (08:51 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 15 Jul 2020 15:57:54 +0000 (08:57 -0700)
Remove the forkSubprocess method and its bookkeeping.
TestCreateAfterAttach is the only test using the fork method and I'm not
convinced it adds enough to warrant the maintenance. Pavel suggested the
same thing in D83815.

lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/functionalities/thread/create_after_attach/TestCreateAfterAttach.py

index 280e02f..b1add79 100644 (file)
@@ -800,9 +800,6 @@ class Base(unittest2.TestCase):
         # List of spawned subproces.Popen objects
         self.subprocesses = []
 
-        # List of forked process PIDs
-        self.forkedProcessPids = []
-
         # List of log files produced by the current test.
         self.log_files = []
 
@@ -892,13 +889,6 @@ class Base(unittest2.TestCase):
             p.terminate()
             del p
         del self.subprocesses[:]
-        # Ensure any forked processes are cleaned up
-        for pid in self.forkedProcessPids:
-            try:
-                os.kill(pid, signal.SIGTERM)
-            except OSError:
-                pass
-        del self.forkedProcessPids[:]
 
     def spawnSubprocess(self, executable, args=[], install_remote=True):
         """ Creates a subprocess.Popen object with the specified executable and arguments,
@@ -910,23 +900,6 @@ class Base(unittest2.TestCase):
         self.subprocesses.append(proc)
         return proc
 
-    def forkSubprocess(self, executable, args=[]):
-        """ Fork a subprocess with its own group ID.
-        """
-        child_pid = os.fork()
-        if child_pid == 0:
-            # If more I/O support is required, this can be beefed up.
-            fd = os.open(os.devnull, os.O_RDWR)
-            os.dup2(fd, 1)
-            os.dup2(fd, 2)
-            # This call causes the child to have its of group ID
-            os.setpgid(0, 0)
-            os.execvp(executable, [executable] + args)
-        # Give the child time to get through the execvp() call
-        time.sleep(0.1)
-        self.forkedProcessPids.append(child_pid)
-        return child_pid
-
     def HideStdout(self):
         """Hide output to stdout from the user.
 
index 19c02c1..8ad9afe 100644 (file)
@@ -14,29 +14,6 @@ class CreateAfterAttachTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIfFreeBSD  # Hangs.  May be the same as Linux issue llvm.org/pr16229 but
-    # not yet investigated.  Revisit once required functionality
-    # is implemented for FreeBSD.
-    # Occasionally hangs on Windows, may be same as other issues.
-    @skipIfWindows
-    @skipIfiOSSimulator
-    @expectedFailureNetBSD
-    def test_create_after_attach_with_popen(self):
-        """Test thread creation after process attach."""
-        self.build(dictionary=self.getBuildFlags(use_cpp11=False))
-        self.create_after_attach(use_fork=False)
-
-    @skipIfFreeBSD  # Hangs. Revisit once required functionality is implemented
-    # for FreeBSD.
-    @skipIfRemote
-    @skipIfWindows  # Windows doesn't have fork.
-    @skipIfiOSSimulator
-    @expectedFailureNetBSD
-    def test_create_after_attach_with_fork(self):
-        """Test thread creation after process attach."""
-        self.build(dictionary=self.getBuildFlags(use_cpp11=False))
-        self.create_after_attach(use_fork=True)
-
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -45,17 +22,21 @@ class CreateAfterAttachTestCase(TestBase):
         self.break_2 = line_number('main.cpp', '// Set second breakpoint here')
         self.break_3 = line_number('main.cpp', '// Set third breakpoint here')
 
-    def create_after_attach(self, use_fork):
+    @skipIfFreeBSD  # Hangs.  May be the same as Linux issue llvm.org/pr16229 but
+    # not yet investigated.  Revisit once required functionality
+    # is implemented for FreeBSD.
+    # Occasionally hangs on Windows, may be same as other issues.
+    @skipIfWindows
+    @skipIfiOSSimulator
+    @expectedFailureNetBSD
+    def test_create_after_attach(self):
         """Test thread creation after process attach."""
-
+        self.build(dictionary=self.getBuildFlags(use_cpp11=False))
         exe = self.getBuildArtifact("a.out")
 
         # Spawn a new process
-        if use_fork:
-            pid = self.forkSubprocess(exe)
-        else:
-            popen = self.spawnSubprocess(exe)
-            pid = popen.pid
+        popen = self.spawnSubprocess(exe)
+        pid = popen.pid
 
         # Attach to the spawned process
         self.runCmd("process attach -p " + str(pid))