Commit 86473746 authored by Mark Brand's avatar Mark Brand Committed by Commit Bot

MojoLPM: Refactor to remove fuzzer-specific Context.

This change cleans up the CodeCacheHost fuzzer, moving the per-testcase
code into the CodeCacheHostTestcase object and removing
CodeCacheHostFuzzerContext since this was redundant.

Bug: 1076336
Change-Id: I8736106edadb4a88c9d46a007ed5404fec6d4d4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2329571
Commit-Queue: Mark Brand <markbrand@google.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799623}
parent c411aa78
...@@ -22,14 +22,16 @@ Context::Storage::Storage() = default; ...@@ -22,14 +22,16 @@ Context::Storage::Storage() = default;
Context::Storage::~Storage() = default; Context::Storage::~Storage() = default;
void Context::StartTestcase( void Context::StartTestcase() {
TestcaseBase* testcase, DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
scoped_refptr<base::SequencedTaskRunner> task_runner) {
testcase_ = testcase;
task_runner_ = task_runner;
} }
void Context::EndTestcase() { void Context::EndTestcase() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Some fuzzers need to destroy the fuzzer thread along with their testcase,
// so we need to detach the sequence checker here so that it will be attached
// to the new sequence for the next testcase.
DETACH_FROM_SEQUENCE(sequence_checker_);
// We need to destroy all Remotes/Receivers before we start destroying other // We need to destroy all Remotes/Receivers before we start destroying other
// objects (like callbacks). // objects (like callbacks).
for (const TypeId& interface_type_id : interface_type_ids_) { for (const TypeId& interface_type_id : interface_type_ids_) {
...@@ -38,41 +40,13 @@ void Context::EndTestcase() { ...@@ -38,41 +40,13 @@ void Context::EndTestcase() {
instances_iter->second.clear(); instances_iter->second.clear();
} }
} }
interface_type_ids_.clear();
instances_.clear(); instances_.clear();
testcase_ = nullptr;
} }
bool Context::IsFinished() {
if (testcase_) {
return testcase_->IsFinished();
}
return true;
}
void Context::NextAction() {
// fprintf(stderr, "NextAction\n");
CHECK(task_runner_->RunsTasksInCurrentSequence());
if (testcase_) {
testcase_->NextAction();
}
}
void Context::PostNextAction() {
if (task_runner_) {
task_runner_->PostTask(FROM_HERE, base::BindOnce(&Context::NextAction,
base::Unretained(this)));
}
}
Context* g_context = nullptr;
Context* GetContext() { Context* GetContext() {
DCHECK(g_context); static base::NoDestructor<Context> context;
return g_context; return context.get();
}
void SetContext(Context* context) {
g_context = context;
} }
bool FromProto(const bool& input, bool& output) { bool FromProto(const bool& input, bool& output) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment