[llvm-branch-commits] [lldb] b505142 - [lldb/test] Change base class of lldb-server tests
Pavel Labath via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Dec 10 07:26:30 PST 2020
Author: Pavel Labath
Date: 2020-12-10T16:21:28+01:00
New Revision: b505142fa5d301238796318d2d092d6fb3bd2d31
URL: https://github.com/llvm/llvm-project/commit/b505142fa5d301238796318d2d092d6fb3bd2d31
DIFF: https://github.com/llvm/llvm-project/commit/b505142fa5d301238796318d2d092d6fb3bd2d31.diff
LOG: [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.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 1f3bc7722290..d240050cc4c6 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1785,6 +1785,12 @@ def getLibcPlusPlusLibs(self):
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 @@ def build(
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():
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 2908ca2809a9..b578aae12062 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -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 @@ def isVerboseLoggingRequested(self):
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 @@ def tearDown(self):
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"
More information about the llvm-branch-commits
mailing list