summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorStella Stamenova <stilis@microsoft.com>2018-06-13 19:02:44 +0000
committerStella Stamenova <stilis@microsoft.com>2018-06-13 19:02:44 +0000
commit9d6fabf9e37b1c2a69ba5d15b1dcbcb044990dc6 (patch)
tree80b112b08704034e18939342757c79890fb8e9de /lldb/packages/Python/lldbsuite/test
parent4fcebf6cf6ec69afe2f3bd8e9d81c93be9668b38 (diff)
downloadbcm5719-llvm-9d6fabf9e37b1c2a69ba5d15b1dcbcb044990dc6.tar.gz
bcm5719-llvm-9d6fabf9e37b1c2a69ba5d15b1dcbcb044990dc6.zip
[lit] Split test_set_working_dir TestProcessLaunch into two tests and fix it on Windows
Summary: test_set_working_dir was testing two scenario: failure to set the working dir because of a non existent directory and succeeding to set the working directory. Since the negative case fails on both Linux and Windows, the positive case was never tested. I split the test into two which allows us to always run both the negative and positive cases. The positive case now succeeds on Linux and the negative case still fails. During the investigation, it turned out that lldbtest.py will try to execute a process launch command up to 3 times if the command failed. This means that we could be covering up intermittent failures by running any test that does process launch multiple times without ever realizing it. I've changed the counter to 1 (though it can still be overwritten with the environment variable). This change also fixes both the positive and negative cases on Windows. There were a few issues: 1) In ProcessLauncherWindows::LaunchProcess, the error was not retrieved until CloseHandle was possibly called. Since CloseHandle is also a system API, its success would overwrite any existing error that could be retrieved using GetLastError. So by the time the error was retrieved, it was now a success. 2) In DebuggerThread::StopDebugging TerminateProcess was called on the process handle regardless of whether it was a valid handle. This was causing the process to crash when the handle was LLDB_INVALID_PROCESS (0xFFFFFFFF). 3) In ProcessWindows::DoLaunch we need to check that the working directory exists before launching the process to have the same behavior as other platforms which first check the directory and then launch process. This way we also control the exact error string. Reviewers: labath, zturner, asmith, jingham Reviewed By: labath Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48050 llvm-svn: 334642
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py39
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py2
2 files changed, 29 insertions, 12 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
index 67501340c28..9d1cac90d85 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
@@ -85,7 +85,34 @@ class ProcessLaunchTestCase(TestBase):
# not working?
@not_remote_testsuite_ready
@expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20265")
- def test_set_working_dir(self):
+ def test_set_working_dir_nonexisting(self):
+ """Test that '-w dir' fails to set the working dir when running the inferior with a dir which doesn't exist."""
+ d = {'CXX_SOURCES': 'print_cwd.cpp'}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(d)
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe)
+
+ mywd = 'my_working_dir'
+ out_file_name = "my_working_dir_test.out"
+ err_file_name = "my_working_dir_test.err"
+
+ my_working_dir_path = self.getBuildArtifact(mywd)
+ out_file_path = os.path.join(my_working_dir_path, out_file_name)
+ err_file_path = os.path.join(my_working_dir_path, err_file_name)
+
+ # Check that we get an error when we have a nonexisting path
+ invalid_dir_path = mywd + 'z'
+ launch_command = "process launch -w %s -o %s -e %s" % (
+ invalid_dir_path, out_file_path, err_file_path)
+
+ self.expect(
+ launch_command, error=True, patterns=[
+ "error:.* No such file or directory: %s" %
+ invalid_dir_path])
+
+ @not_remote_testsuite_ready
+ def test_set_working_dir_existing(self):
"""Test that '-w dir' sets the working dir when running the inferior."""
d = {'CXX_SOURCES': 'print_cwd.cpp'}
self.build(dictionary=d)
@@ -109,16 +136,6 @@ class ProcessLaunchTestCase(TestBase):
except OSError:
pass
- # Check that we get an error when we have a nonexisting path
- launch_command = "process launch -w %s -o %s -e %s" % (
- my_working_dir_path + 'z', out_file_path, err_file_path)
-
- self.expect(
- launch_command, error=True, patterns=[
- "error:.* No such file or directory: %sz" %
- my_working_dir_path])
-
- # Really launch the process
launch_command = "process launch -w %s -o %s -e %s" % (
my_working_dir_path, out_file_path, err_file_path)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 4ccf13959bc..d5dd90a8651 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1833,7 +1833,7 @@ class TestBase(Base):
# Maximum allowed attempts when launching the inferior process.
# Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
- maxLaunchCount = 3
+ maxLaunchCount = 1
# Time to wait before the next launching attempt in second(s).
# Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable.
OpenPOWER on IntegriCloud