Commit bdb272a6 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Verify that an owner gets notified

Add a basic sanity check on notification: if a request is blocked,
and all old pending owners and blockers give up their resources,
the owner gets notified of his lock being granted.
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarPetr Pudlak <>
parent 3b907f06
......@@ -157,8 +157,26 @@ prop_PendingGetFulfilledEventually =
\ resources, a pending request must be granted automatically"
$ all (requestSucceeded finallyOwned) req
-- | Verify that the owner of a pending request gets notified once all blockers
-- release their resources.
prop_PendingGetNotifiedEventually :: Property
prop_PendingGetNotifiedEventually =
forAllBlocked $ \state owner prio req ->
let oldpending = getPendingOwners state
(state', (resultBlockers, _)) = updateLocksWaiting prio owner req state
blockers = genericResult (const S.empty) id resultBlockers
releaseOneOwner (s, tonotify) o =
let (s', newnotify) = releaseResources o s
in (s', newnotify `S.union` tonotify)
(_, notified) = S.foldl releaseOneOwner (state', S.empty)
$ S.union oldpending blockers
in printTestCase "After all blockers and old pending owners give up their\
\ resources, a pending owner must be notified"
$ S.member owner notified
testSuite "Locking/Waiting"
[ 'prop_NoActionWithPendingRequests
, 'prop_WaitingRequestsGetPending
, 'prop_PendingGetFulfilledEventually
, 'prop_PendingGetNotifiedEventually
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment