Skip to content

Commit 7d977b1

Browse files
committed
Translate tests to new ocamltest script language
1 parent b87afe3 commit 7d977b1

File tree

1,479 files changed

+9671
-7819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,479 files changed

+9671
-7819
lines changed

ocaml/testsuite/HACKING.adoc

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ a specific sub-directory.
1313
There are many kind of tests already, so the easiest way to start is
1414
to extend or copy an existing test.
1515

16+
Note: in april 2023, the test scripting language has changed: the
17+
org-mode-based syntax was replaced by at C-like syntax. ocamltest
18+
includes options to translate from the old to the new syntax:
19+
`-translate`, `-compact`, `-keep-lines`, `-keep-chars`. Look at
20+
`tools/translate-all-tests` for an example using them. These options
21+
will be removed after a transitional period.
22+
1623
== Sorts of tests
1724

1825
A test is specified in a `.ml` file containing a `TEST` block which is
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
(* TEST (* Just a test-driver *)
2-
* skip
3-
reason = "Broken, ask mshinwell if you want to try to fix it"
1+
(* TEST
2+
reason = "Broken, ask mshinwell if you want to try to fix it";
3+
skip;
44
*)
5-
(*
6-
* native-compiler
7-
** script
8-
script = "sh ${test_source_directory}/has-afl-fuzz.sh"
9-
readonly_files = "readline.ml"
10-
*** setup-ocamlopt.byte-build-env
11-
**** ocamlopt.byte
12-
program = "${test_build_directory}/readline"
13-
flags = "-afl-instrument"
14-
all_modules = "readline.ml"
15-
***** run
5+
(* TEST
6+
native-compiler;
7+
script = "sh ${test_source_directory}/has-afl-fuzz.sh";
8+
readonly_files = "readline.ml";
9+
script;
10+
setup-ocamlopt.byte-build-env;
11+
program = "${test_build_directory}/readline";
12+
flags = "-afl-instrument";
13+
all_modules = "readline.ml";
14+
ocamlopt.byte;
15+
run;
1616
*)
17+
18+
(* No code here, this file is a pure test script. *)
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
(* TEST (* Just a test-driver *)
2-
* native-compiler
3-
** script
4-
script = "sh ${test_source_directory}/has-afl-showmap.sh"
5-
readonly_files = "harness.ml test.ml"
6-
*** setup-ocamlopt.byte-build-env
7-
**** ocamlopt.byte
8-
module = "test.ml"
9-
flags = "-afl-instrument"
10-
***** ocamlopt.byte
11-
module = ""
12-
program = "${test_build_directory}/test"
13-
flags = "-afl-inst-ratio 0"
14-
all_modules = "test.cmx harness.ml"
15-
****** run
1+
(* TEST
2+
native-compiler;
3+
script = "sh ${test_source_directory}/has-afl-showmap.sh";
4+
readonly_files = "harness.ml test.ml";
5+
script;
6+
setup-ocamlopt.byte-build-env;
7+
module = "test.ml";
8+
flags = "-afl-instrument";
9+
ocamlopt.byte;
10+
module = "";
11+
program = "${test_build_directory}/test";
12+
flags = "-afl-inst-ratio 0";
13+
all_modules = "test.cmx harness.ml";
14+
ocamlopt.byte;
15+
run;
1616
*)
17+
18+
(* No code here, this file is a pure test script. *)

ocaml/testsuite/tests/arch-power/exn_raise.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(* TEST
2-
* arch_power
3-
** native
4-
*** ocamlopt.byte
5-
ocamlopt_flags = "-flarge-toc"
6-
**** run
2+
arch_power;
3+
native;
4+
ocamlopt_flags = "-flarge-toc";
5+
ocamlopt.byte;
6+
run;
77
*)
88

99
(* GPR#8506

ocaml/testsuite/tests/array-functions/test_iarray.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
(* TEST
2-
*)
1+
(* TEST *)
32

43
module Iarray = Stdlib__Iarray
54
external ( .:() ) : 'a iarray -> int -> 'a = "%array_safe_get"

ocaml/testsuite/tests/asmcomp/bind_tuples.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* TEST
2-
* native
2+
native;
33
*)
44

55
(* Check the effectiveness of optimized compilation of tuple binding

ocaml/testsuite/tests/asmcomp/compare.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* TEST
2-
* native
2+
native;
33
*)
44
let[@inline never] float () = print_string "hello\n"; 42.
55
let[@inline never] f () = compare (float ()) 0.5;;

ocaml/testsuite/tests/asmcomp/evaluation_order.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
(* TEST
2-
*)
1+
(* TEST *)
32
external unsafe_get : 'a array -> int -> 'a = "%array_unsafe_get"
43
external caml_bytes_get_16 : bytes -> int -> int = "%caml_bytes_get16"
54
external caml_bytes_set_16 : bytes -> int -> int -> unit = "%caml_bytes_set16"

ocaml/testsuite/tests/asmcomp/evaluation_order_broken.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* TEST
2-
* bytecode
2+
bytecode;
33
*)
44

55
(* The following examples have different output on bytecode and native.

ocaml/testsuite/tests/asmcomp/func_sections.ml

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
(* TEST
2-
* function_sections
3-
flags = "-S -function-sections"
4-
** arch_arm
5-
*** native
6-
reference = "${test_source_directory}/func_sections.arm.reference"
7-
** arch_arm64
8-
*** native
9-
reference = "${test_source_directory}/func_sections.arm.reference"
10-
** arch_amd64
11-
*** native
12-
reference = "${test_source_directory}/func_sections.reference"
13-
** arch_i386
14-
*** native
15-
reference = "${test_source_directory}/func_sections.reference"
2+
flags = "-S -function-sections";
3+
function_sections;
4+
{
5+
arch_arm;
6+
reference = "${test_source_directory}/func_sections.arm.reference";
7+
native;
8+
}{
9+
arch_arm64;
10+
reference = "${test_source_directory}/func_sections.arm.reference";
11+
native;
12+
}{
13+
arch_amd64;
14+
reference = "${test_source_directory}/func_sections.reference";
15+
native;
16+
}{
17+
arch_i386;
18+
reference = "${test_source_directory}/func_sections.reference";
19+
native;
20+
}
1621
*)
1722

1823
(* We have a separate reference output for ARM because

ocaml/testsuite/tests/asmcomp/is_static.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(* TEST
2-
modules = "is_in_static_data.c"
3-
* naked_pointers
4-
** native
2+
modules = "is_in_static_data.c";
3+
naked_pointers;
4+
native;
55
*)
66

77
(* Data that should be statically allocated by the compiler (all versions) *)

ocaml/testsuite/tests/asmcomp/is_static_flambda.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(* TEST
2-
modules = "is_in_static_data.c is_static_flambda_dep.ml"
3-
* flambda
4-
** naked_pointers
5-
*** native
2+
modules = "is_in_static_data.c is_static_flambda_dep.ml";
3+
flambda;
4+
naked_pointers;
5+
native;
66
*)
77

88
(* Data that should be statically allocated by the compiler (flambda only) *)

ocaml/testsuite/tests/asmcomp/lift_mutable_let_flambda.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(* TEST
2-
* flambda
3-
** native
2+
flambda;
3+
native;
44
*)
55

66
type t = T of { pos : int }

ocaml/testsuite/tests/asmcomp/optargs.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(* TEST
2-
flags = "-g"
3-
* native
2+
flags = "-g";
3+
native;
44
*)
55

66
(* Check the effectiveness of inlining the wrapper which fills in
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
(* TEST
2-
* poll-insertion
3-
** setup-ocamlopt.byte-build-env
4-
*** ocamlopt.byte
5-
ocamlopt_byte_exit_status = "2"
6-
**** check-ocamlopt.byte-output
7-
8-
** setup-ocamlopt.opt-build-env
9-
*** ocamlopt.opt
10-
ocamlopt_opt_exit_status = "2"
11-
**** check-ocamlopt.opt-output
1+
(* TEST_BELOW
2+
(* Blank lines added here to preserve locations. *)
3+
4+
5+
6+
7+
8+
9+
10+
11+
1212
*)
1313

1414
let[@inline never][@local never] v x = x + 1
@@ -20,3 +20,18 @@ let[@poll error] c x =
2020
ignore(Sys.opaque_identity(42))
2121
done;
2222
x2 + !y
23+
24+
(* TEST
25+
poll-insertion;
26+
{
27+
setup-ocamlopt.byte-build-env;
28+
ocamlopt_byte_exit_status = "2";
29+
ocamlopt.byte;
30+
check-ocamlopt.byte-output;
31+
}{
32+
setup-ocamlopt.opt-build-env;
33+
ocamlopt_opt_exit_status = "2";
34+
ocamlopt.opt;
35+
check-ocamlopt.opt-output;
36+
}
37+
*)

ocaml/testsuite/tests/asmcomp/poll_attr_inserted.ml

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
(* TEST
2-
* poll-insertion
3-
** setup-ocamlopt.byte-build-env
4-
*** ocamlopt.byte
5-
ocamlopt_byte_exit_status = "2"
6-
**** check-ocamlopt.byte-output
7-
8-
** setup-ocamlopt.opt-build-env
9-
*** ocamlopt.opt
10-
ocamlopt_opt_exit_status = "2"
11-
**** check-ocamlopt.opt-output
2+
poll-insertion;
3+
{
4+
setup-ocamlopt.byte-build-env;
5+
ocamlopt_byte_exit_status = "2";
6+
ocamlopt.byte;
7+
check-ocamlopt.byte-output;
8+
}{
9+
setup-ocamlopt.opt-build-env;
10+
ocamlopt_opt_exit_status = "2";
11+
ocamlopt.opt;
12+
check-ocamlopt.opt-output;
13+
}
1214
*)
1315

1416
let[@poll error] c x =
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
(* TEST
2-
* poll-insertion
3-
** setup-ocamlopt.byte-build-env
4-
*** ocamlopt.byte
5-
ocamlopt_byte_exit_status = "2"
6-
**** check-ocamlopt.byte-output
7-
8-
** setup-ocamlopt.opt-build-env
9-
*** ocamlopt.opt
10-
ocamlopt_opt_exit_status = "2"
11-
**** check-ocamlopt.opt-output
1+
(* TEST_BELOW
2+
(* Blank lines added here to preserve locations. *)
3+
4+
5+
6+
7+
8+
9+
10+
11+
1212
*)
1313

1414
let[@poll error] rec c x l =
1515
match l with
1616
| [] -> 0
1717
| _ :: tl -> (c[@tailcall]) (x+1) tl
18+
19+
(* TEST
20+
poll-insertion;
21+
{
22+
setup-ocamlopt.byte-build-env;
23+
ocamlopt_byte_exit_status = "2";
24+
ocamlopt.byte;
25+
check-ocamlopt.byte-output;
26+
}{
27+
setup-ocamlopt.opt-build-env;
28+
ocamlopt_opt_exit_status = "2";
29+
ocamlopt.opt;
30+
check-ocamlopt.opt-output;
31+
}
32+
*)
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
(* TEST
2-
* poll-insertion
3-
** setup-ocamlopt.byte-build-env
4-
*** ocamlopt.byte
5-
ocamlopt_byte_exit_status = "2"
6-
**** check-ocamlopt.byte-output
7-
8-
** setup-ocamlopt.opt-build-env
9-
*** ocamlopt.opt
10-
ocamlopt_opt_exit_status = "2"
11-
**** check-ocamlopt.opt-output
1+
(* TEST_BELOW
2+
(* Blank lines added here to preserve locations. *)
3+
4+
5+
6+
7+
8+
9+
10+
11+
1212
*)
1313

1414
let[@inline never][@local never] v x = x + 1
@@ -20,3 +20,18 @@ let[@poll error] c x =
2020
ignore(Sys.opaque_identity(ref 42))
2121
done;
2222
x2 + !y
23+
24+
(* TEST
25+
poll-insertion;
26+
{
27+
setup-ocamlopt.byte-build-env;
28+
ocamlopt_byte_exit_status = "2";
29+
ocamlopt.byte;
30+
check-ocamlopt.byte-output;
31+
}{
32+
setup-ocamlopt.opt-build-env;
33+
ocamlopt_opt_exit_status = "2";
34+
ocamlopt.opt;
35+
check-ocamlopt.opt-output;
36+
}
37+
*)

ocaml/testsuite/tests/asmcomp/polling_insertion.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(* TEST
2-
modules = "polling.c"
3-
compare_programs = "false"
4-
* poll-insertion
5-
** arch64
6-
*** native
2+
modules = "polling.c";
3+
compare_programs = "false";
4+
poll-insertion;
5+
arch64;
6+
native;
77
*)
88

99
(* This set of tests examine poll insertion behaviour. We do this by requesting

ocaml/testsuite/tests/asmcomp/prevent_fma.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* TEST
2-
* native
2+
native;
33
*)
44

55
let ( *. ) x y = Sys.opaque_identity (x *. y)

0 commit comments

Comments
 (0)