sb-simple-streams: In test lp491087, merge the pathname
[sbcl.git] / contrib / sb-simple-streams / simple-stream-tests.lisp
index 557fb63..f0d5a73 100644 (file)
         (string= (prog1 (write-line "Got it!" s) (finish-output s))
                  (read-line s)))
     ;; Fail gracefully if echo isn't activated on the system
-    (sb-bsd-sockets::connection-refused-error () t))
+    (sb-bsd-sockets::connection-refused-error () t)
+    ;; Timeout may occur on the restricted systems (e.g. FreeBSD
+    ;; with jail(8) or blackhole(4) is used).
+    (sb-bsd-sockets::operation-timeout-error () t))
   t)
 
 (deftest write-read-large-sc-1
        (string= (prog1 (write-line content s) (finish-output s))
                 (read-line s))))
     ;; Fail gracefully if echo isn't activated on the system
-   (sb-bsd-sockets::connection-refused-error () t))
+   (sb-bsd-sockets::connection-refused-error () t)
+   ;; Timeout may occur on the restricted systems (e.g. FreeBSD
+   ;; with jail(8) or blackhole(4) is used).
+   (sb-bsd-sockets::operation-timeout-error () t))
   t)
 
 
@@ -924,3 +930,24 @@ Nothing to see here, move along.")
                        :external-format :utf-8)
         (char-code (read-char s))))
   196)
+
+;; launchpad bug #491087
+
+(deftest lp491087
+    (labels ((read-big-int (stream)
+               (let ((b (make-array 1 :element-type '(signed-byte 32)
+                                    :initial-element 0)))
+                 (declare (dynamic-extent b))
+                 (sb-simple-streams::read-vector b stream
+                                                 :endian-swap :network-order)
+                 (aref b 0))))
+      (with-open-file (stream
+                       (merge-pathnames #P"lp491087.txt" *test-path*)
+                       :class 'file-simple-stream)
+        (let* ((start (file-position stream))
+               (integer (read-big-int stream))
+               (end (file-position stream)))
+          (and (= start 0)
+               (= integer #x30313233)
+               (= end 4)))))
+  T)