X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fsignals.impure.lisp;h=c4f347e443d069ad1956fa3c943377f5bd2a0ee1;hb=69e6aef5e6fb3bd682c7a2cbf774034d2ea58ee8;hp=16b9767bc3e45ea20f68c6a539762f17bc44d384;hpb=26bbfd93d01cefc0bbf97727379bdbdace8bf609;p=sbcl.git diff --git a/tests/signals.impure.lisp b/tests/signals.impure.lisp index 16b9767..c4f347e 100644 --- a/tests/signals.impure.lisp +++ b/tests/signals.impure.lisp @@ -35,3 +35,65 @@ (princ '*) (force-output)) (terpri))) + +(require :sb-posix) + +(with-test (:name (:signal :errno) + ;; This test asserts that nanosleep behaves correctly + ;; for invalid values and sets EINVAL. Well, we have + ;; nanosleep on Windows, but it depends on the caller + ;; (namely SLEEP) to produce known-good arguments, and + ;; even if we wanted to check argument validity, + ;; integration with `errno' is not to be expected. + :skipped-on :win32) + (let* (saved-errno + (returning nil) + (timer (make-timer (lambda () + (sb-unix:unix-open "~!@#$%^&*[]()/\\" 0 0) + (assert (= sb-unix:enoent + (sb-unix::get-errno))) + (setq returning t))))) + (schedule-timer timer 0.2) + ;; Fail and set errno. + (sb-unix:nanosleep -1 -1) + (setq saved-errno (sb-unix::get-errno)) + (assert (= saved-errno sb-posix:einval)) + ;; Wait, but not with sleep because that will be interrupted and + ;; we get EINTR. + (loop until returning) + (loop repeat 1000000000) + (assert (= saved-errno (sb-unix::get-errno))))) + +(with-test (:name :handle-interactive-interrupt + ;; It is desirable to support C-c on Windows, but SIGINT + ;; is not the mechanism to use on this platform. + :skipped-on :win32) + (assert (eq :condition + (handler-case + (progn + (sb-thread::kill-safely + (sb-thread::thread-os-thread sb-thread::*current-thread*) + sb-unix:sigint) + #+sb-safepoint-strictly + ;; In this case, the signals handler gets invoked + ;; indirectly through an INTERRUPT-THREAD. Give it + ;; enough time to hit. + (sleep 1)) + (sb-sys:interactive-interrupt () + :condition))))) + +(with-test (:name :bug-640516) + ;; On Darwin interrupting a SLEEP so that it took longer than + ;; the requested amount caused it to hang. + (assert + (handler-case + (sb-ext:with-timeout 10 + (let (to) + (handler-bind ((sb-ext:timeout (lambda (c) + (unless to + (setf to t) + (sleep 2) + (continue c))))) + (sb-ext:with-timeout 0.1 (sleep 1) t)))) + (sb-ext:timeout () + nil))))