X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcallback.impure.lisp;h=bb62a6808ea8334ea16795216b0fab3f910adf8d;hb=31f68584d0732dc0d17f379773e5f87f1e5a78ad;hp=34bb23f6a6b94c3cacc16f3910a354bd8927a6d7;hpb=57d893458e9cb6fdc902d78f69fc3e4f362fe778;p=sbcl.git diff --git a/tests/callback.impure.lisp b/tests/callback.impure.lisp index 34bb23f..bb62a68 100644 --- a/tests/callback.impure.lisp +++ b/tests/callback.impure.lisp @@ -1,4 +1,4 @@ -;;;; package lock tests with side effects +;;;; callback tests with side effects ;;;; This software is part of the SBCL system. See the README file for ;;;; more information. @@ -15,7 +15,7 @@ ;;; callbacks only on a few platforms #-alien-callbacks -(quit :unix-status 104) +(exit :code 104) ;;; simple callback for a function @@ -130,24 +130,33 @@ ;;; callbacks with void return values -(with-test (:name void-return) +(with-test (:name :void-return) (sb-alien::alien-lambda void () (values))) -;;; tests for a sign extension problem in callback argument handling on x86-64 +;;; tests for integer-width problems in callback result handling -(defvar *add-two-ints* (sb-alien::alien-callback (function int int int) #'+)) +(defvar *add-two-ints* + (sb-alien::alien-callback (function int int int) #'+)) +(defvar *add-two-shorts* + (sb-alien::alien-callback (function short short short) #'+)) -(with-test (:name :sign-extension) - (assert (= (alien-funcall *add-two-ints* #x-80000000 1) -2147483647))) +;;; The original test cases here were what are now (:int-result +;;; :sign-extension) and (:int-result :underflow-detection), the latter +;;; of which would fail on 64-bit platforms. Upon further investigation, +;;; it turned out that the same tests with a SHORT return type instead of +;;; an INT return type would also fail on 32-bit platforms. + +(with-test (:name (:short-result :sign-extension)) + (assert (= (alien-funcall *add-two-shorts* #x-8000 1) -32767))) -;;; On x86 This'll signal a TYPE-ERROR "The value -2147483649 is not of type -;;; (SIGNED-BYTE 32)". On x86-64 it'll wrap around to 2147483647, probably -;;; due to the sign-extension done by the (INTEGER :NATURALIZE-GEN) -;;; alien-type-method. I believe the former behaviour is the one we want. -;;; -- JES, 2005-10-16 +(with-test (:name (:short-result :underflow-detection)) + (assert (raises-error? (alien-funcall *add-two-shorts* #x-8000 -1)))) + +(with-test (:name (:int-result :sign-extension)) + (assert (= (alien-funcall *add-two-ints* #x-80000000 1) -2147483647))) -(with-test (:name :underflow-detection :fails-on :x86-64) +(with-test (:name (:int-result :underflow-detection)) (assert (raises-error? (alien-funcall *add-two-ints* #x-80000000 -1)))) ;;; tests for handling 64-bit arguments - this was causing problems on