[compiler-rt] 082d2ad - [libFuzzer] Improve corpus replacement unit test.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 26 08:09:29 PDT 2021
Author: Matt Morehouse
Date: 2021-10-26T08:09:11-07:00
New Revision: 082d2ad015bdc3c70768d02beba905489daa1c0e
URL: https://github.com/llvm/llvm-project/commit/082d2ad015bdc3c70768d02beba905489daa1c0e
DIFF: https://github.com/llvm/llvm-project/commit/082d2ad015bdc3c70768d02beba905489daa1c0e.diff
LOG: [libFuzzer] Improve corpus replacement unit test.
Verify that SecondII is not replaced.
Added:
Modified:
compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp b/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
index 7c6ecfb13687..5315a8ec0167 100644
--- a/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
+++ b/compiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
@@ -671,12 +671,12 @@ TEST(Corpus, Replace) {
/*TimeOfUnit*/ std::chrono::microseconds(5678),
/*FeatureSet*/ {}, DFT,
/*BaseII*/ nullptr);
- (void) SecondII;
Unit ReplacedU = Unit{0x03};
C->Replace(FirstII, ReplacedU,
/*TimeOfUnit*/ std::chrono::microseconds(321));
+ // FirstII should be replaced.
EXPECT_EQ(FirstII->U, Unit{0x03});
EXPECT_EQ(FirstII->Reduced, true);
EXPECT_EQ(FirstII->TimeOfUnit, std::chrono::microseconds(321));
@@ -684,6 +684,11 @@ TEST(Corpus, Replace) {
ComputeSHA1(ReplacedU.data(), ReplacedU.size(), ExpectedSha1.data());
std::vector<uint8_t> IISha1(FirstII->Sha1, FirstII->Sha1 + kSHA1NumBytes);
EXPECT_EQ(IISha1, ExpectedSha1);
+
+ // SecondII should not be replaced.
+ EXPECT_EQ(SecondII->U, Unit{0x02});
+ EXPECT_EQ(SecondII->Reduced, false);
+ EXPECT_EQ(SecondII->TimeOfUnit, std::chrono::microseconds(5678));
}
template <typename T>
More information about the llvm-commits
mailing list