Skip to content

Commit a64594d

Browse files
committedSep 3, 2017
Add test case for attach-by-pid from different cwd
This was failing on FreeBSD prior to r312430. Patch by Vignesh Balu. Differential Revision: https://reviews.llvm.org/D32522 llvm-svn: 312431
1 parent 207184f commit a64594d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎lldb/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py

+24
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import time
1010
import lldb
11+
import shutil
1112
from lldbsuite.test.decorators import *
1213
from lldbsuite.test.lldbtest import *
1314
from lldbsuite.test import lldbutil
@@ -38,6 +39,29 @@ def test_attach_to_process_by_id(self):
3839
process = target.GetProcess()
3940
self.assertTrue(process, PROCESS_IS_VALID)
4041

42+
def test_attach_to_process_from_different_dir_by_id(self):
43+
"""Test attach by process id"""
44+
try:
45+
os.mkdir(os.path.join(os.getcwd(),'newdir'))
46+
except OSError, e:
47+
if e.errno != os.errno.EEXIST:
48+
raise
49+
self.buildProgram('main.cpp',os.path.join(os.getcwd(),'newdir','proc_attach'))
50+
exe = os.path.join('.','newdir','proc_attach')
51+
self.addTearDownHook(lambda: shutil.rmtree(os.path.join(os.getcwd())))
52+
53+
# Spawn a new process
54+
popen = self.spawnSubprocess(exe)
55+
self.addTearDownHook(self.cleanupSubprocesses)
56+
57+
os.chdir('newdir')
58+
self.runCmd("process attach -p " + str(popen.pid))
59+
60+
target = self.dbg.GetSelectedTarget()
61+
62+
process = target.GetProcess()
63+
self.assertTrue(process, PROCESS_IS_VALID)
64+
4165
def test_attach_to_process_by_name(self):
4266
"""Test attach by process name"""
4367
self.build()

0 commit comments

Comments
 (0)
Please sign in to comment.