summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib-threads
diff options
context:
space:
mode:
authorLuc Maranget <luc.maranget@inria.fr>2014-03-13 12:44:09 +0000
committerLuc Maranget <luc.maranget@inria.fr>2014-03-13 12:44:09 +0000
commit1f5876189e29730e9b8f40c2808d1d7b84a37af0 (patch)
tree948ec02afaa09b40f4e8e8344cd99463ad96add8 /testsuite/tests/lib-threads
parentf69e779f366e356ffb03a9d334465dc073ee6c08 (diff)
downloadocaml-1f5876189e29730e9b8f40c2808d1d7b84a37af0.tar.gz
Merge with ocaml trunk 12778 -> 13774
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/jocamltrunk@14456 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'testsuite/tests/lib-threads')
-rw-r--r--testsuite/tests/lib-threads/Makefile16
-rw-r--r--testsuite/tests/lib-threads/close.ml29
-rw-r--r--testsuite/tests/lib-threads/close.reference1
-rw-r--r--testsuite/tests/lib-threads/sieve.ml14
-rw-r--r--testsuite/tests/lib-threads/sieve.reference73
-rw-r--r--testsuite/tests/lib-threads/test-file-short-lines10
-rw-r--r--testsuite/tests/lib-threads/test1.checker14
-rw-r--r--testsuite/tests/lib-threads/test1.ml12
-rw-r--r--testsuite/tests/lib-threads/test2.checker12
-rw-r--r--testsuite/tests/lib-threads/test2.ml12
-rw-r--r--testsuite/tests/lib-threads/test3.checker12
-rw-r--r--testsuite/tests/lib-threads/test3.ml12
-rw-r--r--testsuite/tests/lib-threads/test3.precheck13
-rw-r--r--testsuite/tests/lib-threads/test3.runner16
-rw-r--r--testsuite/tests/lib-threads/test4.checker14
-rw-r--r--testsuite/tests/lib-threads/test4.ml12
-rw-r--r--testsuite/tests/lib-threads/test4.runner14
-rw-r--r--testsuite/tests/lib-threads/test5.checker14
-rw-r--r--testsuite/tests/lib-threads/test5.ml12
-rw-r--r--testsuite/tests/lib-threads/test5.precheck13
-rw-r--r--testsuite/tests/lib-threads/test5.runner18
-rw-r--r--testsuite/tests/lib-threads/test6.checker14
-rw-r--r--testsuite/tests/lib-threads/test6.ml12
-rw-r--r--testsuite/tests/lib-threads/test6.precheck13
-rw-r--r--testsuite/tests/lib-threads/test6.runner14
-rw-r--r--testsuite/tests/lib-threads/test7.checker14
-rw-r--r--testsuite/tests/lib-threads/test7.ml12
-rw-r--r--testsuite/tests/lib-threads/test7.precheck13
-rw-r--r--testsuite/tests/lib-threads/test7.runner14
-rw-r--r--testsuite/tests/lib-threads/test8.ml33
-rw-r--r--testsuite/tests/lib-threads/test9.checker13
-rw-r--r--testsuite/tests/lib-threads/test9.ml12
-rw-r--r--testsuite/tests/lib-threads/test9.reference2
-rw-r--r--testsuite/tests/lib-threads/testA.checker14
-rw-r--r--testsuite/tests/lib-threads/testA.ml12
-rw-r--r--testsuite/tests/lib-threads/testexit.checker14
-rw-r--r--testsuite/tests/lib-threads/testexit.ml12
-rw-r--r--testsuite/tests/lib-threads/testio.ml14
-rw-r--r--testsuite/tests/lib-threads/testsieve.ml12
-rw-r--r--testsuite/tests/lib-threads/testsignal.checker14
-rw-r--r--testsuite/tests/lib-threads/testsignal.ml12
-rw-r--r--testsuite/tests/lib-threads/testsignal.precheck13
-rw-r--r--testsuite/tests/lib-threads/testsignal.runner16
-rw-r--r--testsuite/tests/lib-threads/testsignal2.checker12
-rw-r--r--testsuite/tests/lib-threads/testsignal2.ml12
-rw-r--r--testsuite/tests/lib-threads/testsignal2.precheck13
-rw-r--r--testsuite/tests/lib-threads/testsignal2.runner14
-rw-r--r--testsuite/tests/lib-threads/testsocket.ml12
-rw-r--r--testsuite/tests/lib-threads/testsocket.precheck23
-rw-r--r--testsuite/tests/lib-threads/token1.ml12
-rw-r--r--testsuite/tests/lib-threads/token2.ml25
-rw-r--r--testsuite/tests/lib-threads/torture.ml47
-rw-r--r--testsuite/tests/lib-threads/torture.reference2
-rw-r--r--testsuite/tests/lib-threads/torture.runner14
54 files changed, 698 insertions, 130 deletions
diff --git a/testsuite/tests/lib-threads/Makefile b/testsuite/tests/lib-threads/Makefile
index 8729461a77..fc098713f3 100644
--- a/testsuite/tests/lib-threads/Makefile
+++ b/testsuite/tests/lib-threads/Makefile
@@ -1,6 +1,20 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
BASEDIR=../..
LIBRARIES=unix threads
-ADD_COMPFLAGS=-thread
+ADD_COMPFLAGS=-thread -I $(OTOPDIR)/otherlibs/systhreads \
+ -I $(OTOPDIR)/otherlibs/$(UNIXLIBVAR)unix
+LD_PATH=$(TOPDIR)/otherlibs/systhreads:$(TOPDIR)/otherlibs/$(UNIXLIBVAR)unix
include $(BASEDIR)/makefiles/Makefile.several
include $(BASEDIR)/makefiles/Makefile.common
diff --git a/testsuite/tests/lib-threads/close.ml b/testsuite/tests/lib-threads/close.ml
index 7bda242600..01b90afdc2 100644
--- a/testsuite/tests/lib-threads/close.ml
+++ b/testsuite/tests/lib-threads/close.ml
@@ -1,15 +1,30 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let main () =
let (rd, wr) = Unix.pipe() in
- let _ = Thread.create
+ let t = Thread.create
(fun () ->
- ignore (Unix.write wr "0123456789" 0 10);
- Thread.delay 3.0;
+ Thread.delay 1.0;
print_endline "closing fd...";
- Unix.close rd)
+ Unix.close wr;
+ )
() in
let buf = String.create 10 in
print_endline "reading...";
- ignore (Unix.read rd buf 0 10);
- print_endline "read returned"
+ begin try ignore (Unix.read rd buf 0 10) with Unix.Unix_error _ -> () end;
+ print_endline "read returned";
+ t
+
+let t = Unix.handle_unix_error main ()
-let _ = Unix.handle_unix_error main ()
+let _ = Thread.join t
diff --git a/testsuite/tests/lib-threads/close.reference b/testsuite/tests/lib-threads/close.reference
index 53b6e2a87a..bb5061c8c7 100644
--- a/testsuite/tests/lib-threads/close.reference
+++ b/testsuite/tests/lib-threads/close.reference
@@ -1,2 +1,3 @@
reading...
+closing fd...
read returned
diff --git a/testsuite/tests/lib-threads/sieve.ml b/testsuite/tests/lib-threads/sieve.ml
index 72e2656605..ac3a9d2f97 100644
--- a/testsuite/tests/lib-threads/sieve.ml
+++ b/testsuite/tests/lib-threads/sieve.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Printf
open Thread
@@ -28,6 +40,6 @@ let go max =
in Thread.create (integers 2) ch;
print_primes ch max;;
-let _ = go 1000
+let _ = go 500
;;
diff --git a/testsuite/tests/lib-threads/sieve.reference b/testsuite/tests/lib-threads/sieve.reference
index 1d0db0877c..3e7998db49 100644
--- a/testsuite/tests/lib-threads/sieve.reference
+++ b/testsuite/tests/lib-threads/sieve.reference
@@ -93,76 +93,3 @@
487
491
499
-503
-509
-521
-523
-541
-547
-557
-563
-569
-571
-577
-587
-593
-599
-601
-607
-613
-617
-619
-631
-641
-643
-647
-653
-659
-661
-673
-677
-683
-691
-701
-709
-719
-727
-733
-739
-743
-751
-757
-761
-769
-773
-787
-797
-809
-811
-821
-823
-827
-829
-839
-853
-857
-859
-863
-877
-881
-883
-887
-907
-911
-919
-929
-937
-941
-947
-953
-967
-971
-977
-983
-991
-997
diff --git a/testsuite/tests/lib-threads/test-file-short-lines b/testsuite/tests/lib-threads/test-file-short-lines
new file mode 100644
index 0000000000..35abe7ca2e
--- /dev/null
+++ b/testsuite/tests/lib-threads/test-file-short-lines
@@ -0,0 +1,10 @@
+##
+# Host Database
+#
+# localhost is used to configure the loopback interface
+# when the system is booting. Do not change this entry.
+##
+127.0.0.1 localhost
+255.255.255.255 broadcasthost
+::1 localhost
+fe80::1%lo0 localhost
diff --git a/testsuite/tests/lib-threads/test1.checker b/testsuite/tests/lib-threads/test1.checker
index 1d10457284..94778f234d 100644
--- a/testsuite/tests/lib-threads/test1.checker
+++ b/testsuite/tests/lib-threads/test1.checker
@@ -1 +1,13 @@
-LC_ALL=C sort test1.result | diff -q test1.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT test1.result | $DIFF test1.reference -
diff --git a/testsuite/tests/lib-threads/test1.ml b/testsuite/tests/lib-threads/test1.ml
index 66c402400f..8961b6f857 100644
--- a/testsuite/tests/lib-threads/test1.ml
+++ b/testsuite/tests/lib-threads/test1.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Classic producer-consumer *)
type 'a prodcons =
diff --git a/testsuite/tests/lib-threads/test2.checker b/testsuite/tests/lib-threads/test2.checker
index f9bc427164..75f6cf5666 100644
--- a/testsuite/tests/lib-threads/test2.checker
+++ b/testsuite/tests/lib-threads/test2.checker
@@ -1 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
sed -e 1q test2.result | grep -q '^[ab]*'
diff --git a/testsuite/tests/lib-threads/test2.ml b/testsuite/tests/lib-threads/test2.ml
index 926f09078f..85a5e65a7f 100644
--- a/testsuite/tests/lib-threads/test2.ml
+++ b/testsuite/tests/lib-threads/test2.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let yield = ref false
let print_message c =
diff --git a/testsuite/tests/lib-threads/test3.checker b/testsuite/tests/lib-threads/test3.checker
index 95fa0ed048..88fa4934d4 100644
--- a/testsuite/tests/lib-threads/test3.checker
+++ b/testsuite/tests/lib-threads/test3.checker
@@ -1 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
sed -e 1q test3.result | grep -q '^[ab]*'
diff --git a/testsuite/tests/lib-threads/test3.ml b/testsuite/tests/lib-threads/test3.ml
index c6df3326e4..1540363c5b 100644
--- a/testsuite/tests/lib-threads/test3.ml
+++ b/testsuite/tests/lib-threads/test3.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let print_message delay c =
while true do
print_char c; flush stdout; Thread.delay delay
diff --git a/testsuite/tests/lib-threads/test3.precheck b/testsuite/tests/lib-threads/test3.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/test3.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/test3.runner b/testsuite/tests/lib-threads/test3.runner
index 907135b622..dc04062a1b 100644
--- a/testsuite/tests/lib-threads/test3.runner
+++ b/testsuite/tests/lib-threads/test3.runner
@@ -1,4 +1,16 @@
-./program > test3.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >test3.result &
pid=$!
sleep 5
-kill -9 $pid \ No newline at end of file
+kill -9 $pid
diff --git a/testsuite/tests/lib-threads/test4.checker b/testsuite/tests/lib-threads/test4.checker
index b8661a9821..38cc61865c 100644
--- a/testsuite/tests/lib-threads/test4.checker
+++ b/testsuite/tests/lib-threads/test4.checker
@@ -1 +1,13 @@
-LC_ALL=C sort -u test4.result | diff -q test4.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT -u test4.result | $DIFF test4.reference -
diff --git a/testsuite/tests/lib-threads/test4.ml b/testsuite/tests/lib-threads/test4.ml
index 3acd9c6089..90692c9a08 100644
--- a/testsuite/tests/lib-threads/test4.ml
+++ b/testsuite/tests/lib-threads/test4.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let output_lock = Mutex.create()
let rec fib n = if n <= 2 then 1 else fib(n-1) + fib(n-2)
diff --git a/testsuite/tests/lib-threads/test4.runner b/testsuite/tests/lib-threads/test4.runner
index 4f1a16d087..43ac563295 100644
--- a/testsuite/tests/lib-threads/test4.runner
+++ b/testsuite/tests/lib-threads/test4.runner
@@ -1 +1,13 @@
-./program < test4.data > test4.result 2> /dev/null || true \ No newline at end of file
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program <test4.data >test4.result 2>/dev/null || true
diff --git a/testsuite/tests/lib-threads/test5.checker b/testsuite/tests/lib-threads/test5.checker
index e991875718..5eef50b1c4 100644
--- a/testsuite/tests/lib-threads/test5.checker
+++ b/testsuite/tests/lib-threads/test5.checker
@@ -1 +1,13 @@
-LC_ALL=C sort -u test5.result | diff -q test5.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT -u test5.result | $DIFF test5.reference -
diff --git a/testsuite/tests/lib-threads/test5.ml b/testsuite/tests/lib-threads/test5.ml
index 3534d03b7b..24591919d7 100644
--- a/testsuite/tests/lib-threads/test5.ml
+++ b/testsuite/tests/lib-threads/test5.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Event
let ch = (new_channel() : string channel)
diff --git a/testsuite/tests/lib-threads/test5.precheck b/testsuite/tests/lib-threads/test5.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/test5.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/test5.runner b/testsuite/tests/lib-threads/test5.runner
index 877d176e02..80dfe37eac 100644
--- a/testsuite/tests/lib-threads/test5.runner
+++ b/testsuite/tests/lib-threads/test5.runner
@@ -1,4 +1,16 @@
-./program > test5.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >test5.result &
pid=$!
-sleep 1
-kill -9 $pid \ No newline at end of file
+sleep 3
+kill -9 $pid
diff --git a/testsuite/tests/lib-threads/test6.checker b/testsuite/tests/lib-threads/test6.checker
index d2e9930af5..cc00a6310e 100644
--- a/testsuite/tests/lib-threads/test6.checker
+++ b/testsuite/tests/lib-threads/test6.checker
@@ -1 +1,13 @@
-LC_ALL=C sort -u test6.result | diff -q test6.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT -u test6.result | $DIFF test6.reference -
diff --git a/testsuite/tests/lib-threads/test6.ml b/testsuite/tests/lib-threads/test6.ml
index 9573a66108..1db9911d47 100644
--- a/testsuite/tests/lib-threads/test6.ml
+++ b/testsuite/tests/lib-threads/test6.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Event
let ch = (new_channel() : string channel)
diff --git a/testsuite/tests/lib-threads/test6.precheck b/testsuite/tests/lib-threads/test6.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/test6.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/test6.runner b/testsuite/tests/lib-threads/test6.runner
index 96bca7d768..50f88d8c0a 100644
--- a/testsuite/tests/lib-threads/test6.runner
+++ b/testsuite/tests/lib-threads/test6.runner
@@ -1,4 +1,16 @@
-./program > test6.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >test6.result &
pid=$!
sleep 1
kill -9 $pid
diff --git a/testsuite/tests/lib-threads/test7.checker b/testsuite/tests/lib-threads/test7.checker
index c5eb2dcd7b..55396e1382 100644
--- a/testsuite/tests/lib-threads/test7.checker
+++ b/testsuite/tests/lib-threads/test7.checker
@@ -1 +1,13 @@
-test `grep -E '^-?[0123456789]+$' test7.result | wc -l` = `cat test7.result | wc -l` \ No newline at end of file
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+test `grep -E '^-?[0123456789]+$' test7.result | wc -l` = `cat test7.result | wc -l`
diff --git a/testsuite/tests/lib-threads/test7.ml b/testsuite/tests/lib-threads/test7.ml
index 0ac3474287..9dae688f21 100644
--- a/testsuite/tests/lib-threads/test7.ml
+++ b/testsuite/tests/lib-threads/test7.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Event
let add_ch = new_channel()
diff --git a/testsuite/tests/lib-threads/test7.precheck b/testsuite/tests/lib-threads/test7.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/test7.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/test7.runner b/testsuite/tests/lib-threads/test7.runner
index c1e163db8e..ccd56a31d6 100644
--- a/testsuite/tests/lib-threads/test7.runner
+++ b/testsuite/tests/lib-threads/test7.runner
@@ -1,4 +1,16 @@
-./program > test7.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >test7.result &
pid=$!
sleep 1
kill -9 $pid
diff --git a/testsuite/tests/lib-threads/test8.ml b/testsuite/tests/lib-threads/test8.ml
index 897fd09eee..b3d1025dbb 100644
--- a/testsuite/tests/lib-threads/test8.ml
+++ b/testsuite/tests/lib-threads/test8.ml
@@ -1,22 +1,38 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Event
-type 'a buffer_channel = { input: 'a channel; output: 'a channel }
+type 'a buffer_channel = {
+ input: 'a channel;
+ output: 'a channel;
+ thread: Thread.t;
+}
let new_buffer_channel() =
let ic = new_channel() in
let oc = new_channel() in
- let buff = Queue.create() in
let rec buffer_process front rear =
match (front, rear) with
- ([], []) -> buffer_process [sync(receive ic)] []
+ | (["EOF"], []) -> Thread.exit ()
+ | ([], []) -> buffer_process [sync(receive ic)] []
| (hd::tl, _) ->
select [
wrap (receive ic) (fun x -> buffer_process front (x::rear));
wrap (send oc hd) (fun () -> buffer_process tl rear)
]
| ([], _) -> buffer_process (List.rev rear) [] in
- Thread.create (buffer_process []) [];
- { input = ic; output = oc }
+ let t = Thread.create (buffer_process []) [] in
+ { input = ic; output = oc; thread = t }
let buffer_send bc data =
sync(send bc.input data)
@@ -40,5 +56,8 @@ let g () =
print_string (sync(buffer_receive box)); print_newline()
let _ =
- Thread.create f ();
- g()
+ let t = Thread.create f () in
+ g();
+ buffer_send box "EOF";
+ Thread.join box.thread;
+ Thread.join t
diff --git a/testsuite/tests/lib-threads/test9.checker b/testsuite/tests/lib-threads/test9.checker
new file mode 100644
index 0000000000..09dd0e2547
--- /dev/null
+++ b/testsuite/tests/lib-threads/test9.checker
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT test9.result | $DIFF test9.reference -
diff --git a/testsuite/tests/lib-threads/test9.ml b/testsuite/tests/lib-threads/test9.ml
index 1f80beb8f8..16d61e0433 100644
--- a/testsuite/tests/lib-threads/test9.ml
+++ b/testsuite/tests/lib-threads/test9.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Event
type 'a swap_chan = ('a * 'a channel) channel
diff --git a/testsuite/tests/lib-threads/test9.reference b/testsuite/tests/lib-threads/test9.reference
index 0be61d1244..58dc8b586d 100644
--- a/testsuite/tests/lib-threads/test9.reference
+++ b/testsuite/tests/lib-threads/test9.reference
@@ -1,2 +1,2 @@
-g F
f G
+g F
diff --git a/testsuite/tests/lib-threads/testA.checker b/testsuite/tests/lib-threads/testA.checker
index 9f5d00a879..00fdfb7ad4 100644
--- a/testsuite/tests/lib-threads/testA.checker
+++ b/testsuite/tests/lib-threads/testA.checker
@@ -1 +1,13 @@
-LC_ALL=C sort testA.result | diff -q testA.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT testA.result | $DIFF testA.reference -
diff --git a/testsuite/tests/lib-threads/testA.ml b/testsuite/tests/lib-threads/testA.ml
index 25c2f6e029..bdd33c3459 100644
--- a/testsuite/tests/lib-threads/testA.ml
+++ b/testsuite/tests/lib-threads/testA.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let private_data = (Hashtbl.create 17 : (Thread.t, string) Hashtbl.t)
let private_data_lock = Mutex.create()
let output_lock = Mutex.create()
diff --git a/testsuite/tests/lib-threads/testexit.checker b/testsuite/tests/lib-threads/testexit.checker
index c1182d6f8e..55dcd7ba38 100644
--- a/testsuite/tests/lib-threads/testexit.checker
+++ b/testsuite/tests/lib-threads/testexit.checker
@@ -1 +1,13 @@
-LC_ALL=C sort testexit.result | diff -q testexit.reference -
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+LC_ALL=C $SORT testexit.result | $DIFF testexit.reference -
diff --git a/testsuite/tests/lib-threads/testexit.ml b/testsuite/tests/lib-threads/testexit.ml
index 4564a483c9..b0cb80d61f 100644
--- a/testsuite/tests/lib-threads/testexit.ml
+++ b/testsuite/tests/lib-threads/testexit.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Test Thread.exit *)
let somethread (name, limit, last) =
diff --git a/testsuite/tests/lib-threads/testio.ml b/testsuite/tests/lib-threads/testio.ml
index 80eac2966c..de0e41362f 100644
--- a/testsuite/tests/lib-threads/testio.ml
+++ b/testsuite/tests/lib-threads/testio.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Test a file copy function *)
let test msg producer consumer src dst =
@@ -107,7 +119,7 @@ let main() =
test "0...8192 byte chunks"
(copy_random 8192) (copy_random 8192) ifile ofile;
test "line per line, short lines"
- copy_line copy_line "/etc/hosts" ofile;
+ copy_line copy_line "test-file-short-lines" ofile;
let linesfile = Filename.temp_file "lines" "" in
make_lines linesfile;
test "line per line, short and long lines"
diff --git a/testsuite/tests/lib-threads/testsieve.ml b/testsuite/tests/lib-threads/testsieve.ml
index 6079d8a8eb..6979f80318 100644
--- a/testsuite/tests/lib-threads/testsieve.ml
+++ b/testsuite/tests/lib-threads/testsieve.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let sieve primes=
Event.sync (Event.send primes 0);
Event.sync (Event.send primes 1);
diff --git a/testsuite/tests/lib-threads/testsignal.checker b/testsuite/tests/lib-threads/testsignal.checker
index 2e8ef03a23..3febbff492 100644
--- a/testsuite/tests/lib-threads/testsignal.checker
+++ b/testsuite/tests/lib-threads/testsignal.checker
@@ -1 +1,13 @@
-sed -e 1q testsignal.result | grep -q '^[ab]*Got ctrl-C, exiting...$'
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+sed -e 1q testsignal.result | grep -q '^[ab]*Got ctrl-C, exiting...$'
diff --git a/testsuite/tests/lib-threads/testsignal.ml b/testsuite/tests/lib-threads/testsignal.ml
index 7781f3377b..67fa75f742 100644
--- a/testsuite/tests/lib-threads/testsignal.ml
+++ b/testsuite/tests/lib-threads/testsignal.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let sighandler _ =
print_string "Got ctrl-C, exiting..."; print_newline();
exit 0
diff --git a/testsuite/tests/lib-threads/testsignal.precheck b/testsuite/tests/lib-threads/testsignal.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/testsignal.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/testsignal.runner b/testsuite/tests/lib-threads/testsignal.runner
index 897ef1733a..ed4e9279e0 100644
--- a/testsuite/tests/lib-threads/testsignal.runner
+++ b/testsuite/tests/lib-threads/testsignal.runner
@@ -1,4 +1,16 @@
-./program > testsignal.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >testsignal.result &
pid=$!
sleep 3
-kill -INT $pid \ No newline at end of file
+kill -INT $pid
diff --git a/testsuite/tests/lib-threads/testsignal2.checker b/testsuite/tests/lib-threads/testsignal2.checker
index 6808a2659d..47ede35860 100644
--- a/testsuite/tests/lib-threads/testsignal2.checker
+++ b/testsuite/tests/lib-threads/testsignal2.checker
@@ -1 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
sed -e 1q testsignal2.result | grep -q '^[ab]*'
diff --git a/testsuite/tests/lib-threads/testsignal2.ml b/testsuite/tests/lib-threads/testsignal2.ml
index c73bdb9954..e59a8557ab 100644
--- a/testsuite/tests/lib-threads/testsignal2.ml
+++ b/testsuite/tests/lib-threads/testsignal2.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
let print_message delay c =
while true do
print_char c; flush stdout; Thread.delay delay
diff --git a/testsuite/tests/lib-threads/testsignal2.precheck b/testsuite/tests/lib-threads/testsignal2.precheck
new file mode 100644
index 0000000000..aa357092af
--- /dev/null
+++ b/testsuite/tests/lib-threads/testsignal2.precheck
@@ -0,0 +1,13 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$CANKILL
diff --git a/testsuite/tests/lib-threads/testsignal2.runner b/testsuite/tests/lib-threads/testsignal2.runner
index e215ec6ed4..19a3942f97 100644
--- a/testsuite/tests/lib-threads/testsignal2.runner
+++ b/testsuite/tests/lib-threads/testsignal2.runner
@@ -1,4 +1,16 @@
-./program > testsignal2.result &
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program >testsignal2.result &
pid=$!
sleep 3
kill -INT $pid
diff --git a/testsuite/tests/lib-threads/testsocket.ml b/testsuite/tests/lib-threads/testsocket.ml
index c5fc40b178..ec16c058c2 100644
--- a/testsuite/tests/lib-threads/testsocket.ml
+++ b/testsuite/tests/lib-threads/testsocket.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
open Unix
let engine verbose number address =
diff --git a/testsuite/tests/lib-threads/testsocket.precheck b/testsuite/tests/lib-threads/testsocket.precheck
new file mode 100644
index 0000000000..15ae35c52e
--- /dev/null
+++ b/testsuite/tests/lib-threads/testsocket.precheck
@@ -0,0 +1,23 @@
+#########################################################################
+# #
+# OCaml #
+# #
+# Damien Doligez, projet Gallium, INRIA Rocquencourt #
+# #
+# Copyright 2013 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+
+##########################################
+##########################################
+#### TEMPORARY ####
+##########################################
+##########################################
+
+# disable this test on Windows non-cygwin ports until we decide
+# how to fix PR#5325 and PR#5578
+
+$CANKILL \ No newline at end of file
diff --git a/testsuite/tests/lib-threads/token1.ml b/testsuite/tests/lib-threads/token1.ml
index 5dab410b01..d6e7a1b7ab 100644
--- a/testsuite/tests/lib-threads/token1.ml
+++ b/testsuite/tests/lib-threads/token1.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Performance test for mutexes and conditions *)
let mut = Mutex.create()
diff --git a/testsuite/tests/lib-threads/token2.ml b/testsuite/tests/lib-threads/token2.ml
index 32f2c6ed37..9ef05806ef 100644
--- a/testsuite/tests/lib-threads/token2.ml
+++ b/testsuite/tests/lib-threads/token2.ml
@@ -1,3 +1,15 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Performance test for I/O scheduling *)
let mut = Mutex.create()
@@ -7,13 +19,13 @@ let niter = ref 0
let token = ref 0
let process (n, ins, outs, nprocs) =
- let buf = String.create 1 in
- while true do
+ let buf = String.make 1 '.' in
+ while buf <> "-" do
Unix.read ins.(n) buf 0 1;
(* Printf.printf "Thread %d got the token\n" n; *)
if n = 0 then begin
decr niter;
- if !niter <= 0 then exit 0
+ if !niter <= 0 then buf.[0] <- '-';
end;
let next = if n + 1 >= nprocs then 0 else n + 1 in
(* Printf.printf "Thread %d sending token to thread %d\n" n next; *)
@@ -25,12 +37,15 @@ let main() =
let iter = try int_of_string Sys.argv.(2) with _ -> 1000 in
let ins = Array.create nprocs Unix.stdin in
let outs = Array.create nprocs Unix.stdout in
+ let threads = Array.create nprocs (Thread.self ()) in
for n = 0 to nprocs - 1 do
let (i, o) = Unix.pipe() in ins.(n) <- i; outs.(n) <- o
done;
niter := iter;
- for i = 0 to nprocs - 1 do Thread.create process (i, ins, outs, nprocs) done;
+ for i = 0 to nprocs - 1 do
+ threads.(i) <- Thread.create process (i, ins, outs, nprocs)
+ done;
Unix.write outs.(0) "X" 0 1;
- Thread.delay 3600.
+ for i = 0 to nprocs - 1 do Thread.join threads.(i) done
let _ = main()
diff --git a/testsuite/tests/lib-threads/torture.ml b/testsuite/tests/lib-threads/torture.ml
index cfc5783334..0c1a3a3a0e 100644
--- a/testsuite/tests/lib-threads/torture.ml
+++ b/testsuite/tests/lib-threads/torture.ml
@@ -1,25 +1,41 @@
+(***********************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
(* Torture test - lots of GC *)
+let finished = ref false;;
+
let gc_thread () =
- while true do
+ while not !finished do
(* print_string "gc"; print_newline(); *)
Gc.minor();
Thread.yield()
done
let stdin_thread () =
- while true do
- print_string "> "; flush stdout;
+ while not !finished do
+ print_string ">"; flush stdout;
let s = read_line() in
- print_string ">>> "; print_string s; print_newline()
+ print_string " >>> "; print_string s; print_newline()
done
let writer_thread (oc, size) =
- while true do
+ while not !finished do
(* print_string "writer "; print_int size; print_newline(); *)
let buff = String.make size 'a' in
Unix.write oc buff 0 size
- done
+ done;
+ let buff = String.make size 'b' in
+ Unix.write oc buff 0 size
let reader_thread (ic, size) =
while true do
@@ -28,18 +44,23 @@ let reader_thread (ic, size) =
let n = Unix.read ic buff 0 size in
(* print_string "reader "; print_int n; print_newline(); *)
for i = 0 to n-1 do
- if buff.[i] <> 'a' then prerr_endline "error in reader_thread"
+ if buff.[i] = 'b' then raise Exit
+ else if buff.[i] <> 'a' then prerr_endline "error in reader_thread"
done
done
let main() =
- Thread.create gc_thread ();
+ let t1 = Thread.create gc_thread () in
let (out1, in1) = Unix.pipe() in
- Thread.create writer_thread (in1, 4096);
- Thread.create reader_thread (out1, 4096);
+ let t2 = Thread.create writer_thread (in1, 4096) in
+ let t3 = Thread.create reader_thread (out1, 4096) in
let (out2, in2) = Unix.pipe() in
- Thread.create writer_thread (in2, 16);
- Thread.create reader_thread (out2, 16);
- stdin_thread()
+ let t4 = Thread.create writer_thread (in2, 16) in
+ let t5 = Thread.create reader_thread (out2, 16) in
+ try
+ stdin_thread()
+ with _ ->
+ finished := true;
+ List.iter Thread.join [t1; t2; t3; t4; t5]
let _ = main()
diff --git a/testsuite/tests/lib-threads/torture.reference b/testsuite/tests/lib-threads/torture.reference
index cd5f474fb6..f726cc4682 100644
--- a/testsuite/tests/lib-threads/torture.reference
+++ b/testsuite/tests/lib-threads/torture.reference
@@ -1,4 +1,4 @@
> >>> abc
> >>> def
> >>> ghi
-> \ No newline at end of file
+> \ No newline at end of file
diff --git a/testsuite/tests/lib-threads/torture.runner b/testsuite/tests/lib-threads/torture.runner
index f4ad597bff..fc1ed3879e 100644
--- a/testsuite/tests/lib-threads/torture.runner
+++ b/testsuite/tests/lib-threads/torture.runner
@@ -1 +1,13 @@
-./program < torture.data > torture.result 2> /dev/null || true \ No newline at end of file
+#########################################################################
+# #
+# OCaml #
+# #
+# Xavier Clerc, SED, INRIA Rocquencourt #
+# #
+# Copyright 2010 Institut National de Recherche en Informatique et #
+# en Automatique. All rights reserved. This file is distributed #
+# under the terms of the Q Public License version 1.0. #
+# #
+#########################################################################
+
+$RUNTIME ./program <torture.data >torture.result 2>/dev/null || true