diff --git a/test/dune b/test/dune new file mode 100644 index 0000000..e2dce67 --- /dev/null +++ b/test/dune @@ -0,0 +1,13 @@ +(executable + (name sleep) + (modules sleep) + (modes native) + (link_flags :standard -cclib "-z solo5-abi=hvt") + (enabled_if (= %{context_name} "solo5")) + (libraries miou-solo5) + (foreign_stubs (language c) (names manifest))) + +(rule + (targets manifest.c) + (deps manifest.json) + (action (run solo5-elftool gen-manifest manifest.json manifest.c))) diff --git a/test/manifest.json b/test/manifest.json new file mode 100644 index 0000000..836f1a5 --- /dev/null +++ b/test/manifest.json @@ -0,0 +1,5 @@ +{ + "type": "solo5.manifest", + "version": 1, + "devices": [] +} diff --git a/test/sleep.ml b/test/sleep.ml new file mode 100644 index 0000000..f50eabd --- /dev/null +++ b/test/sleep.ml @@ -0,0 +1,23 @@ +let _1s = 1_000_000_000 + +let sleep_and ns fn = + Miou_solo5.sleep ns; + fn () + +let rec repeat_until n fn = + if n > 0 then begin + fn (); + repeat_until (n - 1) fn + end + +let () = Miou_solo5.run @@ fun () -> + let prm0 = Miou.async @@ fun () -> + repeat_until 3 @@ fun () -> + sleep_and _1s @@ fun () -> + print_endline "Hello" in + let prm1 = Miou.async @@ fun () -> + repeat_until 3 @@ fun () -> + sleep_and _1s @@ fun () -> + print_endline "World" in + let res = Miou.await_all [ prm0; prm1 ] in + List.iter (function Ok () -> () | Error exn -> raise exn) res