From b371a677843df35e0b6273014f1ed44168e3a533 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 10 Mar 2023 13:18:01 +0100 Subject: [PATCH 1/3] lib_scoru_wasm/test: port tests to alcotezt --- manifest/main.ml | 50 ++++++++++++---- manifest/manifest.ml | 10 +++- manifest/manifest.mli | 2 + opam/tezos-scoru-wasm-fast-test.opam | 3 +- opam/tezos-scoru-wasm-test-helpers.opam | 2 +- opam/tezos-scoru-wasm-test.opam | 3 +- opam/virtual/octez-deps.opam | 1 - src/lib_scoru_wasm/fast/test/dune | 38 ++++++++++-- src/lib_scoru_wasm/fast/test/test_fast.ml | 14 +++++ .../fast/test/test_fast_cache.ml | 9 ++- .../fast/test/test_memory_access.ml | 14 +++++ .../fast/test/test_scoru_wasm_fast.ml | 41 ------------- src/lib_scoru_wasm/test/dune | 50 ++++++++++++++-- src/lib_scoru_wasm/test/helpers/dune | 3 +- .../test/helpers/test_encodings_util.ml | 2 +- .../test/test_ast_generators.ml | 7 ++- src/lib_scoru_wasm/test/test_debug.ml | 11 ++-- .../test/test_durable_shapshot.ml | 7 ++- .../test/test_durable_storage.ml | 7 ++- .../test/test_fixed_nb_ticks.ml | 7 ++- src/lib_scoru_wasm/test/test_get_set.ml | 7 ++- .../test/test_hash_consistency.ml | 14 +++++ .../test/test_host_functions_ticks.ml | 10 +++- src/lib_scoru_wasm/test/test_init.ml | 14 +++++ src/lib_scoru_wasm/test/test_input.ml | 7 ++- src/lib_scoru_wasm/test/test_output.ml | 7 ++- .../test/test_parser_encoding.ml | 7 ++- .../test/test_protocol_migration.ml | 10 +++- src/lib_scoru_wasm/test/test_reveal.ml | 7 ++- src/lib_scoru_wasm/test/test_scoru_wasm.ml | 60 ------------------- src/lib_scoru_wasm/test/test_wasm_encoding.ml | 7 ++- src/lib_scoru_wasm/test/test_wasm_pvm.ml | 7 ++- .../test/test_wasm_pvm_encodings.ml | 10 +++- src/lib_scoru_wasm/test/test_wasm_vm.ml | 36 +++++++++++ tezt/tests/dune | 2 + 35 files changed, 323 insertions(+), 163 deletions(-) delete mode 100644 src/lib_scoru_wasm/fast/test/test_scoru_wasm_fast.ml delete mode 100644 src/lib_scoru_wasm/test/test_scoru_wasm.ml diff --git a/manifest/main.ml b/manifest/main.ml index 96446244d8a6..bf2bf0cb84a8 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -70,8 +70,6 @@ let final_protocol_versions = let alcotest = external_lib ~js_compatible:true "alcotest" V.(at_least "1.5.0") -let alcotest_lwt = external_lib "alcotest-lwt" V.(at_least "1.5.0") - let astring = external_lib ~js_compatible:true "astring" V.True let bigarray_compat = external_lib ~js_compatible:true "bigarray-compat" V.True @@ -411,7 +409,8 @@ let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_globs_rec ?dep_files ?opam_with_test ?synopsis - ?(with_macos_security_framework = false) ?dune l = + ?(with_macos_security_framework = false) ?dune ?preprocess + ?preprocessor_deps l = tezt_without_tezt_lib_dependency ~with_macos_security_framework ~opam @@ -427,6 +426,8 @@ let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_files ?opam_with_test ?dune + ?preprocess + ?preprocessor_deps l (* The main module [Octez_alcotest] is [open_] so that one can replace @@ -4142,7 +4143,7 @@ let octez_scoru_wasm_tests_helpers = octez_scoru_wasm_fast; octez_scoru_wasm_helpers; qcheck_alcotest; - alcotest_lwt; + alcotezt; octez_webassembly_interpreter_extra |> open_; ] ~preprocess:[staged_pps [ppx_import; ppx_deriving_show]] @@ -4175,8 +4176,30 @@ let _octez_scoru_wasm_benchmark_exe = ~deps:[octez_base |> open_ ~m:"TzPervasives"; octez_scoru_wasm_benchmark] let _octez_scoru_wasm_tests = - test - "test_scoru_wasm" + tezt + [ + "test_ast_generators"; + "test_debug"; + (* TODO: https://gitlab.com/tezos/tezos/-/issues/5028 + Beware: there is a weird test failure when + Durable snapshot test doesn't go first *) + "test_durable_shapshot"; + "test_durable_storage"; + "test_fixed_nb_ticks"; + "test_get_set"; + "test_hash_consistency"; + "test_host_functions_ticks"; + "test_init"; + "test_input"; + "test_output"; + "test_parser_encoding"; + "test_protocol_migration"; + "test_reveal"; + "test_wasm_encoding"; + "test_wasm_pvm_encodings"; + "test_wasm_pvm"; + "test_wasm_vm"; + ] ~path:"src/lib_scoru_wasm/test" ~opam:"tezos-scoru-wasm-test" ~synopsis:"Tests for the scoru-wasm functionality" @@ -4190,7 +4213,7 @@ let _octez_scoru_wasm_tests = octez_test_helpers |> open_; octez_scoru_wasm; qcheck_alcotest; - alcotest_lwt; + alcotezt; octez_scoru_wasm_helpers |> open_; octez_scoru_wasm_tests_helpers |> open_; octez_webassembly_interpreter_extra |> open_; @@ -4198,8 +4221,15 @@ let _octez_scoru_wasm_tests = ~preprocess:[staged_pps [ppx_import; ppx_deriving_show]] let _octez_scoru_wasm_fast_tests = - test - "test_scoru_wasm_fast" + tezt + [ + "gen"; + "partial_memory"; + "qcheck_helpers"; + "test_fast_cache"; + "test_fast"; + "test_memory_access"; + ] ~path:"src/lib_scoru_wasm/fast/test" ~opam:"tezos-scoru-wasm-fast-test" ~synopsis:"Tests for the scoru-wasm-fast functionality" @@ -4216,7 +4246,7 @@ let _octez_scoru_wasm_fast_tests = octez_scoru_wasm; octez_scoru_wasm_fast; qcheck_alcotest; - alcotest_lwt; + alcotezt; ] ~preprocess:[staged_pps [ppx_import; ppx_deriving_show]] diff --git a/manifest/manifest.ml b/manifest/manifest.ml index f64c4fb7180f..baa94e0f8f4b 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -1847,6 +1847,8 @@ type tezt_target = { with_macos_security_framework : bool; dune : Dune.s_expr; tezt_local_test_lib : target; + preprocess : Target.preprocessor list; + preprocessor_deps : Target.preprocessor_dep list; } let tezt_targets_by_path : tezt_target String_map.t ref = ref String_map.empty @@ -1854,7 +1856,7 @@ let tezt_targets_by_path : tezt_target String_map.t ref = ref String_map.empty let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) ?(js_deps = []) ?(dep_globs = []) ?(dep_globs_rec = []) ?(dep_files = []) ?synopsis ?opam_with_test ?(with_macos_security_framework = false) - ?(dune = Dune.[]) modules = + ?(dune = Dune.[]) ?(preprocess = []) ?(preprocessor_deps = []) modules = if String_map.mem path !tezt_targets_by_path then invalid_arg ("cannot call Manifest.tezt twice for the same directory: " ^ path) ; @@ -1892,6 +1894,8 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) with_macos_security_framework; dune; tezt_local_test_lib; + preprocess; + preprocessor_deps; } in tezt_targets_by_path := String_map.add path tezt_target !tezt_targets_by_path ; @@ -1912,6 +1916,8 @@ let register_tezt_targets ~make_tezt_exe = opam_with_test; with_macos_security_framework; tezt_local_test_lib; + preprocess; + preprocessor_deps; _; } = tezt_test_libs := tezt_local_test_lib :: !tezt_test_libs ; @@ -1942,6 +1948,8 @@ let register_tezt_targets ~make_tezt_exe = ~dep_files ~modules:[exe_name] ?opam_with_test + ~preprocess + ~preprocessor_deps ~dune: Dune. [ diff --git a/manifest/manifest.mli b/manifest/manifest.mli index 1bd153333567..a95fee9ab5a2 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -967,6 +967,8 @@ val tezt : ?opam_with_test:with_test -> ?with_macos_security_framework:bool -> ?dune:Dune.s_expr -> + ?preprocess:preprocessor list -> + ?preprocessor_deps:preprocessor_dep list -> string list -> target diff --git a/opam/tezos-scoru-wasm-fast-test.opam b/opam/tezos-scoru-wasm-fast-test.opam index aa8ac0927403..7f622e5172a3 100644 --- a/opam/tezos-scoru-wasm-fast-test.opam +++ b/opam/tezos-scoru-wasm-fast-test.opam @@ -12,6 +12,7 @@ depends: [ "ocaml" { >= "4.14" } "ppx_import" {with-test} "ppx_deriving" {with-test} + "tezt" { with-test & >= "3.1.0" } "tezos-base" {with-test} "tezos-tree-encoding" {with-test} "tezos-context" {with-test} @@ -22,7 +23,7 @@ depends: [ "tezos-scoru-wasm" {with-test} "tezos-scoru-wasm-fast" {with-test} "qcheck-alcotest" { with-test & >= "0.20" } - "alcotest-lwt" { with-test & >= "1.5.0" } + "octez-alcotezt" {with-test} ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-scoru-wasm-test-helpers.opam b/opam/tezos-scoru-wasm-test-helpers.opam index 479a75ec688b..5b06e2fd1155 100644 --- a/opam/tezos-scoru-wasm-test-helpers.opam +++ b/opam/tezos-scoru-wasm-test-helpers.opam @@ -22,7 +22,7 @@ depends: [ "tezos-scoru-wasm-fast" "tezos-scoru-wasm-helpers" "qcheck-alcotest" { >= "0.20" } - "alcotest-lwt" { >= "1.5.0" } + "octez-alcotezt" "tezos-webassembly-interpreter-extra" ] build: [ diff --git a/opam/tezos-scoru-wasm-test.opam b/opam/tezos-scoru-wasm-test.opam index 2e304f4099c6..b9890eeda8f3 100644 --- a/opam/tezos-scoru-wasm-test.opam +++ b/opam/tezos-scoru-wasm-test.opam @@ -12,6 +12,7 @@ depends: [ "ocaml" { >= "4.14" } "ppx_import" {with-test} "ppx_deriving" {with-test} + "tezt" { with-test & >= "3.1.0" } "tezos-base" {with-test} "tezos-tree-encoding" {with-test} "tezos-context" {with-test} @@ -19,7 +20,7 @@ depends: [ "tezos-test-helpers" {with-test} "tezos-scoru-wasm" {with-test} "qcheck-alcotest" { with-test & >= "0.20" } - "alcotest-lwt" { with-test & >= "1.5.0" } + "octez-alcotezt" {with-test} "tezos-scoru-wasm-helpers" {with-test} "tezos-scoru-wasm-test-helpers" {with-test} "tezos-webassembly-interpreter-extra" {with-test} diff --git a/opam/virtual/octez-deps.opam b/opam/virtual/octez-deps.opam index 0435d930552d..600356c2c945 100644 --- a/opam/virtual/octez-deps.opam +++ b/opam/virtual/octez-deps.opam @@ -11,7 +11,6 @@ depends: [ "aches" { >= "1.0.0" } "aches-lwt" { >= "1.0.0" } "alcotest" { >= "1.5.0" } - "alcotest-lwt" { >= "1.5.0" } "astring" "base-unix" "bigarray-compat" diff --git a/src/lib_scoru_wasm/fast/test/dune b/src/lib_scoru_wasm/fast/test/dune index 82fd09e25114..6f73ab4774f4 100644 --- a/src/lib_scoru_wasm/fast/test/dune +++ b/src/lib_scoru_wasm/fast/test/dune @@ -1,9 +1,11 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name test_scoru_wasm_fast) +(library + (name src_lib_scoru_wasm_fast_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-tree-encoding tezos-base.unix @@ -15,17 +17,41 @@ tezos-scoru-wasm tezos-scoru-wasm-fast qcheck-alcotest - alcotest-lwt) - (preprocess (staged_pps ppx_import ppx_deriving.show)) + octez-alcotezt) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base.TzPervasives -open Tezos_base_test_helpers -open Tezos_scoru_wasm_helpers -open Tezos_scoru_wasm_test_helpers - -open Tezos_test_helpers)) + -open Tezos_test_helpers + -open Octez_alcotezt) + (modules + gen + partial_memory + qcheck_helpers + test_fast_cache + test_fast + test_memory_access)) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + src_lib_scoru_wasm_fast_test_tezt_lib + tezt) + (preprocess (staged_pps ppx_import ppx_deriving.show)) + (modules main)) (rule (alias runtest) (package tezos-scoru-wasm-fast-test) - (action (run %{dep:./test_scoru_wasm_fast.exe}))) + (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/src/lib_scoru_wasm/fast/test/test_fast.ml b/src/lib_scoru_wasm/fast/test/test_fast.ml index 20dadcfd66f3..2cac24f5208c 100644 --- a/src/lib_scoru_wasm/fast/test/test_fast.ml +++ b/src/lib_scoru_wasm/fast/test/test_fast.ml @@ -23,6 +23,13 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: Lib_scoru_wasm_fast + Invocation: dune exec src/lib_scoru_wasm/fast/test/main.exe -- --file test_fast.ml + Subject: Tests for the tezos-scoru-wasm library +*) + module Preimage_map = Map.Make (String) open Wasm_utils open Tztest_helper @@ -989,3 +996,10 @@ let tests = `Quick, test_read_input_write_output_failing ); ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru-wasm-fast" + [("Fast Execution", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/fast/test/test_fast_cache.ml b/src/lib_scoru_wasm/fast/test/test_fast_cache.ml index 3121a62c7350..2c2a834764d6 100644 --- a/src/lib_scoru_wasm/fast/test/test_fast_cache.ml +++ b/src/lib_scoru_wasm/fast/test/test_fast_cache.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: Tezos_scoru_wasm_fast.Module_cache - Invocation: dune exec src/lib_scoru_wasm/test/test_fast_cache.exe + Invocation: dune exec src/lib_scoru_wasm/fast/test/main.exe -- --file test_fast_cache.ml Subject: Test the cache used for Wasmer modules *) @@ -128,3 +128,10 @@ let tests = Tztest.tztest "add max number of keys" `Quick test_add_max_nb; Tztest.tztest "add more than max" `Quick test_add_more_than_max; ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru-wasm-fast" + [("Fast Execution cache", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/fast/test/test_memory_access.ml b/src/lib_scoru_wasm/fast/test/test_memory_access.ml index e28035f3f014..f28fd06a8e2f 100644 --- a/src/lib_scoru_wasm/fast/test/test_memory_access.ml +++ b/src/lib_scoru_wasm/fast/test/test_memory_access.ml @@ -23,6 +23,13 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: Lib_scoru_wasm_fast + Invocation: dune exec src/lib_scoru_wasm/fast/test/main.exe -- --file test_memory_access.ml + Subject: Tests for the tezos-scoru-wasm library +*) + module Wasmer = Tezos_wasmer module Preimage_map = Map.Make (String) module Memory_access_fast = Tezos_scoru_wasm_fast.Memory_access.Wasmer @@ -116,3 +123,10 @@ let tests : unit Alcotest_lwt.test_case list = List.map Qcheck_helpers.to_alcotest_lwt [test_store_bytes; test_load_bytes; test_store_num] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru-wasm-fast" + [("Memory access", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/fast/test/test_scoru_wasm_fast.ml b/src/lib_scoru_wasm/fast/test/test_scoru_wasm_fast.ml deleted file mode 100644 index 6be158110809..000000000000 --- a/src/lib_scoru_wasm/fast/test/test_scoru_wasm_fast.ml +++ /dev/null @@ -1,41 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Marigold *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** Testing - ------- - Component: Lib_scoru_wasm_fast - Invocation: dune runtest src/lib_scoru_wasm/fast - Subject: Tests for the tezos-scoru-wasm library -*) - -let () = - Alcotest_lwt.run - "test lib scoru-wasm-fast" - [ - ("Memory access", Test_memory_access.tests); - ("Fast Execution", Test_fast.tests); - ("Fast Execution cache", Test_fast_cache.tests); - ] - |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/dune b/src/lib_scoru_wasm/test/dune index 0b840033c722..b58c0cda29b1 100644 --- a/src/lib_scoru_wasm/test/dune +++ b/src/lib_scoru_wasm/test/dune @@ -1,9 +1,11 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name test_scoru_wasm) +(library + (name src_lib_scoru_wasm_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-tree-encoding tezos-base.unix @@ -12,21 +14,57 @@ tezos-test-helpers tezos-scoru-wasm qcheck-alcotest - alcotest-lwt + octez-alcotezt tezos-scoru-wasm-helpers tezos_scoru_wasm_test_helpers tezos-webassembly-interpreter-extra) - (preprocess (staged_pps ppx_import ppx_deriving.show)) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base.TzPervasives -open Tezos_base_test_helpers -open Tezos_test_helpers + -open Octez_alcotezt -open Tezos_scoru_wasm_helpers -open Tezos_scoru_wasm_test_helpers - -open Tezos_webassembly_interpreter_extra)) + -open Tezos_webassembly_interpreter_extra) + (modules + test_ast_generators + test_debug + test_durable_shapshot + test_durable_storage + test_fixed_nb_ticks + test_get_set + test_hash_consistency + test_host_functions_ticks + test_init + test_input + test_output + test_parser_encoding + test_protocol_migration + test_reveal + test_wasm_encoding + test_wasm_pvm_encodings + test_wasm_pvm + test_wasm_vm)) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + src_lib_scoru_wasm_test_tezt_lib + tezt) + (preprocess (staged_pps ppx_import ppx_deriving.show)) + (modules main)) (rule (alias runtest) (package tezos-scoru-wasm-test) - (action (run %{dep:./test_scoru_wasm.exe}))) + (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/src/lib_scoru_wasm/test/helpers/dune b/src/lib_scoru_wasm/test/helpers/dune index 8461c408f4c0..11f75c020c41 100644 --- a/src/lib_scoru_wasm/test/helpers/dune +++ b/src/lib_scoru_wasm/test/helpers/dune @@ -17,11 +17,12 @@ tezos-scoru-wasm-fast tezos-scoru-wasm-helpers qcheck-alcotest - alcotest-lwt + octez-alcotezt tezos-webassembly-interpreter-extra) (preprocess (staged_pps ppx_import ppx_deriving.show)) (flags (:standard) -open Tezos_base.TzPervasives -open Tezos_base_test_helpers + -open Octez_alcotezt -open Tezos_webassembly_interpreter_extra)) diff --git a/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml b/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml index 3cb8224e98e9..63328958c79c 100644 --- a/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml +++ b/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml @@ -40,7 +40,7 @@ let qcheck ?count ?print gen f = QCheck2.Test.make ?count ?print gen (fun x -> Result.is_ok @@ Lwt_main.run (f x)) in - let res = QCheck_base_runner.run_tests ~verbose:true [test] in + let res = QCheck_base_runner.run_tests [test] in if res = 0 then return_unit else failwith "QCheck tests failed" let make_test ?print encoding gen check () = diff --git a/src/lib_scoru_wasm/test/test_ast_generators.ml b/src/lib_scoru_wasm/test/test_ast_generators.ml index c9ac97a6be00..8cc0f40ebe9b 100644 --- a/src/lib_scoru_wasm/test/test_ast_generators.ml +++ b/src/lib_scoru_wasm/test/test_ast_generators.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Tree_encoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^AST Generators$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_ast_generators.ml Subject: Encoding tests for the tezos-scoru-wasm library *) @@ -52,3 +51,7 @@ let test_gen_print_module () = return_unit) let tests = [tztest "Module" `Quick test_gen_print_module] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("AST Generators", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_debug.ml b/src/lib_scoru_wasm/test/test_debug.ml index 1e5516d8587c..6c98f30592a5 100644 --- a/src/lib_scoru_wasm/test/test_debug.ml +++ b/src/lib_scoru_wasm/test/test_debug.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Tree_encoding_decoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Debug$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_debug.ml Subject: Debug facilities tests for the tezos-scoru-wasm library *) @@ -249,10 +248,10 @@ let tests = `Quick, test_write_debug_too_many_memories ); ("debug during init", `Quick, test_write_debug_init); - ( "debug with inputs outside of the memory", + ( "debug with inputs outside of the memory (invalid length)", `Quick, test_write_debug_invalid_length ); - ( "debug with inputs outside of the memory", + ( "debug with inputs outside of the memory (invalid offset)", `Quick, test_write_debug_invalid_offset ); ( "Check reading at invalid position of the memory doesn't fail and \ @@ -260,3 +259,7 @@ let tests = `Quick, test_read_mem_outside_of_bounds ); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Debug", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_durable_shapshot.ml b/src/lib_scoru_wasm/test/test_durable_shapshot.ml index 5db2194bbfee..1d009283d9cb 100644 --- a/src/lib_scoru_wasm/test/test_durable_shapshot.ml +++ b/src/lib_scoru_wasm/test/test_durable_shapshot.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm durable - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Durable snapshot$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_durable_shapshot.ml Subject: Tests for the tezos-scoru-wasm durable snapshotting *) @@ -234,3 +233,7 @@ let tests : unit Alcotest_lwt.test_case trace = stress_strcture_ops ~init_size:2000 ~rounds:3000; ] (stress_each_op ()) + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Durable snapshot", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_durable_storage.ml b/src/lib_scoru_wasm/test/test_durable_storage.ml index 829b683c095d..a8f077c41539 100644 --- a/src/lib_scoru_wasm/test/test_durable_storage.ml +++ b/src/lib_scoru_wasm/test/test_durable_storage.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm durable - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "Durable storage" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_durable_storage.ml Subject: Durable storage tests for the tezos-scoru-wasm library *) @@ -1285,3 +1284,7 @@ let tests = tztest "Durable: invalid keys" `Quick test_durable_invalid_keys; tztest "Durable: readonly keys" `Quick test_readonly_key; ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Durable storage", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml b/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml index ad610b2cac2c..8bb7ebf2105a 100644 --- a/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml +++ b/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Wasm_pvm - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Max nb of ticks$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_fixed_nb_ticks.ml Subject: WASM PVM evaluation tests for fixed nb of ticks per top level call *) @@ -161,3 +160,7 @@ let tests = ("stuck in decode", `Quick, test_stuck_in_decode_kernel); ("stuck in init", `Quick, test_stuck_in_init_kernel); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Max nb of ticks", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_get_set.ml b/src/lib_scoru_wasm/test/test_get_set.ml index 1be5e1ac06e1..95fdaf44cf23 100644 --- a/src/lib_scoru_wasm/test/test_get_set.ml +++ b/src/lib_scoru_wasm/test/test_get_set.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm input - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "Set/get" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_get_set.ml Subject: Input tests for the tezos-scoru-wasm library *) @@ -219,3 +218,7 @@ let tests = ("Set input", `Quick, test_set_input); ("Get output", `Quick, test_get_output); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Set/get", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_hash_consistency.ml b/src/lib_scoru_wasm/test/test_hash_consistency.ml index 30e64894700b..e19c644e5e92 100644 --- a/src/lib_scoru_wasm/test/test_hash_consistency.ml +++ b/src/lib_scoru_wasm/test/test_hash_consistency.ml @@ -23,6 +23,13 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: Lib_scoru_wasm execution + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_hash_consistency.ml + Subject: Tests execution for the tezos-scoru-wasm library +*) + open Wasm_utils open Tztest_helper module Context = Tezos_context_memory.Context_binary @@ -81,3 +88,10 @@ let tests = `Quick, test_execution_correspondance 30_000L 5_000L ); ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru wasm" + [("Hash correspondence", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_host_functions_ticks.ml b/src/lib_scoru_wasm/test/test_host_functions_ticks.ml index 4878155248d8..319e7e5c88bf 100644 --- a/src/lib_scoru_wasm/test/test_host_functions_ticks.ml +++ b/src/lib_scoru_wasm/test/test_host_functions_ticks.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Test - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Host functions ticks$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_host_functions_ticks.ml Subject: Tickification of host functions tests for the \ tezos-scoru-wasm library *) @@ -115,3 +114,10 @@ let tests = tztests_with_pvm ~versions:[V0; V1] [("Test tickified host function", `Quick, test_tickified_host_function)] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru wasm" + [("Host functions ticks", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_init.ml b/src/lib_scoru_wasm/test/test_init.ml index 400935618ad4..76b990533aa9 100644 --- a/src/lib_scoru_wasm/test/test_init.ml +++ b/src/lib_scoru_wasm/test/test_init.ml @@ -23,6 +23,13 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: Lib_scoru_wasm + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_init.ml + Subject: Init tests for the tezos-scoru-wasm library +*) + open Tezos_scoru_wasm open Wasm_utils open Tztest_helper @@ -364,3 +371,10 @@ let tests = ("64 bits float types are forbidden", `Quick, test_float64_type); ("float values are forbidden", `Quick, test_float_value); ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru wasm" + [("Module Initialisation", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_input.ml b/src/lib_scoru_wasm/test/test_input.ml index 0fa387a453c2..3e098ac8e4b5 100644 --- a/src/lib_scoru_wasm/test/test_input.ml +++ b/src/lib_scoru_wasm/test/test_input.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm input - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Input$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_input.ml Subject: Input tests for the tezos-scoru-wasm library *) @@ -328,3 +327,7 @@ let tests = `Quick test_read_input_max_size_above_limit; ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Input", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_output.ml b/src/lib_scoru_wasm/test/test_output.ml index 14f021b7b19b..81eed1b23306 100644 --- a/src/lib_scoru_wasm/test/test_output.ml +++ b/src/lib_scoru_wasm/test/test_output.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm input - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "Output" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_output.ml Subject: Input tests for the tezos-scoru-wasm library *) @@ -362,3 +361,7 @@ let tests = `Quick test_push_output_bigger_than_max_size; ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Output", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_parser_encoding.ml b/src/lib_scoru_wasm/test/test_parser_encoding.ml index e3a0c7c38769..d3fba508bc93 100644 --- a/src/lib_scoru_wasm/test/test_parser_encoding.ml +++ b/src/lib_scoru_wasm/test/test_parser_encoding.ml @@ -27,8 +27,7 @@ (** Testing ------- Component: Tree_encoding_decoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Parser Encodings$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_parser_encoding.ml Subject: Parser encoding tests for the tezos-scoru-wasm library *) @@ -1368,3 +1367,7 @@ let tests = @ Imports.tests @ LazyStack.tests @ Exports.tests @ Instr_block.tests @ Block.tests @ Size.tests @ Code.tests @ Elem.tests @ Data.tests @ Field.tests @ Module.tests + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Parser Encodings", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_protocol_migration.ml b/src/lib_scoru_wasm/test/test_protocol_migration.ml index ede388112a1c..7bba5f0872c3 100644 --- a/src/lib_scoru_wasm/test/test_protocol_migration.ml +++ b/src/lib_scoru_wasm/test/test_protocol_migration.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm protocol migration internal message - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "Protocol migration" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_protocol_migration.ml Subject: Protocol migration tests for the tezos-scoru-wasm library *) @@ -66,3 +65,10 @@ let tests = `Quick test_protocol_migration_message; ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru wasm" + [("Protocol migration", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_reveal.ml b/src/lib_scoru_wasm/test/test_reveal.ml index a70d6cacdc21..e8eab80eec0a 100644 --- a/src/lib_scoru_wasm/test/test_reveal.ml +++ b/src/lib_scoru_wasm/test/test_reveal.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Lib_scoru_wasm reveal - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "Reveal" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_reveal.ml Subject: Reveal tests for the tezos-scoru-wasm library *) @@ -364,3 +363,7 @@ let tests = ("Test reveal_metadata", `Quick, test_reveal_metadata); ("Test reveal_preimage with Fast Exec", `Quick, test_fast_exec_reveal); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("Reveal", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_scoru_wasm.ml b/src/lib_scoru_wasm/test/test_scoru_wasm.ml deleted file mode 100644 index 45d1d1e6f401..000000000000 --- a/src/lib_scoru_wasm/test/test_scoru_wasm.ml +++ /dev/null @@ -1,60 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Trili Tech *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(** Testing - ------- - Component: Lib_scoru_wasm - Invocation: dune runtest src/lib_scoru_wasm/ - Subject: Tests for the tezos-scoru-wasm library -*) - -let () = - Alcotest_lwt.run - "test lib scoru wasm" - [ - (* TODO: https://gitlab.com/tezos/tezos/-/issues/5028 - Beware: there is a weird test failure when - Durable snapshot test doesn't go first - *) - ("Durable snapshot", Test_durable_shapshot.tests); - ("Input", Test_input.tests); - ("Output", Test_output.tests); - ("Set/get", Test_get_set.tests); - ("Durable storage", Test_durable_storage.tests); - ("AST Generators", Test_ast_generators.tests); - ("WASM Encodings", Test_wasm_encoding.tests); - ("WASM PVM Encodings", Test_wasm_pvm_encodings.tests); - ("Parser Encodings", Test_parser_encoding.tests); - ("WASM PVM", Test_wasm_pvm.tests); - ("WASM VM", Test_wasm_vm.tests); - ("Module Initialisation", Test_init.tests); - ("Max nb of ticks", Test_fixed_nb_ticks.tests); - ("Hash correspondence", Test_hash_consistency.tests); - ("Reveal", Test_reveal.tests); - ("Debug", Test_debug.tests); - ("Host functions ticks", Test_host_functions_ticks.tests); - ("Protocol migration", Test_protocol_migration.tests); - ] - |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_wasm_encoding.ml b/src/lib_scoru_wasm/test/test_wasm_encoding.ml index 60bb66d05a0e..e2d118451a5b 100644 --- a/src/lib_scoru_wasm/test/test_wasm_encoding.ml +++ b/src/lib_scoru_wasm/test/test_wasm_encoding.ml @@ -26,8 +26,7 @@ (** Testing ------- Component: Tree_encoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^WASM Encodings$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_wasm_encoding.ml Subject: Encoding tests for the tezos-scoru-wasm library *) @@ -158,3 +157,7 @@ let tests = tztest "Frame trees" `Quick test_frame_tree; tztest "Config trees" `Quick test_config_tree; ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("WASM Encodings", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_wasm_pvm.ml b/src/lib_scoru_wasm/test/test_wasm_pvm.ml index 5a9aca4be0c0..6f04f572a42c 100644 --- a/src/lib_scoru_wasm/test/test_wasm_pvm.ml +++ b/src/lib_scoru_wasm/test/test_wasm_pvm.ml @@ -27,8 +27,7 @@ (** Testing ------- Component: Tree_encoding_decoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^WASM PVM$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_wasm_pvm.ml Subject: WASM PVM evaluation tests for the tezos-scoru-wasm library *) @@ -1816,3 +1815,7 @@ let tests = `Quick, test_outbox_validity_period ); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("WASM PVM", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml b/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml index 332135b5476a..98d08b80b99e 100644 --- a/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml +++ b/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml @@ -27,8 +27,7 @@ (** Testing ------- Component: Tree_encoding_decoding - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^WASM PVM Encodings$" + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_wasm_pvm_encodings.ml Subject: WASM PVM encoding tests for the tezos-scoru-wasm library *) @@ -312,3 +311,10 @@ let tests = error_state_gen error_state_check); ] + +let () = + Alcotest_lwt.run + ~__FILE__ + "test lib scoru wasm" + [("WASM PVM Encodings", tests)] + |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_wasm_vm.ml b/src/lib_scoru_wasm/test/test_wasm_vm.ml index ed8bcacd1108..51a476223dde 100644 --- a/src/lib_scoru_wasm/test/test_wasm_vm.ml +++ b/src/lib_scoru_wasm/test/test_wasm_vm.ml @@ -1,3 +1,35 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Trili Tech *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Testing + ------- + Component: Lib_scoru_wasm + Invocation: dune exec src/lib_scoru_wasm/test/main.exe -- --file test_wasm_vm.ml + Subject: Tests for the tezos-scoru-wasm library +*) + open Tezos_scoru_wasm open Wasm_utils open Tztest_helper @@ -138,3 +170,7 @@ let tests = `Quick, test_last_input_info_updated_in_set_input_step ); ] + +let () = + Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("WASM VM", tests)] + |> Lwt_main.run diff --git a/tezt/tests/dune b/tezt/tests/dune index acc73cbf9324..e1722b2a422b 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -73,6 +73,8 @@ src_lib_signer_backends_test_tezt_lib src_lib_shell_services_test_tezt_lib src_lib_shell_test_tezt_lib + src_lib_scoru_wasm_test_tezt_lib + src_lib_scoru_wasm_fast_test_tezt_lib src_lib_sapling_test_tezt_lib src_lib_rpc_http_test_tezt_lib src_lib_requester_test_tezt_lib -- GitLab From edf673670d3f3a135c6da2ad510bc825cc915ffb Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Tue, 2 May 2023 14:37:14 +0200 Subject: [PATCH 2/3] lib_scoru_wasm/test: use [alcotest-qcheck] --- .../test/helpers/test_encodings_util.ml | 16 +-- .../test/test_ast_generators.ml | 18 ++-- src/lib_scoru_wasm/test/test_output.ml | 30 +++--- .../test/test_parser_encoding.ml | 100 +++++++----------- src/lib_scoru_wasm/test/test_wasm_encoding.ml | 43 ++++---- .../test/test_wasm_pvm_encodings.ml | 15 ++- 6 files changed, 94 insertions(+), 128 deletions(-) diff --git a/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml b/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml index 63328958c79c..f2fa8191dc71 100644 --- a/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml +++ b/src/lib_scoru_wasm/test/helpers/test_encodings_util.ml @@ -34,18 +34,10 @@ let test_encode_decode enc value f = let encode_decode enc value = test_encode_decode enc value Lwt.return -let qcheck ?count ?print gen f = - let open Lwt_result_syntax in - let test = - QCheck2.Test.make ?count ?print gen (fun x -> - Result.is_ok @@ Lwt_main.run (f x)) - in - let res = QCheck_base_runner.run_tests [test] in - if res = 0 then return_unit else failwith "QCheck tests failed" - -let make_test ?print encoding gen check () = - qcheck ?print gen (fun value -> +let make_test ?print ~name encoding gen check = + Tztest.tztest_qcheck2 ?print ~name gen (fun value -> let open Lwt_result_syntax in let*! value' = encode_decode encoding value in let* res = check value value' in - if res then return_unit else fail ()) + if res then return_unit + else tzfail (Exn (Failure "Encoding round-trip failed."))) diff --git a/src/lib_scoru_wasm/test/test_ast_generators.ml b/src/lib_scoru_wasm/test/test_ast_generators.ml index 8cc0f40ebe9b..eb5e0a4b5ec7 100644 --- a/src/lib_scoru_wasm/test/test_ast_generators.ml +++ b/src/lib_scoru_wasm/test/test_ast_generators.ml @@ -32,25 +32,21 @@ open Tztest -let qcheck ?print gen f = - let open Lwt_result_syntax in - let test = - QCheck2.Test.make ?print gen (fun x -> Result.is_ok @@ Lwt_main.run (f x)) - in - let res = QCheck_base_runner.run_tests [test] in - if res = 0 then return_unit else failwith "QCheck tests failed" - let print = Format.asprintf "%a" Ast_printer.pp_module (** A simple test that checks that generating and printing a module doesn't throw an exception. *) -let test_gen_print_module () = +let test_gen_print_module = let open Lwt_result_syntax in - qcheck ~print (Ast_generators.module_gen ()) (fun module_ -> + tztest_qcheck2 + ~print + ~name:"gen_print_module" + (Ast_generators.module_gen ()) + (fun module_ -> let _ = print module_ in return_unit) -let tests = [tztest "Module" `Quick test_gen_print_module] +let tests = [test_gen_print_module] let () = Alcotest_lwt.run ~__FILE__ "test lib scoru wasm" [("AST Generators", tests)] diff --git a/src/lib_scoru_wasm/test/test_output.ml b/src/lib_scoru_wasm/test/test_output.ml index 81eed1b23306..dacdead9c858 100644 --- a/src/lib_scoru_wasm/test/test_output.ml +++ b/src/lib_scoru_wasm/test/test_output.ml @@ -35,26 +35,26 @@ open Tezos_lazy_containers open Tezos_webassembly_interpreter open Tezos_scoru_wasm -let test_output_buffer () = +let test_output_buffer = let open Lwt_result_syntax in let test (level, output_buffer) = match Output_buffer.Internal_for_tests.level_range output_buffer with - | None -> true + | None -> return_unit | Some (first_level, max_level) -> if level <= max_level && level >= first_level then - Output_buffer.Internal_for_tests.is_outbox_available - output_buffer - level - else true + if + Output_buffer.Internal_for_tests.is_outbox_available + output_buffer + level + then return_unit + else failwith "[test_output_buffer] test failed" + else return_unit in - let test = - QCheck2.Test.make - QCheck2.Gen.( - tup2 (map Int32.of_int small_int) Ast_generators.output_buffer_gen) - test - in - let result = QCheck_base_runner.run_tests [test] in - if result = 0 then return_unit else failwith "QCheck tests failed" + tztest_qcheck2 + ~name:"Output buffer" + QCheck2.Gen.( + tup2 (map Int32.of_int small_int) Ast_generators.output_buffer_gen) + test let test_aux_write_output () = let open Lwt.Syntax in @@ -351,7 +351,7 @@ let tests = test_write_output_above_limit ); ] @ [ - tztest "Output buffer" `Quick test_output_buffer; + test_output_buffer; tztest "Aux_write_output" `Quick test_aux_write_output; tztest "Push message below the limit" `Quick test_messages_below_limit; tztest "Push message at the limit" `Quick test_messages_at_limit; diff --git a/src/lib_scoru_wasm/test/test_parser_encoding.ml b/src/lib_scoru_wasm/test/test_parser_encoding.ml index d3fba508bc93..b0851fe2fd71 100644 --- a/src/lib_scoru_wasm/test/test_parser_encoding.ml +++ b/src/lib_scoru_wasm/test/test_parser_encoding.ml @@ -31,7 +31,6 @@ Subject: Parser encoding tests for the tezos-scoru-wasm library *) -open Tztest open Tezos_lazy_containers open Tezos_webassembly_interpreter open Tezos_scoru_wasm @@ -95,12 +94,7 @@ module Byte_vector = struct | _, _ -> Lwt.return_ok false let tests = - [ - tztest - "Byte_vector" - `Quick - (make_test Parser.Byte_vector.encoding gen check); - ] + [make_test ~name:"Byte_vector" Parser.Byte_vector.encoding gen check] end (* Lazy_vector generators *) @@ -148,13 +142,11 @@ module Vec = struct let tests = let eq x y = Lwt.return_ok (Int32.equal x y) in [ - tztest - "Vec" - `Quick - (make_test - Parser.(vector_encoding (value [] Data_encoding.int32)) - (gen QCheck2.Gen.int32) - (check eq)); + make_test + ~name:"Vec" + Parser.(vector_encoding (value [] Data_encoding.int32)) + (gen QCheck2.Gen.int32) + (check eq); ] end @@ -185,13 +177,11 @@ module LazyVec = struct let tests = let eq x y = Lwt.return_ok (Int32.equal x y) in [ - tztest - "LazyVec" - `Quick - (make_test - Parser.Lazy_vec.(encoding (value [] Data_encoding.int32)) - (gen QCheck2.Gen.int32) - (check eq)); + make_test + ~name:"LazyVec" + Parser.Lazy_vec.(encoding (value [] Data_encoding.int32)) + (gen QCheck2.Gen.int32) + (check eq); ] end @@ -228,7 +218,7 @@ module Names = struct let check ns ns' = Lwt_result.return (check ns ns') - let tests = [tztest "Names" `Quick (make_test Parser.Name.encoding gen check)] + let tests = [make_test ~name:"Names" Parser.Name.encoding gen check] end module Func_type = struct @@ -279,8 +269,7 @@ module Func_type = struct | FKStop ft, FKStop ft' -> func_type_check ft ft' | _, _ -> return false - let tests = - [tztest "Func_type" `Quick (make_test Parser.Func_type.encoding gen check)] + let tests = [make_test ~name:"Func_type" Parser.Func_type.encoding gen check] end module Imports = struct @@ -327,8 +316,7 @@ module Imports = struct | ImpKStop imp, ImpKStop imp' -> return (import_check imp imp') | _, _ -> return false - let tests = - [tztest "Imports" `Quick (make_test Parser.Import.encoding gen check)] + let tests = [make_test ~name:"Imports" Parser.Import.encoding gen check] end module LazyStack = struct @@ -349,13 +337,11 @@ module LazyStack = struct let tests = let eq x y = Lwt.return_ok (Int32.equal x y) in [ - tztest - "LazyStack" - `Quick - (make_test - Parser.Lazy_stack.(encoding (value [] Data_encoding.int32)) - (gen QCheck2.Gen.int32) - (check eq)); + make_test + ~name:"LazyStack" + Parser.Lazy_stack.(encoding (value [] Data_encoding.int32)) + (gen QCheck2.Gen.int32) + (check eq); ] end @@ -392,8 +378,7 @@ module Exports = struct | ExpKStop exp, ExpKStop exp' -> return (export_check exp exp') | _, _ -> return false - let tests = - [tztest "Exports" `Quick (make_test Parser.Export.encoding gen check)] + let tests = [make_test ~name:"Exports" Parser.Export.encoding gen check] end module Size = struct @@ -409,7 +394,7 @@ module Size = struct let open Lwt_result_syntax in return (s.Decode.size = s'.Decode.size && s.start = s'.start) - let tests = [tztest "Size" `Quick (make_test Parser.Size.encoding gen check)] + let tests = [make_test ~name:"Size" Parser.Size.encoding gen check] end module Instr_block = struct @@ -461,12 +446,7 @@ module Instr_block = struct | _, _ -> return_false let tests = - [ - tztest - "Instr_block" - `Quick - (make_test Parser.Instr_block.encoding gen check); - ] + [make_test ~name:"Instr_block" Parser.Instr_block.encoding gen check] end module Block = struct @@ -493,8 +473,7 @@ module Block = struct | BlockStop l, BlockStop l' -> return (l = l') | _, _ -> return_false - let tests = - [tztest "Block" `Quick (make_test Parser.Block.encoding gen check)] + let tests = [make_test ~name:"Block" Parser.Block.encoding gen check] end module Code = struct @@ -595,7 +574,7 @@ module Code = struct check_func func func' | _, _ -> return false - let tests = [tztest "Code" `Quick (make_test Parser.Code.encoding gen check)] + let tests = [make_test ~name:"Code" Parser.Code.encoding gen check] end module Elem = struct @@ -703,7 +682,7 @@ module Elem = struct | EKStop elem, EKStop elem' -> elem_check elem elem' | _, _ -> return_false - let tests = [tztest "Elem" `Quick (make_test Parser.Elem.encoding gen check)] + let tests = [make_test ~name:"Elem" Parser.Elem.encoding gen check] end module Data = struct @@ -767,7 +746,7 @@ module Data = struct | DKStop data, DKStop data' -> data_check data data' | _, _ -> return false - let tests = [tztest "Data" `Quick (make_test Parser.Data.encoding gen check)] + let tests = [make_test ~name:"Data" Parser.Data.encoding gen check] end module Field = struct @@ -997,20 +976,16 @@ module Field = struct let tests = [ - tztest - "Field" - `Quick - (make_test - Parser.Field.building_state_encoding - building_state_gen - building_state_check); - tztest - "Field.Packed" - `Quick - (make_test - Parser.Field.packed_field_type_encoding - field_type_gen - check_packed_field_type); + make_test + ~name:"Field" + Parser.Field.building_state_encoding + building_state_gen + building_state_check; + make_test + ~name:"Field.Packed" + Parser.Field.packed_field_type_encoding + field_type_gen + check_packed_field_type; ] end @@ -1358,8 +1333,7 @@ module Module = struct eq_code_kont && eq_size && eq_vec_kont && pos = pos' | _, _ -> return_false - let tests = - [tztest "Module" `Quick (make_test Parser.Module.encoding gen check)] + let tests = [make_test ~name:"Module" Parser.Module.encoding gen check] end let tests = diff --git a/src/lib_scoru_wasm/test/test_wasm_encoding.ml b/src/lib_scoru_wasm/test/test_wasm_encoding.ml index e2d118451a5b..1b71e389e904 100644 --- a/src/lib_scoru_wasm/test/test_wasm_encoding.ml +++ b/src/lib_scoru_wasm/test/test_wasm_encoding.ml @@ -37,19 +37,19 @@ open Encodings_util open Test_encodings_util (** Test serialize/deserialize instructions. *) -let test_instr_roundtrip () = - let open Lwt_result_syntax in - qcheck Ast_generators.instr_gen (fun instr -> - let*! instr' = encode_decode Wasm_encoding.instruction_encoding instr in - assert (instr = instr') ; - return_unit) +let test_instr_roundtrip = + make_test + Wasm_encoding.instruction_encoding + Ast_generators.instr_gen + ~name:"Instruction roundtrip" + (fun instr instr' -> Lwt_result.return (instr = instr')) let assert_string_equal s1 s2 = let open Lwt_result_syntax in if String.equal s1 s2 then return_unit else failwith "Not equal" (** Test serialize/deserialize modules. *) -let test_module_roundtrip () = +let test_module_roundtrip = let print = Format.asprintf "%a" Ast_printer.pp_module in let open Lwt_result_syntax in let dummy_module_reg = @@ -58,8 +58,9 @@ let test_module_roundtrip () = Instance.ModuleMap.create () in - qcheck + Tztest.tztest_qcheck2 ~print + ~name:"Module roundtrip" (Ast_generators.module_gen ~module_reg:dummy_module_reg ()) (fun module1 -> (* We need to print here in order to force lazy bindings to be evaluated. *) @@ -81,7 +82,7 @@ let test_module_roundtrip () = More formally, test that for all values, encoding, decoding and re-encoding yields the same tree. *) -let test_generic_tree ~pp ~gen ~encoding () = +let test_generic_tree ~pp ~gen ~encoding name = let print = Format.asprintf "%a" pp in let open Lwt_result_syntax in let dummy_module_reg = @@ -89,7 +90,7 @@ let test_generic_tree ~pp ~gen ~encoding () = is not important when encoding or decoding. *) Instance.ModuleMap.create () in - qcheck ~print (gen ~module_reg:dummy_module_reg) (fun value1 -> + tztest_qcheck2 ~name ~print (gen ~module_reg:dummy_module_reg) (fun value1 -> let*! empty_tree = empty_tree () in (* We need to print here in order to force lazy bindings to be evaluated. *) let _ = print value1 in @@ -107,6 +108,7 @@ let test_module_tree = ~pp:Ast_printer.pp_module ~gen:(fun ~module_reg -> Ast_generators.module_gen ~module_reg ()) ~encoding:Wasm_encoding.module_instance_encoding + "Module trees" (** Test serialize/deserialize frames and compare trees. *) let test_frame_tree = @@ -114,6 +116,7 @@ let test_frame_tree = ~pp:Ast_printer.pp_frame ~gen:Ast_generators.frame_gen ~encoding:Wasm_encoding.frame_encoding + "Frame trees" (** Test serialize/deserialize input and output buffers and compare trees. *) let test_buffers_tree = @@ -121,6 +124,7 @@ let test_buffers_tree = ~pp:Ast_printer.pp_buffers ~gen:(fun ~module_reg:_ -> Ast_generators.buffers_gen) ~encoding:Wasm_encoding.buffers_encoding + "Input and output buffers trees" (** Test serialize/deserialize values and compare trees. *) let test_values_tree = @@ -132,6 +136,7 @@ let test_values_tree = Tezos_lazy_containers.Lazy_vector.Int32Vector.of_list (list Ast_generators.value_gen))) ~encoding:Wasm_encoding.values_encoding + "Values tree" (** Test serialize/deserialize administrative instructions and compare trees. *) let test_admin_instr_tree = @@ -139,23 +144,25 @@ let test_admin_instr_tree = ~pp:Ast_printer.pp_admin_instr ~gen:(fun ~module_reg -> Ast_generators.admin_instr_gen ~module_reg) ~encoding:Wasm_encoding.admin_instr_encoding + "Admin_instr trees" let test_config_tree = test_generic_tree ~pp:Ast_printer.pp_config ~gen:Ast_generators.config_gen ~encoding:Wasm_encoding.config_encoding + "Config trees" let tests = [ - tztest "Instruction roundtrip" `Quick test_instr_roundtrip; - tztest "Module roundtrip" `Quick test_module_roundtrip; - tztest "Module trees" `Quick test_module_tree; - tztest "Values trees" `Quick test_values_tree; - tztest "Admin_instr trees" `Quick test_admin_instr_tree; - tztest "Input and output buffers trees" `Quick test_buffers_tree; - tztest "Frame trees" `Quick test_frame_tree; - tztest "Config trees" `Quick test_config_tree; + test_instr_roundtrip; + test_module_roundtrip; + test_module_tree; + test_values_tree; + test_admin_instr_tree; + test_buffers_tree; + test_frame_tree; + test_config_tree; ] let () = diff --git a/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml b/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml index 98d08b80b99e..1a9bec01086b 100644 --- a/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml +++ b/src/lib_scoru_wasm/test/test_wasm_pvm_encodings.ml @@ -31,7 +31,6 @@ Subject: WASM PVM encoding tests for the tezos-scoru-wasm library *) -open Tztest open Tezos_scoru_wasm open Tezos_webassembly_interpreter module Contest = Tezos_context_memory.Context_binary @@ -302,14 +301,12 @@ let error_state_check state state' = let tests = [ - tztest - "Wasm_pvm_errors" - `Quick - (Test_encodings_util.make_test - ~print:Wasm_utils.print_error_state - (Tezos_tree_encoding.value [] Wasm_pvm_errors.encoding) - error_state_gen - error_state_check); + Test_encodings_util.make_test + ~print:Wasm_utils.print_error_state + ~name:"Wasm_pvm_errors" + (Tezos_tree_encoding.value [] Wasm_pvm_errors.encoding) + error_state_gen + error_state_check; ] let () = -- GitLab From 11f92be5ebc7d75b1b41f5d8390e468c6aa83c8b Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Wed, 3 May 2023 10:51:24 +0200 Subject: [PATCH 3/3] scripts/version.sh: update [(full_)opam_repository_tag] --- .gitlab-ci.yml | 2 +- scripts/version.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d39666b6510..a9fa217b030c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ variables: # /!\ CI_REGISTRY is overriden to use a private Docker registry mirror in AWS ECR # in GitLab namespaces `nomadic-labs` and `tezos` ## This value MUST be the same as `opam_repository_tag` in `scripts/version.sh` - build_deps_image_version: da2df2ce8692b6167411bdb4ddaf88c14eba4bb1 + build_deps_image_version: 205530c16047066997bf2b210542ceeef8fb96d1 build_deps_image_name: "${CI_REGISTRY}/tezos/opam-repository" GIT_STRATEGY: fetch GIT_DEPTH: "1" diff --git a/scripts/version.sh b/scripts/version.sh index 9998dc82642a..effd441948c8 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -20,12 +20,12 @@ export recommended_node_version=16.18.1 ## full_opam_repository is a commit hash of the public OPAM repository, i.e. ## https://github.com/ocaml/opam-repository -export full_opam_repository_tag=a7495d2d37112169545ae00fb1b4f41a1381edc1 +export full_opam_repository_tag=0e89b5b0195c6f2597c95251896e1ef8b199c1d2 ## opam_repository is an additional, tezos-specific opam repository. ## This value MUST be the same as `build_deps_image_version` in `.gitlab-ci.yml` export opam_repository_url=https://gitlab.com/tezos/opam-repository -export opam_repository_tag="${OPAM_REPOSITORY_TAG:-da2df2ce8692b6167411bdb4ddaf88c14eba4bb1}" +export opam_repository_tag="${OPAM_REPOSITORY_TAG:-205530c16047066997bf2b210542ceeef8fb96d1}" export opam_repository_git="$opam_repository_url.git" export opam_repository="$opam_repository_git"\#"$opam_repository_tag" -- GitLab