[Lldb-commits] [PATCH] Fix TestAttachDenied.py remote execution on Linux.
Oleksiy Vyalov
ovyalov at google.com
Sun Feb 15 18:08:55 PST 2015
Hi vharron,
TestAttachDenied should create the pipe on a target machine in case of remote execution - use SBPlatform::Run to create/read/remove a pipe either on local or remote machine.
http://reviews.llvm.org/D7659
Files:
test/functionalities/process_attach/attach_denied/TestAttachDenied.py
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:',
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7659.19996.patch
Type: text/x-patch
Size: 2241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150216/5a3523ef/attachment.bin>
More information about the lldb-commits
mailing list