|
| 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 | + |
1 | 9 | #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
|
2 | 10 | #include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
|
| 11 | +#include "TestingSupport/SubsystemRAII.h" |
3 | 12 | #include "lldb/Core/Debugger.h"
|
4 | 13 | #include "lldb/Core/Progress.h"
|
5 | 14 | #include "lldb/Host/FileSystem.h"
|
|
11 | 20 | using namespace lldb;
|
12 | 21 | using namespace lldb_private;
|
13 | 22 |
|
14 |
| -namespace { |
15 | 23 | 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(); } |
29 | 32 | };
|
30 |
| -} // namespace |
| 33 | + |
31 | 34 | TEST_F(ProgressReportTest, TestReportCreation) {
|
32 | 35 | std::chrono::milliseconds timeout(100);
|
33 | 36 |
|
@@ -75,28 +78,23 @@ TEST_F(ProgressReportTest, TestReportCreation) {
|
75 | 78 |
|
76 | 79 | data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
|
77 | 80 | ASSERT_EQ(data->GetDetails(), "Starting report 3");
|
78 |
| - |
79 |
| - std::this_thread::sleep_for(timeout); |
80 | 81 | }
|
81 | 82 |
|
82 | 83 | // Progress report objects should be destroyed at this point so
|
83 | 84 | // get each report from the queue and check that they've been
|
84 | 85 | // destroyed in reverse order
|
85 |
| - std::this_thread::sleep_for(timeout); |
86 | 86 | EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
|
87 | 87 | data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
|
88 | 88 |
|
89 | 89 | ASSERT_EQ(data->GetTitle(), "Progress report 3");
|
90 | 90 | ASSERT_TRUE(data->GetCompleted());
|
91 | 91 |
|
92 |
| - std::this_thread::sleep_for(timeout); |
93 | 92 | EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
|
94 | 93 | data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
|
95 | 94 |
|
96 | 95 | ASSERT_EQ(data->GetTitle(), "Progress report 2");
|
97 | 96 | ASSERT_TRUE(data->GetCompleted());
|
98 | 97 |
|
99 |
| - std::this_thread::sleep_for(timeout); |
100 | 98 | EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
|
101 | 99 | data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
|
102 | 100 |
|
|
0 commit comments