mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-12-18 19:11:37 +03:00
Define default text execution parameters in Test.DejaFu.Defaults
This commit is contained in:
parent
44c31f879c
commit
4ffd7587ad
@ -10,6 +10,11 @@ This project is versioned according to the [Package Versioning Policy](https://p
|
||||
unreleased
|
||||
----------
|
||||
|
||||
### Test.DejaFu.Defaults
|
||||
|
||||
- The `default*` values are now defined in the new Test.DejaFu.Defaults module. There is no breaking
|
||||
API change as they are re-exported from Test.DejaFu.
|
||||
|
||||
### Fixed
|
||||
|
||||
- An issue where `subconcurrency` would re-use `MVar` IDs, leading to false reports of deadlock on
|
||||
|
@ -242,17 +242,18 @@ module Test.DejaFu
|
||||
, gives'
|
||||
) where
|
||||
|
||||
import Control.Arrow (first)
|
||||
import Control.DeepSeq (NFData(..))
|
||||
import Control.Monad (unless, when)
|
||||
import Control.Monad.Ref (MonadRef)
|
||||
import Control.Monad.ST (runST)
|
||||
import Data.Function (on)
|
||||
import Data.List (intercalate, intersperse, minimumBy)
|
||||
import Data.Ord (comparing)
|
||||
import Control.Arrow (first)
|
||||
import Control.DeepSeq (NFData(..))
|
||||
import Control.Monad (unless, when)
|
||||
import Control.Monad.Ref (MonadRef)
|
||||
import Control.Monad.ST (runST)
|
||||
import Data.Function (on)
|
||||
import Data.List (intercalate, intersperse, minimumBy)
|
||||
import Data.Ord (comparing)
|
||||
|
||||
import Test.DejaFu.Common
|
||||
import Test.DejaFu.Conc
|
||||
import Test.DejaFu.Defaults
|
||||
import Test.DejaFu.SCT
|
||||
|
||||
|
||||
@ -689,60 +690,6 @@ gives' :: (Eq a, Show a) => [a] -> Predicate a
|
||||
gives' = gives . map Right
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Defaults
|
||||
|
||||
-- | A default way to execute concurrent programs: systematically
|
||||
-- using 'defaultBounds'.
|
||||
--
|
||||
-- @since 0.6.0.0
|
||||
defaultWay :: Way
|
||||
defaultWay = Systematically defaultBounds
|
||||
|
||||
-- | The default memory model: @TotalStoreOrder@
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultMemType :: MemType
|
||||
defaultMemType = TotalStoreOrder
|
||||
|
||||
-- | All bounds enabled, using their default values.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultBounds :: Bounds
|
||||
defaultBounds = Bounds
|
||||
{ boundPreemp = Just defaultPreemptionBound
|
||||
, boundFair = Just defaultFairBound
|
||||
, boundLength = Just defaultLengthBound
|
||||
}
|
||||
|
||||
-- | A sensible default preemption bound: 2.
|
||||
--
|
||||
-- See /Concurrency Testing Using Schedule Bounding: an Empirical Study/,
|
||||
-- P. Thomson, A. F. Donaldson, A. Betts for justification.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultPreemptionBound :: PreemptionBound
|
||||
defaultPreemptionBound = 2
|
||||
|
||||
-- | A sensible default fair bound: 5.
|
||||
--
|
||||
-- This comes from playing around myself, but there is probably a
|
||||
-- better default.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultFairBound :: FairBound
|
||||
defaultFairBound = 5
|
||||
|
||||
-- | A sensible default length bound: 250.
|
||||
--
|
||||
-- Based on the assumption that anything which executes for much
|
||||
-- longer (or even this long) will take ages to test.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultLengthBound :: LengthBound
|
||||
defaultLengthBound = 250
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Utils
|
||||
|
||||
|
63
dejafu/Test/DejaFu/Defaults.hs
Normal file
63
dejafu/Test/DejaFu/Defaults.hs
Normal file
@ -0,0 +1,63 @@
|
||||
-- |
|
||||
-- Module : Test.DejaFu.Defaults
|
||||
-- Copyright : (c) 2017 Michael Walker
|
||||
-- License : MIT
|
||||
-- Maintainer : Michael Walker <mike@barrucadu.co.uk>
|
||||
-- Stability : experimental
|
||||
-- Portability : portable
|
||||
--
|
||||
-- Default parameters for test execution.
|
||||
module Test.DejaFu.Defaults where
|
||||
|
||||
import Test.DejaFu.Common
|
||||
import Test.DejaFu.SCT
|
||||
|
||||
-- | A default way to execute concurrent programs: systematically
|
||||
-- using 'defaultBounds'.
|
||||
--
|
||||
-- @since 0.6.0.0
|
||||
defaultWay :: Way
|
||||
defaultWay = Systematically defaultBounds
|
||||
|
||||
-- | The default memory model: @TotalStoreOrder@
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultMemType :: MemType
|
||||
defaultMemType = TotalStoreOrder
|
||||
|
||||
-- | All bounds enabled, using their default values.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultBounds :: Bounds
|
||||
defaultBounds = Bounds
|
||||
{ boundPreemp = Just defaultPreemptionBound
|
||||
, boundFair = Just defaultFairBound
|
||||
, boundLength = Just defaultLengthBound
|
||||
}
|
||||
|
||||
-- | A sensible default preemption bound: 2.
|
||||
--
|
||||
-- See /Concurrency Testing Using Schedule Bounding: an Empirical Study/,
|
||||
-- P. Thomson, A. F. Donaldson, A. Betts for justification.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultPreemptionBound :: PreemptionBound
|
||||
defaultPreemptionBound = 2
|
||||
|
||||
-- | A sensible default fair bound: 5.
|
||||
--
|
||||
-- This comes from playing around myself, but there is probably a
|
||||
-- better default.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultFairBound :: FairBound
|
||||
defaultFairBound = 5
|
||||
|
||||
-- | A sensible default length bound: 250.
|
||||
--
|
||||
-- Based on the assumption that anything which executes for much
|
||||
-- longer (or even this long) will take ages to test.
|
||||
--
|
||||
-- @since 0.2.0.0
|
||||
defaultLengthBound :: LengthBound
|
||||
defaultLengthBound = 250
|
@ -43,6 +43,7 @@ library
|
||||
exposed-modules: Test.DejaFu
|
||||
, Test.DejaFu.Conc
|
||||
, Test.DejaFu.Common
|
||||
, Test.DejaFu.Defaults
|
||||
, Test.DejaFu.Schedule
|
||||
, Test.DejaFu.SCT
|
||||
, Test.DejaFu.STM
|
||||
|
Loading…
Reference in New Issue
Block a user