Skip to content

Commit 00f14cc

Browse files
Log shrinking status (#1454)
* Add cli option to include shrinking status in status lines A worker event is also logged showing the shrinking operation and the sequence length before and after each successful step. * Add `logShrinking` flag to `default.yaml` * Remove last shrinking op from status line * Always display shrinking info in status line * Comment cleanup * Remove shrinking step log and `logShrinking` flag * Compute status line reproducer length on demand * Log per-worker shrinking status * Display shrinking status when shrinking and active shrinking workers data
1 parent b314059 commit 00f14cc

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/Echidna/Shrink.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ shrinkSeq vm f v txs = do
103103
-- check if the sequence still triggers a failed transaction
104104
(value, vm') <- check txs'' vm
105105
-- if the test passed it means we didn't shrink successfully (returns Nothing)
106-
-- otherwise, return a reduced sequence of transaction
106+
-- otherwise, return a reduced sequence of transactions
107107
pure $ case (value,v) of
108108
(BoolValue False, _) -> Just (txs'', value, vm')
109109
(IntValue x, IntValue y) | x >= y -> Just (txs'', value, vm')

lib/Echidna/UI.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Control.Monad.ST (RealWorld)
1515
import Data.ByteString.Lazy qualified as BS
1616
import Data.List.Split (chunksOf)
1717
import Data.Map (Map)
18-
import Data.Maybe (isJust)
18+
import Data.Maybe (isJust, mapMaybe)
1919
import Data.Sequence ((|>))
2020
import Data.Text (Text)
2121
import Data.Time
@@ -41,7 +41,7 @@ import Echidna.Types.Campaign
4141
import Echidna.Types.Config
4242
import Echidna.Types.Corpus qualified as Corpus
4343
import Echidna.Types.Coverage (coverageStats)
44-
import Echidna.Types.Test (EchidnaTest(..), didFail, isOptimizationTest)
44+
import Echidna.Types.Test (EchidnaTest(..), TestState(..), didFail, isOptimizationTest)
4545
import Echidna.Types.Tx (Tx)
4646
import Echidna.Types.Worker
4747
import Echidna.UI.Report
@@ -408,10 +408,23 @@ statusLine env states lastUpdateRef = do
408408
let gasPerSecond = if deltaTime > 0 then deltaGas `div` deltaTime else 0
409409
writeIORef lastUpdateRef $ GasTracker now totalGas
410410

411+
let shrinkLimit = env.cfg.campaignConf.shrinkLimit
412+
let shrinkingWorkers = mapMaybe getShrinkingWorker tests
413+
where getShrinkingWorker test = case (test.state, test.workerId) of
414+
(Large step, Just wid) | step < shrinkLimit -> Just (wid, step, length test.reproducer)
415+
_ -> Nothing
416+
let shrinkingPart
417+
| null shrinkingWorkers = ""
418+
| otherwise = ", shrinking: " <> unwords (map formatWorker shrinkingWorkers)
419+
where
420+
formatWorker (wid, step, seqLength) =
421+
"W" <> show wid <> ":" <> show step <> "/" <> show shrinkLimit <> "(" <> show seqLength <> ")"
422+
411423
pure $ "tests: " <> show (length $ filter didFail tests) <> "/" <> show (length tests)
412424
<> ", fuzzing: " <> show totalCalls <> "/" <> show env.cfg.campaignConf.testLimit
413425
<> ", values: " <> show ((.value) <$> filter isOptimizationTest tests)
414426
<> ", cov: " <> show points
415427
<> ", corpus: " <> show (Corpus.corpusSize corpus)
428+
<> shrinkingPart
416429
<> ", gas/s: " <> show gasPerSecond
417430

0 commit comments

Comments
 (0)