0.7.1.38:
[sbcl.git] / tests / foreign.test.sh
index 69702f6..eaa3b4b 100644 (file)
 # absolutely no warranty. See the COPYING and CREDITS files for
 # more information.
 
-testfilestem=$TMPDIR/sbcl-foreign-test-$$
+echo //entering foreign.test.sh
 
+testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$
+
+# FIXME: At least on OpenBSD, the "make $testfilestem.o" puts the
+# output file into the current directory, instead of the 
+# target directory. E.g. "make /tmp/foo.o" causes "./foo.o" to be
+# created (!). Since OpenBSD doesn't support LOAD-FOREIGN, this
+# doesn't matter much, since it punts with UNSUPPORTED-OPERATOR
+# instead of not finding the file. But it'd be nice to straighten
+# this out, if only so that sbcl-foreign-test-*.o clutter
+# doesn't pile up in this directory. Maybe some time when I have
+# several test machines at hand to check the behavior of different
+# versions of "make"...
 echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c
 make $testfilestem.o
 ld -shared -o $testfilestem.so $testfilestem.o
 
-sbcl --noinform --noprint --sysinit /dev/null --userinit /dev/null <<EOF
-  (load-foreign '("$testfilestem.so"))
-  (def-alien-routine summish int (x int) (y int))
+${SBCL:-sbcl} <<EOF
+  (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
@@ -36,5 +54,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