diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 6c9584224f4a919cb106a0c4dd0cdcffd15669f0..ab14c7445907bc38fda8ee07987e2f26a20d8cd8 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -63,19 +63,18 @@ class Builder: string used for the make system. """ - # If d is None or an empty mapping, just return an empty string. if not d: - return "" - pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'" + d = {} - def setOrAppendVariable(k, v): - append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"] - if k in append_vars and k in os.environ: - v = os.environ[k] + " " + v - return pattern % (k, v) + pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'" + append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"] + for var in append_vars: + val = (d.get(var, '') + ' ' + os.getenv(var, '')).strip() + if val: + d[var] = val cmdline = " ".join( - [setOrAppendVariable(k, v) for k, v in list(d.items())]) + [pattern % (k, v) for k, v in d.items()]).strip() return cmdline diff --git a/lldb/packages/Python/lldbsuite/test/concurrent_base.py b/lldb/packages/Python/lldbsuite/test/concurrent_base.py index 6acd71ce9e46d8acc124301d0937218e659f3c90..bb33d05da2167a03f90d66aaf02da125a72e1177 100644 --- a/lldb/packages/Python/lldbsuite/test/concurrent_base.py +++ b/lldb/packages/Python/lldbsuite/test/concurrent_base.py @@ -76,7 +76,7 @@ class ConcurrentEventsBase(TestBase): bp = self.inferior_target.FindBreakpointByID(bpno) descriptions.append( ": file = 'main.cpp', line = %d" % - self.finish_breakpoint_line) + line) return bp def inferior_done(self): diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 964bcfdd1cffead89401400705809d436a803dbe..f3060185bc4db448dac50a8c0f15074649a3927f 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -957,6 +957,56 @@ class Base(unittest2.TestCase): self.subprocesses.append(proc) return proc + def runCmd(self, cmd, msg=None, check=True, trace=False, inHistory=False): + """ + Ask the command interpreter to handle the command and then check its + return status. + """ + # Fail fast if 'cmd' is not meaningful. + if cmd is None: + raise Exception("Bad 'cmd' parameter encountered") + + trace = (True if traceAlways else trace) + + if cmd.startswith("target create "): + cmd = cmd.replace("target create ", "file ") + + running = (cmd.startswith("run") or cmd.startswith("process launch")) + + for i in range(self.maxLaunchCount if running else 1): + self.ci.HandleCommand(cmd, self.res, inHistory) + + with recording(self, trace) as sbuf: + print("runCmd:", cmd, file=sbuf) + if not check: + print("check of return status not required", file=sbuf) + if self.res.Succeeded(): + print("output:", self.res.GetOutput(), file=sbuf) + else: + print("runCmd failed!", file=sbuf) + print(self.res.GetError(), file=sbuf) + + if self.res.Succeeded(): + break + elif running: + # For process launch, wait some time before possible next try. + time.sleep(self.timeWaitNextLaunch) + with recording(self, trace) as sbuf: + print("Command '" + cmd + "' failed!", file=sbuf) + + if check: + output = "" + if self.res.GetOutput(): + output += "\nCommand output:\n" + self.res.GetOutput() + if self.res.GetError(): + output += "\nError output:\n" + self.res.GetError() + if msg: + msg += output + if cmd: + cmd += output + self.assertTrue(self.res.Succeeded(), + msg if (msg) else CMD_MSG(cmd)) + def HideStdout(self): """Hide output to stdout from the user. @@ -1746,7 +1796,7 @@ class Base(unittest2.TestCase): elif self.getPlatform() == "netbsd": # NetBSD defaults to libc++ pass - elif "clang" in self.getCompiler(): + elif "clang" in self.getCompiler() and not lldb.remote_platform: cflags += " -stdlib=libstdc++" return {'CFLAGS_EXTRAS': cflags, @@ -2121,56 +2171,6 @@ class TestBase(Base): if matched: self.runCmd('thread select %s' % matched.group(1)) - def runCmd(self, cmd, msg=None, check=True, trace=False, inHistory=False): - """ - Ask the command interpreter to handle the command and then check its - return status. - """ - # Fail fast if 'cmd' is not meaningful. - if cmd is None: - raise Exception("Bad 'cmd' parameter encountered") - - trace = (True if traceAlways else trace) - - if cmd.startswith("target create "): - cmd = cmd.replace("target create ", "file ") - - running = (cmd.startswith("run") or cmd.startswith("process launch")) - - for i in range(self.maxLaunchCount if running else 1): - self.ci.HandleCommand(cmd, self.res, inHistory) - - with recording(self, trace) as sbuf: - print("runCmd:", cmd, file=sbuf) - if not check: - print("check of return status not required", file=sbuf) - if self.res.Succeeded(): - print("output:", self.res.GetOutput(), file=sbuf) - else: - print("runCmd failed!", file=sbuf) - print(self.res.GetError(), file=sbuf) - - if self.res.Succeeded(): - break - elif running: - # For process launch, wait some time before possible next try. - time.sleep(self.timeWaitNextLaunch) - with recording(self, trace) as sbuf: - print("Command '" + cmd + "' failed!", file=sbuf) - - if check: - output = "" - if self.res.GetOutput(): - output += "\nCommand output:\n" + self.res.GetOutput() - if self.res.GetError(): - output += "\nError output:\n" + self.res.GetError() - if msg: - msg += output - if cmd: - cmd += output - self.assertTrue(self.res.Succeeded(), - msg if (msg) else CMD_MSG(cmd)) - def match( self, str, diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 91509f609096a46e62394b6dafb69efd6c240b88..582c3046f207ba9cb5ca3c7410c56b5187ea35b3 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -139,7 +139,9 @@ class GdbRemoteTestCaseBase(Base): if configuration.lldb_platform_url.startswith('unix-'): url_pattern = '(.+)://\[?(.+?)\]?/.*' else: - url_pattern = '(.+)://(.+):\d+' + # use (.*) for host instead of (.+) because + # 'connect://:port' - is a valid way to connect to lldb-server + url_pattern = '(.+)://(.*):\d+' scheme, host = re.match( url_pattern, configuration.lldb_platform_url).groups() if configuration.lldb_platform_name == 'remote-android' and host != 'localhost': @@ -281,8 +283,8 @@ class GdbRemoteTestCaseBase(Base): logger = self.logger - triple = self.dbg.GetSelectedPlatform().GetTriple() - if re.match(".*-.*-.*-android", triple): + # TODO: forward port always when use adb connection + if configuration.lldb_platform_name == 'remote-android': self.forward_adb_port( self.port, self.port, diff --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py index 12c9d9d59aed307c289172091f100ac281dd8626..3deb775b035e37310d4388d87e39d9cce68f2756 100644 --- a/lldb/test/API/python_api/target/TestTargetAPI.py +++ b/lldb/test/API/python_api/target/TestTargetAPI.py @@ -476,6 +476,10 @@ class TargetAPITestCase(TestBase): desc2 = get_description(symbol2) self.assertTrue(desc1 and desc2 and desc1 == desc2, "The two addresses should resolve to the same symbol") + + # LLDB_ARCH_DEFAULT is for the host arch, + # so we don't want to try to run binary built for remote device locally + @skipIfRemote def test_default_arch(self): """ Test the other two target create methods using LLDB_ARCH_DEFAULT. """ self.build() diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py index 22af21d132da86288f77312c7fe6f5f2215d4eac..0e7f3cbc00a999801d261b9c3dd30942802a8a5c 100644 --- a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py @@ -1,4 +1,5 @@ import tempfile +import os import gdbremote_testcase from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * @@ -11,7 +12,10 @@ class GdbRemoteCompletionTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): self.debug_monitor_exe = get_lldb_server_exe() if not self.debug_monitor_exe: self.skipTest("lldb-server exe not found") - port_file = tempfile.NamedTemporaryFile().name + port_file = os.path.join( + lldb.remote_platform.GetWorkingDirectory(), + 'connect.sock' + ) if lldb.remote_platform else tempfile.NamedTemporaryFile().name commandline_args = [ "platform", "--listen",