Index: lldb/trunk/test/lldbtest.py =================================================================== --- lldb/trunk/test/lldbtest.py +++ lldb/trunk/test/lldbtest.py @@ -44,6 +44,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 Index: lldb/trunk/test/lldbutil.py =================================================================== --- lldb/trunk/test/lldbutil.py +++ lldb/trunk/test/lldbutil.py @@ -890,3 +890,16 @@ 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) Index: lldb/trunk/test/python_api/target/TestTargetAPI.py =================================================================== --- lldb/trunk/test/python_api/target/TestTargetAPI.py +++ lldb/trunk/test/python_api/target/TestTargetAPI.py @@ -375,7 +375,7 @@ # 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() Index: lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py =================================================================== --- lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py +++ lldb/trunk/test/tools/lldb-server/TestLldbGdbServer.py @@ -93,8 +93,7 @@ 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(): Index: lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py =================================================================== --- lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py +++ lldb/trunk/test/tools/lldb-server/gdbremote_testcase.py @@ -387,8 +387,7 @@ 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(): Index: lldb/trunk/test/types/AbstractBase.py =================================================================== --- lldb/trunk/test/types/AbstractBase.py +++ lldb/trunk/test/types/AbstractBase.py @@ -86,7 +86,7 @@ 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(