summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lldbutil.py
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-03-15 13:47:09 +0000
committerPavel Labath <labath@google.com>2018-03-15 13:47:09 +0000
commit107052ff9ded599519445833d755628703027801 (patch)
treeffb1645cdd59e8a980cc33a5908377e4c9bf430d /lldb/packages/Python/lldbsuite/test/lldbutil.py
parentdfc7eb490aab97f2fc93963bd0884ee30ceb257b (diff)
downloadbcm5719-llvm-107052ff9ded599519445833d755628703027801.tar.gz
bcm5719-llvm-107052ff9ded599519445833d755628703027801.zip
Next batch of test-tree-cleaning changes
Summary: The changes here fall into several categories. - some tests were redirecting inferior stdout/err to a file. For these I make sure we use an absolute path for the file. I also create a lldbutil.read_file_on_target helper function to encapsulate the differences between reading a file locally and remotely. - some tests were redirecting the pexpect I/O into a file. For these I use a python StringIO object to avoid creating a file altogether. - the TestSettings inferior was creating a file. Here, I make sure the inferior is launched with pwd=build-dir so that the files end up created there. - lldb-mi --log (used by some tests) creates a log file in PWD without the ability say differently. To make this work I make sure to run lldb-mi with PWD=build_dir. This in turn necessitated a couple of changes in other lldb-mi tests, which were using relative paths to access the source tree. Reviewers: aprantl Subscribers: ki.stfu, mehdi_amini, lldb-commits Differential Revision: https://reviews.llvm.org/D44159 llvm-svn: 327625
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbutil.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index faa1c83757e..2fe24023f48 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1321,6 +1321,21 @@ def skip_if_library_missing(test, target, library):
target))
+def read_file_on_target(test, remote):
+ if lldb.remote_platform:
+ local = test.getBuildArtifact("file_from_target")
+ error = lldb.remote_platform.Get(lldb.SBFileSpec(remote, False),
+ lldb.SBFileSpec(local, True))
+ test.assertTrue(error.Success(), "Reading file {0} failed: {1}".format(remote, error))
+ else:
+ local = remote
+ with open(local, 'r') as f:
+ return f.read()
+
+def read_file_from_process_wd(test, name):
+ path = append_to_process_working_directory(test, name)
+ return read_file_on_target(test, path)
+
def wait_for_file_on_target(testcase, file_path, max_attempts=6):
for i in range(max_attempts):
err, retcode, msg = testcase.run_platform_command("ls %s" % file_path)
@@ -1335,9 +1350,4 @@ def wait_for_file_on_target(testcase, file_path, max_attempts=6):
"File %s not found even after %d attempts." %
(file_path, max_attempts))
- err, retcode, data = testcase.run_platform_command("cat %s" % (file_path))
-
- testcase.assertTrue(
- err.Success() and retcode == 0, "Failed to read file %s: %s, retcode: %d" %
- (file_path, err.GetCString(), retcode))
- return data
+ return read_file_on_target(testcase, file_path)
OpenPOWER on IntegriCloud