# 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 = []
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,
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.
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)
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))