tests: Avoid buffering in 'fcntl-flock' tests.
authorLudovic Courtès <ludo@gnu.org>
Mon, 7 Apr 2014 16:08:56 +0000 (18:08 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 7 Apr 2014 16:16:58 +0000 (18:16 +0200)
Partially fixes <http://bugs.gnu.org/17212>.

* tests/utils.scm ("fcntl-flock wait", "fcntl-flock non-blocking"): Open
  files in binary mode, with no buffering.

tests/utils.scm

index 1da8476..4d2d123 100644 (file)
 (false-if-exception (delete-file temp-file))
 (test-equal "fcntl-flock wait"
   42                                              ; the child's exit status
-  (let ((file (open-file temp-file "w0")))
+  (let ((file (open-file temp-file "w0b")))
     ;; Acquire an exclusive lock.
     (fcntl-flock file 'write-lock)
     (match (primitive-fork)
          (const #t)
          (lambda ()
            ;; Reopen FILE read-only so we can have a read lock.
-           (let ((file (open-file temp-file "r")))
+           (let ((file (open-file temp-file "r0b")))
              ;; Wait until we can acquire the lock.
              (fcntl-flock file 'read-lock)
              (primitive-exit (read file)))
             (read-char input)
 
             ;; Open FILE read-only so we can have a read lock.
-            (let ((file (open-file temp-file "w")))
+            (let ((file (open-file temp-file "w0")))
               (catch 'flock-error
                 (lambda ()
                   ;; This attempt should throw EAGAIN.
                   (fcntl-flock file 'write-lock #:wait? #f))
                 (lambda (key errno)
-                  (primitive-exit errno))))
+                  (primitive-exit (pk 'errno errno)))))
             (primitive-exit -1))
           (lambda ()
             (primitive-exit -2))))
        (pid
         (close-port input)
-        (let ((file (open-file temp-file "w")))
+        (let ((file (open-file temp-file "w0")))
           ;; Acquire an exclusive lock.
           (fcntl-flock file 'write-lock)