summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/tools/lldb-mi
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-01-19 23:24:35 +0000
committerAdrian Prantl <aprantl@apple.com>2018-01-19 23:24:35 +0000
commit595048f3ecf3317aa2d32bed5141a526415f5aea (patch)
tree92980c57a7209f1ec112bb5f938b2021fec08f21 /lldb/packages/Python/lldbsuite/test/tools/lldb-mi
parentce8746d178dba08ae576c7f53448772d6728d2f5 (diff)
downloadbcm5719-llvm-595048f3ecf3317aa2d32bed5141a526415f5aea.tar.gz
bcm5719-llvm-595048f3ecf3317aa2d32bed5141a526415f5aea.zip
Wrap all references to build artifacts in the LLDB testsuite (NFC)
in TestBase::getBuildArtifact(). This NFC commit is in preparation for https://reviews.llvm.org/D42281 (compile the LLDB tests out-of-tree). Differential Revision: https://reviews.llvm.org/D42280 llvm-svn: 323007
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-mi')
-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
4 files changed, 32 insertions, 23 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
OpenPOWER on IntegriCloud