From 2d3af15cd85fa0090f61419e0aa86a940d95792e Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 4 Apr 2024 16:37:07 +0200 Subject: [PATCH 1/4] irmin/test: add irmin-mem tests --- irmin/test/irmin-mem/bench.ml | 23 +++++++++++++++++++ irmin/test/irmin-mem/dune | 39 ++++++++++++++++++++++++++++++++ irmin/test/irmin-mem/test.ml | 21 +++++++++++++++++ irmin/test/irmin-mem/test.mli | 1 + irmin/test/irmin-mem/test_mem.ml | 26 +++++++++++++++++++++ manifest/product_octez.ml | 14 ++++++++++++ tezt/tests/dune | 1 + 7 files changed, 125 insertions(+) create mode 100644 irmin/test/irmin-mem/bench.ml create mode 100644 irmin/test/irmin-mem/dune create mode 100644 irmin/test/irmin-mem/test.ml create mode 100644 irmin/test/irmin-mem/test.mli create mode 100644 irmin/test/irmin-mem/test_mem.ml diff --git a/irmin/test/irmin-mem/bench.ml b/irmin/test/irmin-mem/bench.ml new file mode 100644 index 000000000000..c4bc86d41e57 --- /dev/null +++ b/irmin/test/irmin-mem/bench.ml @@ -0,0 +1,23 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +let config ~root:_ = Irmin_mem.config () + +module KV = Irmin_mem.KV.Make (Irmin.Contents.String) +module Bench = Irmin_bench.Make (KV) + +let size ~root:_ = 0 +let () = Bench.run ~config ~size diff --git a/irmin/test/irmin-mem/dune b/irmin/test/irmin-mem/dune new file mode 100644 index 000000000000..b90121ca7557 --- /dev/null +++ b/irmin/test/irmin-mem/dune @@ -0,0 +1,39 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name irmin_test_irmin_mem_tezt_lib) + (instrumentation (backend bisect_ppx)) + (libraries + tezt.core + octez-libs.tezos-context.memory + octez-internal-libs.irmin_test_helpers + octez-libs.test-helpers + tezt) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezt_core + -open Tezt_core.Base + -open Tezos_test_helpers + -open Tezt + -open Tezt.Base) + (modules test test_mem)) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + irmin_test_irmin_mem_tezt_lib + tezt) + (modules main)) + +(rule + (alias runtest) + (package tezos_internal_irmin_tests) + (enabled_if (<> false %{env:RUNTEZTALIAS=true})) + (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/irmin/test/irmin-mem/test.ml b/irmin/test/irmin-mem/test.ml new file mode 100644 index 000000000000..378104a2bb69 --- /dev/null +++ b/irmin/test/irmin-mem/test.ml @@ -0,0 +1,21 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +let () = + Lwt_main.run + @@ Irmin_test_helpers.Irmin_test.Store.run "irmin-mem" ~slow:true ~misc:[] + ~sleep:Lwt_unix.sleep + [ (`Quick, Test_mem.suite) ] diff --git a/irmin/test/irmin-mem/test.mli b/irmin/test/irmin-mem/test.mli new file mode 100644 index 000000000000..e790aeb70f0d --- /dev/null +++ b/irmin/test/irmin-mem/test.mli @@ -0,0 +1 @@ +(* empty *) diff --git a/irmin/test/irmin-mem/test_mem.ml b/irmin/test/irmin-mem/test_mem.ml new file mode 100644 index 000000000000..0fce312e6307 --- /dev/null +++ b/irmin/test/irmin-mem/test_mem.ml @@ -0,0 +1,26 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +let store = + Irmin_test_helpers.Irmin_test.store + (module Irmin_mem) + (module Irmin.Metadata.None) + +let config = Irmin_mem.config () +let init ~config:_ = Lwt.return_unit + +let suite = + Irmin_test_helpers.Irmin_test.Suite.create ~name:"MEM" ~init ~store ~config () diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index 89fd5832a684..58e73b4659a3 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -2754,6 +2754,20 @@ let _irmin_tests = tezt_lib |> open_ |> open_ ~m:"Base"; ] +let _irmin_mem_tests = + tezt + ["test"; "test_mem"] + ~path:"irmin/test/irmin-mem" + ~opam:"tezos_internal_irmin_tests" + ~synopsis:"Tezos internal irmin tests" + ~deps: + [ + octez_context_memory; + irmin_test_helpers; + octez_test_helpers |> open_; + tezt_lib |> open_ |> open_ ~m:"Base"; + ] + (* This binding assumes that librustzcash.a is installed in the system default directories or in: $OPAM_SWITCH_PREFIX/lib diff --git a/tezt/tests/dune b/tezt/tests/dune index 0cc97784788e..490bad26c87c 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -118,6 +118,7 @@ src_lib_benchmark_lib_micheline_rewriting_test_tezt_lib src_lib_base_unix_test_tezt_lib src_lib_base_test_tezt_lib + irmin_test_irmin_mem_tezt_lib irmin_test_tezt_lib etherlink_tezt_tests_tezt_lib etherlink_bin_node_test_tezt_lib) -- GitLab From ef0e62006894927b9d452daa5d9f66eec9581145 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Thu, 4 Apr 2024 16:38:15 +0200 Subject: [PATCH 2/4] irmin/test: add invocation command comment --- irmin/test/irmin-mem/test.ml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/irmin/test/irmin-mem/test.ml b/irmin/test/irmin-mem/test.ml index 378104a2bb69..b341e8bfc26b 100644 --- a/irmin/test/irmin-mem/test.ml +++ b/irmin/test/irmin-mem/test.ml @@ -14,6 +14,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) +(** Testing + ------- + Component: Irmin-mem + Invocation: dune exec irmin/test/irmin-mem/main.exe + Subject: This file is the entrypoint of all Irmin-mem Tezt tests. It dispatches to other files. +*) + let () = Lwt_main.run @@ Irmin_test_helpers.Irmin_test.Store.run "irmin-mem" ~slow:true ~misc:[] -- GitLab From 3be22a14402a1ae0ec4d383a561357ba14bd5ad2 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 5 Apr 2024 09:46:28 +0200 Subject: [PATCH 3/4] irmin: update readme --- irmin/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/irmin/README.md b/irmin/README.md index e92f1c2cb3c6..8047db5d3564 100644 --- a/irmin/README.md +++ b/irmin/README.md @@ -32,6 +32,13 @@ directory is under the \*`test` is a directory containing **unforked** tests from built for octez purposes that are using the `irmin` libraries. +### Tests + +| Category | Local path | Upstream | +| -------- | --------- | -------- | +| `irmin-mem` | `./test/irmin-mem` | [`test/irmin-mem`](https://github.com/mirage/irmin/tree/main/test/irmin-mem) | + + ## To-do before modifying the code - Import Irmin's tests, and ideally benches. -- GitLab From 38248702a6b044f6b74e3e6b5ad1d0a1310def6a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 8 Apr 2024 15:43:52 +0200 Subject: [PATCH 4/4] irmin/test: fix FILE argument in irmin-mem --- irmin/test/helpers/irmin_test.mli | 1 + irmin/test/helpers/store.ml | 2 +- irmin/test/helpers/store.mli | 1 + irmin/test/irmin-mem/test.ml | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/irmin/test/helpers/irmin_test.mli b/irmin/test/helpers/irmin_test.mli index 52fa646d486b..429fa5175e3c 100644 --- a/irmin/test/helpers/irmin_test.mli +++ b/irmin/test/helpers/irmin_test.mli @@ -62,6 +62,7 @@ val checks : 'a Irmin.Type.t -> string -> 'a list -> 'a list -> unit module Store : sig val run : + __FILE__:string -> string -> ?slow:bool -> ?random_seed:int -> diff --git a/irmin/test/helpers/store.ml b/irmin/test/helpers/store.ml index 44e1bc57e888..a251af14f199 100644 --- a/irmin/test/helpers/store.ml +++ b/irmin/test/helpers/store.ml @@ -2480,7 +2480,7 @@ let slow_suite (speed, x) = ] (speed, x) -let run name ?(slow = false) ?random_seed ~sleep ~misc tl = +let run ~__FILE__ name ?(slow = false) ?random_seed ~sleep ~misc tl = let () = match random_seed with | Some x -> Random.init x diff --git a/irmin/test/helpers/store.mli b/irmin/test/helpers/store.mli index 57aeeb89dc4b..8d5d6a923b63 100644 --- a/irmin/test/helpers/store.mli +++ b/irmin/test/helpers/store.mli @@ -15,6 +15,7 @@ *) val run : + __FILE__:string -> string -> ?slow:bool -> ?random_seed:int -> diff --git a/irmin/test/irmin-mem/test.ml b/irmin/test/irmin-mem/test.ml index b341e8bfc26b..31a7402ba157 100644 --- a/irmin/test/irmin-mem/test.ml +++ b/irmin/test/irmin-mem/test.ml @@ -23,6 +23,6 @@ let () = Lwt_main.run - @@ Irmin_test_helpers.Irmin_test.Store.run "irmin-mem" ~slow:true ~misc:[] - ~sleep:Lwt_unix.sleep + @@ Irmin_test_helpers.Irmin_test.Store.run ~__FILE__ "irmin-mem" ~slow:true + ~misc:[] ~sleep:Lwt_unix.sleep [ (`Quick, Test_mem.suite) ] -- GitLab