summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/exec.test30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/exec.test b/tests/exec.test
index 930a4d3..a80aaeb 100644
--- a/tests/exec.test
+++ b/tests/exec.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: exec.test,v 1.22 2004/07/02 23:31:30 hobbs Exp $
+# RCS: @(#) $Id: exec.test,v 1.23 2005/07/28 10:55:37 dkf Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -600,6 +600,34 @@ test exec-18.1 { exec cat deals with weird file names} {exec tempNotWin} {
set res
} {0 contents}
+# Note that this test cannot be adapted to work on Windows; that platform has
+# no kernel support for an analog of O_APPEND.
+test exec-19.1 {exec >> uses O_APPEND} {
+ -constraints {exec unix}
+ -setup {
+ set tmpfile [makeFile {0} tmpfile.exec-19.1]
+ }
+ -body {
+ # Note that we have to allow for the current contents of the
+ # temporary file, which is why the result is 14 and not 12
+ exec /bin/sh -c \
+ {for a in 1 2 3; do sleep 1; echo $a; done} >>$tmpfile &
+ exec /bin/sh -c \
+ {for a in a b c; do sleep 1; echo $a; done} >>$tmpfile &
+ # The above two shell invokations take about 3 seconds to
+ # finish, so allow 5s (in case the machine is busy)
+ after 5000
+ # Check that no bytes have got lost through mixups with
+ # overlapping appends, which is only guaranteed to work when
+ # we set O_APPEND on the file descriptor in the [exec >>...]
+ file size $tmpfile
+ }
+ -cleanup {
+ removeFile $tmpfile
+ }
+ -result 14
+}
+
# cleanup
foreach file {script gorp.file gorp.file2 echo cat wc sh sleep exit err} {