From 4ffd7587ada9e3c8b13ef460a8e9f2d7a22e7ddd Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Wed, 31 May 2017 12:36:24 +0100 Subject: [PATCH] Define default text execution parameters in Test.DejaFu.Defaults --- dejafu/CHANGELOG.markdown | 5 +++ dejafu/Test/DejaFu.hs | 71 +++++----------------------------- dejafu/Test/DejaFu/Defaults.hs | 63 ++++++++++++++++++++++++++++++ dejafu/dejafu.cabal | 1 + 4 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 dejafu/Test/DejaFu/Defaults.hs diff --git a/dejafu/CHANGELOG.markdown b/dejafu/CHANGELOG.markdown index 52df5df..22601a5 100644 --- a/dejafu/CHANGELOG.markdown +++ b/dejafu/CHANGELOG.markdown @@ -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 diff --git a/dejafu/Test/DejaFu.hs b/dejafu/Test/DejaFu.hs index aadf954..e6a9857 100644 --- a/dejafu/Test/DejaFu.hs +++ b/dejafu/Test/DejaFu.hs @@ -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 diff --git a/dejafu/Test/DejaFu/Defaults.hs b/dejafu/Test/DejaFu/Defaults.hs new file mode 100644 index 0000000..111dddf --- /dev/null +++ b/dejafu/Test/DejaFu/Defaults.hs @@ -0,0 +1,63 @@ +-- | +-- Module : Test.DejaFu.Defaults +-- Copyright : (c) 2017 Michael Walker +-- License : MIT +-- Maintainer : Michael Walker +-- 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 diff --git a/dejafu/dejafu.cabal b/dejafu/dejafu.cabal index 350e15f..1f40d9a 100755 --- a/dejafu/dejafu.cabal +++ b/dejafu/dejafu.cabal @@ -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