Skip to content

Commit 5212206

Browse files
committed
[lldb] Make Reproducer compatbile with SubsystemRAII (NFC)
Make Reproducer compatbile with SubsystemRAII and use it in LocateSymbolFileTest.
1 parent 97ccf93 commit 5212206

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

lldb/include/lldb/Utility/Reproducer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class Reproducer {
197197
static Reproducer &Instance();
198198
static llvm::Error Initialize(ReproducerMode mode,
199199
llvm::Optional<FileSpec> root);
200+
static void Initialize();
200201
static bool Initialized();
201202
static void Terminate();
202203

lldb/source/Utility/Reproducer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,
7373
return Error::success();
7474
}
7575

76+
void Reproducer::Initialize() {
77+
llvm::cantFail(Initialize(repro::ReproducerMode::Off, llvm::None));
78+
}
79+
7680
bool Reproducer::Initialized() { return InstanceImpl().operator bool(); }
7781

7882
void Reproducer::Terminate() {

lldb/unittests/Symbol/LocateSymbolFileTest.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,22 @@ using namespace lldb_private;
2121
namespace {
2222
class SymbolsTest : public ::testing::Test {
2323
public:
24-
SubsystemRAII<FileSystem, HostInfo> subsystems;
24+
SubsystemRAII<repro::Reproducer, FileSystem, HostInfo> subsystems;
2525
};
2626
} // namespace
2727

2828
TEST_F(
2929
SymbolsTest,
3030
TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
31-
EXPECT_THAT_ERROR(
32-
repro::Reproducer::Initialize(repro::ReproducerMode::Off, llvm::None),
33-
llvm::Succeeded());
3431
ModuleSpec module_spec;
3532
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
3633
FileSpec symbol_file_spec =
3734
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
3835
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
39-
repro::Reproducer::Terminate();
4036
}
4137

4238
TEST_F(SymbolsTest,
4339
LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
44-
EXPECT_THAT_ERROR(
45-
repro::Reproducer::Initialize(repro::ReproducerMode::Off, llvm::None),
46-
llvm::Succeeded());
4740
ModuleSpec module_spec;
4841
// using a GUID here because the symbol file shouldn't actually exist on disk
4942
module_spec.GetSymbolFileSpec().SetFile(
@@ -52,5 +45,4 @@ TEST_F(SymbolsTest,
5245
FileSpec symbol_file_spec =
5346
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
5447
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
55-
repro::Reproducer::Terminate();
5648
}

0 commit comments

Comments
 (0)