From 05fa8c7c0755318f674601bfb5a92cec0af574a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Wed, 15 Jan 2025 18:19:24 +0100 Subject: [PATCH 1/3] Wasm: test sandboxing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Vouillon --- .../test-cases/wasmoo/sandboxing.t/dune-project | 1 + .../test-cases/wasmoo/sandboxing.t/inline_test/dune | 11 +++++++++++ .../wasmoo/sandboxing.t/inline_test/inline_test.ml | 0 .../sandboxing.t/inline_test/inline_test_backend.ml | 0 .../test-cases/wasmoo/sandboxing.t/run.t | 3 +++ .../test-cases/wasmoo/sandboxing.t/test/dune | 3 +++ .../test-cases/wasmoo/sandboxing.t/test/test.ml | 0 7 files changed, 18 insertions(+) create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/dune-project create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/dune create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test.ml create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test_backend.ml create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/run.t create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/dune create mode 100644 test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/test.ml diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/dune-project b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/dune-project new file mode 100644 index 00000000000..3e2a6150dda --- /dev/null +++ b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/dune-project @@ -0,0 +1 @@ +(lang dune 3.17) diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/dune b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/dune new file mode 100644 index 00000000000..9f3c7cc0119 --- /dev/null +++ b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/dune @@ -0,0 +1,11 @@ +(library + (name inline_test) + (modules inline_test) + (inline_tests + (modes wasm) + (backend inline_test_backend))) + +(library + (name inline_test_backend) + (modules inline_test_backend) + (inline_tests.backend (generate_runner (echo "")))) diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test.ml b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test.ml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test_backend.ml b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/inline_test/inline_test_backend.ml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/run.t b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/run.t new file mode 100644 index 00000000000..3b99562c493 --- /dev/null +++ b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/run.t @@ -0,0 +1,3 @@ +Run tests and inline tests within a sandbox in copy mode + + $ dune runtest --sandbox=copy diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/dune b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/dune new file mode 100644 index 00000000000..a09499c6339 --- /dev/null +++ b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/dune @@ -0,0 +1,3 @@ +(test + (modes wasm) + (name test)) diff --git a/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/test.ml b/test/blackbox-tests/test-cases/wasmoo/sandboxing.t/test/test.ml new file mode 100644 index 00000000000..e69de29bb2d From 799340dc371e56c306d55062ca8f9dd7e203fb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 14 Jan 2025 16:06:28 +0100 Subject: [PATCH 2/3] Inline tests: make sure the wasm asset directory is included in the sandbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Vouillon --- src/dune_rules/inline_tests.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dune_rules/inline_tests.ml b/src/dune_rules/inline_tests.ml index a6fe30ffad4..cb56097c2c7 100644 --- a/src/dune_rules/inline_tests.ml +++ b/src/dune_rules/inline_tests.ml @@ -296,7 +296,15 @@ include Sub_system.Register_end_point (struct | Error _ -> Action_builder.return action | Ok p -> Action_builder.path p >>> Action_builder.return action) and+ () = deps - and+ () = Action_builder.path exe in + and+ () = Action_builder.path exe + and+ () = + match mode with + | Native | Best | Byte | Jsoo JS -> Action_builder.return () + | Jsoo Wasm -> + Action_builder.path + (Path.build + (Path.Build.relative inline_test_dir (name ^ Js_of_ocaml.Ext.wasm_dir))) + in Action.chdir (Path.build dir) action in let flags partition : string list Action_builder.t = From ce13d6060b4df0f4c74ac06c666736c3e07b714e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Tue, 14 Jan 2025 17:24:46 +0100 Subject: [PATCH 3/3] Test rules: make sure the wasm asset directory is included in the sandbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Vouillon --- src/dune_rules/test_rules.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dune_rules/test_rules.ml b/src/dune_rules/test_rules.ml index d1a5e1ceac9..d91a7d7e765 100644 --- a/src/dune_rules/test_rules.ml +++ b/src/dune_rules/test_rules.ml @@ -104,7 +104,14 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents = | None -> t.deps | Some _ -> Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe)) - :: t.deps + :: + (match runtest_mode with + | `js Wasm -> + Bindings.Unnamed + (Dep_conf.File + (String_with_vars.make_text loc (s ^ Js_of_ocaml.Ext.wasm_dir))) + :: t.deps + | `js JS | `exe | `bc -> t.deps) in let add_alias ~loc ~action = (* CR rgrinberg: why are we going through the stanza api? *)