Skip to content

Commit

Permalink
Merge pull request #329 from edwintorok/ocaml4
Browse files Browse the repository at this point in the history
Make qcheck-lin and qcheck-stm available on OCaml 4.x
  • Loading branch information
jmid committed Apr 26, 2023
2 parents dd7c6fa + 04df34f commit 761fbf3
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next version

- #329: Support `qcheck-lin` and `qcheck-stm` on OCaml 4.14.x without
the `Domain` and `Effect` modes
- #316: Fix `rep_count` in `STM_thread` so that negative and positive
tests repeat equally many times
- #318: avoid repetitive interleaving searches in `STM_domain` and `STM_thread`
Expand Down
6 changes: 3 additions & 3 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ the multicore run-time of OCaml 5.0.")
sequential and parallel tests against a declarative model.")
(tags ("test" "property" "qcheck" "quickcheck" "state-machine testing"
"model-based testing" "parallel testing"))
(depopts base-domains)
(depends
base-domains
(qcheck-core (>= "0.20"))
(qcheck-multicoretests-util (= :version))
(ppx_deriving (and :with-test (>= "5.2.1")))))
Expand All @@ -45,8 +45,9 @@ usage. Lin will generate and run random parallel tests and check the observed
behaviour for sequential consistency, that is, whether they can be linearized
and explained by some sequential interleaving.")
(tags ("test" "property" "qcheck" "quickcheck" "parallelism" "sequential consistency"))
(depopts base-domains)
(depends
base-domains
(ocaml (>= 4.14))
(qcheck-core (>= "0.20"))
(qcheck-multicoretests-util (= :version))
(ppx_deriving (and :with-test (>= "5.2.1")))))
Expand All @@ -58,5 +59,4 @@ and explained by some sequential interleaving.")
multicore programs.")
(tags ("test" "property" "qcheck" "quickcheck" "multicore" "non-determinism"))
(depends
base-domains
(qcheck-core (>= "0.20"))))
3 changes: 3 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(name STM_domain)
(public_name qcheck-stm.domain)
(modules STM_domain)
(enabled_if (>= %{ocaml_version} 5))
(libraries qcheck-core qcheck-stm.stm))

(library
Expand All @@ -32,12 +33,14 @@
(name lin_domain)
(public_name qcheck-lin.domain)
(modules lin_domain)
(enabled_if (>= %{ocaml_version} 5))
(libraries qcheck-core qcheck-core.runner qcheck-multicoretests-util qcheck-lin.lin))

(library
(name lin_effect)
(public_name qcheck-lin.effect)
(modules lin_effect)
(enabled_if (>= %{ocaml_version} 5))
(libraries qcheck-core qcheck-core.runner qcheck-multicoretests-util qcheck-lin.lin))

(library
Expand Down
3 changes: 2 additions & 1 deletion qcheck-lin.opam
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ homepage: "https://github.com/ocaml-multicore/multicoretests"
bug-reports: "https://github.com/ocaml-multicore/multicoretests/issues"
depends: [
"dune" {>= "3.0"}
"base-domains"
"ocaml" {>= "4.14"}
"qcheck-core" {>= "0.20"}
"qcheck-multicoretests-util" {= version}
"ppx_deriving" {with-test & >= "5.2.1"}
"odoc" {with-doc}
]
depopts: ["base-domains"]
build: [
["dune" "subst"] {dev}
[
Expand Down
1 change: 0 additions & 1 deletion qcheck-multicoretests-util.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ homepage: "https://github.com/ocaml-multicore/multicoretests"
bug-reports: "https://github.com/ocaml-multicore/multicoretests/issues"
depends: [
"dune" {>= "3.0"}
"base-domains"
"qcheck-core" {>= "0.20"}
"odoc" {with-doc}
]
Expand Down
2 changes: 1 addition & 1 deletion qcheck-stm.opam
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ homepage: "https://github.com/ocaml-multicore/multicoretests"
bug-reports: "https://github.com/ocaml-multicore/multicoretests/issues"
depends: [
"dune" {>= "3.0"}
"base-domains"
"qcheck-core" {>= "0.20"}
"qcheck-multicoretests-util" {= version}
"ppx_deriving" {with-test & >= "5.2.1"}
"odoc" {with-doc}
]
depopts: ["base-domains"]
build: [
["dune" "subst"] {dev}
[
Expand Down
36 changes: 27 additions & 9 deletions test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,53 @@
(libraries qcheck-multicoretests-util))


(test
(executable
(name cleanup_lin)
(modules cleanup_lin)
(package qcheck-lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq))
(action (run ./%{test} --verbose)))
(enabled_if (>= %{ocaml_version} 5)))

(test
(rule
(alias runtest)
(package qcheck-lin)
(action (run %{exe:cleanup_lin.exe} --verbose))
(enabled_if (>= %{ocaml_version} 5)))

(executable
(name cleanup_stm)
(modules cleanup_stm)
(package qcheck-stm)
(libraries qcheck-stm.sequential qcheck-stm.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq))
(action (run ./%{test} --verbose)))
(enabled_if (>= %{ocaml_version} 5)))

(rule
(enabled_if (= %{arch_sixtyfour} true))
(alias runtest)
(package qcheck-stm)
(action (run %{exe:cleanup_stm.exe} --verbose))
(enabled_if (>= %{ocaml_version} 5)))

(rule
(enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5)))
(action (copy mutable_set_v5.expected.64 mutable_set_v5.expected)))

(rule
(enabled_if (= %{arch_sixtyfour} false))
(enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5)))
(action (copy mutable_set_v5.expected.32 mutable_set_v5.expected)))

(rule
(enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5)))
(action (copy mutable_set_v4.expected.64 mutable_set_v5.expected)))

(rule
(enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5)))
(action (copy mutable_set_v4.expected.32 mutable_set_v5.expected)))

(test
(name mutable_set_v5)
(modules mutable_set_v5)
(package qcheck-stm)
(libraries qcheck-stm.sequential)
(libraries qcheck-stm.sequential threads.posix)
(preprocess (pps ppx_deriving.show))
(action
(with-accepted-exit-codes 1 (run ./%{test} --verbose --seed 229109553))))
24 changes: 24 additions & 0 deletions test/mutable_set_v4.expected.32
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
random seed: 229109553
generated error fail pass / total time test name
[ ] 0 0 0 0 / 100 0.0s STM sequential tests[ ] 0 0 0 0 / 100 0.0s STM sequential tests (generating)[✗] 2 0 1 1 / 100 0.0s STM sequential tests

--- Failure --------------------------------------------------------------------

Test STM sequential tests failed (13 shrink steps):

(Add -605797133)
(Remove -605797133)
Cardinal


+++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Messages for test STM sequential tests:

Results incompatible with model

(Add -605797133) : ()
(Remove -605797133) : Some (-605797133)
Cardinal : 1
================================================================================
failure (1 tests failed, 0 tests errored, ran 1 tests)
Expand Down
24 changes: 24 additions & 0 deletions test/mutable_set_v4.expected.64
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
random seed: 229109553
generated error fail pass / total time test name
[ ] 0 0 0 0 / 100 0.0s STM sequential tests[ ] 0 0 0 0 / 100 0.0s STM sequential tests (generating)[✗] 2 0 1 1 / 100 0.0s STM sequential tests

--- Failure --------------------------------------------------------------------

Test STM sequential tests failed (13 shrink steps):

(Add -3576245632788335623)
(Remove -3576245632788335623)
Cardinal


+++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Messages for test STM sequential tests:

Results incompatible with model

(Add -3576245632788335623) : ()
(Remove -3576245632788335623) : Some (-3576245632788335623)
Cardinal : 1
================================================================================
failure (1 tests failed, 0 tests errored, ran 1 tests)
Expand Down

0 comments on commit 761fbf3

Please sign in to comment.