[Lldb-commits] [lldb] [lldb] Add ability to rate-limit progress reports (PR #119377)
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 10 14:28:34 PST 2024
================
@@ -208,6 +209,110 @@ TEST_F(ProgressReportTest, TestReportDestructionWithPartialProgress) {
EXPECT_EQ(data->GetMessage(), "Infinite progress: Report 2");
}
+TEST_F(ProgressReportTest, TestFiniteOverflow) {
+ ListenerSP listener_sp = CreateListenerFor(lldb::eBroadcastBitProgress);
+ EventSP event_sp;
+ const ProgressEventData *data;
+
+ // Increment the report beyond its limit and make sure we only get one
+ // completed event.
+ {
+ Progress progress("Finite progress", "Report 1", 10);
+ progress.Increment(11);
+ progress.Increment(47);
+ }
+
+ ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT));
+ data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ EXPECT_TRUE(data->IsFinite());
+ EXPECT_EQ(data->GetCompleted(), 0);
+ EXPECT_EQ(data->GetTotal(), 10);
+
+ ASSERT_TRUE(listener_sp->GetEvent(event_sp, TIMEOUT));
+ data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ EXPECT_TRUE(data->IsFinite());
+ EXPECT_EQ(data->GetCompleted(), 10);
+ EXPECT_EQ(data->GetTotal(), 10);
+
+ ASSERT_FALSE(listener_sp->GetEvent(event_sp, TIMEOUT));
+}
+
+TEST_F(ProgressReportTest, TestNonDeterministicOverflow) {
+ ListenerSP listener_sp = CreateListenerFor(lldb::eBroadcastBitProgress);
+ EventSP event_sp;
+ const ProgressEventData *data;
+ constexpr uint64_t max_minus_1 = std::numeric_limits<uint64_t>::max() - 1;
+
+ // Increment the report beyond its limit and make sure we only get one
+ // completed event. The event which overflows the counter should be ignored.
+ {
+ Progress progress("Finite progress", "Report 1");
----------------
chelcassanova wrote:
Super tiny nit: should this be "non-deterministic progress" or something of the sort since we don't have a total set here?
https://github.com/llvm/llvm-project/pull/119377
More information about the lldb-commits
mailing list