blob: fb4c0b259edbdf67867229b225ba218483909d99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
(* TEST
readonly_files = "reflector.ml"
* hasunix
** setup-ocamlc.byte-build-env
program = "${test_build_directory}/wait_nohang.byte"
*** ocamlc.byte
program = "${test_build_directory}/reflector.exe"
all_modules = "reflector.ml"
**** ocamlc.byte
include unix
program = "${test_build_directory}/wait_nohang.byte"
all_modules= "wait_nohang.ml"
***** check-ocamlc.byte-output
****** run
******* check-program-output
** setup-ocamlopt.byte-build-env
program = "${test_build_directory}/wait_nohang.opt"
*** ocamlopt.byte
program = "${test_build_directory}/reflector.exe"
all_modules = "reflector.ml"
**** ocamlopt.byte
include unix
program = "${test_build_directory}/wait_nohang.opt"
all_modules= "wait_nohang.ml"
***** check-ocamlopt.byte-output
****** run
******* check-program-output
*)
let refl =
Filename.concat Filename.current_dir_name "reflector.exe"
let () =
let oc = Unix.open_process_out (refl ^ " -i2o") in
let pid = Unix.process_out_pid oc in
let (pid1, status1) = Unix.waitpid [WNOHANG] pid in
assert (pid1 = 0);
assert (status1 = WEXITED 0);
output_string oc "aa\n"; close_out oc;
let rec busywait () =
let (pid2, status2) = Unix.waitpid [WNOHANG] pid in
if pid2 = 0 then begin
Unix.sleepf 0.001; busywait()
end else begin
assert (pid2 = pid);
assert (status2 = WEXITED 0)
end
in busywait()
|