| 1 |
;; |
| 2 |
;; testing fcntl |
| 3 |
;; |
| 4 |
|
| 5 |
#!no-fold-case |
| 6 |
|
| 7 |
(use gauche.test) |
| 8 |
(test-start "fcntl") |
| 9 |
|
| 10 |
(use gauche.fcntl) |
| 11 |
(test-module 'gauche.fcntl) |
| 12 |
|
| 13 |
(cond-expand |
| 14 |
(gauche.sys.fcntl |
| 15 |
;; It is difficult to compose a full test that works on every situation. |
| 16 |
;; Here I provide tests for some common features. |
| 17 |
|
| 18 |
(test-section "F_GETFL") |
| 19 |
|
| 20 |
(sys-unlink "test.o") |
| 21 |
|
| 22 |
(test* "F_GETFL" O_WRONLY |
| 23 |
(call-with-output-file "test.o" |
| 24 |
(^p (logand (sys-fcntl p F_GETFL) O_ACCMODE)))) |
| 25 |
|
| 26 |
(test* "F_GETFL" O_RDONLY |
| 27 |
(call-with-input-file "test.o" |
| 28 |
(^p (logand (sys-fcntl p F_GETFL) O_ACCMODE)))) |
| 29 |
|
| 30 |
(test* "F_GETFL" #t |
| 31 |
(call-with-input-file "test.o" |
| 32 |
(^p (zero? (logand (sys-fcntl p F_GETFL) O_APPEND))))) |
| 33 |
|
| 34 |
(test* "F_GETFL" #f |
| 35 |
(call-with-output-file "test.o" |
| 36 |
(^p (zero? (logand (sys-fcntl p F_GETFL) O_APPEND))) |
| 37 |
:if-exists :append)) |
| 38 |
|
| 39 |
(sys-unlink "test.o") |
| 40 |
|
| 41 |
;; TODO: test lock |
| 42 |
) |
| 43 |
(else #f)) |
| 44 |
|
| 45 |
(test-end) |