[compiler-rt] ac51289 - [libFuzzer] Deflake entropic exec-time test.

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Mon May 3 10:38:04 PDT 2021


Author: Matt Morehouse
Date: 2021-05-03T10:37:44-07:00
New Revision: ac512890b47032fcee167a702ab14da59137723c

URL: https://github.com/llvm/llvm-project/commit/ac512890b47032fcee167a702ab14da59137723c
DIFF: https://github.com/llvm/llvm-project/commit/ac512890b47032fcee167a702ab14da59137723c.diff

LOG: [libFuzzer] Deflake entropic exec-time test.

Added: 
    

Modified: 
    compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp
    compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp b/compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp
index ec3a6906d3886..0cab7b7035f95 100644
--- a/compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp
+++ b/compiler-rt/test/fuzzer/EntropicScalePerExecTimeTest.cpp
@@ -19,11 +19,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size > 10)
     return 0; // To make the test quicker.
 
-  if (Size == 10) {
+  if (Size != 2) {
+    // execute a lot slower than the crashing input below.
     size_t ExecTimeUSec = 100;
     std::this_thread::sleep_for(std::chrono::microseconds(ExecTimeUSec));
-
-    Sink = 0; // execute a lot slower than the crashing input below.
+    if (Size > 0 && Data[0] == 0xaa && Size > 1 && Data[1] == 0xbb &&
+        Size > 2 && Data[2] == 0xcc && Size > 3 && Data[3] == 0xdd &&
+        Size > 4 && Data[4] == 0xee && Size > 5 && Data[5] == 0xff)
+      Sink += 7;
   }
 
   if (Size == 2 && Data[0] == 0xab && Data[1] == 0xcd)

diff  --git a/compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test b/compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test
index d34550f9c951f..2b8fec98a7b08 100644
--- a/compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test
+++ b/compiler-rt/test/fuzzer/entropic-scale-per-exec-time.test
@@ -1,8 +1,7 @@
 REQUIRES: linux, x86_64
 RUN: %cpp_compiler %S/EntropicScalePerExecTimeTest.cpp -o %t-EntropicScalePerExecTimeTest
-RUN: not %run %t-EntropicScalePerExecTimeTest -entropic=1 -entropic_scale_per_exec_time=1 -seed=1 -runs=100000 -max_len=10
+RUN: not %run %t-EntropicScalePerExecTimeTest -entropic=1 -entropic_scale_per_exec_time=1 -seed=1 -runs=150000 -max_len=10
 
-# The following test is added as a comment here for reference, which should
-# take more runs than with -entropic_scale_per_exec_time=1 to find the crash.
-# (it takes 126,633 runs)
-# RUN: not %run %t-EntropicScalePerExecTimeTest -entropic=1 -seed=1 -runs=200000 -max_len=10
+# Without -entropic_scale_per_exec_time=1, the crash takes longer to find since
+# the slow path is explored first.
+RUN: %run %t-EntropicScalePerExecTimeTest -entropic=1 -seed=1 -runs=150000 -max_len=10


        


More information about the llvm-commits mailing list