[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 29 23:11:28 PST 2024
================
@@ -0,0 +1,125 @@
+//===-- ProgressReportTest.cpp --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "TestingSupport/SubsystemRAII.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;
+
+class ProgressReportTest : public ::testing::Test {
+ SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
+
+ // The debugger's initialization function can't be called with no arguments
+ // so calling it using SubsystemRAII will cause the test build to fail as
+ // SubsystemRAII will call Initialize with no arguments. As such we set it up
+ // here the usual way.
+ void SetUp() override { Debugger::Initialize(nullptr); }
+ void TearDown() override { Debugger::Terminate(); }
+};
+
+TEST_F(ProgressReportTest, TestReportCreation) {
+ std::chrono::milliseconds timeout(100);
+ const unsigned long long NO_TOTAL = 1;
----------------
clayborg wrote:
We should define this in Progress class:
```
class Progress {
constexpr uint64_t NO_TOTAL = UINT64_MAX;
```
UINT64_MAX is better than 1 because someone might actually create a valid finite progress with only 1 item.
https://github.com/llvm/llvm-project/pull/79533
More information about the lldb-commits
mailing list