[lldb/test] Change base class of lldb-server tests

lldb-server tests are a very special subclass of "api" tests. As they
communicate with lldb-server directly, they don't actually need most of
facilities provided by our TestBase class. In particular, they don't
need the ability to fork debug info flavours of tests (but they could
use debug server flavours).

This makes them inherit from "Base" instead. This avoids the need to
explicitly mark these tests as NO_DEBUG_INFO_TEST_CASE. Two additional
necessary tweaks were:
- move run_platform_command to the base (Base) class. This is used in
  one test, and can be generally useful when running tests remotely.
- add a "build" method, forwarding to buildDefault. This is to avoid
  updating each test case to use buildDefault (also, "build" sounds
  better). It might be interesting to refactor the (Test)Base classes so
  that all debug info flavour handling happens in TestBase, and the Base
  class provides a simple build method automatically.
This commit is contained in:
Pavel Labath 2020-12-10 15:25:55 +01:00
parent db84208250
commit b505142fa5
2 changed files with 11 additions and 10 deletions

View File

@ -1785,6 +1785,12 @@ class Base(unittest2.TestCase):
else:
return ['libc++.1.dylib', 'libc++abi.']
def run_platform_command(self, cmd):
platform = self.dbg.GetSelectedPlatform()
shell_command = lldb.SBPlatformShellCommand(cmd)
err = platform.Run(shell_command)
return (err, shell_command.GetStatus(), shell_command.GetOutput())
# Metaclass for TestBase to change the list of test metods when a new TestCase is loaded.
# We change the test methods to create a new test method for each test for each debug info we are
# testing. The name of the new test method will be '<original-name>_<debug-info>' and with adding
@ -2656,12 +2662,6 @@ FileCheck output:
else:
self.fail("Can't build for debug info: %s" % self.getDebugInfo())
def run_platform_command(self, cmd):
platform = self.dbg.GetSelectedPlatform()
shell_command = lldb.SBPlatformShellCommand(cmd)
err = platform.Run(shell_command)
return (err, shell_command.GetStatus(), shell_command.GetOutput())
"""Assert that an lldb.SBError is in the "success" state."""
def assertSuccess(self, obj, msg=None):
if not obj.Success():

View File

@ -27,9 +27,7 @@ class _ConnectionRefused(IOError):
pass
class GdbRemoteTestCaseBase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
class GdbRemoteTestCaseBase(Base):
# Default time out in seconds. The timeout is increased tenfold under Asan.
DEFAULT_TIMEOUT = 20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
@ -83,7 +81,7 @@ class GdbRemoteTestCaseBase(TestBase):
for channel in lldbtest_config.channels)
def setUp(self):
TestBase.setUp(self)
super(GdbRemoteTestCaseBase, self).setUp()
self.setUpBaseLogging()
self.debug_monitor_extra_args = []
@ -121,6 +119,9 @@ class GdbRemoteTestCaseBase(TestBase):
self._verbose_log_handler = None
TestBase.tearDown(self)
def build(self, *args, **kwargs):
self.buildDefault(*args, **kwargs)
def getLocalServerLogFile(self):
return self.log_basename + "-server.log"