[all-commits] [llvm/llvm-project] 5dca05: [lldb] Add a SubsystemRAII that takes care of call...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Mon Dec 23 01:38:47 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 5dca0596a959217a1c18858a62ed35245a4c42b4
      https://github.com/llvm/llvm-project/commit/5dca0596a959217a1c18858a62ed35245a4c42b4
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2019-12-23 (Mon, 23 Dec 2019)

  Changed paths:
    M lldb/unittests/Core/MangledTest.cpp
    M lldb/unittests/Editline/EditlineTest.cpp
    M lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
    M lldb/unittests/Expression/ClangParserTest.cpp
    M lldb/unittests/Expression/CppModuleConfigurationTest.cpp
    M lldb/unittests/Expression/DWARFExpressionTest.cpp
    M lldb/unittests/Host/ConnectionFileDescriptorTest.cpp
    M lldb/unittests/Host/HostInfoTest.cpp
    M lldb/unittests/Host/MainLoopTest.cpp
    M lldb/unittests/Host/SocketAddressTest.cpp
    M lldb/unittests/Host/SocketTest.cpp
    M lldb/unittests/Interpreter/TestCompletion.cpp
    M lldb/unittests/Language/Highlighting/HighlighterTest.cpp
    M lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
    M lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
    M lldb/unittests/Process/minidump/MinidumpParserTest.cpp
    M lldb/unittests/Symbol/LocateSymbolFileTest.cpp
    M lldb/unittests/Symbol/TestClangASTContext.cpp
    M lldb/unittests/Symbol/TestClangASTImporter.cpp
    M lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
    M lldb/unittests/Symbol/TestLineEntry.cpp
    M lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
    M lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
    M lldb/unittests/Target/ModuleCacheTest.cpp
    A lldb/unittests/TestingSupport/SubsystemRAII.h
    M lldb/unittests/Utility/CMakeLists.txt
    A lldb/unittests/Utility/SubsystemRAIITest.cpp

  Log Message:
  -----------
  [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests

Summary:
Many of our tests need to initialize certain subsystems/plugins of LLDB such as
`FileSystem` or `HostInfo` by calling their static `Initialize` functions before the
test starts and then calling `::Terminate` after the test is done (in reverse order).
This adds a lot of error-prone boilerplate code to our testing code.

This patch adds a RAII called SubsystemRAII that ensures that we always call
::Initialize and then call ::Terminate after the test is done (and that the Terminate
calls are always in the reverse order of the ::Initialize calls). It also gets rid of
all of the boilerplate that we had for these calls.

Per-fixture initialization is still not very nice with this approach as it would
require some kind of static unique_ptr that gets manually assigned/reseted
from the gtest SetUpTestCase/TearDownTestCase functions. Because of that
I changed all per-fixture setup to now do per-test setup which can be done
by just having the SubsystemRAII as a member of the test fixture. This change doesn't
influence our normal test runtime as LIT anyway runs each test case separately
(and the Initialize/Terminate calls are anyway not very expensive). It will however
make running all tests in a single executable slightly slower.

Reviewers: labath, JDevlieghere, martong, espindola, shafik

Reviewed By: labath

Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71630




More information about the All-commits mailing list