0.7.12.1:
[sbcl.git] / tests / foreign.test.sh
index 6b5a7cd..ee78f51 100644 (file)
 # absolutely no warranty. See the COPYING and CREDITS files for
 # more information.
 
+echo //entering foreign.test.sh
+
 testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$
 
+# Make a little shared object file to test with.
 echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c
-make $testfilestem.o
+cc -c $testfilestem.c -o $testfilestem.o
 ld -shared -o $testfilestem.so $testfilestem.o
 
+# Test interaction with the shared object file.
 ${SBCL:-sbcl} <<EOF
-  (unless (fboundp 'load-foreign) ; not necessarily supported on all OSes..
-    (sb-ext:quit :unix-status 52)) ; successfully unsupported:-|
-  (load-foreign '("$testfilestem.so"))
-  (def-alien-routine summish int (x int) (y int))
+  (handler-case 
+      (load-foreign '("$testfilestem.so"))
+    (sb-int:unsupported-operator ()
+     ;; At least as of sbcl-0.7.0.5, LOAD-FOREIGN isn't supported
+     ;; on every OS. In that case, there's nothing to test, and we
+     ;; can just fall through to success.
+     (sb-ext:quit :unix-status 52))) ; success convention for Lisp program
+  (define-alien-routine summish int (x int) (y int))
   (assert (= (summish 10 20) 31))
   (sb-ext:quit :unix-status 52) ; success convention for Lisp program
 EOF
@@ -38,7 +46,8 @@ fi
 # rolling over in his grave.:-) It would be good to make a test case
 # for it..
 
+echo //cleanup: removing $testfilestem.*
 rm $testfilestem.*
 
 # success convention for script
-exit 104
+exit 104