summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/tools
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py7
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py2
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py14
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py32
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py2
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py6
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py9
7 files changed, 39 insertions, 33 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
index 1eea89f4fff..dfe639cfa65 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
@@ -41,9 +41,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for absolute path
- import os
- path = os.path.join(os.getcwd(), self.myexe)
- self.runCmd("-file-exec-and-symbols \"%s\"" % path)
+ self.runCmd("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Run
@@ -60,7 +58,8 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
self.spawnLldbMi(args=None)
# Test that -file-exec-and-symbols works for relative path
- path = "./%s" % self.myexe
+ import os
+ path = os.path.relpath(self.myexe)
self.runCmd("-file-exec-and-symbols %s" % path)
self.expect("\^done")
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
index a597ae1397a..d4d7a484be4 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -35,7 +35,7 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
"Contents",
"Resources",
"DWARF",
- self.myexe)
+ "a.out")
def add_slashes(x): return x.replace(
"\\",
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
index 2226395dcf2..e986204e518 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -8,21 +8,24 @@ from __future__ import print_function
from lldbsuite.test.lldbtest import *
-class MiTestCaseBase(Base):
+class MiTestCaseBase(TestBase):
mydir = None
- myexe = "a.out"
- mylog = "child.log"
+ myexe = None
+ mylog = None
@classmethod
def classCleanup(cls):
- TestBase.RemoveTempFile(cls.myexe)
- TestBase.RemoveTempFile(cls.mylog)
+ if cls.myexe:
+ TestBase.RemoveTempFile(cls.myexe)
+ if cls.mylog:
+ TestBase.RemoveTempFile(cls.mylog)
def setUp(self):
Base.setUp(self)
self.buildDefault()
self.child_prompt = "(gdb)"
+ self.myexe = self.getBuildArtifact("a.out")
def tearDown(self):
if self.TraceOn():
@@ -38,6 +41,7 @@ class MiTestCaseBase(Base):
self.child = pexpect.spawn("%s --interpreter %s" % (
self.lldbMiExec, args if args else ""))
self.child.setecho(True)
+ self.mylog = self.getBuildArtifact("child.log")
self.child.logfile_read = open(self.mylog, "w")
# wait until lldb-mi has started up and is ready to go
self.expect(self.child_prompt, exactly=True)
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
index 80b925993d3..2bb71e4fff6 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -9,6 +9,7 @@ from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+import os
class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
@@ -67,14 +68,11 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
# Prepare path to executable
- import os
- path = os.path.join(os.getcwd(), self.myexe)
-
- self.spawnLldbMi(args="%s" % path)
+ self.spawnLldbMi(args="%s" % self.myexe)
# Test that the executable is loaded when file was specified using
# absolute path
- self.expect("-file-exec-and-symbols \"%s\"" % path)
+ self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
self.expect("\^done")
# Test that lldb-mi is ready when executable was loaded
@@ -92,8 +90,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
"""Test that 'lldb-mi --interpreter %s' loads executable which is specified via relative path."""
# Prepare path to executable
- path = "./%s" % self.myexe
-
+ path = os.path.relpath(self.myexe)
self.spawnLldbMi(args="%s" % path)
# Test that the executable is loaded when file was specified using
@@ -129,6 +126,15 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that lldb-mi is ready when executable was loaded
self.expect(self.child_prompt, exactly=True)
+ def copyScript(self, sourceFile):
+ """copy the script to builddir and replace a.out with the full path"""
+ destFile = os.path.join(os.path.dirname(self.myexe),
+ sourceFile+'.script')
+ with open(sourceFile, 'r') as src:
+ with open(destFile, 'w+') as dest:
+ dest.write(src.read().replace("a.out", self.myexe))
+ return destFile
+
@skipIfRemote # We do not currently support remote debugging via the MI.
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@@ -137,8 +143,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
"""Test that 'lldb-mi --interpreter' can execute user's commands after initial commands were executed."""
# Prepared source file
- sourceFile = "start_script"
-
+ sourceFile = self.copyScript("start_script")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -171,6 +176,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-data-evaluate-expression a")
self.expect("\^done,value=\"10\"")
self.expect(self.child_prompt, exactly=True)
+ os.unlink(sourceFile)
@skipIfRemote # We do not currently support remote debugging via the MI.
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@@ -180,8 +186,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
"""Test that 'lldb-mi --interpreter' can execute a prepared file which passed via --source option."""
# Prepared source file
- sourceFile = "start_script_exit"
-
+ sourceFile = self.copyScript("start_script_exit")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -215,6 +220,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("-gdb-exit")
self.expect("\^exit")
self.expect("\*stopped,reason=\"exited-normally\"")
+ os.unlink(sourceFile)
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@@ -222,8 +228,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
"""Test that 'lldb-mi --interpreter' stops execution of initial commands in case of error."""
# Prepared source file
- sourceFile = "start_script_error"
-
+ sourceFile = self.copyScript("start_script_error")
self.spawnLldbMi(args="--source %s" % sourceFile)
# After '-file-exec-and-symbols a.out'
@@ -236,6 +241,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that lldb-mi is ready after execution of --source start_script
self.expect(self.child_prompt, exactly=True)
+ os.unlink(sourceFile)
@skipIfRemote # We do not currently support remote debugging via the MI.
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
index a4f306efdc9..2817f68a202 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -558,7 +558,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.assertIsNotNone(reg_infos)
self.assertTrue(len(reg_infos) > 0)
- inferior_exe_path = os.path.abspath("a.out")
+ inferior_exe_path = self.getBuildArtifact("a.out")
Target = self.dbg.CreateTarget(inferior_exe_path)
byte_order = Target.GetByteOrder()
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 67887256d97..c20dbe3230f 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
@@ -483,7 +483,7 @@ class GdbRemoteTestCaseBase(TestBase):
# This process needs to be started so that it just hangs around for a while. We'll
# have it sleep.
if not exe_path:
- exe_path = os.path.abspath("a.out")
+ exe_path = self.getBuildArtifact("a.out")
args = []
if inferior_args:
@@ -546,7 +546,7 @@ class GdbRemoteTestCaseBase(TestBase):
if self._inferior_startup == self._STARTUP_LAUNCH:
# Build launch args
if not inferior_exe_path:
- inferior_exe_path = os.path.abspath("a.out")
+ inferior_exe_path = self.getBuildArtifact("a.out")
if lldb.remote_platform:
remote_path = lldbutil.append_to_process_working_directory(
@@ -1607,7 +1607,7 @@ class GdbRemoteTestCaseBase(TestBase):
'.*' if lldbplatformutil.hasChattyStderr(self) else '^' + regex + '$'
def install_and_create_launch_args(self):
- exe_path = os.path.abspath('a.out')
+ exe_path = self.getBuildArtifact("a.out")
if not lldb.remote_platform:
return [exe_path]
remote_path = lldbutil.append_to_process_working_directory(
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
index 7e4190b7fe9..2a2ffa60686 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -20,12 +20,9 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
self.init_llgs_test(False)
working_dir = lldb.remote_platform.GetWorkingDirectory()
- err = lldb.remote_platform.Put(
- lldb.SBFileSpec(
- os.path.join(
- os.getcwd(), "a.out")), lldb.SBFileSpec(
- os.path.join(
- working_dir, "a.out")))
+ src = lldb.SBFileSpec(self.getBuildArtifact("a.out"))
+ dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out"))
+ err = lldb.remote_platform.Put(src, dest)
if err.Fail():
raise RuntimeError(
"Unable copy '%s' to '%s'.\n>>> %s" %
OpenPOWER on IntegriCloud