-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a flag that forces failure on issues with the custom mutator.
With this flag, we no longer need to perform the "domain setup check" as part of executing an input. The check happens implicitly during mutation. If the mutation fails, either due to an ineffective domain or other reasons, Centipede itself fails. PiperOrigin-RevId: 726191912
- Loading branch information
1 parent
1d61720
commit 705bcad
Showing
9 changed files
with
264 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2025 The Centipede Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <cstdlib> | ||
#include <cstring> | ||
#include <functional> | ||
#include <vector> | ||
|
||
#include "absl/base/nullability.h" | ||
#include "./centipede/mutation_input.h" | ||
#include "./centipede/runner_interface.h" | ||
#include "./common/defs.h" | ||
|
||
using ::centipede::ByteSpan; | ||
|
||
class CustomMutatorRunnerCallbacks : public centipede::RunnerCallbacks { | ||
public: | ||
bool Execute(ByteSpan input) override { return true; } | ||
|
||
bool Mutate(const std::vector<centipede::MutationInputRef>& inputs, | ||
size_t num_mutants, | ||
std::function<void(ByteSpan)> new_mutant_callback) override { | ||
size_t i = 0; | ||
for (centipede::MutationInputRef input : inputs) { | ||
if (i++ >= num_mutants) break; | ||
// Just return the original input as a mutant. | ||
new_mutant_callback(input.data); | ||
} | ||
return true; | ||
} | ||
}; | ||
|
||
int main(int argc, absl::Nonnull<char**> argv) { | ||
if (argc >= 2 && std::strcmp(argv[1], "--simulate_failure") == 0) { | ||
return EXIT_FAILURE; | ||
} | ||
CustomMutatorRunnerCallbacks runner_callbacks; | ||
return centipede::RunnerMain(argc, argv, runner_callbacks); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters