[Lldb-commits] [lldb] r229587 - Fix TestAttachDenied.py remote execution on Linux.
Oleksiy Vyalov
ovyalov at google.com
Tue Feb 17 15:37:20 PST 2015
Author: ovyalov
Date: Tue Feb 17 17:37:19 2015
New Revision: 229587
URL: http://llvm.org/viewvc/llvm-project?rev=229587&view=rev
Log:
Fix TestAttachDenied.py remote execution on Linux.
http://reviews.llvm.org/D7659
Modified:
lldb/trunk/test/functionalities/process_attach/attach_denied/TestAttachDenied.py
Modified: lldb/trunk/test/functionalities/process_attach/attach_denied/TestAttachDenied.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/process_attach/attach_denied/TestAttachDenied.py?rev=229587&r1=229586&r2=229587&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/process_attach/attach_denied/TestAttachDenied.py (original)
+++ lldb/trunk/test/functionalities/process_attach/attach_denied/TestAttachDenied.py Tue Feb 17 17:37:19 2015
@@ -3,8 +3,7 @@ Test denied process attach.
"""
import os
-import shutil
-import tempfile
+import time
import unittest2
import lldb
from lldbtest import *
@@ -15,6 +14,12 @@ class AttachDeniedTestCase(TestBase):
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 @@ class AttachDeniedTestCase(TestBase):
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:',
More information about the lldb-commits
mailing list