Index: test/functionalities/process_attach/attach_denied/TestAttachDenied.py =================================================================== --- test/functionalities/process_attach/attach_denied/TestAttachDenied.py +++ test/functionalities/process_attach/attach_denied/TestAttachDenied.py @@ -3,8 +3,7 @@ """ import os -import shutil -import tempfile +import time import unittest2 import lldb from lldbtest import * @@ -15,6 +14,12 @@ mydir = TestBase.compute_mydir(__file__) + def run_platform_command(self, cmd): + platform = self.dbg.GetSelectedPlatform() + shell_command = lldb.SBPlatformShellCommand(cmd) + err = platform.Run(shell_command) + return (err, shell_command.GetOutput()) + @skipIfWindows def test_attach_to_process_by_id_denied(self): """Test attach by process id denied""" @@ -22,20 +27,21 @@ self.buildDefault() exe = os.path.join(os.getcwd(), exe_name) - temp_dir = tempfile.mkdtemp() - self.addTearDownHook(lambda: shutil.rmtree(temp_dir)) - # Use named pipe as a synchronization point between test and inferior. - pid_pipe_path = os.path.join(temp_dir, "pid_pipe") - os.mkfifo(pid_pipe_path) + pid_pipe_path = os.path.join(self.get_process_working_directory(), + "pid_pipe_%d" % (int(time.time()))) + + err, _ = self.run_platform_command("mkfifo %s" % (pid_pipe_path)) + self.assertTrue(err.Success(), "Failed to create FIFO %s: %s" % (pid_pipe_path, err.GetCString())) + + self.addTearDownHook(lambda: self.run_platform_command("rm %s" % (pid_pipe_path))) # Spawn a new process popen = self.spawnSubprocess(exe, [pid_pipe_path]) self.addTearDownHook(self.cleanupSubprocesses) - pid_pipe = open(pid_pipe_path, 'r') - self.addTearDownHook(lambda: pid_pipe.close()) - pid = pid_pipe.read() + err, pid = self.run_platform_command("cat %s" % (pid_pipe_path)) + self.assertTrue(err.Success(), "Failed to read FIFO %s: %s" % (pid_pipe_path, err.GetCString())) self.expect('process attach -p ' + pid, startstr = 'error: attach failed:',