Consume result from various SampleRecorder methods. PiperOrigin-RevId: 897903309 Change-Id: I944031c84f2bcc6c116cef750ce789381b134467
diff --git a/absl/container/internal/hashtablez_sampler_test.cc b/absl/container/internal/hashtablez_sampler_test.cc index c313693..ae89c02 100644 --- a/absl/container/internal/hashtablez_sampler_test.cc +++ b/absl/container/internal/hashtablez_sampler_test.cc
@@ -63,9 +63,10 @@ std::vector<size_t> GetSizes(HashtablezSampler* s) { std::vector<size_t> res; - s->Iterate([&](const HashtablezInfo& info) { + EXPECT_EQ(s->Iterate([&](const HashtablezInfo& info) { res.push_back(info.size.load(std::memory_order_acquire)); - }); + }), + 0); return res; } @@ -359,19 +360,20 @@ info->hashes_bitwise_and.store(0x12345678, std::memory_order_relaxed); bool found = false; - sampler.Iterate([&](const HashtablezInfo& h) { + EXPECT_EQ(sampler.Iterate([&](const HashtablezInfo& h) { if (&h == info) { EXPECT_EQ(h.weight, test_stride); EXPECT_EQ(h.hashes_bitwise_and.load(), 0x12345678); found = true; } - }); + }), + 0); EXPECT_TRUE(found); h.Unregister(); h = HashtablezInfoHandle(); found = false; - sampler.Iterate([&](const HashtablezInfo& h) { + EXPECT_EQ(sampler.Iterate([&](const HashtablezInfo& h) { if (&h == info) { // this will only happen if some other thread has resurrected the info // the old handle was using. @@ -379,7 +381,8 @@ found = true; } } - }); + }), + 0); EXPECT_FALSE(found); } #endif @@ -465,9 +468,10 @@ } case 2: { absl::Duration oldest = absl::ZeroDuration(); - sampler.Iterate([&](const HashtablezInfo& info) { + EXPECT_EQ(sampler.Iterate([&](const HashtablezInfo& info) { oldest = std::max(oldest, absl::Now() - info.create_time); - }); + }), + 0); ASSERT_GE(oldest, absl::ZeroDuration()); break; }
diff --git a/absl/container/sample_element_size_test.cc b/absl/container/sample_element_size_test.cc index ccc616f..9ce19fe 100644 --- a/absl/container/sample_element_size_test.cc +++ b/absl/container/sample_element_size_test.cc
@@ -57,12 +57,13 @@ tables.back().insert(values.begin(), values.end()); } size_t new_count = 0; - sampler.Iterate([&](const HashtablezInfo& info) { + EXPECT_EQ(sampler.Iterate([&](const HashtablezInfo& info) { if (preexisting_info.insert(&info).second) { EXPECT_EQ(info.inline_element_size, expected_element_size); ++new_count; } - }); + }), + 0); // Make sure we actually did get a new hashtablez. EXPECT_GT(new_count, 0); } @@ -99,8 +100,10 @@ // cannot be a flat_hash_set, however, since that would introduce a mutex // deadlock. std::unordered_set<const HashtablezInfo*> preexisting_info; // NOLINT - sampler.Iterate( - [&](const HashtablezInfo& info) { preexisting_info.insert(&info); }); + EXPECT_EQ(sampler.Iterate([&](const HashtablezInfo& info) { + preexisting_info.insert(&info); + }), + 0); TestInlineElementSize(sampler, preexisting_info, flat_map_tables, map_values, sizeof(int) + sizeof(bigstruct)); TestInlineElementSize(sampler, preexisting_info, node_map_tables, map_values,
diff --git a/absl/profiling/internal/sample_recorder_test.cc b/absl/profiling/internal/sample_recorder_test.cc index a037f9d..31c72ed 100644 --- a/absl/profiling/internal/sample_recorder_test.cc +++ b/absl/profiling/internal/sample_recorder_test.cc
@@ -49,15 +49,17 @@ std::vector<size_t> GetSizes(SampleRecorder<Info>* s) { std::vector<size_t> res; - s->Iterate([&](const Info& info) { + EXPECT_EQ(s->Iterate([&](const Info& info) { res.push_back(info.size.load(std::memory_order_acquire)); - }); + }), + 0); return res; } std::vector<int64_t> GetWeights(SampleRecorder<Info>* s) { std::vector<int64_t> res; - s->Iterate([&](const Info& info) { res.push_back(info.weight); }); + EXPECT_EQ(s->Iterate([&](const Info& info) { res.push_back(info.weight); }), + 0); return res; } @@ -141,9 +143,10 @@ } case 2: { absl::Duration oldest = absl::ZeroDuration(); - sampler.Iterate([&](const Info& info) { + EXPECT_EQ(sampler.Iterate([&](const Info& info) { oldest = std::max(oldest, absl::Now() - info.create_time); - }); + }), + 0); ASSERT_GE(oldest, absl::ZeroDuration()); break; }