================ @@ -0,0 +1,105 @@ +#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/Progress.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Utility/Listener.h" +#include "gtest/gtest.h" +#include <thread> + +using namespace lldb; +using namespace lldb_private; + +namespace { +class ProgressReportTest : public ::testing::Test { +public: + void SetUp() override { + FileSystem::Initialize(); + HostInfo::Initialize(); + PlatformMacOSX::Initialize(); + Debugger::Initialize(nullptr); + } + void TearDown() override { + Debugger::Terminate(); + PlatformMacOSX::Terminate(); + HostInfo::Terminate(); + FileSystem::Terminate(); + } +}; +} // namespace +TEST_F(ProgressReportTest, TestReportCreation) { + std::chrono::milliseconds timeout(100); + + // Set up the debugger, make sure that was done properly + ArchSpec arch("x86_64-apple-macosx-"); + Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch)); + + DebuggerSP debugger_sp = Debugger::CreateInstance(); + ASSERT_TRUE(debugger_sp); + + // Get the debugger's broadcaster + Broadcaster &broadcaster = debugger_sp->GetBroadcaster(); + + // Create a listener, make sure it can receive events and that it's + // listening to the correct broadcast bit + ListenerSP listener_sp = Listener::MakeListener("progress-listener"); + + listener_sp->StartListeningForEvents(&broadcaster, + Debugger::eBroadcastBitProgress); + EXPECT_TRUE( + broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress)); + + EventSP event_sp; + const ProgressEventData *data; + + // Scope this for RAII on the progress objects + // Create progress reports and check that their respective events for having + // started are broadcasted + { + Progress progress1("Progress report 1", "Starting report 1"); + EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout)); + + data = ProgressEventData::GetEventDataFromEvent(event_sp.get()); + ASSERT_EQ(data->GetDetails(), "Starting report 1"); ---------------- clayborg wrote:
It would be good to verify a few more things here for each start event: ``` ASSERT_FALSE(data->IsFinite()); ASSERT_FALSE(data->GetCompleted()); ASSERT_EQ(data->GetTotal(), 1); ASSERT_EQ(data->GetMessage(), "Progress report 1: Starting report 1"); ``` https://github.com/llvm/llvm-project/pull/79533 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits