@@ -86,7 +86,7 @@ class CentipedeMock : public CentipedeCallbacks {
8686 // i-th element is the number of bytes with the value 'i' in the input.
8787 // `counters` is converted to FeatureVec and added to
8888 // `batch_result.results()`.
89- for (auto & input : inputs) {
89+ for (auto & input : inputs) {
9090 ByteArray counters (256 );
9191 for (uint8_t byte : input) {
9292 counters[byte]++;
@@ -496,7 +496,7 @@ TEST_F(CentipedeWithTemporaryLocalDir, MutateViaExternalBinary) {
496496 // Must contain normal mutants, but not the ones from crossover.
497497 const auto mutant_data = GetDataFromMutants (result.mutants ());
498498 EXPECT_THAT (mutant_data, IsSupersetOf (some_of_expected_mutants));
499- for (const auto & crossover_mutant : expected_crossover_mutants) {
499+ for (const auto & crossover_mutant : expected_crossover_mutants) {
500500 EXPECT_THAT (mutant_data, Not (Contains (crossover_mutant)));
501501 }
502502 }
@@ -525,7 +525,7 @@ class MergeMock : public CentipedeCallbacks {
525525 std::vector<Mutant> Mutate (absl::Span<const MutationInputRef> inputs,
526526 size_t num_mutants) override {
527527 std::vector<Mutant> mutants (num_mutants);
528- for (auto & mutant : mutants) {
528+ for (auto & mutant : mutants) {
529529 mutant.data .resize (1 );
530530 mutant.data [0 ] = ++number_of_mutations_;
531531 mutant.origin = Mutant::kOriginNone ;
@@ -611,7 +611,7 @@ class FunctionFilterMock : public CentipedeCallbacks {
611611 // Sets the inputs to one of 3 pre-defined values.
612612 std::vector<Mutant> Mutate (absl::Span<const MutationInputRef> inputs,
613613 size_t num_mutants) override {
614- for (auto & input : inputs) {
614+ for (auto & input : inputs) {
615615 if (!seed_inputs_.contains (input.data )) {
616616 observed_inputs_.insert (input.data );
617617 }
@@ -628,8 +628,8 @@ class FunctionFilterMock : public CentipedeCallbacks {
628628 // Returns one of 3 pre-defined values, that trigger different code paths in
629629 // the test target.
630630 static ByteArray GetMutant (size_t idx) {
631- const char * mutants[3 ] = {" func1" , " func2-A" , " foo" };
632- const char * mutant = mutants[idx % 3 ];
631+ const char * mutants[3 ] = {" func1" , " func2-A" , " foo" };
632+ const char * mutant = mutants[idx % 3 ];
633633 return {mutant, mutant + strlen (mutant)};
634634 }
635635
@@ -646,7 +646,7 @@ class FunctionFilterMock : public CentipedeCallbacks {
646646// Runs a short fuzzing session with the provided `function_filter`.
647647// Returns a sorted array of observed inputs.
648648static std::vector<ByteArray> RunWithFunctionFilter (
649- std::string_view function_filter, const TempDir & tmp_dir) {
649+ std::string_view function_filter, const TempDir& tmp_dir) {
650650 Environment env;
651651 env.workdir = tmp_dir.path ();
652652 env.seed = 1 ; // make the runs predictable.
@@ -717,9 +717,9 @@ class ExtraBinariesMock : public CentipedeCallbacks {
717717 bool Execute (std::string_view binary, absl::Span<const ByteSpan> inputs,
718718 BatchResult& batch_result) override {
719719 bool res = true ;
720- for (const auto & input : inputs) {
720+ for (const auto & input : inputs) {
721721 if (input.size () != 1 ) continue ;
722- for (const Crash & crash : crashes_) {
722+ for (const Crash& crash : crashes_) {
723723 if (binary == crash.binary && input[0 ] == crash.input ) {
724724 batch_result.exit_code () = EXIT_FAILURE ;
725725 batch_result.failure_description () = crash.description ;
@@ -736,7 +736,7 @@ class ExtraBinariesMock : public CentipedeCallbacks {
736736 std::vector<Mutant> Mutate (absl::Span<const MutationInputRef> inputs,
737737 size_t num_mutants) override {
738738 std::vector<Mutant> mutants (num_mutants);
739- for (auto & mutant : mutants) {
739+ for (auto & mutant : mutants) {
740740 mutant.data .resize (1 );
741741 mutant.data [0 ] = ++number_of_mutations_;
742742 mutant.origin = Mutant::kOriginNone ;
@@ -754,20 +754,20 @@ struct FileAndContents {
754754 std::string file;
755755 std::string contents;
756756
757- bool operator ==(const FileAndContents & other) const {
757+ bool operator ==(const FileAndContents& other) const {
758758 return file == other.file && contents == other.contents ;
759759 }
760760
761761 template <typename Sink>
762- friend void AbslStringify (Sink & sink, const FileAndContents & f) {
762+ friend void AbslStringify (Sink& sink, const FileAndContents& f) {
763763 absl::Format (&sink, " FileAndContents{%s, \" %s\" }" , f.file , f.contents );
764764 }
765765};
766766
767767MATCHER_P (HasFilesWithContents, expected_files_and_contents, " " ) {
768- const std::string & dir_path = arg;
768+ const std::string& dir_path = arg;
769769 std::vector<FileAndContents> files_and_contents;
770- for (const auto & dir_ent : std::filesystem::directory_iterator (dir_path)) {
770+ for (const auto & dir_ent : std::filesystem::directory_iterator (dir_path)) {
771771 auto file_and_contents = FileAndContents{dir_ent.path ().filename ()};
772772 ReadFromLocalFile (dir_ent.path ().c_str (), file_and_contents.contents );
773773 files_and_contents.push_back (std::move (file_and_contents));
@@ -843,7 +843,7 @@ class UndetectedCrashingInputMock : public CentipedeCallbacks {
843843 if (!first_pass_) {
844844 num_inputs_triaged_ += inputs.size ();
845845 }
846- for (const auto & input : inputs) {
846+ for (const auto & input : inputs) {
847847 FUZZTEST_CHECK_EQ (input.size (), 1 ); // By construction in `Mutate()`.
848848 // The contents of each mutant is its sequential number.
849849 if (input[0 ] == crashing_input_idx_) {
@@ -933,7 +933,7 @@ TEST(Centipede, UndetectedCrashingInput) {
933933 absl::StrCat (" crashing_batch-" , crashing_input_hash);
934934 EXPECT_TRUE (std::filesystem::exists (crashes_dir_path)) << crashes_dir_path;
935935 std::vector<std::string> found_crash_file_names;
936- for (auto const & dir_ent :
936+ for (auto const & dir_ent :
937937 std::filesystem::directory_iterator (crashes_dir_path)) {
938938 found_crash_file_names.push_back (dir_ent.path ().filename ());
939939 }
@@ -963,14 +963,8 @@ TEST_F(CentipedeWithTemporaryLocalDir, GetsSeedInputs) {
963963 CentipedeDefaultCallbacks callbacks (env, stop_condition);
964964
965965 std::vector<ByteArray> seeds;
966- EXPECT_EQ (callbacks.GetSeeds (10 , seeds), 10 );
967- EXPECT_THAT (seeds, testing::ContainerEq (std::vector<ByteArray>{
968- {0 }, {1 }, {2 }, {3 }, {4 }, {5 }, {6 }, {7 }, {8 }, {9 }}));
969- EXPECT_EQ (callbacks.GetSeeds (5 , seeds), 10 );
970- EXPECT_THAT (seeds, testing::ContainerEq (
971- std::vector<ByteArray>{{0 }, {1 }, {2 }, {3 }, {4 }}));
972- EXPECT_EQ (callbacks.GetSeeds (100 , seeds), 10 );
973- EXPECT_THAT (seeds, testing::ContainerEq (std::vector<ByteArray>{
966+ callbacks.GetSeeds (10 , seeds);
967+ EXPECT_THAT (seeds, testing::IsSupersetOf (std::vector<ByteArray>{
974968 {0 }, {1 }, {2 }, {3 }, {4 }, {5 }, {6 }, {7 }, {8 }, {9 }}));
975969}
976970
@@ -1400,8 +1394,9 @@ TEST_F(CentipedeWithTemporaryLocalDir, EngineWorksInWorkerMode) {
14001394 env.test_name = " some_test" ;
14011395 env.populate_binary_info = false ;
14021396 env.fork_server = false ;
1403- env.persistent_mode = false ;
1397+ env.persistent_mode = true ;
14041398 env.exit_on_crash = true ;
1399+ env.stop_at = absl::Now () + absl::Seconds (10 );
14051400 fuzztest::internal::DefaultCallbacksFactory<
14061401 fuzztest::internal::CentipedeDefaultCallbacks>
14071402 callbacks;
0 commit comments