[Lldb-commits] [lldb] r237006 - os.path.join does not always work for paths on remote platforms.
Chaoren Lin
chaorenl at google.com
Mon May 11 10:53:40 PDT 2015
Author: chaoren
Date: Mon May 11 12:53:39 2015
New Revision: 237006
URL: http://llvm.org/viewvc/llvm-project?rev=237006&view=rev
Log:
os.path.join does not always work for paths on remote platforms.
Summary:
Since we don't yet have remote windows debugging, it should be safe to assume
that the remote target uses unix path separators.
Reviewers: ovyalov, zturner, clayborg, vharron
Reviewed By: vharron
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D9633
Modified:
lldb/trunk/test/lldbtest.py
lldb/trunk/test/lldbutil.py
lldb/trunk/test/python_api/target/TestTargetAPI.py
lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py
lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py
lldb/trunk/test/types/AbstractBase.py
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon May 11 12:53:39 2015
@@ -44,6 +44,7 @@ import types
import unittest2
import lldb
import lldbtest_config
+import lldbutil
from _pyio import __metaclass__
# See also dotest.parseOptionsAndInitTestdirs(), where the environment variables
@@ -304,11 +305,9 @@ class _RemoteProcess(_BaseProcess):
return self._pid
def launch(self, executable, args):
- remote_work_dir = lldb.remote_platform.GetWorkingDirectory()
-
if self._install_remote:
src_path = executable
- dst_path = os.path.join(remote_work_dir, os.path.basename(executable))
+ dst_path = lldbutil.append_to_remote_wd(os.path.basename(executable))
dst_file_spec = lldb.SBFileSpec(dst_path, False)
err = lldb.remote_platform.Install(lldb.SBFileSpec(src_path, True), dst_file_spec)
@@ -320,7 +319,7 @@ class _RemoteProcess(_BaseProcess):
launch_info = lldb.SBLaunchInfo(args)
launch_info.SetExecutableFile(dst_file_spec, True)
- launch_info.SetWorkingDirectory(remote_work_dir)
+ launch_info.SetWorkingDirectory(lldb.remote_platform.GetWorkingDirectory())
# Redirect stdout and stderr to /dev/null
launch_info.AddSuppressFileAction(1, False, True)
@@ -1389,7 +1388,7 @@ class Base(unittest2.TestCase):
if bugnumber == None:
print >> sbuf, "expected failure"
else:
- print >> sbuf, "expected failure (problem id:" + str(bugnumber) + ")"
+ print >> sbuf, "expected failure (problem id:" + str(bugnumber) + ")"
def markSkippedTest(self):
"""Callback invoked when a test is skipped."""
@@ -1410,7 +1409,7 @@ class Base(unittest2.TestCase):
if bugnumber == None:
print >> sbuf, "unexpected success"
else:
- print >> sbuf, "unexpected success (problem id:" + str(bugnumber) + ")"
+ print >> sbuf, "unexpected success (problem id:" + str(bugnumber) + ")"
def getRerunArgs(self):
return " -f %s.%s" % (self.__class__.__name__, self._testMethodName)
@@ -2003,11 +2002,11 @@ class TestBase(Base):
lldb.pre_flight(self)
if lldb.remote_platform:
- #remote_test_dir = os.path.join(lldb.remote_platform_working_dir, self.mydir)
- remote_test_dir = os.path.join(lldb.remote_platform_working_dir,
- self.getArchitecture(),
- str(self.test_number),
- self.mydir)
+ remote_test_dir = lldbutil.join_remote_paths(
+ lldb.remote_platform_working_dir,
+ self.getArchitecture(),
+ str(self.test_number),
+ self.mydir)
error = lldb.remote_platform.MakeDirectory(remote_test_dir, 0700)
if error.Success():
lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
@@ -2056,7 +2055,7 @@ class TestBase(Base):
if lldb.remote_platform:
# We must set the remote install location if we want the shared library
# to get uploaded to the remote target
- remote_shlib_path = os.path.join(lldb.remote_platform.GetWorkingDirectory(), os.path.basename(local_shlib_path))
+ remote_shlib_path = lldbutil.append_to_remote_wd(os.path.basename(local_shlib_path))
shlib_module.SetRemoteInstallFileSpec(lldb.SBFileSpec(remote_shlib_path, False))
return environment
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Mon May 11 12:53:39 2015
@@ -890,3 +890,16 @@ class RecursiveDecentFormatter(BasicForm
BasicFormatter.format(self, child, buffer=output, indent=new_indent)
return output.getvalue()
+
+# ===========================================================
+# Utility functions for path manipulation on remote platforms
+# ===========================================================
+
+def join_remote_paths(*paths):
+ # TODO: update with actual platform name for remote windows once it exists
+ if lldb.remote_platform.GetName() == 'remote-windows':
+ return os.path.join(*paths).replace(os.path.sep, '\\')
+ return os.path.join(*paths).replace(os.path.sep, '/')
+
+def append_to_remote_wd(*paths):
+ return join_remote_paths(lldb.remote_platform.GetWorkingDirectory(), *paths)
Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Mon May 11 12:53:39 2015
@@ -375,7 +375,7 @@ class TargetAPITestCase(TestBase):
# The inferior should run to completion after "process.Continue()" call.
local_path = "stdout.txt";
if lldb.remote_platform:
- stdout_path = os.path.join(lldb.remote_platform.GetWorkingDirectory(), "lldb-stdout-redirect.txt")
+ stdout_path = lldbutil.append_to_remote_wd("lldb-stdout-redirect.txt")
else:
stdout_path = local_path
error = lldb.SBError()
Modified: lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py (original)
+++ lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py Mon May 11 12:53:39 2015
@@ -93,8 +93,7 @@ class LldbGdbServerTestCase(gdbremote_te
exe_path = os.path.abspath('a.out')
if not lldb.remote_platform:
return [exe_path]
- remote_work_dir = lldb.remote_platform.GetWorkingDirectory()
- remote_path = os.path.join(remote_work_dir, os.path.basename(exe_path))
+ remote_path = lldbutil.append_to_remote_wd(os.path.basename(exe_path))
remote_file_spec = lldb.SBFileSpec(remote_path, False)
err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), remote_file_spec)
if err.Fail():
Modified: lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py (original)
+++ lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py Mon May 11 12:53:39 2015
@@ -387,8 +387,7 @@ class GdbRemoteTestCaseBase(TestBase):
inferior_exe_path = os.path.abspath("a.out")
if lldb.remote_platform:
- remote_work_dir = lldb.remote_platform.GetWorkingDirectory()
- remote_path = os.path.join(remote_work_dir, os.path.basename(inferior_exe_path))
+ remote_path = lldbutil.append_to_remote_wd(os.path.basename(inferior_exe_path))
remote_file_spec = lldb.SBFileSpec(remote_path, False)
err = lldb.remote_platform.Install(lldb.SBFileSpec(inferior_exe_path, True), remote_file_spec)
if err.Fail():
Modified: lldb/trunk/test/types/AbstractBase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=237006&r1=237005&r2=237006&view=diff
==============================================================================
--- lldb/trunk/test/types/AbstractBase.py (original)
+++ lldb/trunk/test/types/AbstractBase.py Mon May 11 12:53:39 2015
@@ -86,7 +86,7 @@ class GenericTester(TestBase):
if lldb.remote_platform:
# process launch -o requires a path that is valid on the target
self.assertIsNotNone(lldb.remote_platform.GetWorkingDirectory())
- remote_path = os.path.join(lldb.remote_platform.GetWorkingDirectory(), "lldb-stdout-redirect.txt")
+ remote_path = lldbutil.append_to_remote_wd("lldb-stdout-redirect.txt")
self.runCmd('process launch -o {remote}'.format(remote=remote_path))
# copy remote_path to local host
self.runCmd('platform get-file {remote} "{local}"'.format(
More information about the lldb-commits
mailing list