Updates the lldb python test suite to ensure we call dumpSessionInfo()
in the test result's stopTest() method. This will ensure that we get the
session info dumped for all tests, even those that don't have an
explicit call to dumpSessionInfo() in the test case.
Additionally, I updated the lldb-dap test case to mark the '-dap.log' as
a log file, which will be recorded in the test output on failure.
Here is an example test run with a failure:
```
PASS: LLDB (build/bin/clang-arm64) :: test_step (TestDAP_step.TestDAP_step)
FAIL: LLDB (build/bin/clang-arm64) :: test_step_over_inlined_function (TestDAP_step.TestDAP_step)
Log Files:
- build/lldb-test-build.noindex/tools/lldb-dap/step/TestDAP_step/Failure.log
- build/lldb-test-build.noindex/tools/lldb-dap/step/TestDAP_step/Failure-dap.log
======================================================================
FAIL: test_step_over_inlined_function (TestDAP_step.TestDAP_step)
Test stepping over when the program counter is in another file.
----------------------------------------------------------------------
Traceback (most recent call last):
File "llvm-project/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py", line 113, in test_step_over_inlined_function
self.assertFalse(
AssertionError: True is not false : expect path ending with 'main.cpp'.
Config=arm64-build/bin/clang
----------------------------------------------------------------------
Ran 2 tests in 4.849s
```
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
"""
|
|
Test lldb-dap IO handling.
|
|
"""
|
|
|
|
import sys
|
|
|
|
from lldbsuite.test.decorators import *
|
|
import lldbdap_testcase
|
|
import dap_server
|
|
|
|
EXIT_FAILURE = 1
|
|
EXIT_SUCCESS = 0
|
|
|
|
|
|
class TestDAP_io(lldbdap_testcase.DAPTestCaseBase):
|
|
def launch(self):
|
|
self.create_debug_adapter()
|
|
self.assertIsNotNone(self.dap_server.process)
|
|
process = self.dap_server.process
|
|
|
|
def cleanup():
|
|
# If the process is still alive, kill it.
|
|
if process.poll() is None:
|
|
process.kill()
|
|
process.wait()
|
|
|
|
# Execute the cleanup function during test case tear down.
|
|
self.addTearDownHook(cleanup)
|
|
|
|
return process
|
|
|
|
def test_eof_immediately(self):
|
|
"""
|
|
lldb-dap handles EOF without any other input.
|
|
"""
|
|
process = self.launch()
|
|
process.stdin.close()
|
|
self.assertEqual(process.wait(timeout=self.DEFAULT_TIMEOUT), EXIT_SUCCESS)
|
|
|
|
def test_invalid_header(self):
|
|
"""
|
|
lldb-dap returns a failure exit code when the input stream is closed
|
|
with a malformed request header.
|
|
"""
|
|
process = self.launch()
|
|
process.stdin.write(b"not the correct message header")
|
|
process.stdin.close()
|
|
self.assertEqual(process.wait(timeout=self.DEFAULT_TIMEOUT), EXIT_FAILURE)
|
|
|
|
def test_partial_header(self):
|
|
"""
|
|
lldb-dap returns a failure exit code when the input stream is closed
|
|
with an incomplete message header is in the message buffer.
|
|
"""
|
|
process = self.launch()
|
|
process.stdin.write(b"Content-Length: ")
|
|
process.stdin.close()
|
|
self.assertEqual(process.wait(timeout=self.DEFAULT_TIMEOUT), EXIT_FAILURE)
|
|
|
|
def test_incorrect_content_length(self):
|
|
"""
|
|
lldb-dap returns a failure exit code when reading malformed content
|
|
length headers.
|
|
"""
|
|
process = self.launch()
|
|
process.stdin.write(b"Content-Length: abc")
|
|
process.stdin.close()
|
|
self.assertEqual(process.wait(timeout=self.DEFAULT_TIMEOUT), EXIT_FAILURE)
|
|
|
|
def test_partial_content_length(self):
|
|
"""
|
|
lldb-dap returns a failure exit code when the input stream is closed
|
|
with a partial message in the message buffer.
|
|
"""
|
|
process = self.launch()
|
|
process.stdin.write(b"Content-Length: 10\r\n\r\n{")
|
|
process.stdin.close()
|
|
self.assertEqual(process.wait(timeout=self.DEFAULT_TIMEOUT), EXIT_FAILURE)
|