Extend the cmp tracing entry size to 128. This would make it the same as the legacy FuzzTest. PiperOrigin-RevId: 881473331
diff --git a/centipede/byte_array_mutator.h b/centipede/byte_array_mutator.h index 349ed48..fae36f3 100644 --- a/centipede/byte_array_mutator.h +++ b/centipede/byte_array_mutator.h
@@ -34,7 +34,7 @@ // A simple class representing an array of up to kMaxEntrySize bytes. class DictEntry { public: - static constexpr uint8_t kMaxEntrySize = 16; + static constexpr uint8_t kMaxEntrySize = 128; explicit DictEntry(ByteSpan bytes) : bytes_{}, // initialize bytes_ to all zeros
diff --git a/centipede/byte_array_mutator_test.cc b/centipede/byte_array_mutator_test.cc index abc96b5..e28dff3 100644 --- a/centipede/byte_array_mutator_test.cc +++ b/centipede/byte_array_mutator_test.cc
@@ -18,6 +18,7 @@ #include <cstdint> #include <cstring> #include <limits> +#include <numeric> #include <vector> #include "gmock/gmock.h" @@ -93,8 +94,9 @@ namespace { TEST(DictEntry, DictEntry) { - uint8_t bytes[17] = {0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16}; + uint8_t bytes[129]; + std::iota(bytes, bytes + 129, 0); + DictEntry a_0_10({bytes + 0, 10}); DictEntry a_0_4({bytes + 0, 4}); DictEntry a_1_8({bytes + 1, 8}); @@ -103,7 +105,7 @@ EXPECT_LT(a_0_10, a_1_8); EXPECT_EQ(memcmp(a_0_10.begin(), bytes, a_0_10.end() - a_0_10.begin()), 0); - EXPECT_DEATH({ DictEntry a_0_10({bytes, 17}); }, ""); + EXPECT_DEATH({ DictEntry a_0_10({bytes, 129}); }, ""); } TEST(CmpDictionary, CmpDictionary) { @@ -162,7 +164,7 @@ traceN.Clear(); constexpr uint8_t long_array[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; - traceN.Capture(20, long_array, long_array); // will be trimmed to 16. + traceN.Capture(20, long_array, long_array); ExecutionMetadata metadata; bool append_failed = false;
diff --git a/centipede/fuzztest_mutator.cc b/centipede/fuzztest_mutator.cc index 57261cb..1af4e17 100644 --- a/centipede/fuzztest_mutator.cc +++ b/centipede/fuzztest_mutator.cc
@@ -67,7 +67,7 @@ void PopulateCmpEntries(const ExecutionMetadata& metadata, TablesOfRecentCompares& cmp_tables) { // Size limits on the cmp entries to be populated. - static constexpr uint8_t kMaxCmpEntrySize = 15; + static constexpr uint8_t kMaxCmpEntrySize = 128; static constexpr uint8_t kMinCmpEntrySize = 2; size_t uint16_sample_counter = 0; size_t uint32_sample_counter = 0;
diff --git a/centipede/fuzztest_mutator_test.cc b/centipede/fuzztest_mutator_test.cc index 6c4d747..a732bca 100644 --- a/centipede/fuzztest_mutator_test.cc +++ b/centipede/fuzztest_mutator_test.cc
@@ -285,22 +285,34 @@ INSTANTIATE_TEST_SUITE_P(SkipsLongCmpEntry, MutationStepTest, Values([] { MutationStepTestParameter params; params.seed_input = {0}; + ByteArray short_entry; + for (size_t i = 0; i < 5; ++i) { + short_entry.push_back(i); + } params.expected_mutants = { - {0, 1, 2, 3, 4}, + short_entry, }; + ByteArray long_entry; + for (size_t i = 0; i < 129; ++i) { + long_entry.push_back(i); + } params.unexpected_mutants = { - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, + long_entry, }; - params.cmp_data = { - 20, // size - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, // lhs - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, // rhs - 4, // size - 1, 2, 3, 4, // lhs - 1, 2, 3, 4}; // rhs + params.cmp_data.push_back(short_entry.size()); + params.cmp_data.insert(params.cmp_data.end(), + short_entry.begin(), + short_entry.end()); // lhs + params.cmp_data.insert(params.cmp_data.end(), + short_entry.begin(), + short_entry.end()); // rhs + params.cmp_data.push_back(long_entry.size()); + params.cmp_data.insert(params.cmp_data.end(), + long_entry.begin(), + long_entry.end()); // lhs + params.cmp_data.insert(params.cmp_data.end(), + long_entry.begin(), + long_entry.end()); // rhs return params; }()));
diff --git a/centipede/runner_cmp_trace.h b/centipede/runner_cmp_trace.h index 7267950..32f081a 100644 --- a/centipede/runner_cmp_trace.h +++ b/centipede/runner_cmp_trace.h
@@ -43,7 +43,7 @@ class CmpTrace { public: // kMaxNumBytesPerValue does not depend on kFixedSize. - static constexpr size_t kMaxNumBytesPerValue = 16; + static constexpr size_t kMaxNumBytesPerValue = 128; static constexpr size_t kNumBytesPerValue = kFixedSize ? kFixedSize : kMaxNumBytesPerValue;
diff --git a/centipede/runner_cmp_trace_test.cc b/centipede/runner_cmp_trace_test.cc index 04d20ca..ade09d4 100644 --- a/centipede/runner_cmp_trace_test.cc +++ b/centipede/runner_cmp_trace_test.cc
@@ -16,6 +16,7 @@ #include <cstddef> #include <cstdint> +#include <numeric> #include <vector> #include "gmock/gmock.h" @@ -102,12 +103,12 @@ constexpr uint8_t value0[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; constexpr uint8_t value1[10] = {0, 9, 8, 7, 6, 5, 4, 3, 2, 1}; - constexpr uint8_t long_array[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; + uint8_t long_array[129]; + std::iota(long_array, long_array + 129, 0); traceN.Capture(7, value0, value1); traceN.Capture(3, value0, value1); traceN.Capture(10, value0, value1); - traceN.Capture(20, long_array, long_array); // will be trimmed to 16. + traceN.Capture(129, long_array, long_array); // will be trimmed to 128. observed_pairs.clear(); traceN.ForEachNonZero(callback); EXPECT_THAT(observed_pairs, @@ -115,7 +116,7 @@ TwoArraysToByteVector(value0, value1, 10), TwoArraysToByteVector(value0, value1, 7), TwoArraysToByteVector(value0, value1, 3), - TwoArraysToByteVector(long_array, long_array, 16))); + TwoArraysToByteVector(long_array, long_array, 128))); } } // namespace