X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-bsd-sockets%2Ftests.lisp;h=776878c7f5425e2829b95c6183a91c9d8ac629db;hb=7f4bf063d5f4716b87d34cc706f05b27ad3906b1;hp=f624297ee6c311e590d177a06f91daec74a6d3b4;hpb=d0f4d5a8caeb1982083cb973cb1e6844457ed58f;p=sbcl.git diff --git a/contrib/sb-bsd-sockets/tests.lisp b/contrib/sb-bsd-sockets/tests.lisp index f624297..776878c 100644 --- a/contrib/sb-bsd-sockets/tests.lisp +++ b/contrib/sb-bsd-sockets/tests.lisp @@ -50,7 +50,7 @@ (and (> (socket-file-descriptor s) 1) t)) t) -(deftest* (make-inet-socket-wrong :fails-on :win32) +(deftest* (make-inet-socket-wrong) ;; fail to make a socket: check correct error return. There's no nice ;; way to check the condition stuff on its own, which is a shame (handler-case @@ -66,7 +66,7 @@ (:no-error nil)) t) -(deftest* (make-inet-socket-keyword-wrong :fails-on :win32) +(deftest* (make-inet-socket-keyword-wrong) ;; same again with keywords (handler-case (make-instance 'inet-socket :type :stream :protocol :udp) @@ -83,7 +83,7 @@ t) -(deftest* (non-block-socket :fails-on :win32) +(deftest* (non-block-socket) (let ((s (make-instance 'inet-socket :type :stream :protocol :tcp))) (setf (non-blocking-mode s) t) (non-blocking-mode s)) @@ -112,7 +112,7 @@ (address-in-use-error () t))) t) -(deftest* (simple-sockopt-test :fails-on :win32) +(deftest* (simple-sockopt-test) ;; test we can set SO_REUSEADDR on a socket and retrieve it, and in ;; the process that all the weird macros in sockopt happened right. (let ((s (make-instance 'inet-socket :type :stream :protocol (get-protocol-by-name "tcp")))) @@ -311,4 +311,57 @@ (format t "Received ~A bytes from ~A:~A - ~A ~%" len address port (subseq buf 0 (min 10 len))))))) - +#+sb-thread +(deftest interrupt-io + (let (result) + (labels + ((client (port) + (setf result + (let ((s (make-instance 'inet-socket + :type :stream + :protocol :tcp))) + (socket-connect s #(127 0 0 1) port) + (let ((stream (socket-make-stream s + :input t + :output t + :buffering :none))) + (handler-case + (prog1 + (catch 'stop + (progn + (read-char stream) + (sleep 0.1) + (sleep 0.1) + (sleep 0.1))) + (close stream)) + (error (c) + c)))))) + (server () + (let ((s (make-instance 'inet-socket + :type :stream + :protocol :tcp))) + (setf (sockopt-reuse-address s) t) + (socket-bind s (make-inet-address "127.0.0.1") 0) + (socket-listen s 5) + (multiple-value-bind (* port) + (socket-name s) + (let* ((client (sb-thread:make-thread + (lambda () (client port)))) + (r (socket-accept s)) + (stream (socket-make-stream r + :input t + :output t + :buffering :none)) + (ok :ok)) + (socket-close s) + (sleep 5) + (sb-thread:interrupt-thread client + (lambda () (throw 'stop ok))) + (sleep 5) + (setf ok :not-ok) + (write-char #\x stream) + (close stream) + (socket-close r)))))) + (server)) + result) + :ok)