summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-05-11 17:53:39 +0000
committerChaoren Lin <chaorenl@google.com>2015-05-11 17:53:39 +0000
commit3e2bdb464098ea29e588ace34c6d65b40709cf64 (patch)
tree2f59bbd182199434d8f2155468bfdb23365ee43d
parent59b60af06de92d704f7134d5d5fee54298ec20eb (diff)
downloadbcm5719-llvm-3e2bdb464098ea29e588ace34c6d65b40709cf64.tar.gz
bcm5719-llvm-3e2bdb464098ea29e588ace34c6d65b40709cf64.zip
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 llvm-svn: 237006
-rw-r--r--lldb/test/lldbtest.py23
-rw-r--r--lldb/test/lldbutil.py13
-rw-r--r--lldb/test/python_api/target/TestTargetAPI.py2
-rw-r--r--lldb/test/tools/lldb-server/TestLldbGdbServer.py3
-rw-r--r--lldb/test/tools/lldb-server/gdbremote_testcase.py3
-rw-r--r--lldb/test/types/AbstractBase.py2
6 files changed, 28 insertions, 18 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index aaa35bb432c..1b48d786e18 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -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
diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py
index a0292fbf6bb..219791e0f08 100644
--- a/lldb/test/lldbutil.py
+++ b/lldb/test/lldbutil.py
@@ -890,3 +890,16 @@ class RecursiveDecentFormatter(BasicFormatter):
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)
diff --git a/lldb/test/python_api/target/TestTargetAPI.py b/lldb/test/python_api/target/TestTargetAPI.py
index 2494c0f0c23..0dcafcef622 100644
--- a/lldb/test/python_api/target/TestTargetAPI.py
+++ b/lldb/test/python_api/target/TestTargetAPI.py
@@ -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()
diff --git a/lldb/test/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/tools/lldb-server/TestLldbGdbServer.py
index b81a5f536ee..91610a49bcc 100644
--- a/lldb/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/tools/lldb-server/TestLldbGdbServer.py
@@ -93,8 +93,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
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():
diff --git a/lldb/test/tools/lldb-server/gdbremote_testcase.py b/lldb/test/tools/lldb-server/gdbremote_testcase.py
index 781ca4dadaa..658487ad4a0 100644
--- a/lldb/test/tools/lldb-server/gdbremote_testcase.py
+++ b/lldb/test/tools/lldb-server/gdbremote_testcase.py
@@ -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():
diff --git a/lldb/test/types/AbstractBase.py b/lldb/test/types/AbstractBase.py
index 3b567f86bfc..9b149e9534f 100644
--- a/lldb/test/types/AbstractBase.py
+++ b/lldb/test/types/AbstractBase.py
@@ -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(
OpenPOWER on IntegriCloud