[Lldb-commits] [lldb] [lldb] Add ability to rate-limit progress reports (PR #119377)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 13 05:51:47 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");
----------------
labath wrote:
It should. Thanks for catching that.
https://github.com/llvm/llvm-project/pull/119377
More information about the lldb-commits
mailing list