Module Stateful.Concurrent_rule

One possible action in a concurrent stateful test.

type ('ctx, 'state) t
val create : ?groups:string list -> ?weight:float -> name:string -> step:(test_case -> 'ctx -> 'state -> unit) -> unit -> ('ctx, 'state) t

create ?groups ?weight ~name ~step () declares a concurrent rule.

  • groups lists the concurrency groups of the rule. Only rules within the same group may run concurrently, and a rule in several groups runs in the rounds of each of them. Rules without explicit groups are in one anonymous group. The list must name at least one group and must not repeat one; the engine reports either as a Usage_error when the machine starts.
  • weight is a hint of how frequently the rule should be run. The default weight is 1.0, and weights must be finite and strictly positive.
  • name is printed in the final output when the rule is run.
  • step tc ctx state performs one application of the rule, drawing any arguments it needs from tc and updating state in place. ctx is the context the concurrency capability gives the worker. tc and ctx are valid only for that step.

With the PPX, a concurrent rule takes the following options: [@@rule { groups = [ "a"; "b" ]; weight = <weight> }]. The order of the fields does not matter and neither are required.

val name : (_, _) t -> string

Returns the name of the rule.

val groups : (_, _) t -> string list

Returns the concurrency groups of the rule.

val weight : (_, _) t -> float

Returns the weight of the rule.