-
Notifications
You must be signed in to change notification settings - Fork 414
coverage: count number of executions per line #1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
41b1187
ba4e55d
b5b724c
6e46d86
559bbc1
8d2cb5e
924dfb2
989c708
cde4695
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import Data.IORef (readIORef, atomicWriteIORef, newIORef, writeIORef, modifyIORe | |
| import Data.Map qualified as Map | ||
| import Data.Maybe (fromMaybe, fromJust) | ||
| import Data.Text qualified as T | ||
| import Data.TLS.GHC (getTLS) | ||
| import Data.Vector qualified as V | ||
| import Data.Vector.Unboxed.Mutable qualified as VMut | ||
| import System.Process (readProcessWithExitCode) | ||
|
|
@@ -296,6 +297,15 @@ execTxWithCov tx = do | |
| forM_ [0..size-1] $ \i -> VMut.write vec i (-1, 0, 0) | ||
| pure $ Just vec | ||
|
|
||
| statsRef <- getTLS env.statsRef | ||
| maybeStatsVec <- lookupUsingCodehashOrInsert env.codehashMap contract env.dapp statsRef $ do | ||
| let size = BS.length . forceBuf . fromJust . view bytecode $ contract | ||
| if size == 0 then pure Nothing else do | ||
| -- IO for making a new vec | ||
| vec <- VMut.new size | ||
| forM_ [0..size-1] $ \i -> VMut.write vec i (0, 0) | ||
| pure $ Just vec | ||
|
|
||
| case maybeCovVec of | ||
| Nothing -> pure () | ||
| Just vec -> do | ||
|
|
@@ -304,13 +314,13 @@ execTxWithCov tx = do | |
| -- bug in another place, investigate. | ||
| -- ... this should be fixed now, since we use `codeContract` instead | ||
| -- of `contract` for everything; it may be safe to remove this check. | ||
| when (pc < VMut.length vec) $ | ||
| when (pc < VMut.length vec) $ do | ||
| VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see anywhere where we increment revertQty
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I have not implemented counting of reverts. I meant to do it at first but then it wasn't clear to me where I should be counting them. If you have any pointers there I'd appreciate them, otherwise I may remove the extra var at this time. |
||
| VMut.read vec pc >>= \case | ||
| (_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do | ||
| VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop) | ||
| writeIORef covContextRef (True, Just (vec, pc)) | ||
| _ -> | ||
| modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc)) | ||
| _ -> modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc)) | ||
|
|
||
| -- | Get the VM's current execution location | ||
| currentCovLoc vm = (vm.state.pc, fromMaybe 0 $ vmOpIx vm, length vm.frames) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ dependencies: | |
| - semver | ||
| - split | ||
| - text | ||
| - thread-local-storage | ||
| - transformers | ||
| - time | ||
| - unliftio | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.