llvm-project/lldb/unittests/Utility
Raphael Isemann 5dca0596a9 [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
2019-12-23 10:38:25 +01:00
..
Inputs Move StructuredData from Core to Utility 2017-06-27 10:45:31 +00:00
AnsiTerminalTest.cpp [NFC] Remove lldb_utility namespace. 2019-08-21 00:50:46 +00:00
ArchSpecTest.cpp Avoid triple corruption while merging core info 2019-12-05 13:10:04 +05:00
ArgsTest.cpp [lldb][NFC] Remove ArgEntry::ref member 2019-09-13 11:26:48 +00:00
BroadcasterTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
CompletionRequestTest.cpp [lldb][NFC] Add CompletionRequest::AppendEmptyArgument 2019-09-25 12:40:01 +00:00
ConstStringTest.cpp Allow direct comparison of ConstString against StringRef 2019-04-26 07:21:36 +00:00
DataExtractorTest.cpp [LLDB] Replacing use of ul suffix in GetMaxU64Bitfield since it not guarenteed to be 64 bit 2019-12-05 10:03:53 -08:00
EnvironmentTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
EventTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FileSpecTest.cpp [lldb] s/FileSpec::Equal/FileSpec::Match 2019-12-04 10:42:32 +01:00
FlagsTest.cpp [lldb] Remove SetCount/ClearCount from Flags 2019-09-16 18:02:49 +00:00
ListenerTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LogTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
NameMatchesTest.cpp [Utility] Reimplement RegularExpression on top of llvm::Regex 2019-08-16 21:25:36 +00:00
OptionsWithRawTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PredicateTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ProcessInfoTest.cpp Move ProcessInfo from Host to Utility. 2019-03-04 21:51:03 +00:00
ProcessInstanceInfoTest.cpp ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested, take 2 2019-10-11 10:56:54 +00:00
RangeMapTest.cpp Move RangeMap.h into Utility 2019-03-06 14:41:43 +00:00
RangeTest.cpp Move RangeMap.h into Utility 2019-03-06 14:41:43 +00:00
RegisterValueTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RegularExpressionTest.cpp [Utility] Reimplement RegularExpression on top of llvm::Regex 2019-08-16 21:25:36 +00:00
ReproducerInstrumentationTest.cpp Silence 'warning C4305: 'initializing': truncation from 'double' to 'float'' with MSVC 19.16.27021.1 (VS2017 15.9.12) 2019-06-03 18:46:30 +00:00
ReproducerTest.cpp [Reproducer] Use // in the unit tests 2019-09-27 20:35:55 +00:00
ScalarTest.cpp Use llvm for dumping DWARF expressions 2019-09-30 13:44:17 +00:00
StateTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StatusTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StreamTeeTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StreamTest.cpp [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream 2019-12-05 14:41:33 +01:00
StringExtractorTest.cpp [NFC] Return llvm::StringRef from StringExtractor::GetStringRef. 2019-08-21 04:55:56 +00:00
StringLexerTest.cpp [NFC] Remove lldb_utility namespace. 2019-08-21 00:50:46 +00:00
StringListTest.cpp [lldb][NFC] Address review comments to StringList for-loop support 2019-08-19 07:22:19 +00:00
StructuredDataTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SubsystemRAIITest.cpp [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
TildeExpressionResolverTest.cpp Revert "[FileSystem] Make use of FS in TildeExpressionResolver" 2018-11-09 01:59:28 +00:00
TimeoutTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TimerTest.cpp Remove length modifier when using assignment suppression in TimerTest 2019-05-30 15:38:05 +00:00
UUIDTest.cpp Add UUID::SetFromOptionalStringRef, use it in DynamicLoaderDarwin 2019-01-24 22:43:44 +00:00
UriParserTest.cpp
UserIDResolverTest.cpp Refactor user/group name resolving code 2019-03-04 18:48:00 +00:00
VASprintfTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
VMRangeTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00