39
39
namespace fuzztest ::internal {
40
40
namespace {
41
41
42
+ using ::testing::Contains;
42
43
using ::testing::ContainsRegex;
43
44
using ::testing::Eq;
44
45
using ::testing::HasSubstr;
@@ -101,9 +102,9 @@ class UpdateCorpusDatabaseTest
101
102
102
103
static void TearDownTestSuite () { run_map_->clear (); }
103
104
104
- static std::string GetCorpusDatabasePath () {
105
+ static std::string UpdateCorpusDatabaseAndGetPath () {
105
106
RunUpdateCorpusDatabase ();
106
- return (*run_map_)[ GetParam ()]. workspace -> path () / " corpus_database " ;
107
+ return GetCorpusDatabasePath () ;
107
108
}
108
109
109
110
static absl::string_view GetUpdateCorpusDatabaseStdErr () {
@@ -149,6 +150,10 @@ class UpdateCorpusDatabaseTest
149
150
}
150
151
151
152
private:
153
+ static std::string GetCorpusDatabasePath () {
154
+ return (*run_map_)[GetParam ()].workspace ->path () / " corpus_database" ;
155
+ }
156
+
152
157
static absl::NoDestructor<
153
158
absl::flat_hash_map<ExecutionModelParam, UpdateCorpusDatabaseRun>>
154
159
run_map_;
@@ -184,6 +189,12 @@ TEST_P(UpdateCorpusDatabaseTest, FindsAllCrashes) {
184
189
<< std_err;
185
190
}
186
191
192
+ TEST_P (UpdateCorpusDatabaseTest, DeduplicatesCrashes) {
193
+ EXPECT_THAT (
194
+ ListDirectoryRecursively (UpdateCorpusDatabaseAndGetPath ()),
195
+ Contains (HasSubstr (" FuzzTest.FailsInTwoWays/crashing/" )).Times (2 ));
196
+ }
197
+
187
198
TEST_P (UpdateCorpusDatabaseTest, StartsNewFuzzTestRunsWithoutExecutionIds) {
188
199
TempDir corpus_database;
189
200
@@ -331,9 +342,10 @@ TEST_P(UpdateCorpusDatabaseTest,
331
342
332
343
TEST_P (UpdateCorpusDatabaseTest, ReplaysFuzzTestsInParallel) {
333
344
RunOptions run_options;
334
- run_options.fuzztest_flags = {{" corpus_database" , GetCorpusDatabasePath ()},
335
- {" replay_corpus_for" , " inf" },
336
- {" jobs" , " 2" }};
345
+ run_options.fuzztest_flags = {
346
+ {" corpus_database" , UpdateCorpusDatabaseAndGetPath ()},
347
+ {" replay_corpus_for" , " inf" },
348
+ {" jobs" , " 2" }};
337
349
run_options.timeout = absl::Seconds (30 );
338
350
auto [status, std_out, std_err] = RunBinaryMaybeWithCentipede (
339
351
GetCorpusDatabaseTestingBinaryPath (), run_options);
@@ -347,8 +359,9 @@ TEST_P(UpdateCorpusDatabaseTest, ReplaysFuzzTestsInParallel) {
347
359
348
360
TEST_P (UpdateCorpusDatabaseTest, PrintsErrorsWhenBazelTimeoutIsNotEnough) {
349
361
RunOptions run_options;
350
- run_options.fuzztest_flags = {{" corpus_database" , GetCorpusDatabasePath ()},
351
- {" fuzz_for" , " 20s" }};
362
+ run_options.fuzztest_flags = {
363
+ {" corpus_database" , UpdateCorpusDatabaseAndGetPath ()},
364
+ {" fuzz_for" , " 20s" }};
352
365
run_options.env = {{" TEST_TIMEOUT" , " 30" }};
353
366
run_options.timeout = absl::Seconds (60 );
354
367
auto [status, std_out, std_err] = RunBinaryMaybeWithCentipede (
0 commit comments