lama_byterun/stdlib/regression/gen.ml
Kakadu 708022fbd2 Repair tests in stdlib/regression
Signed-off-by: Kakadu <Kakadu@pm.me>
2024-11-15 21:28:01 +03:00

50 lines
2 KiB
OCaml

(* Run as `ocaml gen.ml` *)
let count = 35
let stdlib = ["Array"; "Buffer"; "Collection"; "Data"; "Fun"; "Lazy"; "List"; "Matcher"; "Ostap"; "Random"; "Ref"; "STM"; "Timer" ]
let sprintf = Printf.sprintf
let () =
Out_channel.with_open_text "dune" (fun dunech ->
let dprintfn fmt = Format.kasprintf (Printf.fprintf dunech "%s\n") fmt in
dprintfn "; This file was autogenerated\n";
dprintfn "(cram (deps ../../src/Driver.exe))";
dprintfn "(cram (deps ../../runtime32/runtime.a ../../runtime32/Std.i))";
dprintfn "(cram (deps ../../runtime/runtime.a ../../runtime/Std.i))";
dprintfn "(cram (deps %s))"
(String.concat " " (List.concat_map (fun s ->
[sprintf "../x32/%s.i" s
;sprintf "../x32/%s.o" s
])
stdlib));
dprintfn "(cram (deps %s))"
(String.concat " " (List.concat_map (fun s ->
[sprintf "../x64/%s.i" s
;sprintf "../x64/%s.o" s
])
stdlib));
for i = 0 to count - 1 do
let cram_buf = Buffer.create 100 in
let cram_printfn fmt =
Format.kasprintf (Printf.bprintf cram_buf "%s\n") fmt
in
let cram_file = ref (Printf.sprintf "test%02d.t" i) in
let lama_file = ref (Printf.sprintf "test%02d.lama" i) in
let found =
if Sys.file_exists !lama_file && i <> 30 then (
(* cram_printfn " $ ls ../x64"; *)
cram_printfn
" $ ../../src/Driver.exe -runtime ../../runtime -I ../../runtime -I ../../stdlib/x64 -ds -dp test%02d.lama -o test | grep -v 'section .note.GNU-stack'" i;
cram_printfn " $ ./test";
true)
else false
in
if found then (
dprintfn "(cram (applies_to test%02d)" i;
dprintfn " (deps %s))" !lama_file;
Out_channel.with_open_text !cram_file (fun ch ->
output_string ch "This file was autogenerated.\n";
output_string ch (Buffer.contents cram_buf)))
done)