Double added reclaimers need not be called (#28378)

pull/28388/head
Craig Tiller 3 years ago committed by GitHub
parent f109a4bce4
commit 7d6000082a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      test/core/resource_quota/call_checker.h
  2. 2
      test/core/resource_quota/memory_quota_fuzzer.cc
  3. 32
      test/core/resource_quota/memory_quota_fuzzer_corpus/bad-reclaim

@ -31,7 +31,10 @@ namespace testing {
// Will crash if: f never called, or f called more than once.
class CallChecker {
public:
~CallChecker() { GPR_ASSERT(called_); }
explicit CallChecker(bool optional) : optional_(optional) {}
~CallChecker() {
if (!optional_) GPR_ASSERT(called_);
}
void Called() {
GPR_ASSERT(!called_);
@ -39,11 +42,16 @@ class CallChecker {
}
static std::shared_ptr<CallChecker> Make() {
return std::make_shared<CallChecker>();
return std::make_shared<CallChecker>(false);
}
static std::shared_ptr<CallChecker> MakeOptional() {
return std::make_shared<CallChecker>(true);
}
private:
bool called_ = false;
const bool optional_ = false;
};
} // namespace testing

@ -134,7 +134,7 @@ class Fuzzer {
WithAllocator(
action.allocator(), [pass, reclaimer](MemoryOwner* a) {
// ensure called exactly once
auto call_checker = CallChecker::Make();
auto call_checker = CallChecker::MakeOptional();
a->PostReclaimer(pass,
[reclaimer, call_checker](
absl::optional<ReclamationSweep> sweep) {

@ -0,0 +1,32 @@
actions {
create_quota {}
}
actions {
create_allocator {}
}
actions {
set_quota_size: 0
}
actions {
post_reclaimer {}
}
actions {
delete_allocator {}
}
actions {
flush_exec_ctx {}
}
actions {
allocator: 111
create_allocator {}
}
actions {
allocator: 111
post_reclaimer {}
}
actions {
create_allocator {}
}
actions {
post_reclaimer {}
}
Loading…
Cancel
Save