llvm.org GIT mirror llvm / a204f09
[libFuzzer] make sure that -reduce_inputs=1 deletes redundant files in the corpus git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307875 91177308-0d34-0410-b5e6-96231b3b80d8 Kostya Serebryany 3 years ago
2 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
138138 }
139139
140140 void Replace(InputInfo *II, const Unit &U) {
141 assert(II->U.size());
142 Hashes.erase(Sha1ToString(II->Sha1));
143 DeleteFile(*II);
141144 ComputeSHA1(U.data(), U.size(), II->Sha1);
142145 Hashes.insert(Sha1ToString(II->Sha1));
143146 II->U = U;
181184 Printf("\n");
182185 }
183186
187 void DeleteFile(const InputInfo &II) {
188 if (!OutputCorpus.empty() && II.MayDeleteFile)
189 RemoveFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));
190 }
191
184192 void DeleteInput(size_t Idx) {
185193 InputInfo &II = *Inputs[Idx];
186 if (!OutputCorpus.empty() && II.MayDeleteFile)
187 RemoveFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));
194 DeleteFile(II);
188195 Unit().swap(II.U);
189196 if (FeatureDebug)
190197 Printf("EVICTED %zd\n", Idx);
0 # Test -reduce_inputs=1
1
2 RUN: rm -rf %t/C
3 RUN: mkdir -p %t/C
4 RUN: LLVMFuzzer-ShrinkControlFlowSimpleTest -exit_on_item=0eb8e4ed029b774d80f2b66408203801cb982a60 -reduce_inputs=1 -runs=1000000 %t/C 2>&1 | FileCheck %s
5 CHECK: INFO: found item with checksum '0eb8e4ed029b774d80f2b66408203801cb982a60'
1 RUN: LLVMFuzzer-ShrinkControlFlowSimpleTest -exit_on_item=0eb8e4ed029b774d80f2b66408203801cb982a60 -reduce_inputs=1 -runs=1000000 2>&1 | FileCheck %s
6
7 # Test that reduce_inputs deletes redundant files in the corpus.
8 RUN: LLVMFuzzer-ShrinkControlFlowSimpleTest -runs=0 %t/C 2>&1 | FileCheck %s --check-prefix=COUNT
9 COUNT: READ units: 3
10
11
12