Define default text execution parameters in Test.DejaFu.Defaults

This commit is contained in:
Michael Walker 2017-05-31 12:36:24 +01:00
parent 44c31f879c
commit 4ffd7587ad
4 changed files with 78 additions and 62 deletions

View File

@ -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

View File

@ -253,6 +253,7 @@ 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

View 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

View File

@ -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