Skip to content

Commit 9843ff7

Browse files
committed
Simplify set up, remove timeouts, add license
Uses `SubsystemRAII` to initialize the necessary platform and host information. Since the debugger cannot be initialized with no arguments (which is how `SubsystemRAII` will initialize everything), the debugger will be initialized the usual way. Also removes the thread timeouts and adds the LLVM license header.
1 parent 10343b6 commit 9843ff7

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

lldb/unittests/Core/ProgressReportTest.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
//===-- ProgressReportTest.cpp --------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
19
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
210
#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
11+
#include "TestingSupport/SubsystemRAII.h"
312
#include "lldb/Core/Debugger.h"
413
#include "lldb/Core/Progress.h"
514
#include "lldb/Host/FileSystem.h"
@@ -11,23 +20,17 @@
1120
using namespace lldb;
1221
using namespace lldb_private;
1322

14-
namespace {
1523
class ProgressReportTest : public ::testing::Test {
16-
public:
17-
void SetUp() override {
18-
FileSystem::Initialize();
19-
HostInfo::Initialize();
20-
PlatformMacOSX::Initialize();
21-
Debugger::Initialize(nullptr);
22-
}
23-
void TearDown() override {
24-
Debugger::Terminate();
25-
PlatformMacOSX::Terminate();
26-
HostInfo::Terminate();
27-
FileSystem::Terminate();
28-
}
24+
SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
25+
26+
// The debugger's initialization function can't be called with no arguments
27+
// so calling it using SubsystemRAII will cause the test build to fail as
28+
// SubsystemRAII will call Initialize with no arguments. As such we set it up
29+
// here the usual way.
30+
void SetUp() override { Debugger::Initialize(nullptr); }
31+
void TearDown() override { Debugger::Terminate(); }
2932
};
30-
} // namespace
33+
3134
TEST_F(ProgressReportTest, TestReportCreation) {
3235
std::chrono::milliseconds timeout(100);
3336

@@ -75,28 +78,23 @@ TEST_F(ProgressReportTest, TestReportCreation) {
7578

7679
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
7780
ASSERT_EQ(data->GetDetails(), "Starting report 3");
78-
79-
std::this_thread::sleep_for(timeout);
8081
}
8182

8283
// Progress report objects should be destroyed at this point so
8384
// get each report from the queue and check that they've been
8485
// destroyed in reverse order
85-
std::this_thread::sleep_for(timeout);
8686
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
8787
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
8888

8989
ASSERT_EQ(data->GetTitle(), "Progress report 3");
9090
ASSERT_TRUE(data->GetCompleted());
9191

92-
std::this_thread::sleep_for(timeout);
9392
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
9493
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
9594

9695
ASSERT_EQ(data->GetTitle(), "Progress report 2");
9796
ASSERT_TRUE(data->GetCompleted());
9897

99-
std::this_thread::sleep_for(timeout);
10098
EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
10199
data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
102100

0 commit comments

Comments
 (0)