diff options
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r-- | llvm/lib/Fuzzer/test/FuzzerUnittest.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Fuzzer/test/merge-summary.test | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/FuzzerUnittest.cpp b/llvm/lib/Fuzzer/test/FuzzerUnittest.cpp index 4992ef57b6c..5eb915a9162 100644 --- a/llvm/lib/Fuzzer/test/FuzzerUnittest.cpp +++ b/llvm/lib/Fuzzer/test/FuzzerUnittest.cpp @@ -14,6 +14,7 @@ #include "gtest/gtest.h" #include <memory> #include <set> +#include <sstream> using namespace fuzzer; @@ -636,7 +637,10 @@ static void Merge(const std::string &Input, Merger M; std::vector<std::string> NewFiles; EXPECT_TRUE(M.Parse(Input, true)); + std::stringstream SS; + M.PrintSummary(SS); EXPECT_EQ(NumNewFeatures, M.Merge(&NewFiles)); + EXPECT_EQ(M.AllFeatures(), M.ParseSummary(SS)); EQ(NewFiles, Result); } @@ -706,6 +710,16 @@ TEST(Merge, Good) { EQ(M.Files[2].Features, {1, 3, 6}); EXPECT_EQ(3U, M.Merge(&NewFiles)); EQ(NewFiles, {"B"}); + + // Same as the above, but with InitialFeatures. + EXPECT_TRUE(M.Parse("2\n0\nB\nC\n" + "STARTED 0 1001\nDONE 0 4 5 6 \n" + "STARTED 1 1002\nDONE 1 6 1 3\n" + "", true)); + EQ(M.Files[0].Features, {4, 5, 6}); + EQ(M.Files[1].Features, {1, 3, 6}); + EXPECT_EQ(3U, M.Merge({1, 2, 3}, &NewFiles)); + EQ(NewFiles, {"B"}); } TEST(Merge, Merge) { diff --git a/llvm/lib/Fuzzer/test/merge-summary.test b/llvm/lib/Fuzzer/test/merge-summary.test new file mode 100644 index 00000000000..df9d62dec63 --- /dev/null +++ b/llvm/lib/Fuzzer/test/merge-summary.test @@ -0,0 +1,15 @@ +RUN: rm -rf %t/T1 %t/T2 +RUN: mkdir -p %t/T0 %t/T1 %t/T2 +RUN: echo ...Z.. > %t/T2/1 +RUN: echo ....E. > %t/T2/2 +RUN: echo .....R > %t/T2/3 +RUN: echo F..... > %t/T2/a +RUN: echo .U.... > %t/T2/b +RUN: echo ..Z... > %t/T2/c + +RUN: LLVMFuzzer-FullCoverageSetTest -merge=1 %t/T1 %t/T2 -save_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=SAVE_SUMMARY +SAVE_SUMMARY: MERGE-OUTER: writing coverage summary for 6 files to {{.*}}SUMMARY +RUN: rm %t/T1/* +RUN: LLVMFuzzer-FullCoverageSetTest -merge=1 %t/T1 %t/T2 -load_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=LOAD_SUMMARY +LOAD_SUMMARY: MERGE-OUTER: coverage summary loaded from {{.*}}SUMMAR +LOAD_SUMMARY: MERGE-OUTER: 0 new files with 0 new features added |